How to debug using gdb?

Here is a quick start tutorial for gdb: /* test.c */ /* Sample program to debug. */ #include <stdio.h> #include <stdlib.h> int main (int argc, char **argv) { if (argc != 3) return 1; int a = atoi (argv[1]); int b = atoi (argv[2]); int c = a + b; printf (“%d\n”, c); return 0; … Read more

Can I set a breakpoint on ‘memory access’ in GDB?

watch only breaks on write, rwatch let you break on read, and awatch let you break on read/write. You can set read watchpoints on memory locations: gdb$ rwatch *0xfeedface Hardware read watchpoint 2: *0xfeedface but one limitation applies to the rwatch and awatch commands; you can’t use gdb variables in expressions: gdb$ rwatch $ebx+0xec1a04f Expression … Read more