cancel
Showing results for 
Search instead for 
Did you mean: 

How does the data fetching for the "SWV Data Trace" work on GDB level or register level?

Hueli.1
Associate III

I am trying to design a tool that does the same as the "SWV Data Trace" in STMCubeIDE but by using GDB and a J-Link directly instead of the IDE.

I have recorded the GDB traces (appended) and they show that the IDE writes to the configuration registers of my Cortex-M4 processor in order to set up the DWT and ITM registers correctly.

But then I don't understand how "tracing" data comes back to the IDE since in the GDB trace nothing can be seen anymore after the configuration. Does this even happen over GDB? or does the IDE directly access some DLL functions of J-Link to read these values? And does it affect the execution time?

Thanks for any help

#################################### starting SWV recording ###############
 
552,121 46-data-read-memory --thread-group i1 0xe0042004 x 4 1 1 y
552,122 46^done,addr="0xe0042004",nr-bytes="4",total-bytes="4",next-row="0xe0042008",prev-row="0xe00\
42000",next-page="0xe0042008",prev-page="0xe0042000",memory=[{addr="0xe0042004",data=["0x00003337"],\
ascii="73yy"}]
552,122 (gdb) 
552,122 47-data-read-memory --thread-group i1 0xe0001fe0 x 4 1 1 y
552,123 47^done,addr="0xe0001fe0",nr-bytes="4",total-bytes="4",next-row="0xe0001fe4",prev-row="0xe00\
01fdc",next-page="0xe0001fe4",prev-page="0xe0001fdc",memory=[{addr="0xe0001fe0",data=["0x00000002"],\
ascii="yyyy"}]
552,123 (gdb) 
552,123 48ptype counter
552,123 &"ptype counter\n"
552,123 ~"type = int\n"
552,123 48^done
552,123 (gdb) 
552,124 49-data-evaluate-expression &counter
552,124 49^done,value="0x20000000 <counter>"
552,124 (gdb) 
552,124 50-data-evaluate-expression "sizeof counter"
552,124 50^done,value="4"
552,124 (gdb) 
552,125 51-data-write-memory --thread-group i1 0xe000edfc x 4 0x1000000
552,126 51^done
552,126 (gdb) 
552,126 52-data-write-memory --thread-group i1 0xe0042004 x 4 0x3337
552,126 52^done
552,127 (gdb) 
552,127 53-data-write-memory --thread-group i1 0xe00400f0 x 4 0x2
552,127 53^done
552,127 (gdb) 
552,127 54-data-write-memory --thread-group i1 0xe0040010 x 4 0x13
552,127 54^done
552,127 (gdb) 
552,128 55-data-write-memory --thread-group i1 0xe0000fb0 x 4 0xc5acce55
552,129 55^done
552,129 (gdb) 
552,129 56-data-write-memory --thread-group i1 0xe0000e80 x 4 0x1000f
552,130 56^done
552,130 (gdb) 
552,130 57-data-write-memory --thread-group i1 0xe0000e40 x 4 0x0
552,130 57^done
552,130 (gdb) 
552,130 58-data-write-memory --thread-group i1 0xe0000e00 x 4 0x0
552,131 58^done
552,131 (gdb) 
552,131 59-data-write-memory --thread-group i1 0xe0001020 x 4 0x20000000
552,132 59^done
552,132 (gdb) 
552,132 60-data-write-memory --thread-group i1 0xe0001024 x 4 0x2
552,133 60^done
552,133 (gdb) 
552,133 61-data-write-memory --thread-group i1 0xe0001028 x 4 0x3
552,134 61^done
552,134 (gdb) 
552,134 62-data-write-memory --thread-group i1 0xe0001030 x 4 0x0
552,135 62^done
552,135 (gdb) 
552,135 63-data-write-memory --thread-group i1 0xe0001040 x 4 0x0
552,136 63^done
552,136 (gdb) 
552,136 64-data-write-memory --thread-group i1 0xe0001050 x 4 0x0
552,137 64^done
552,137 (gdb) 
552,137 65-data-write-memory --thread-group i1 0xe0001000 x 4 0x3ff
552,138 65^done
552,138 (gdb) 
552,138 66-data-write-memory --thread-group i1 0xe0040304 x 4 0x701
552,139 66^done
552,139 (gdb) 
 
 
 
 
 
################################ start debugging with SWV recording on ###############
 
560,709 69-exec-continue --thread 1
560,710 69^running
560,710 *running,thread-id="all"
560,710 (gdb) 
560,723 70-trace-status
560,723 70^done,supported="0"
560,723 (gdb) 
560,740 71-thread-select 1
560,740 71^error,msg="Cannot execute this command while the target is running.\nUse the \"interrupt\\
" command to stop the target\nand then try again."
560,740 (gdb)
 
 
----- after pausing debugging ------
 
