Good afternoon, I would like to announce the breakthrough in extending gdb with non intrusive instructions and functions tracing on ARM processors using Coresight ETM traces, as described in previous mails. the source code is made public in the git repository https://github.com/gzied/binutils-gdb/ in the branch gdb_arm_coresight. this implementation was compiled and tested on an STM32MP1 (ARMv7 Architecture) board running "Linux arm 5.3.10-armv7-lpae-x15" distribution where the device tree was modified to declare CoreSight components.
to build the software
checkout the software from the branch gdb_arm_coresight cd .. mkdir build cd build ../binutils-gdb/configure --with-arm-cs make
after a successful build gdb will be available in the folder build/gdb
to run the software build the software you would like to debug with debugging info (-g flag)
gcc -g software.c -o software
start debugging your software
gdb software
set a breakpoint at main (gdb) b main (gdb) run set a breakpoint in a location after the code you would like to trace (gdb) b my_function set your etm sink, sinks can be found by listing the folder /sys/bus/event_source/devices/cs_etm/sinks/. use a sink that is capable of storing the traces on chip (etf, etb ...) (gdb) set record btrace etm sink tmc_etf0 start recording etm traces (gdb) record btrace etm continue the execution of the program (gdb) c wait until the breakpoint is hit, analyse and display the traces - on assembly level (gdb) record instruction-history - on c level (gdb) record function-call-history /ilc you can increase the number of instructions displayed by using (gdb) set record instruction-history-size size (gdb) set record function-call-history-size size
the work is still in an early stage and needs to be improved, extended and stabilized. your feedback and contributions are welcome
Kind Regards Zied Guermazi