Search code examples
cdebuggingembeddedtrace32lauterbach

How to save the stackframe in Lauterbach when the breakpoints is hit


So i want to dump full stackframe with local variables to the .txt file when the breakpoint is reached and then use the "resume" option to restart again and when the breakpoint is reached again create new .txt file and save the callstack again. I just went through the documentation and i couldn't find the option to save he stackframe the CMD in breakpoint window is clear for me.


Solution

  • In TRACE32 you can view a window showing the callstack (with local variables) with the command Frame /Args /Locals.

    Like any other command you can redirect the display of the window to a text-file with the pre-command WinPrint..

    Therefore, first setup printing in TRACE32 to save every "print" to a file.
    E.g. PRinTer.FILE c:/myProject/myLogfile-001.txt ASCIIE
    If the choosen filename ends with a number, TRACE32 will increment the number after every print automatically.

    Now, the command WinPrint.Frame /Args /Locals will save the callstack to the file c:/myProject/myLogfile-001.txt and increments the file-index.

    Putting all together:

    1. Setup printing to file with E.g. PRinTer.FILE c:/myProject/myLogfile-001.txt ASCIIE
    2. Set your breakpoint with E.g. Break.Set <address> /CMD "WinPrint.Frame /Args /Locals" /RESUME

    When you wrote "stackframe" you might meant only the local variables of the current function instead of the full callstack. In this case use the command Var.Local instead of Frame /Args /Locals