Author Topic: Trace and log values of a variable with GDB  (Read 8269 times)

Martin1987

  • Guest
Trace and log values of a variable with GDB
« on: September 07, 2013, 03:20:53 pm »
Hi,

I am not an experienced programmer but I recently have to check a C code translated from Matlab, in order to ensure that with the same data set, C and Matlab are giving the identical results.

Watches are what I am able to use until now but that requires me to sit in front of the screen and watch the values of a variable change at each loop. Is there a way to trace and log the values of a variable into a .txt file so that I can plot it later to compare with the results from Matlab?  ???

I have already tried to write the values into some .txt file with 'fwrite' but there is not the ideal solution as I have to do that in the C code that I want to check.  :-[  I am currently reading about tracepoint of gdb and will try to use that but I am still unsure if that is what I need. If you have some tips about what else I try.

Thanks!  :)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11939
    • Travis build status
Re: Trace and log values of a variable with GDB
« Reply #1 on: September 07, 2013, 06:52:50 pm »
As far as I know you need tracepoints for this, but they are not natively supported by C::B, so you'll either have to manually set them up (entering commands by hand) or you'll have to use a gdb script which you can source, with the "source" gdb command in the initial commands or manually.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]