According to these docs it isn't possible to get a complete stack backtrace from a tracepoint, but it is possible to get a partial trace by recording a section of the stack.
How do I go about doing this?
I've approximated the behaviour I wanted using commands on a breakpoint to print a backtrace then auto-continue:
> break functionName
> commands
> bt
> continue
> end
For future reference, I just found something related to this in the gdb documentation 13.1.10 tracepoint restrictions which says that it is not possible to collect the result of the backtrace command in a tracepoint, but it's possible to collect the stack by reading something like *(unsigned char *)$esp@300
. You'll probably need to adapt a little bit: you may need to read more bytes, and the stack pointer may have a different name (rsp for x86-64)
Otherwise:
>collect *(unsigned char *)$esp@300
'esp' is a pseudo-register; GDB cannot yet trace its contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With