How to monitor variables in GDB and log it if it meets certain conditions?
Set a watch point on the counter: (gdb) watch var And make that watchpoint conditional: (gdb) cond <watchpoint_number> var>=value If you want to log to a file: (gdb) set logging file <filename> (gdb) set logging on By default gdb logs to gdb.txt