Search code examples
embeddedtrace32lauterbach

trace32 correlate function and data trace timestamps


Using Trace32 (currently in simulation mode, but will be using real hardware as well) I'm running a demo program. I want to trace both function calls and variables (data trace), so when I break I run the following:

trace.EXPORT.CSVFunc <funcfile>
PRINTER.FILE <varfile>
WinPrint.Trace.ListVar %hex var1 var2 var3

This gives two resulting files. The first with function calls which includes positive timestamps (in ns resolution). The second with data access (reads and writes) but this contains negative timestamps (with 100 ns resolution). So far I have not been able to find any way of generating different timestamps for either of the exports, and I have also not been able to correlate the times in any way. If I assume that the timestamp from the last line in my is the same as 0 time for , I get the correct magnitude of the timestamps from , but they are still off by too much. I know from the code that certain write updates is between specific function entry/exit so I can see that it is off.

Anyone else have used these two exports in combination? Are there any other way of getting the "current time" that is using translated to format, or vice versa? Or am I using the wrong exports maybe? I haven't found any other good export commands, but there are so many that I can be missing an obvious one.


Solution

  • Trace.EXPORT.CSVFunc always exports the time for every function entries and exists as elapsed nanoseconds, since the first trace record. (So for Trace.EXPORT.CSVFunc the first record always has the timestamp 0.ns).

    The window Trace.ListVar however shows by default the time elapsed since the last read or write access. Luckily you can specify what columns you'd like to have in that window via the option /List. So the following command shows the same content than a normal Trace.ListVar window but with absolute timestamps:

    Trace.ListVar /List Run Address CYcle Data Var %TimeFixed TIme.Zero 
    

    Before exporting that data, set the absolute timestamp to zero for the first record with the command Trace.ZERO Trace.FIRST() and you will have the same kind of timestamps as with Trace.EXPORT.CSVFunc

    Putting all together:

    Trace.ZERO Trace.FIRST()    
    Trace.EXPORT.CSVFunc <funcfile>
    PRinTer.FILE <varfile>
    WinPrint.Trace.ListVar %Hex var1 var2 var3 /List Run Address CYcle Data Var %TimeFixed TIme.Zero 
    

    Maybe you'd like to consider also the command Trace.EXPORT.Ascii, which is my personal favorite. That export command works almost the same as the Trace.List window, but supports also filters. So e.g. to export the access to your three variables you could write

    Trace.EXPORT.Ascii <varfile> CYcle Address Data Var %TimeFixed TIme.Zero /FILTER Address var1 OR Address var2 OR Address var3