[En-Nut-Discussion] Cortex-M thread awareness for OpenOCD

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Thu Dec 1 14:21:19 CET 2016


some time ago I added a patch http://openocd.zylin.com/#/c/3881/ to OpenOCD
to enable thread awareness for debugging NutOS and asked for feedback on
this list. 

Example usage on a Nucleo-l053 board, running openocd in-tree:
> cd openocd
> src/openocd -s tcl -f tcl/board/stm32l0discovery.cfg -c "stm32l0.cpu
> configure -rtos auto"
> arm-none-eabi-gdb  *elf
(gdb) tar ext :3333
A program is being debugged already.  Kill it? (y or n) y
Remote debugging using :3333
0x08002776 in NutThreadSwitch () at /devel/ethernut_sf/nut/arch/cm3/os/context.c:228
228          M0_PopContext();
(gdb) inf thr
  Id   Target Id         Frame
  2    Thread 536872800 (idle) NutThreadResume () at /devel/ethernut_sf/nut/os/thread.c:232
* 1    Thread 536873880 (main) 0x08002776 in NutThreadSwitch () at /devel/ethernut_sf/nut/arch/cm3/os/context.c:228
(gdb) c
Program received signal SIGINT, Interrupt.
[Switching to Thread 536872800]
NutIdle (arg=<optimized out>) at /devel/ethernut_sf/nut/arch/cm3/os/nutinit.c:213
213             NutThreadYield();
(gdb) inf thr
  Id   Target Id         Frame
* 2    Thread 536872800 (idle) NutIdle (arg=<optimized out>) at /devel/ethernut_sf/nut/arch/cm3/os/nutinit.c:213
  1    Thread 536873880 (main) NutThreadResume () at /devel/ethernut_sf/nut/os/thread.c:232
(gdb) thr 1
[Switching to thread 1 (Thread 536873880)]
#0  NutThreadResume () at /devel/ethernut_sf/nut/os/thread.c:232
232             NutExitCritical();
(gdb) bt
#0  NutThreadResume () at /devel/ethernut_sf/nut/os/thread.c:232
#1  0x080030dc in NutEventWait (qhp=qhp at entry=0x200000e4 <Stm32Usart2Dcb+36>, ms=ms at entry=0) at /devel/ethernut_sf/nut/os/event.c:321
#2  0x080002fa in UartPut (dev=0x2000015c <Usart2Stm32Dma>, buffer=<optimized out>, len=107, pflg=pflg at entry=0)
    at /devel/uart_dma/nucleo_l053r8/../uart_dma.c:466
#3  0x0800049e in UartDmaWrite (fp=<optimized out>, buffer=<optimized out>, len=<optimized out>) at /devel/uart_dma/nucleo_l053r8/../uart_dma.c:505
#4  0x080019be in _write (fd=<optimized out>, data=data at entry=0x200001e0 <inbuf>, count=<optimized out>) at /devel/ethernut_sf/nut/crt/write.c:106
#5  0x08001a78 in fputs (string=string at entry=0x200001e0 <inbuf> '6' <repeats 107 times>, stream=0x20000c8c) at /devel/ethernut_sf/nut/crt/fputs.c:74
#6  0x080013f6 in puts (string=string at entry=0x200001e0 <inbuf> '6' <repeats 107 times>) at /devel/ethernut_sf/nut/crt/puts.c:60
#7  0x080001e4 in main () at /devel/uart_dma/nucleo_l053r8/../uart_app.c:105

Even without the patch, on L0 gdb often refuses to attach to OpenOCD. I
investigate that problem...

Please test and give feedback on gerrit.


Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------

More information about the En-Nut-Discussion mailing list