代码示例(foo.c)
int main(){
int *x=(int*)malloc(sizeof(int)); // break here
*x=10;
free(x);
return 0;
}
我想在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.
我的系统规格是:
请告诉我我要去哪里错了!
我无法可靠地重现该错误,但是在Linux上,您可以尝试在__libc_malloc
而不是处中断malloc
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句