79797991

Date: 2025-10-23 16:02:17
Score: 0.5
Natty:
Report link

A way of addressing this would be to run gdb in batch mode. Based on the trick described in [1] about associating commands with breakpoints/watchpoints, you could do something like this:

Create a gdb batch file, say test.gdb:

# http://sourceware.org/gdb/wiki/FAQ: to disable the
# "---Type <return> to continue, or q <return> to quit---"
# in batch mode:
set width 0
set height 0
set verbose off
#set confirm off            # if you want to use breakpoints
#set breakpoint pending on  # if you want to use breakpoints

watch *(int *) 0x600850 # use the appropriate type and address
commands 1 # commands to run at watchpoint 1
  bt
  exit
end

# if your program has arguments you may have to specify them here;
# see [1] for details
run

then run your program:

gdb --batch --command=test.gdb --args <your program>

This will print a backtrace when the watch point is hit, without you waiting at the console.

[1] https://stackoverflow.com/a/10775939/8729545

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: dsouzai