This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: create a watchpoint with trace functionality


martin mangard wrote:
Hello

I'm trying to trace the value of a global status variable of an
application. This variable is changed from various code positions. I
would like to log/trace each change of this variable without stopping
the application (at least for a long time) in order to perform a
longterm test. I'm currently using a hardware-watchpoint

Is there a possibility to configure a "autocontinue"  after a
watchpoint-event? Which means that the changed value is printed and
the execution continues without any user interaction (pressing "c")?

Yes, sure. See below.


Is ist possible to set a tracepoint on a change of a memory area?

A tracepoint is different from a watchpoint, and no, I don't remember that you can do that with a tracepoint (I could be wrong). But if you just want your "log" to be written to the console or captured as text to a file, this is easy.

(gdb) watch ival3
Hardware watchpoint 2: ival3
(gdb) commands 2
Type commands for when breakpoint 2 is hit, one per line.
End with a line saying just "end".
> continue
> end
(gdb) continue
Continuing.
Hardware watchpoint 2: ival3

Old value = -1
New value = 0
0x080484c4 in main ()
at /data/home/msnyder/cvs/localhost/quilt/gdb/testsuite/gdb.base/watchpoint.c:137
137 ival3 = count; ival4 = count;
Hardware watchpoint 2: ival3


Old value = 0
New value = 1
0x080484c4 in main ()
at /data/home/msnyder/cvs/localhost/quilt/gdb/testsuite/gdb.base/watchpoint.c:137
137 ival3 = count; ival4 = count;
Hardware watchpoint 2: ival3


Old value = 1
New value = 2
0x080484c4 in main ()
at /data/home/msnyder/cvs/localhost/quilt/gdb/testsuite/gdb.base/watchpoint.c:137
137 ival3 = count; ival4 = count;
Hardware watchpoint 2: ival3


Old value = 2
New value = 3
0x080484c4 in main ()
at /data/home/msnyder/cvs/localhost/quilt/gdb/testsuite/gdb.base/watchpoint.c:137
137 ival3 = count; ival4 = count;
Hardware watchpoint 2: ival3


Old value = 3
New value = 4
0x080484f4 in main ()
at /data/home/msnyder/cvs/localhost/quilt/gdb/testsuite/gdb.base/watchpoint.c:141
141 ival3 = count; ival4 = count;


Program exited normally.
(gdb)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]