I'm following Erickson 2008 Hacking the art of exploitation. The program is very simple.
#include <stdio.h>
#include <string.h>
int main() {
char str_a[20];
strcpy(str_a, "Hello, world!\n");
printf(str_a);
}
I set a break at line 6
(gdb)break 6
(gdb)break strcpy
...which prompts
Function "strcpy" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (strcpy) pending.
(gdb) break 8
Then I should be able to step through the program. With run or start and cont. However the program skips the break point 2. "info breakpoints" says breakpoint already hit 1 time at start. How do I make GDB stop at breakpoints even after being reached once? I thought this was the answer.
enable -- Enable all or some breakpoints.
enable breakpoints -- Enable all or some breakpoints.
enable breakpoints count -- Enable some breakpoints for COUNT hits.
enable breakpoints delete -- Enable some breakpoints and delete when hit.
enable breakpoints once -- Enable some breakpoints for one hit.
enable count -- Enable some breakpoints for COUNT hits.
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 I'll keep digging trying to find the solution but for now it seems a mystery.
Edit: I believe the problem lies in gdb disabling my breakpoint at start. When I start the program, it disables breakpoint 2, then I run enable 2 check info breakpoints, and it's enabled, but it never stops there. I changed the addresses and "What" column for formatting.
Num Type Disp Enb Address What. . .
1 breakpoint keep y 0x0005 in main at **7.
breakpoint already hit 1 time. . .
2 STT_GNU_IFUNC resolver keep y 0x0007 <strcpy_ifunc>. . .
3 breakpoint keep y 0x0005 in main at **8.
breakpoint already hit 1 time