Learning gdb (gdb, breakpoint and shared library)

I'm trying to debug the following program:
Code:
#include <stdio.h>
#include <string.h>

int main() {
   char str_a[20];

   strcpy(str_a, "Hello World!\n");
   printf(str_a);
}

I set a breakpoint in strcpy, but I can't reach it. Why?

Code:
ishayahu@zabbix-agent-9:~ % gdb -q ca2
(gdb) break strcpy
Function "strcpy" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (strcpy) pending.
(gdb) r
Starting program: /usr/home/ishayahu/ca2
Breakpoint 2 at 0x28168800
Pending breakpoint "strcpy" resolved
Hello World!

Program exited with code 015.
(gdb)

Thanks for the help!
 
Last edited by a moderator:
Try compiling using gcc -fno-builtin. In this way, it will not use strcpy as __builtin_strcpy. Look here for more info.
 
Last edited by a moderator:
Back
Top