563,197 72-exec-interrupt --thread 1
563,197 72^done
563,197 (gdb) 
563,226 ~"\nProgram"
563,226 ~" received signal SIGTRAP, Trace/breakpoint trap.\n"
563,228 ~"0x08000f5a in delay (loops=1966452) at ../Src/main.c:160\n"
563,228 ~"160\t  while(loops) loops--;\n"
563,228 *stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint tra\
p",frame={addr="0x08000f5a",func="delay",args=[{name="loops",value="1966452"}],file="../Src/main.c",\
fullname="/home/user/Desktop/blink_led/Src/main.c",line="160"},thread-id="1",stopped-threads="all"
563,242 73-stack-info-depth --thread 1 11
563,243 73^done,depth="3"
563,243 (gdb) 
563,258 74-stack-select-frame --thread 1 0
563,258 74^done
563,258 (gdb) 
563,260 75-trace-status
563,260 75^done,supported="0"
563,260 (gdb) 
563,266 76-var-create --thread 1 --frame 0 - * counter
563,266 77-var-create --thread 1 --frame 0 - * &counter
563,267 76^done,name="var3",numchild="0",value="36",type="int",has_more="0"
563,267 (gdb) 
563,267 77^done,name="var4",numchild="1",value="0x20000000 <counter>",type="int *",has_more="0"
563,268 (gdb) 
563,276 78-list-thread-groups
563,276 79-thread-info 1
563,276 78^done,groups=[{id="i1",type="process",pid="42000"}]
563,276 (gdb) 
563,276 79^done,threads=[{id="1",target-id="Thread 57005",frame={level="0",addr="0x08000f5a",func="d\
elay",args=[{name="loops",value="1966452"}],file="../Src/main.c",fullname="/home/user/Desktop/blink_\
led/Src/main.c",line="160"},state="stopped"}]
563,276 (gdb) 
563,299 80-stack-list-frames --thread 1 0 100
563,299 80^done,stack=[frame={level="0",addr="0x08000f5a",func="delay",file="../Src/main.c",fullname\
="/home/user/Desktop/blink_led/Src/main.c",line="160"},frame={level="1",addr="0x08000d48",func="main\
",file="../Src/main.c",fullname="/home/user/Desktop/blink_led/Src/main.c",line="89"},frame={level="2\
",addr="0x08001186",func="Reset_Handler",file="../Startup/startup_stm32l433cctx.s",fullname="/home/u\
ser/Desktop/blink_led/Startup/startup_stm32l433cctx.s",line="83"}]
563,299 (gdb) 

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

When you enable SWO tracing in STM32cubeIDE > Debug Configuration > Debugger tab, an additional TCP port is configured. While a SWO debug session is running, you can check the additional command line options induced by enabling SWO using Process Explorer (Win) or ps aux (Linux), e.g.

-z 61235 -a 84000000 -b 42.

Using netstat, you find out that this TCP connection is used by ST-LINK_gdbserver.exe and arm-none-eabi-gdb.exe (Win). If you send some test output from the target via SWO, the content will be sent over that connection. To prove, use WireShark.

Let us know when your open source tool is ready

hth

KnarfB

View solution in original post

4 REPLIES 4
KnarfB
Principal III

When you enable SWO tracing in STM32cubeIDE > Debug Configuration > Debugger tab, an additional TCP port is configured. While a SWO debug session is running, you can check the additional command line options induced by enabling SWO using Process Explorer (Win) or ps aux (Linux), e.g.

-z 61235 -a 84000000 -b 42.

Using netstat, you find out that this TCP connection is used by ST-LINK_gdbserver.exe and arm-none-eabi-gdb.exe (Win). If you send some test output from the target via SWO, the content will be sent over that connection. To prove, use WireShark.

Let us know when your open source tool is ready

hth

KnarfB

Hueli.1
Associate III

After using the proposed method by @KnarfB​ I found that he following processes are using the gdb server ports (Linux with J-Link):

JLinkGDBServerCLExe -port 2331 -s -device STM32L433CC -endian little -speed 4000 -if swd -swoport 2332 -vd

arm-none-eabi-gdb --interpreter mi2 --nx -q --interpreter console -ex new-ui mi /dev/pts/7 -ex set pagination off -ex show version

and the eclipse plugin:

org.eclipse.equinox.launcher_1.5.500.v20190715-1310.jar <many arguments>

Example wireshark data of an RSP packet:

0000  c0 ff 88 7a 47 dc 0b 00 08 87 5f 00 00 00 c0 a4

0010  82 05 47 e2 0b 00 08 8f 60 00 00 00 f0 fe 0a

After using the proposed method by @KnarfB (Community Member)​ I found that he following processes are using the gdb server ports (Linux with J-Link):

JLinkGDBServerCLExe -port 2331 -s -device STM32L433CC -endian little -speed 4000 -if swd -swoport 2332 -vd

arm-none-eabi-gdb --interpreter mi2 --nx -q --interpreter console -ex new-ui mi /dev/pts/7 -ex set pagination off -ex show version

and the eclipse plugin:

org.eclipse.equinox.launcher_1.5.500.v20190715-1310.jar <many arguments>

Example wireshark data of an RSP packet:

0000  c0 ff 88 7a 47 dc 0b 00 08 87 5f 00 00 00 c0 a4

0010  82 05 47 e2 0b 00 08 8f 60 00 00 00 f0 fe 0a