xuxingliang
d02dc3893c
tools/gdb: decode backtrace of crashlog
...
Now crash log can be directly pass to addr2line tool to get all backtraces.
E.g.
(gdb) addr2line -f crash.log -p 485
Address Symbol Source
Backtrace of 485
0x402cc0ac <up_switch_context+84> /home/work/ssd1/workspace/MiRTOS-X4b-Stable-Build/nuttx/include/arch/syscall.h:179
0x40291276 <nxsig_timedwait+386> signal/sig_timedwait.c:365
0x4028fc7e <nxsig_nanosleep+106> signal/sig_nanosleep.c:141
0x4028fdba <clock_nanosleep+26> signal/sig_nanosleep.c:333
0x402c3736 <usleep+62> unistd/lib_usleep.c:108
0x415018c0 <cs2p2p_mSecSleep+24> Src/PPPP_Common.c:1139
0x414fabde <cs2p2p_Run_send_DRW+258> Src/PPPP_API.c:5577
0x414fac62 <cs2p2p_PPPP_thread_send_DRW+18> Src/PPPP_API.c:5616
0x40446f62 <pthread_startup+10> pthread/pthread_create.c:59
0x41094f4a <pthread_start+106> pthread/pthread_create.c:139
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 03:03:40 +08:00
huangyin5
1e265af8eb
tools/gdb: add utils.get_tid(tcb)
...
Signed-off-by: huangyin5 <huangyin5@xiaomi.com>
2024-11-24 03:03:40 +08:00
xuxingliang
69613d5199
tools/gdb: add array iterator
...
Use array iterator where possible.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 03:03:40 +08:00
Zhe Weng
0cda6278d3
tools/gdb: Use ptr's value instead of ptr's adderess in container_of
...
We're using `ptr.cast(get_long_type())` a week ago to get the pointer's value, it's alright, but `ptr.address` is not, the `ptr.address` will return **the address of the pointer**.
These values are the address of first element in the queue:
- `int(g_sigfreeaction["head"])`
- `g_sigfreeaction["head"].cast(get_long_type())`
- `g_sigfreeaction["head"].dereference().address`
But:
`int(g_sigfreeaction["head"].address)` is the address of the "head" member, which equals to the address of `g_sigfreeaction`
It's happening in NxSQueue:
g_sigfreeaction = gdb.parse_and_eval("g_sigfreeaction")
print(["%x" % (node) for node in NxSQueue(g_sigfreeaction)])
print(["%x" % (node) for node in NxSQueue(g_sigfreeaction, "sigactq_t", "flink")])
Without this patch:
['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
['55db90a0', 'f3c0aa10', 'f3c0aa2c']
With this patch:
['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-24 03:03:40 +08:00
Zhe Weng
a4e5689c7f
tools/gdb: Allow utils.container_of with str input
...
After we introduced NxDQueue and NxSQueue, we're using them like `NxDQueue(g_active_connections, "struct socket_conn_s", "node")` and leads to `utils.container_of(ptr, str, str)`, so maybe we need to allow str input for `utils.container_of`
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-24 03:03:40 +08:00
buxiasen
bb461b532b
nuttxgdb: fix container_of pointer offset calc problem
...
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-24 03:03:40 +08:00
xuxingliang
b296b1debe
gdb/macro: cache macro info to json and load directly
...
Use json module to save macro info to json file and load directly. It can save 2seconds for x4b projects to load plugin
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 03:03:40 +08:00
xuxingliang
96a518af35
tools/gdb: fix elf file with special character
...
Make sure file name is surrounded by \"
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 03:03:40 +08:00
xuxingliang
6d0d4458cd
gdb/macro: fix cached macro info is outdated
...
Use the file hash instead to avoid file name conflicts
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 03:03:40 +08:00
Zhe Weng
aa74ba5ace
tools/gdb: Add command 'netcheck' for checks on network stack
...
The diagnostics result looks like:
{
"title": "Netcheck Report",
"command": "netcheck",
"result": "PASS",
"message": []
}
or
{
"title": "Netcheck Report",
"command": "netcheck",
"result": "WARN",
"message": [
"[WARNING] IOB used up: free -1 throttle 0"
]
}
The netcheck command reports like:
IOB check: WARN
[WARNING] IOB used up: free -1 throttle 0
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-24 02:57:05 +08:00
Zhe Weng
b293c722bd
tools/gdb: Make netstats work without socket import
...
We may get normal IPv4 address print like 10.10.0.1:5001 and a longer
IPv6 like fc000000000000000000000000000001:5001
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-24 02:57:05 +08:00
xuxingliang
b885cb3633
gdb/lists: add element option to foreach list
...
So we can focus on single element of struct, same as array.
Fix typo in foreach array args.element
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 02:55:46 +08:00
xuxingliang
d8eccbc0f2
gdb/lists: add foreach array command to dump array
...
This command can dump any array with auto length detection or specified
length.
An optional `element` parameter is used to only dump this element in
array when array is in type of struct.
E.g.
(gdb) foreach array g_mmheap->mm_nodelist
0: {preceding = 0, size = 0, pid = 0, seqno = 0, backtrace = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, flink = 0x41692cb8, blink = 0x0}
1: {preceding = 0, size = 0, pid = 0, seqno = 0, backtrace = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, flink = 0x40c378a0, blink = 0x40605f58}
(gdb) foreach array g_mmheap->mm_nodelist -e "flink"
0: 0x41692cb8
1: 0x40c378a0
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 02:55:46 +08:00
xuxingliang
cd3d639153
gdb/lists: optimize foreach list command
...
NuttX has various of list implementation, but the core of list is to
find next node, and stop iteration.
This change addes parameter of how to get next node by specifying its
element name.
Note the list head must be a pointer type.
E.g.
(gdb) foreach list -n next &g_msgfree
0: {prev = 0x40286200 <g_msgpool+280>, next = 0x4028628c <g_msgpool+420>}
1: {prev = 0x40286e30 <g_msgfree>, next = 0x40286318 <g_msgpool+560>}
(gdb) foreach list "(struct list_node *) 0x40286e30"
0: {prev = 0x40286200 <g_msgpool+280>, next = 0x4028628c <g_msgpool+420>}
1: {prev = 0x40286e30 <g_msgfree>, next = 0x40286318 <g_msgpool+560>}
(gdb) foreach list g_active_tcp_connections.head -n flink -c "struct tcp_conn_s" -m "sconn" 13:14:07 [1047/1047]
0 @ *(struct tcp_conn_s *)0x40441510 {
sconn = {
node = {
flink = 0x40441658 <g_tcp_connections+984>,
blink = 0x0
},
list = 0x40443754 <g_cbprealloc+1488>,
list_tail = 0x40443754 <g_cbprealloc+1488>,
s_error = 0,
s_options = 0,
s_rcvtimeo = 0,
s_sndtimeo = 0,
s_boundto = 0 '\000',
s_flags = 105 'i',
s_tos = 0 '\000',
s_ttl = 64 '@'
},
u = {
ipv4 = {
laddr = 16777343,
raddr = 16777343
},
ipv6 = {
laddr = {127, 256, 127, 256, 0, 0, 0, 0},
raddr = {0, 0, 0, 0, 0, 0, 0, 0}
}
},
rcvseq = "h\374\375\064",
sndseq = "h\374\375\063",
crefs = 1 '\001',
domain = 2 '\002',
sa = 0 '\000',
sv = 12 '\f',
rto = 12 '\f',
tcpstateflags = 4 '\004',
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-24 02:55:46 +08:00
buxiasen
8cda0c8648
nuttxgdb: sq_check no normal print when sq_count
...
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-24 02:55:46 +08:00
buxiasen
1a87d4cc3e
nuttxgdb: add sq_count support
...
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-24 02:55:46 +08:00
Zhe Weng
c70f3e3f98
tools/gdb: Add check for tail when checking a queue
...
Tested for:
dq: &g_notifier_pending in both good and bad state (tail goes wrong)
sq: &g_sigfreeaction in good state
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-24 02:55:46 +08:00
Zhe Weng
813ba4d714
tools/gdb: Add support for dq in list_check
...
Tested:
list_check &g_notifier_pending
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-24 02:55:46 +08:00
xuxingliang
1485ecd28e
gdb/dmesg: print dmesg in the correct order
...
Now the dmesg output log in correct time order, from oldest to latest.
The NULL strings are also stripped, if the buffer is never get fully
filled.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
yangao1
c29f93922a
nuttxgdb/dmesg.py:add diagnose api
...
Signed-off-by: yangao1 <yangao1@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
4e6026efe6
gdb/dmesg: replace non-printable NULL terminator
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
472b49e11f
dmesg.py:use 'replace' avoid decode error
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
8b4a4f8539
tools/gdb: add get_task_tls and get_thread_tls
...
Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
5d86bee5c7
tools/gdb: add diagnose commands
...
Run diagnostic related commands anytime to generate report.
E.g `diag report -o systemreport.json`
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
a2da6b94f0
tools/gdb: add foreach prefixed command
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
04b35a2e8f
tools/gdb: add pyproject.toml to build as a package
...
Now the GDB tool can be built with python -m build . to generate a
package.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
5a82e21edb
tools/gdb: use iterator for list
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
e7c2e7c576
tools/gdb: use remote-register standard
...
GDB uses remote-register to describe g/G packet. Whatever the target is,
we can always find out the register offset in packet by `maint print
remote-registers`.
In NuttX, we follow the same standard to prepare the packet, in both
coredump and GDB stub.
For example, the CPSR for arm-v7a is at register number of 25, byte
offset of 164. So we define the CPSR in g_reg_offs (164 /4 = 41)th
elementent.
If GDB stub supports qXfer feature, then GDB will ask stub for target
descriptor, which is a standard xml file. If this file is provided, then
the register order is also changed. It's also reflected in 'maint print
remote-registers' output. JLink GDB server supports it for example.
We always use manually added second inferiort to query the original
remote register layout. So it can match with tcbinfo.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
68d47ee847
tools/gdb: init superclass in python3 code style
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
74bac56539
tools/gdb: fix regression on older version of GDB
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
94a2ce3641
tools/gdb: need to switch back to inferior 1
...
After check version using inferior 2, need to switch back for normal operation
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
5f34b44fca
gdb python:support check elf version
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
92d79d5e71
utils.py:add profile
command to profile python command
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
160f61cd4d
memdump.py:add some error info to mmforeach and try dump mempool frist
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
8adbf6c504
gdb/memdump:fixed the problem of inaccurate statistics
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
75c1b26cbc
tools/gdb: accept expression or value for arguments
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
0f0fefb942
gdb:add dmesg command show ramlog buffer data as syslog
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
cbf778cb60
tools/gdb: add addr2line tool
...
Usage: addr2line address1 address2 expression1
Example: addr2line 0x1234 0x5678
addr2line "0x1234 + pointer->abc" &var var->field function_name var
addr2line $pc $r1 "$r2 + var"
addr2line [24/08/29 20:51:02] [CPU1] [209] [ap] sched_dumpstack: backtrace| 0: 0x402cd484 0x4028357e
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
1a934a4da0
tools/gdb: fix older version gdb compatibility issue
...
Prebuilt arm-none-eabi-gdb may have not socket module available.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
58cd81ea46
tools/gdb: register NuttX commands when loading the first elf file
...
Make sure elf exists before registering our commands. If no elf at the moment, register event to GDB to get notified when user adds the first object file.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
444396ee37
tools/gdb: use os.system to call readelf
...
Some version of gdb does not support subprocess
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
d15540a836
tools/gdb: add deadlock detect tool
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
7b43cf5221
tools/gdb: make entry for list iteration optional
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
buxiasen
3f3bbf76f9
tool/gdb/memdump: fix orphan, fix -p support
...
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
796806c65b
tools/gdb: allow to use info nxthreads
...
(gdb) info threads
Id Target Id Frame
* 1.1 Thread 1 (Name: CPU0 IDLE, State: 3, Pri: 0, Stack: 41eccfec, Size: 3976) 0x402cd586 in up_idle () at chip/r528_idle.c:80
1.2 Thread 2 (Name: CPU1 IDLE, State: 4, Pri: 0, Stack: 4194bb78, Size: 3976) 0x402cd586 in up_idle () at chip/r528_idle.c:80
(gdb) info nxthreads
Index Tid Pid Cpu Thread Info Frame
0 0 0 0 '\000' Thread 0x419633b8 (Name: CPU0 IDLE, State: Assigned, Priority: 0, Stack: 3976) 0x402cd586 up_idle() at chip/r528_idle.c:80
*1 1 1 1 '\001' Thread 0x41963498 (Name: CPU1 IDLE, State: Running, Priority: 0, Stack: 3976) 0x402cd586 up_idle() at chip/r528_idle.c:80
(gdb)
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
db1e97405a
thread.py: fix bug that ARM-A TCB info register[2]
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
Gao Jiawei
b5e7f8a40f
trvial adjustment on get_arch_(sp|pc)_name()
...
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-23 13:09:16 +08:00
Gao Jiawei
1b5b882e53
improve sanity checking when constructing the stack object
...
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-23 13:09:16 +08:00
Gao Jiawei
fa8aff6d9b
regression: use stack TLS region to retrieve task argument vector
...
ta_argv is removed, we use pointer to the TLS instead
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
7daecfb10c
tools/gdb: fallback to parse elf to get macro
...
For LTO optimization, we may not be able to parse the macro value. Parse .debug_macro section from elf manually.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
yinshengkai
0413d74f31
libs: add gcov framework support
...
In devices without storage media, you can export data to the
command line and then generate the corresponding gcda file
It can save the result output by calling __gcov_info_to_gcda
The usage is similar to:
https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html#Profiling-and-Test-Coverage-in-Freestanding-Environments
Usage:
./tools/configure.sh qemu-armv7a:nsh
Modify the configuration
+CONFIG_COVERAGE_ALL=y
+CONFIG_COVERAGE_MINI=y
+CONFIG_SYSTEM_GCOV=y
Run:
qemu-system-arm -cpu cortex-a7 -nographic -smp 4 \
-machine virt,virtualization=off,gic-version=2 \
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
-mon chardev=con,mode=readline -kernel ./nuttx/nuttx -semihosting -s | tee gcov.txt
./nuttx/tools/gcov_convert.py -i ./gcov.txt
./nuttx/tools/gcov.sh -t arm-none-eabi-gcov
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-22 19:08:08 +08:00
Jouni Ukkonen
74cdb53027
tools/imx9: Add norimage support to bootloader
...
Fetch fspi header and fcb generation script,
using mkimage generate nor bootable image.
compile bootloader using -mstrict-align
Signed-off-by: Jouni Ukkonen <jouni.ukkonen@unikie.com>
2024-11-22 18:53:21 +08:00
Zhe Weng
5ec2c97424
tools/gdb: Supports args and help for netstats
...
(gdb) help netstats
Network statistics
Usage: netstats [iob|pkt|tcp|udp|all]
Examples: netstats - Show all stats
netstats all - Show all stats
netstats iob - Show IOB stats
netstats tcp udp - Show both TCP and UDP stats
(gdb) netstats iob pkt
IOB: size ntotal nfree nwait nthrottle
1518 72 72 0 40
Packets: IPv4 IPv6 TCP UDP ICMP ICMPv6
Received 12 20 2 10 0 0
Dropped 0 20 0 0 0 0
VHL 0 0 - - - -
Frag 0 0 - - - -
Chksum 0 - 0 0 - -
Type - - - - 0 0
Proto 0 0 - - - -
Sent 4 0 4 0 0 0
Rexmit - - 2 - - -
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
d0884828ed
tools/gdb: Add TCP in netstats
...
(gdb) netstats
IOB: size ntotal nfree nwait nthrottle
1518 72 70 0 38
<...>
TCP Conn: st flg ref tmr uack nrt txbuf rxbuf+ofo local_address remote_address
0 4 61 1 3 0 0 0/16384 28/16384+0 10.0.1.2:11315 10.0.1.1:5001
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
395090284a
tools/gdb: Add UDP in netstats
...
(gdb) netstats
IOB: size ntotal nfree nwait nthrottle
1518 72 70 0 38
<...>
UDP Conn: flg txbuf rxbuf local_address remote_address
0 41 0/16384 0/16384 :::19279 fc00::1:5001
1 41 0/16384 0/16384 :::19280 fc00::1:5001
2 41 0/16384 0/16384 :::19281 fc00::1:5001
3 41 0/16384 0/16384 :::19282 fc00::1:5001
4 41 0/16384 0/16384 :::19283 fc00::1:5001
5 41 0/16384 0/16384 0.0.0.0:19284 10.0.1.1:5001
6 41 0/16384 0/16384 0.0.0.0:19285 10.0.1.1:5001
7 41 0/16384 0/16384 0.0.0.0:19286 10.0.1.1:5001
8 41 0/16384 0/16384 0.0.0.0:19287 10.0.1.1:5001
9 41 0/16384 0/16384 0.0.0.0:19288 10.0.1.1:5001
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
1c884ee230
tools/gdb: Add packet statistic in netstats
...
Unlike NuttX's one, we use decimal instead of hexadecimal, because other
stats may all use decimal.
(gdb) netstats
IOB: size ntotal nfree nwait nthrottle
1518 72 72 0 40
Packets: IPv4 IPv6 TCP UDP ICMP ICMPv6
Received 137 43 0 49 88 0
Dropped 0 43 0 0 74 0
VHL 0 0 - - - -
Frag 0 0 - - - -
Chksum 0 - 0 0 - -
Type - - - - 74 0
Proto 0 0 - - - -
Sent 11481 11542 0 17223 27 4
Rexmit - - 0 - - -
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
4ff0447027
tools/gdb: Add net.py and netstats command
...
Only support IOB stats now, may add socket status later.
(gdb) netstats
IOB: size ntotal nfree nwait nthrottle
1518 72 72 0 40
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
xuxingliang
992d5e0127
tools/gdb: add info shm
command
...
(gdb) info shm
/var/shm/xms:bq-325-1044165565 memsize: 1536000, paddr: 0x41de3970
/var/shm/xms:bq-325-2123092606 memsize: 1536000, paddr: 0x41f5a9a8
/var/shm/xms:fakemq-325-1835096569 memsize: 12, paddr: 0x420d19e0
(gdb)
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-22 12:30:12 +08:00
xuxingliang
4e2ad314d7
tools/gdb: avoid building a full list
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-22 12:30:12 +08:00
yangao1
ab3aa41f39
tools/gdb/fs.py: add print fdinfo,modify the print format
...
Execute fdinfo or fdinfo -p pid.
(gdb) fdinfo
PID: 0
FD OFLAGS POS PATH BACKTRACE
0 3 0 /dev/console 0x4028ff0c <sched_backtrace+48> /home/neo/projects/vela2/nuttx/sched/sched/sched_backtrace.c:105
0x402888f8 <file_allocate_from_tcb+236> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:615
0x402979d0 <nx_vopen+104> /home/neo/projects/vela2/nuttx/fs/vfs/fs_open.c:326
0x40297ad4 <nx_open+116> /home/neo/projects/vela2/nuttx/fs/vfs/fs_open.c:449
0x40291eb4 <group_setupidlefiles+28> /home/neo/projects/vela2/nuttx/sched/group/group_setupidlefiles.c:75
0x4028df94 <nx_start+628> /home/neo/projects/vela2/nuttx/sched/init/nx_start.c:651
0x4028119c <arm64_boot_primary_c_routine+16> /home/neo/projects/vela2/nuttx/arch/arm64/src/common/arm64_boot.c:205
1 3 0 /dev/console 0x4028ff0c <sched_backtrace+48> /home/neo/projects/vela2/nuttx/sched/sched/sched_backtrace.c:105
0x40289574 <file_dup3+248> /home/neo/projects/vela2/nuttx/fs/vfs/fs_dup2.c:177
0x40288b88 <nx_dup3_from_tcb+176> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:314
0x40288c64 <nx_dup2_from_tcb+16> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:901
0x40288c88 <nx_dup2+28> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:924
0x40291ec4 <group_setupidlefiles+44> /home/neo/projects/vela2/nuttx/sched/group/group_setupidlefiles.c:84
0x4028df94 <nx_start+628> /home/neo/projects/vela2/nuttx/sched/init/nx_start.c:651
0x4028119c <arm64_boot_primary_c_routine+16> /home/neo/projects/vela2/nuttx/arch/arm64/src/common/arm64_boot.c:205
2 3 0 /dev/console 0x4028ff0c <sched_backtrace+48> /home/neo/projects/vela2/nuttx/sched/sched/sched_backtrace.c:105
0x40289574 <file_dup3+248> /home/neo/projects/vela2/nuttx/fs/vfs/fs_dup2.c:177
0x40288b88 <nx_dup3_from_tcb+176> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:314
0x40288c64 <nx_dup2_from_tcb+16> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:901
0x40288c88 <nx_dup2+28> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:924
0x40291ed0 <group_setupidlefiles+56> /home/neo/projects/vela2/nuttx/sched/group/group_setupidlefiles.c:117
0x4028df94 <nx_start+628> /home/neo/projects/vela2/nuttx/sched/init/nx_start.c:651
0x4028119c <arm64_boot_primary_c_routine+16> /home/neo/projects/vela2/nuttx/arch/arm64/src/common/arm64_boot.c:205
Signed-off-by: yangao1 <yangao1@xiaomi.com>
2024-11-22 12:30:12 +08:00
zhengyu9
136b7065b7
gdb tools: print inode info
...
go through each inode and print its structure info
in the form like below:
├── i_name: bin, i_ino: 51
│ i_parent: , i_peer: data, i_child: , i_crefs: 1, i_flags: 3
│ ......(other info)
│ ├── i_name: audio, i_ino: 5
│ │ i_parent: dev, i_peer: binder, i_child: mixer......
Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
2024-11-22 12:30:12 +08:00
zhengyu9
fab9670857
gdb tools: mount command
...
support mount command in gdb, print mount information
test result:
/bin type binfs
/data type hostfs
/etc type romfs
/proc type procfs
/resource type hostfs
/tmp type tmpfs
Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
2024-11-22 12:30:12 +08:00
Neo Xu
1518f8bdb8
tools/gdb: fix type and comments
...
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-11-21 23:08:55 +08:00
anjiahao
cd78de7c63
memleak:Add reminder information
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-21 23:08:55 +08:00
anjiahao
b507a57158
thread.py: fix bug that ARM-A TCB info register offset is discontinuous
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
0f1e2cc7dc
tools/gdb: make it compatible with older gdb
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
anjiahao
f53869f86f
memleak:use global symbol to search all global variables
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-21 23:08:55 +08:00
anjiahao
8575f11e1e
memdump.py:use import_check inside of once_init
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-21 23:08:55 +08:00
anjiahao
e71d45ce86
utils.py:support import check and requirements.txt
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-21 23:08:55 +08:00
buxiasen
bf2d6a3554
tools/gdb/memdump: add biggest/orphon dump.
...
information prefer from gdb to python class
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
fc0f7365bb
tools/gdb: fix import error for certain gdb
...
For the prebuilt arm-none-eabi-gdb, there's no python builtin module
available.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
de5f70b3c8
tools/gdb: remove 'Nx' prefix for unique commands
...
1. Remove Nx prefix for nuttx unique commands.
2. Add docstring for most of the commands in order to show help message.
3. Add 'init_once' method for Memmap command. The prerequisite is checked the moment it's used.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
3a46b6e6af
tools/gdb: cache gdb.Type result
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
1d25eed55c
tools/gdb: fix CONFIG_SMP_NCPUS could be none
...
The macro could be eliminated by optimization.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
715c3ab079
tools/gdb: fix notification suppress not working
...
"on" string is always in the word 'notification'. Should use "is on" instead.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
ad1be85be7
tools/gdb: catch exception when there's no selected frame
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
bbf51ba071
tools/gdb: no need to read the whole memory firstly
...
Read the whole memory costs additional time. When the number memory nodes is
small, test on qemu shows that read memory directly is faster.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
12783c031c
tools/gdb: only define c and s when thread comands enabled
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
yinshengkai
b81212e96f
tools/gdb: Add memory fragmentation rate calculation
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
9dbf58f1be
tools/gdb: optimize memleak speed
...
1. Avoid to_bytes by using memoryview directly.
2. No need to call gdb to cast to char *.
3. Cache the memory data without invoke gdb in every iteration.
4. Do code cleanup.
memleak speed improved from 261.93 seconds to 29.9 seconds for x4b
usecase.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
4e067fd762
tool/gdb: use second inferior to get symbol
...
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
yinshengkai
614e07c8f0
tools/gdb: supports generating memory map images
...
Display all memory nodes in a picture, which can be used to help analyze memory fragmentation
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-21 23:08:55 +08:00
xuxingliang
2f8c9070c5
tools/gdb: use native thread command
...
For coredump, gdb-stub, the thread command is natively supported.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-21 23:08:55 +08:00
anjiahao
089877c693
memleak:support use gdb to catching absolute memory leaks
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-21 23:08:55 +08:00
Peter Bee
c0f776dbc3
follow upstream change & fix minor things
...
Signed-off-by: Peter Bee <pbjd97@gmail.com>
2024-11-20 16:32:05 -03:00
Marco Casaroli
dac3f315a1
uf2
2024-11-20 16:32:05 -03:00
Neo Xu
edc410f26f
format code to pass CI
...
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-11-20 09:04:22 +08:00
buxiasen
96a3bc2b5c
tools/gdb: fix if restore_regs failed script abort
...
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-20 09:04:22 +08:00
anjiahao
eded2017d4
memdump.py:Enhance the printing function of memdump
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-20 09:04:22 +08:00
anjiahao
477f7b92ee
tools/gdb/memdump.py:fix mempool memory traversal missing nodes
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-20 09:04:22 +08:00
xuxingliang
8264c05c15
tools/gdb: use f string where possible
...
misc update.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-20 09:04:22 +08:00
Gao Jiawei
06d640a677
implement ps
nx shell utility for ez debugging with GDB
...
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-20 09:04:22 +08:00
Gao Jiawei
e31fe0fb55
add custom command and APIs for retrieving/displaying stack statistics
...
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-20 09:04:22 +08:00
Gao Jiawei
8edb9283ba
trivial modification on the utility module
...
1. add get macro related inteface, for now we have't fully implemented
the way to expand and evalute macros at runtime. We just deal with some macros that can be expand and evaluate into essential constants that will be needed later.
2. rearrange utility functions in a different order
3. reimplment the get register API to make it more commonly used
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-20 09:04:22 +08:00
Gao Jiawei
76db3c8939
enable stack trace printing on excpetion
...
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-20 09:04:22 +08:00
anjiahao
e0bea987d1
gdb python plugin:support dump list member
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-20 09:04:22 +08:00
anjiahao
daac426f79
gdb python plugin:add hexdump command support
...
hexdump useful to debug
format such as:
(gdb) hexdump 0x0062fd30 500
0062fd30 73 68 6f 77 5f 76 61 72 69 61 62 6c 65 3a 20 45 show_variable: E
0062fd40 52 52 4f 52 20 56 61 72 69 61 62 6c 65 3d 25 73 RROR Variable=%s
0062fd50 20 68 61 73 20 74 68 65 20 77 72 6f 6e 67 20 76 has the wrong v
0062fd60 61 6c 75 65 0a 00 6f 73 74 65 73 74 5f 6d 61 69 alue..ostest_mai
0062fd70 6e 2e 63 00 73 68 6f 77 5f 76 61 72 69 61 62 6c n.c.show_variabl
0062fd80 65 3a 20 45 52 52 4f 52 20 56 61 72 69 61 62 6c e: ERROR Variabl
0062fd90 65 3d 25 73 20 68 61 73 20 61 20 76 61 6c 75 65 e=%s has a value
0062fda0 20 77 68 65 6e 20 69 74 20 73 68 6f 75 6c 64 20 when it should
0062fdb0 6e 6f 74 0a 00 73 68 6f 77 5f 76 61 72 69 61 62 not..show_variab
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-20 09:04:22 +08:00
anjiahao
635e324e9a
gdb/thread.py:simplify the logic of nxsetregs
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-20 09:04:22 +08:00
wangmingrong
8eb1047595
gdb python tools: fix command "info thread" echo error
...
Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2024-11-20 09:04:22 +08:00
anjiahao
eccd26a162
gdb/thread.py:Print colorful
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-20 09:04:22 +08:00