2020-07-02 10:46:10 +02:00
|
|
|
############################################################################
|
|
|
|
# tools/nuttx-gdbinit
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
# NOTE: you need to use gdb configured '--with-python'
|
|
|
|
# usage: gdb -ix=./tools/nuttx-gdbinit nuttx
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
# new commands: nxthread pid, nxthread_all_bt
|
2020-07-02 10:46:10 +02:00
|
|
|
|
2020-11-27 02:44:59 +01:00
|
|
|
# Do not stop with SIGUSR1 which is used for the NuttX sim SMP
|
|
|
|
handle SIGUSR1 "nostop" "pass" "noprint"
|
|
|
|
|
2020-07-02 10:46:10 +02:00
|
|
|
set $_current_tcb = 0x0
|
|
|
|
set $_target_examined = 0x0
|
|
|
|
|
|
|
|
define _examine_arch
|
|
|
|
python _target_frame = gdb.selected_frame()
|
|
|
|
python _target_arch = _target_frame.architecture()
|
|
|
|
|
|
|
|
python if (_target_arch.name() == 'armv7e-m') : \
|
|
|
|
gdb.execute("set $_target_arch = \"armv7e-m\"")
|
|
|
|
|
|
|
|
python if (_target_arch.name() == 'armv7') : \
|
|
|
|
gdb.execute("set $_target_arch = \"armv7e-m\"")
|
|
|
|
|
2021-07-22 00:28:49 +02:00
|
|
|
# TODO: need more smart way to detect armv7-a
|
|
|
|
python if (type(gdb.lookup_global_symbol("arm_gic_initialize")) is gdb.Symbol) : \
|
|
|
|
gdb.execute("set $_target_arch = \"armv7-a\"")
|
|
|
|
|
2020-07-02 10:46:10 +02:00
|
|
|
python if (_target_arch.name() == 'i386:x86-64') : \
|
|
|
|
gdb.execute("set $_target_arch = \"i386:x86-64\"")
|
|
|
|
|
|
|
|
# NOTE: we assume that sim has sim_bringup function
|
2021-11-08 13:43:54 +01:00
|
|
|
python if (type(gdb.lookup_static_symbol("sim_start")) is gdb.Symbol \
|
2021-11-05 16:56:06 +01:00
|
|
|
and _target_arch.name() == 'i386') : \
|
|
|
|
gdb.execute("set $_target_arch=\"sim:x86\"")
|
|
|
|
|
2021-11-08 13:43:54 +01:00
|
|
|
python if (type(gdb.lookup_static_symbol("sim_start")) is gdb.Symbol \
|
2021-11-05 16:56:06 +01:00
|
|
|
and _target_arch.name() == 'i386:x86-64') : \
|
2020-07-02 10:46:10 +02:00
|
|
|
gdb.execute("set $_target_arch=\"sim:x86-64\"")
|
|
|
|
end
|
|
|
|
|
|
|
|
define _examine_target
|
|
|
|
if ($_target_examined == 0x0)
|
|
|
|
_examine_arch
|
|
|
|
|
2023-05-06 06:07:29 +02:00
|
|
|
set $_xcp_nregs = sizeof(g_last_regs) / sizeof(void *)
|
2020-11-23 00:31:35 +01:00
|
|
|
set $_target_has_fpu = 0
|
|
|
|
|
|
|
|
if ($_streq($_target_arch, "armv7e-m") == 1)
|
|
|
|
if ($_xcp_nregs != 19)
|
|
|
|
set $_target_has_fpu = 1
|
|
|
|
end
|
|
|
|
end
|
2020-07-02 10:46:10 +02:00
|
|
|
|
2021-07-22 00:28:49 +02:00
|
|
|
if ($_streq($_target_arch, "armv7-a") == 1)
|
|
|
|
if ($_xcp_nregs != 17)
|
|
|
|
set $_target_has_fpu = 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-02 10:46:10 +02:00
|
|
|
python gdb.execute("set $_target_has_smp = 0")
|
|
|
|
python if (type(gdb.lookup_global_symbol("g_assignedtasks")) is gdb.Symbol) : \
|
|
|
|
gdb.execute("set $_target_has_smp = 1")
|
|
|
|
|
|
|
|
set $_target_examined = 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
define _running_task
|
|
|
|
if ($_target_has_smp == 0)
|
|
|
|
set $rtcb = (struct tcb_s *)g_readytorun->head
|
|
|
|
else
|
|
|
|
set $rtcb = (struct tcb_s *)g_assignedtasks[up_cpu_index()]->head
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-02 10:46:10 +02:00
|
|
|
define _print_thread
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
_running_task
|
2020-07-02 10:46:10 +02:00
|
|
|
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
if ($tcb == $rtcb)
|
2020-07-02 10:46:10 +02:00
|
|
|
printf "* "
|
|
|
|
else
|
|
|
|
printf " "
|
|
|
|
end
|
|
|
|
|
2023-05-06 06:10:09 +02:00
|
|
|
printf "%d Thread 0x%x (Name: %s, State: %s, Priority: %d, Stack: %d) PC: 0x%x in ", \
|
2020-07-02 10:46:10 +02:00
|
|
|
$tcb->pid, $tcb, $tcb->name, g_statenames[$tcb->task_state], $tcb->sched_priority, \
|
2023-05-06 06:10:09 +02:00
|
|
|
$tcb->adj_stack_size, $tcb->xcp.regs[$_pc_reg_idx]
|
2020-07-02 10:46:10 +02:00
|
|
|
python _symbol = gdb.execute("info symbol $tcb->xcp.regs[$_pc_reg_idx]", to_string=True); \
|
|
|
|
print(_symbol.split()[0] + "()")
|
|
|
|
end
|
|
|
|
|
|
|
|
define _save_tcb
|
|
|
|
_examine_target
|
|
|
|
|
|
|
|
set $tcb = $arg0
|
2021-07-22 00:28:49 +02:00
|
|
|
if ($_streq($_target_arch, "armv7-a") == 1)
|
|
|
|
_save_tcb_armv7-a $tcb
|
|
|
|
end
|
2020-07-02 10:46:10 +02:00
|
|
|
if ($_streq($_target_arch, "armv7e-m") == 1)
|
|
|
|
if ($_target_has_fpu == 0)
|
|
|
|
_save_tcb_armv7e-m $tcb
|
|
|
|
else
|
|
|
|
_save_tcb_armv7e-mf $tcb
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if ($_streq($_target_arch, "i386:x86-64") == 1)
|
|
|
|
_save_tcb_i386x86-64 $tcb
|
|
|
|
end
|
|
|
|
if ($_streq($_target_arch, "sim:x86-64") == 1)
|
|
|
|
_save_tcb_simx86-64 $tcb
|
|
|
|
end
|
2021-11-05 16:56:06 +01:00
|
|
|
if ($_streq($_target_arch, "sim:x86") == 1)
|
|
|
|
_save_tcb_simx86 $tcb
|
|
|
|
end
|
2020-07-02 10:46:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
define _save_current_tcb
|
|
|
|
_examine_target
|
|
|
|
|
|
|
|
if ($_current_tcb == 0)
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
_running_task
|
|
|
|
_save_tcb $rtcb
|
|
|
|
set $_current_tcb = $rtcb
|
2020-07-02 10:46:10 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
define _switch_tcb
|
|
|
|
_save_current_tcb
|
|
|
|
|
|
|
|
# set the current frame to the newest before switching
|
|
|
|
python if (gdb.selected_frame() != gdb.newest_frame()) : \
|
|
|
|
gdb.newest_frame().select()
|
|
|
|
|
|
|
|
set $tcb = $arg0
|
2021-07-22 00:28:49 +02:00
|
|
|
if ($_streq($_target_arch, "armv7-a") == 1)
|
|
|
|
_switch_tcb_armv7-a $tcb
|
|
|
|
end
|
2020-07-02 10:46:10 +02:00
|
|
|
if ($_streq($_target_arch, "armv7e-m") == 1)
|
|
|
|
if ($_target_has_fpu == 0)
|
|
|
|
_switch_tcb_armv7e-m $tcb
|
|
|
|
else
|
|
|
|
_switch_tcb_armv7e-mf $tcb
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if ($_streq($_target_arch, "i386:x86-64") == 1)
|
|
|
|
_switch_tcb_i386x86-64 $tcb
|
|
|
|
end
|
|
|
|
if ($_streq($_target_arch, "sim:x86-64") == 1)
|
|
|
|
_switch_tcb_simx86-64 $tcb
|
|
|
|
end
|
2021-11-05 16:56:06 +01:00
|
|
|
if ($_streq($_target_arch, "sim:x86") == 1)
|
|
|
|
_switch_tcb_simx86 $tcb
|
|
|
|
end
|
2020-07-02 10:46:10 +02:00
|
|
|
|
|
|
|
# update _current_tcb
|
|
|
|
set $_current_tcb = $tcb
|
|
|
|
end
|
|
|
|
|
2021-07-22 00:28:49 +02:00
|
|
|
# see nuttx/arch/arm/include/armv7-a/irq.h
|
|
|
|
define _save_tcb_armv7-a
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
2023-05-08 12:17:15 +02:00
|
|
|
set $tcb.xcp.regs[0] = $r13
|
|
|
|
set $tcb.xcp.regs[1] = $r14
|
|
|
|
set $tcb.xcp.regs[2] = $r0
|
|
|
|
set $tcb.xcp.regs[3] = $r1
|
|
|
|
set $tcb.xcp.regs[4] = $r2
|
|
|
|
set $tcb.xcp.regs[5] = $r3
|
|
|
|
set $tcb.xcp.regs[6] = $r4
|
|
|
|
set $tcb.xcp.regs[7] = $r5
|
|
|
|
set $tcb.xcp.regs[8] = $r6
|
|
|
|
set $tcb.xcp.regs[9] = $r7
|
|
|
|
set $tcb.xcp.regs[10] = $r8
|
|
|
|
set $tcb.xcp.regs[11] = $r9
|
|
|
|
set $tcb.xcp.regs[12] = $r10
|
|
|
|
set $tcb.xcp.regs[13] = $r11
|
|
|
|
set $tcb.xcp.regs[14] = $r12
|
2021-07-22 00:28:49 +02:00
|
|
|
set $tcb.xcp.regs[15] = $r15
|
2023-05-08 12:17:15 +02:00
|
|
|
set $tcb.xcp.regs[16] = $cpsr
|
2021-07-22 00:28:49 +02:00
|
|
|
|
|
|
|
set $_pc_reg_idx = 15
|
|
|
|
end
|
|
|
|
|
|
|
|
define _switch_tcb_armv7-a
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
2023-05-08 12:17:15 +02:00
|
|
|
set $r13 = $tcb.xcp.regs[0]
|
|
|
|
set $r14 = $tcb.xcp.regs[1]
|
|
|
|
set $r0 = $tcb.xcp.regs[2]
|
|
|
|
set $r1 = $tcb.xcp.regs[3]
|
|
|
|
set $r2 = $tcb.xcp.regs[4]
|
|
|
|
set $r3 = $tcb.xcp.regs[5]
|
|
|
|
set $r4 = $tcb.xcp.regs[6]
|
|
|
|
set $r5 = $tcb.xcp.regs[7]
|
|
|
|
set $r6 = $tcb.xcp.regs[8]
|
|
|
|
set $r7 = $tcb.xcp.regs[9]
|
|
|
|
set $r8 = $tcb.xcp.regs[10]
|
|
|
|
set $r9 = $tcb.xcp.regs[11]
|
|
|
|
set $r10 = $tcb.xcp.regs[12]
|
|
|
|
set $r11 = $tcb.xcp.regs[13]
|
|
|
|
set $r12 = $tcb.xcp.regs[14]
|
2021-07-22 00:28:49 +02:00
|
|
|
set $r15 = $tcb.xcp.regs[15]
|
2023-05-08 12:17:15 +02:00
|
|
|
set $cpsr = $tcb.xcp.regs[16]
|
2021-07-22 00:28:49 +02:00
|
|
|
end
|
|
|
|
|
2020-07-02 10:46:10 +02:00
|
|
|
# see nuttx/arch/arm/include/armv7-m/irq_cmnvector.h
|
|
|
|
define _save_tcb_armv7e-m
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $tcb.xcp.regs[0] = $sp
|
|
|
|
# TODO: basepri/primask
|
|
|
|
set $tcb.xcp.regs[2] = $r4
|
|
|
|
set $tcb.xcp.regs[3] = $r5
|
|
|
|
set $tcb.xcp.regs[4] = $r6
|
|
|
|
set $tcb.xcp.regs[5] = $r7
|
|
|
|
set $tcb.xcp.regs[6] = $r8
|
|
|
|
set $tcb.xcp.regs[7] = $r9
|
|
|
|
set $tcb.xcp.regs[8] = $r10
|
|
|
|
set $tcb.xcp.regs[9] = $r11
|
|
|
|
# TODO: EXC_RETURN (protected)
|
2020-09-23 09:18:00 +02:00
|
|
|
set $tcb.xcp.regs[11] = $r0
|
|
|
|
set $tcb.xcp.regs[12] = $r1
|
|
|
|
set $tcb.xcp.regs[13] = $r2
|
|
|
|
set $tcb.xcp.regs[14] = $r3
|
|
|
|
set $tcb.xcp.regs[15] = $r12
|
|
|
|
set $tcb.xcp.regs[16] = $lr
|
|
|
|
set $tcb.xcp.regs[17] = $pc
|
2020-07-02 10:46:10 +02:00
|
|
|
# TODO: xPSR
|
|
|
|
|
2020-09-23 09:18:00 +02:00
|
|
|
set $_pc_reg_idx = 17
|
2020-07-02 10:46:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
define _switch_tcb_armv7e-m
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $sp = $tcb.xcp.regs[0]
|
|
|
|
# TODO: basepri/primask
|
|
|
|
set $r4 = $tcb.xcp.regs[2]
|
|
|
|
set $r5 = $tcb.xcp.regs[3]
|
|
|
|
set $r6 = $tcb.xcp.regs[4]
|
|
|
|
set $r7 = $tcb.xcp.regs[5]
|
|
|
|
set $r8 = $tcb.xcp.regs[6]
|
|
|
|
set $r9 = $tcb.xcp.regs[7]
|
|
|
|
set $r10 = $tcb.xcp.regs[8]
|
|
|
|
set $r11 = $tcb.xcp.regs[9]
|
|
|
|
# TODO: EXC_RETURN (protected)
|
2020-09-23 09:18:00 +02:00
|
|
|
set $r0 = $tcb.xcp.regs[11]
|
|
|
|
set $r1 = $tcb.xcp.regs[12]
|
|
|
|
set $r2 = $tcb.xcp.regs[13]
|
|
|
|
set $r3 = $tcb.xcp.regs[14]
|
|
|
|
set $r12 = $tcb.xcp.regs[15]
|
|
|
|
set $lr = $tcb.xcp.regs[16]
|
|
|
|
set $pc = $tcb.xcp.regs[17]
|
2020-07-02 10:46:10 +02:00
|
|
|
# TODO: xPSR
|
|
|
|
end
|
|
|
|
|
|
|
|
# see nuttx/arch/arm/include/armv7-m/irq_cmnvector.h
|
|
|
|
define _save_tcb_armv7e-mf
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $tcb.xcp.regs[0] = $sp
|
|
|
|
# TODO: basepri/primask
|
|
|
|
set $tcb.xcp.regs[2] = $r4
|
|
|
|
set $tcb.xcp.regs[3] = $r5
|
|
|
|
set $tcb.xcp.regs[4] = $r6
|
|
|
|
set $tcb.xcp.regs[5] = $r7
|
|
|
|
set $tcb.xcp.regs[6] = $r8
|
|
|
|
set $tcb.xcp.regs[7] = $r9
|
|
|
|
set $tcb.xcp.regs[8] = $r10
|
|
|
|
set $tcb.xcp.regs[9] = $r11
|
|
|
|
# TODO: EXC_RETURN (protected)
|
|
|
|
# TODO: FPU
|
|
|
|
set $tcb.xcp.regs[27] = $r0
|
|
|
|
set $tcb.xcp.regs[28] = $r1
|
|
|
|
set $tcb.xcp.regs[29] = $r2
|
|
|
|
set $tcb.xcp.regs[30] = $r3
|
|
|
|
set $tcb.xcp.regs[31] = $r12
|
|
|
|
set $tcb.xcp.regs[32] = $lr
|
|
|
|
set $tcb.xcp.regs[33] = $pc
|
|
|
|
# TODO: xPSR
|
|
|
|
|
|
|
|
set $_pc_reg_idx = 33
|
|
|
|
end
|
|
|
|
|
|
|
|
define _switch_tcb_armv7e-mf
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $sp = $tcb.xcp.regs[0]
|
|
|
|
# TODO: basepri/primask
|
|
|
|
set $r4 = $tcb.xcp.regs[2]
|
|
|
|
set $r5 = $tcb.xcp.regs[3]
|
|
|
|
set $r6 = $tcb.xcp.regs[4]
|
|
|
|
set $r7 = $tcb.xcp.regs[5]
|
|
|
|
set $r8 = $tcb.xcp.regs[6]
|
|
|
|
set $r9 = $tcb.xcp.regs[7]
|
|
|
|
set $r10 = $tcb.xcp.regs[8]
|
|
|
|
set $r11 = $tcb.xcp.regs[9]
|
|
|
|
# TODO: EXC_RETURN (protected)
|
|
|
|
# TODO: FPU
|
|
|
|
set $r0 = $tcb.xcp.regs[27]
|
|
|
|
set $r1 = $tcb.xcp.regs[28]
|
|
|
|
set $r2 = $tcb.xcp.regs[29]
|
|
|
|
set $r3 = $tcb.xcp.regs[30]
|
|
|
|
set $r12 = $tcb.xcp.regs[31]
|
|
|
|
set $lr = $tcb.xcp.regs[32]
|
|
|
|
set $pc = $tcb.xcp.regs[33]
|
|
|
|
# TODO: xPSR
|
|
|
|
end
|
|
|
|
|
|
|
|
# see nuttx/arch/x86_64/include/intel64/irq.h
|
|
|
|
define _save_tcb_i386x86-64
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $tcb.xcp.regs[6 + 64] = $rbx
|
|
|
|
set $tcb.xcp.regs[7 + 64] = $rbp
|
|
|
|
set $tcb.xcp.regs[10 + 64] = $r12
|
|
|
|
set $tcb.xcp.regs[11 + 64] = $r13
|
|
|
|
set $tcb.xcp.regs[12 + 64] = $r14
|
|
|
|
set $tcb.xcp.regs[13 + 64] = $r15
|
|
|
|
set $tcb.xcp.regs[21 + 64] = $rip
|
|
|
|
set $tcb.xcp.regs[24 + 64] = $rsp
|
|
|
|
|
|
|
|
set $_pc_reg_idx = (21 + 64)
|
|
|
|
end
|
|
|
|
|
|
|
|
define _switch_tcb_i386x86-64
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $rbx = $tcb.xcp.regs[6 + 64]
|
|
|
|
set $rbp = $tcb.xcp.regs[7 + 64]
|
|
|
|
set $r12 = $tcb.xcp.regs[10 + 64]
|
|
|
|
set $r13 = $tcb.xcp.regs[11 + 64]
|
|
|
|
set $r14 = $tcb.xcp.regs[12 + 64]
|
|
|
|
set $r15 = $tcb.xcp.regs[13 + 64]
|
|
|
|
set $rip = $tcb.xcp.regs[21 + 64]
|
|
|
|
set $rsp = $tcb.xcp.regs[24 + 64]
|
|
|
|
end
|
|
|
|
|
|
|
|
# see nuttx/arch/sim/src/sim/up_internal.h
|
|
|
|
define _save_tcb_simx86-64
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $tcb.xcp.regs[0] = $rbx
|
|
|
|
set $tcb.xcp.regs[1] = $rsp
|
|
|
|
set $tcb.xcp.regs[2] = $rbp
|
|
|
|
set $tcb.xcp.regs[3] = $r12
|
|
|
|
set $tcb.xcp.regs[4] = $r13
|
|
|
|
set $tcb.xcp.regs[5] = $r14
|
|
|
|
set $tcb.xcp.regs[6] = $r15
|
|
|
|
set $tcb.xcp.regs[7] = $rip
|
|
|
|
|
|
|
|
set $_pc_reg_idx = 7
|
|
|
|
end
|
|
|
|
|
|
|
|
define _switch_tcb_simx86-64
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $rbx = $tcb.xcp.regs[0]
|
|
|
|
set $rsp = $tcb.xcp.regs[1]
|
|
|
|
set $rbp = $tcb.xcp.regs[2]
|
|
|
|
set $r12 = $tcb.xcp.regs[3]
|
|
|
|
set $r13 = $tcb.xcp.regs[4]
|
|
|
|
set $r14 = $tcb.xcp.regs[5]
|
|
|
|
set $r15 = $tcb.xcp.regs[6]
|
|
|
|
set $rip = $tcb.xcp.regs[7]
|
|
|
|
end
|
|
|
|
|
2021-11-05 16:56:06 +01:00
|
|
|
# see nuttx/arch/sim/src/sim/up_internal.h
|
|
|
|
define _save_tcb_simx86
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $tcb.xcp.regs[0] = $ebx
|
|
|
|
set $tcb.xcp.regs[1] = $esi
|
|
|
|
set $tcb.xcp.regs[2] = $edi
|
|
|
|
set $tcb.xcp.regs[3] = $ebp
|
|
|
|
set $tcb.xcp.regs[4] = $sp
|
|
|
|
set $tcb.xcp.regs[5] = $pc
|
|
|
|
|
|
|
|
set $_pc_reg_idx = 5
|
|
|
|
end
|
|
|
|
|
|
|
|
define _switch_tcb_simx86
|
|
|
|
set $tcb = (struct tcb_s *)$arg0
|
|
|
|
set $ebx = $tcb.xcp.regs[0]
|
|
|
|
set $esi = $tcb.xcp.regs[1]
|
|
|
|
set $edi = $tcb.xcp.regs[2]
|
|
|
|
set $ebp = $tcb.xcp.regs[3]
|
|
|
|
set $sp = $tcb.xcp.regs[4]
|
|
|
|
set $pc = $tcb.xcp.regs[5]
|
|
|
|
end
|
|
|
|
|
2022-11-24 15:46:03 +01:00
|
|
|
define _restore_current_tcb
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
_examine_target
|
|
|
|
_running_task
|
|
|
|
_switch_tcb $rtcb
|
2022-11-24 15:46:03 +01:00
|
|
|
set $_current_tcb = 0x0
|
|
|
|
end
|
|
|
|
|
2020-07-02 10:46:10 +02:00
|
|
|
define nxthread
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
set $hash = ($arg0 & (g_npidhash - 1))
|
2021-10-14 05:03:07 +02:00
|
|
|
set $tcb = g_pidhash[$hash]
|
2020-07-02 10:46:10 +02:00
|
|
|
if ($tcb != 0x0)
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
_switch_tcb $tcb
|
2020-07-02 10:46:10 +02:00
|
|
|
_print_thread $tcb
|
|
|
|
if ($argc == 2)
|
|
|
|
if ($arg1 == 1)
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
_switch_tcb $tcb
|
|
|
|
where
|
2020-07-02 10:46:10 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
define nxthread_all_bt
|
|
|
|
_save_current_tcb
|
|
|
|
set $i = 0
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
while ($i < g_npidhash)
|
2020-07-02 10:46:10 +02:00
|
|
|
# 1: backtrace
|
|
|
|
nxthread $i 1
|
|
|
|
set $i = $i + 1
|
|
|
|
end
|
2022-11-24 15:46:03 +01:00
|
|
|
_restore_current_tcb
|
2020-07-02 10:46:10 +02:00
|
|
|
end
|
|
|
|
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
define info threads
|
2020-07-02 10:46:10 +02:00
|
|
|
_save_current_tcb
|
|
|
|
set $i = 0
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
while ($i < g_npidhash)
|
2020-07-02 10:46:10 +02:00
|
|
|
# dummy : 0 0
|
|
|
|
nxthread $i 0 0
|
|
|
|
set $i = $i + 1
|
|
|
|
end
|
2022-11-24 15:46:03 +01:00
|
|
|
_restore_current_tcb
|
2020-07-02 10:46:10 +02:00
|
|
|
end
|
|
|
|
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
define c
|
2022-11-24 15:46:03 +01:00
|
|
|
_restore_current_tcb
|
2020-07-02 10:46:10 +02:00
|
|
|
continue
|
|
|
|
end
|
tools/nuttx-gdbinit: improve experience of gdb backend scripts
Redefine built-in command (info thread/thread/c) to compatible with developer habits
Test board:
./tools/configure.sh -E lm3s6965-ek:qemu-flat
1. start qemu:
qemu-system-arm -M lm3s6965evb -device loader,file=nuttx -serial mon:stdio -nographic -s
2. gdb attach:
gdb-multiarch -ix tools/nuttx-gdbinit nuttx -ex "target extended-remote localhost:1234"
3. show thread info and callstack:
| (gdb) info thread
| * 0 Thread 0x20001548 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) PC: 0x9eee in up_idle()
| 1 Thread 0x20005058 (Name: hpwork, State: Waiting,Semaphore, Priority: 224, Stack: 1992) PC: 0xa124 in up_switch_context()
| 2 Thread 0x20005c20 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) PC: 0xa124 in up_switch_context()
| 3 Thread 0x20006b30 (Name: NTP daemon, State: Waiting,Semaphore, Priority: 100, Stack: 1952) PC: 0xa124 in up_switch_context()
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 0x00009eee in up_idle () at chip/common/tiva_idle.c:62
| #1 0x00003dd2 in nx_start () at init/nx_start.c:698
| #2 0x00000190 in __start () at chip/common/lmxx_tm4c_start.c:177
| (gdb) thread 4
| 4 Thread 0x200086f0 (Name: telnetd, State: Waiting,Semaphore, Priority: 100, Stack: 2008) PC: 0xa124 in up_switch_context()
| (gdb) bt
| #0 up_switch_context (tcb=0x20001548 <g_idletcb>, rtcb=rtcb@entry=0x200086f0) at common/arm_switchcontext.c:95
| #1 0x0000453a in nxsem_wait (sem=sem@entry=0x2000916c) at semaphore/sem_wait.c:176
| #2 0x0000197e in _net_timedwait (sem=sem@entry=0x2000916c, interruptible=interruptible@entry=true, timeout=timeout@entry=4294967295) at utils/net_lock.c:101
| #3 0x0000198e in net_sem_timedwait (sem=sem@entry=0x2000916c, timeout=timeout@entry=4294967295) at utils/net_lock.c:242
| #4 0x00001996 in net_sem_wait (sem=sem@entry=0x2000916c) at utils/net_lock.c:330
| #5 0x00025f84 in psock_tcp_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newconn=newconn@entry=0x2000956c) at tcp/tcp_accept.c:274
| #6 0x00025432 in inet_accept (psock=<optimized out>, addr=<optimized out>, addrlen=<optimized out>, newsock=0x20009568, flags=0) at inet/inet_sockif.c:1443
| #7 0x00027a10 in psock_accept (psock=0x200044b8, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, newsock=newsock@entry=0x20009568, flags=flags@entry=0) at socket/accept.c:149
| #8 0x00027a8c in accept4 (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c, flags=flags@entry=0) at socket/accept.c:280
| #9 0x0002a256 in accept (sockfd=sockfd@entry=3, addr=addr@entry=0x2000921c, addrlen=addrlen@entry=0x2000920c) at net/lib_accept.c:50
| #10 0x0001efaa in telnetd_daemon (config=config@entry=0x20009290) at telnetd_daemon.c:200
| #11 0x0001e508 in telnetd_main (argc=1, argv=0x20008af8) at telnetd.c:98
| #12 0x00008486 in nxtask_startup (entrypt=0x1e4bd <telnetd_main>, entrypt@entry=0x1 <up_putc>, argc=1, argv=0x20008af8) at sched/task_startup.c:70
| #13 0x000056d2 in nxtask_start () at task/task_start.c:134
| #14 0x00000000 in ?? ()
| (gdb) c
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-06 06:20:59 +02:00
|
|
|
|
|
|
|
define thread
|
|
|
|
_save_current_tcb
|
|
|
|
if ($argc == 0)
|
|
|
|
_running_task
|
|
|
|
set $pid = $rtcb->pid
|
|
|
|
else
|
|
|
|
set $pid = $arg0
|
|
|
|
end
|
|
|
|
|
|
|
|
nxthread $pid
|
|
|
|
end
|