anchao commented on issue #9200:
URL: https://github.com/apache/nuttx/issues/9200#issuecomment-1539849605

   I just tried another stm32 board on Linux(Ubuntu 22.04), thread aware 
debugging works as expected:
   1. make image:
   ```
   ./tools/configure.sh stm32f429i-disco:nsh
   
   enable  CONFIG_DEBUG_TCBINFO=y
           CONFIG_TASK_NAME_SIZE=32
   ```
           
   2. connect the jlink:
   ```
   $ make -f Makefile.host jlink-nuttx.so
   $ JLinkGDBServer -if SWD -device Cortex-M33 -rtos $PWD/jlink-nuttx.so
   SEGGER J-Link GDB Server V7.88a Command Line Version
   
   JLinkARM.dll V7.88a (DLL compiled May  3 2023 14:37:20)
   
   Command line: -if SWD -device Cortex-M33 -rtos 
/home/archer/code/nuttx/n11/incubator-nuttx/tools/jlink-nuttx.so
   -----GDB Server start settings-----
   GDBInit file:                  none
   GDB Server Listening port:     2331
   SWO raw output listening port: 2332
   Terminal I/O port:             2333
   Accept remote connection:      yes
   Generate logfile:              off
   Verify download:               off
   Init regs on start:            off
   Silent mode:                   off
   Single run mode:               off
   Target connection timeout:     0 ms
   ------J-Link related settings------
   J-Link Host interface:         USB
   J-Link script:                 none
   J-Link settings file:          none
   ------Target related settings------
   Target device:                 Cortex-M33
   Target device parameters:      none
   Target interface:              SWD
   Target interface speed:        4000kHz
   Target endian:                 little
   
   Connecting to J-Link...
   J-Link is connected.
   Firmware: J-Link V11 compiled Mar 28 2023 16:59:55
   Hardware: V11.00
   S/N: 51015399
   Feature(s): GDB
   Checking target voltage...
   Target voltage: 2.89 V
   Listening on TCP/IP port 2331
   Connecting to target...
   Halting core...
   Connected to target
   Waiting for GDB connection...Connected to 127.0.0.1
   GDB client (conn. 9) requested target.xml from GDB Server
   Reading common registers: Read register 'r0' (4 bytes) from hardware: 
0x00000000
   Read register 'r1' (4 bytes) from hardware: 0x0C040020
   Read register 'r2' (4 bytes) from hardware: 0xDC0C0010
   Read register 'r3' (4 bytes) from hardware: 0x00000000
   Read register 'r4' (4 bytes) from hardware: 0x00000000
   Read register 'r5' (4 bytes) from hardware: 0x00000000
   Read register 'r6' (4 bytes) from hardware: 0x00000000
   Read register 'r7' (4 bytes) from hardware: 0x00000000
   Read register 'r8' (4 bytes) from hardware: 0x00000000
   Read register 'r9' (4 bytes) from hardware: 0x00000000
   Read register 'r10' (4 bytes) from hardware: 0x00000000
   Read register 'r11' (4 bytes) from hardware: 0x00000000
   Read register 'r12' (4 bytes) from hardware: 0x00000000
   Read register 'sp' (4 bytes) from hardware: 0x840D0020
   Read register 'lr' (4 bytes) from hardware: 0xC91A0008
   Read register 'pc' (4 bytes) from hardware: 0xC81A0008
   Read register 'xpsr' (4 bytes) from hardware: 0x00000041
   Read 4 bytes @ address 0x08001AC8 (Data = 0xBF00E7FC)
   Loading RTOS plugin: 
//home/archer/code/nuttx/n11/incubator-nuttx/tools/jlink-nuttx.so...
   RTOS plugin (API v1.1) loaded successfully
   RTOS plugin: Loaded
   Received symbol: g_pidhash (0x20000380)
   Received symbol: g_npidhash (0x20000384)
   Received symbol: g_tcbinfo (0x0801D7C8)
   Received symbol: g_readytorun (0x20000358)
   All mandatory symbols successfully loaded.
   npidhash change from 0 to 4!
   ERROR: error in get_idx_from_pid return -2
   Read 4 bytes @ address 0x08001AC8 (Data = 0xBF00E7FC)
   Reading common registers: Read register 'r0' (4 bytes) from hardware: 
0x00000000
   Read register 'r1' (4 bytes) from hardware: 0x0C040020
   Read register 'r2' (4 bytes) from hardware: 0xDC0C0010
   Read register 'r3' (4 bytes) from hardware: 0x00000000
   Read register 'r4' (4 bytes) from hardware: 0x00000000
   Read register 'r5' (4 bytes) from hardware: 0x00000000
   Read register 'r6' (4 bytes) from hardware: 0x00000000
   Read register 'r7' (4 bytes) from hardware: 0x00000000
   Read register 'r8' (4 bytes) from hardware: 0x00000000
   ```
   
   
   ```
   $ arm-none-eabi-gdb ./nuttx -ex "target remote localhost:2331"
   GNU gdb (Arm GNU Toolchain 11.3.Rel1) 12.1.90.20220802-git
   Copyright (C) 2022 Free Software Foundation, Inc.
   License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
   This is free software: you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.
   Type "show copying" and "show warranty" for details.
   This GDB was configured as "--host=x86_64-pc-linux-gnu 
--target=arm-none-eabi".
   Type "show configuration" for configuration details.
   For bug reporting instructions, please see:
   <https://bugs.linaro.org/>.
   Find the GDB manual and other documentation resources online at:
       <http://www.gnu.org/software/gdb/documentation/>.
   
   For help, type "help".
   Type "apropos word" to search for commands related to "word"...
   Reading symbols from ./nuttx...
   Remote debugging using localhost:2331
   up_idle () at chip/stm32_idle.c:195
   195  }
   (gdb) info thread
   [New Thread 1]
   [New Thread 2]
   [New Thread 3]
     Id   Target Id                                       Frame 
   * 1    Thread 57005 ([PID:000]Idle Task:0003[PRI:000]) up_idle () at 
chip/stm32_idle.c:195
     2    Thread 1 ([PID:000]Idle Task:0003[PRI:000])     up_idle () at 
chip/stm32_idle.c:195
     3    Thread 2 ([PID:001]nsh_main:0005[PRI:100])      sys_call2 (nbr=2, 
parm1=268435956, parm2=268442532) at 
/home/archer/code/nuttx/n11/incubator-nuttx/include/arch/syscall.h:187
     4    Thread 3 ([PID:002]hello:0006[PRI:100])         sys_call2 (nbr=2, 
parm1=268439708, parm2=536874324) at 
/home/archer/code/nuttx/n11/incubator-nuttx/include/arch/syscall.h:187
   (gdb) thread 4
   [Switching to thread 4 (Thread 3)]
   #0  sys_call2 (nbr=2, parm1=268439708, parm2=536874324) at 
/home/archer/code/nuttx/n11/incubator-nuttx/include/arch/syscall.h:187
   187    return reg0;
   (gdb) thread 1
   Thread ID 1 has terminated.
   (gdb) bt
   #0  sys_call2 (nbr=2, parm1=268439708, parm2=536874324) at 
/home/archer/code/nuttx/n11/incubator-nuttx/include/arch/syscall.h:187
   #1  0x0800a7a8 in up_switch_context (tcb=0x2000038c <g_idletcb>, 
rtcb=0x10001020) at common/arm_switchcontext.c:95
   #2  0x0801828a in nxsig_timedwait (set=0x10001b24, info=0x0, 
timeout=0x10001b98) at signal/sig_timedwait.c:367
   #3  0x08017f4e in nxsig_nanosleep (rqtp=0x10001b98, rmtp=0x10001b90) at 
signal/sig_nanosleep.c:123
   #4  0x0801806c in clock_nanosleep (clockid=0 '\000', flags=0, 
rqtp=0x10001b98, rmtp=0x10001b90) at signal/sig_nanosleep.c:308
   #5  0x080198e0 in sleep (seconds=1) at unistd/lib_sleep.c:110
   #6  0x0801a8e2 in hello_main (argc=1, argv=0x10001408) at hello_main.c:41
   #7  0x080080be in nxtask_startup (entrypt=0x801a8c9 <hello_main>, argc=1, 
argv=0x10001408) at sched/task_startup.c:70
   #8  0x08003906 in nxtask_start () at task/task_start.c:134
   #9  0x00000000 in ?? ()
   (gdb) thread 2
   [Switching to thread 2 (Thread 1)]
   #0  up_idle () at chip/stm32_idle.c:195
   195  }
   (gdb) bt
   #0  up_idle () at chip/stm32_idle.c:195
   #1  0x08001ac4 in nx_start () at init/nx_start.c:698
   #2  0x08000202 in __start () at chip/stm32_start.c:199
   (gdb) thread 3
   [Switching to thread 3 (Thread 2)]
   #0  sys_call2 (nbr=2, parm1=268435956, parm2=268442532) at 
/home/archer/code/nuttx/n11/incubator-nuttx/include/arch/syscall.h:187
   187    return reg0;
   (gdb) bt
   #0  sys_call2 (nbr=2, parm1=268435956, parm2=268442532) at 
/home/archer/code/nuttx/n11/incubator-nuttx/include/arch/syscall.h:187
   #1  0x0800a7a8 in up_switch_context (tcb=0x10001020, rtcb=0x10000178) at 
common/arm_switchcontext.c:95
   #2  0x08004bd4 in nxsem_wait (sem=0x20000020 <g_usart1priv+32>) at 
semaphore/sem_wait.c:176
   #3  0x080070cc in uart_read (filep=0x100004c0, buffer=0x10000c53 "\b\244\f", 
buflen=1) at serial/serial.c:1063
   #4  0x08013126 in file_read (filep=0x100004c0, buf=0x10000c53, nbytes=1) at 
vfs/fs_read.c:92
   #5  0x0801315e in nx_read (fd=0, buf=0x10000c53, nbytes=1) at 
vfs/fs_read.c:140
   #6  0x0801317c in read (fd=0, buf=0x10000c53, nbytes=1) at vfs/fs_read.c:170
   #7  0x0800af0a in readline_getc (vtbl=0x10000ca4) at readline_fd.c:72
   #8  0x0800b042 in readline_common (vtbl=0x10000ca4, buf=0x10000fd8 "hello", 
buflen=64) at readline_common.c:513
   #9  0x0800aff4 in readline_fd (buf=0x10000fd8 "hello", buflen=64, infd=0, 
outfd=1) at readline_fd.c:222
   #10 0x0800ae80 in nsh_session (pstate=0x10000d50, login=1, argc=1, 
argv=0x10000560) at nsh_session.c:212
   #11 0x0800aad8 in nsh_consolemain (argc=1, argv=0x10000560) at 
nsh_consolemain.c:71
   #12 0x0800aa9a in nsh_main (argc=1, argv=0x10000560) at nsh_main.c:74
   #13 0x080080be in nxtask_startup (entrypt=0x800aa65 <nsh_main>, argc=1, 
argv=0x10000560) at sched/task_startup.c:70
   #14 0x08003906 in nxtask_start () at task/task_start.c:134
   #15 0x00000000 in ?? ()
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to