2
代碼示例(foo.c的)不能設置在的malloc()
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.
我的系統規格爲:
- OS:CentOS的5.5
- GCC:GCC(海灣合作委員會)4.1.2 20080704(紅帽4.1.2- 52)
- GDB:GNU GDB(GDB)的紅帽企業Linux(7.0.1-42.el5)
請告訴我我哪裏錯了!
找到malloc的一行,在GDB裏面打破line_number – tesseract
我在調用malloc的行號處設置了一個斷點,它似乎工作正常。 –
這裏(Fedora 20,gcc-4.8.2)它詢問我是否在庫加載時啓用斷點,並且工作正常。 – vonbrand