nxgdb/irq: add irqinfo command

(gdb) irqinfo
IRQ  COUNT      TIME   RATE   HANDLER                                          ARGUMENT
0    0          0      N/A    mps_reserved                             0x0 <sensor_unregister>
2    0          0      N/A    mps_nmi                                  0x0 <sensor_unregister>
3    0          0      N/A    arm_hardfault                            0x0 <sensor_unregister>
4    0          0      N/A    arm_memfault                             0x0 <sensor_unregister>
5    0          0      N/A    arm_busfault                             0x0 <sensor_unregister>
6    0          0      N/A    arm_usagefault                           0x0 <sensor_unregister>
11   1          0      N/A    arm_svcall                               0x0 <sensor_unregister>
12   0          0      N/A    arm_dbgmonitor                           0x0 <up_debugpoint_remove>
14   0          0      N/A    mps_pendsv                               0x0 <up_debugpoint_remove>
15   6581421    0      N/A    systick_interrupt                        0x100010c <g_systick_lower>
49   2          0      N/A    uart_cmsdk_tx_interrupt                  0x1000010 <g_uart0port>
50   0          0      N/A    uart_cmsdk_rx_interrupt                  0x1000010 <g_uart0port>
59   2          0      N/A    uart_cmsdk_ov_interrupt                  0x1000010 <g_uart0port>
(gdb)

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang
2024-11-27 11:29:49 +08:00
committed by Alan C. Assis
parent 06c7e2a02e
commit 1bfb42d127
2 changed files with 115 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
############################################################################
# tools/pynuttx/nxgdb/irq.py
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
from __future__ import annotations
from typing import List
import gdb
from . import utils
from .protocols import irq as p
g_irqvector = utils.parse_and_eval("g_irqvector")
NR_IRQS = utils.nitems(g_irqvector)
CONFIG_SCHED_IRQMONITOR = utils.has_field(g_irqvector, "count")
class IRQInfo(utils.Value, p.IRQInfo):
def __init__(self, irq: gdb.Value):
super().__init__(irq)
@property
def count(self) -> int:
return self["count"] if CONFIG_SCHED_IRQMONITOR else -1
@property
def time(self) -> int:
return self["time"] if CONFIG_SCHED_IRQMONITOR else -1
@property
def start(self) -> int:
return self["start"] if CONFIG_SCHED_IRQMONITOR else -1
def get_irqs() -> List[IRQInfo]:
return (IRQInfo(irq) for irq in utils.ArrayIterator(g_irqvector))
class IRQInfoDump(gdb.Command):
"""Dump irqinfo"""
formatter = "{:<4} {:<10} {:<6} {:<6} {:<48} {} "
header = ("IRQ", "COUNT", "TIME", "RATE", "HANDLER", "ARGUMENT")
def __init__(self):
super().__init__("irqinfo", gdb.COMMAND_USER)
def invoke(self, arg: str, from_tty: bool) -> None:
irq_unexpected_isr = utils.gdb_eval_or_none("irq_unexpected_isr")
print(self.formatter.format(*self.header))
for i, irq in enumerate(get_irqs()):
if not irq.handler or (int(irq.handler) & ~0x01) == irq_unexpected_isr:
continue
handler = irq.handler.format_string(styling=True, address=False).strip("<>")
irq_arg = irq.arg.format_string(styling=True)
print(
self.formatter.format(i, irq.count, irq.time, "N/A", handler, irq_arg)
)
+35
View File
@@ -0,0 +1,35 @@
############################################################################
# tools/pynuttx/nxgdb/protocols/irq.py
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
from __future__ import annotations
from .value import Value
class IRQInfo(Value):
"""struct irq_info_s"""
handler: Value
arg: Value
start: Value
time: Value
count: Value