Sur*_*shi 2 c linux malloc gcc gdb
代码示例(foo.c)
int main(){
int *x=(int*)malloc(sizeof(int)); // break here
*x=10;
free(x);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想在 malloc 处中断。这是我尝试的:
# gcc -g foo.c -o bar
# gdb bar
(gdb) b main
Breakpoint 1 at 0x80484cf: file src.c, line 7.
(gdb) r
Breakpoint 1, main () at src.c:7
(gdb) b malloc
Breakpoint 2 at 0x550944
(gdb) c
Program exited normally.
Run Code Online (Sandbox Code Playgroud)
我的系统规格是:
请告诉我哪里错了!!