当前位置: 技术问答>linux和unix
how to debug in linux ?
来源: 互联网 发布时间:2014-10-31
本文导语: I wrote a programmer with c++ under linux, it has a Segmentation fault, how can i debug it with gdb? I compile them with g++ -p -g -c a.c; when i run the programmer, it corrupt, and generate a file "core", I use gdb -c core, and type ...
I wrote a programmer with c++ under linux, it has a Segmentation fault, how can i debug it with gdb? I compile them with g++ -p -g -c a.c;
when i run the programmer, it corrupt, and generate a file "core", I use gdb -c core, and type "where", but it just show some address, how can i let it show somthing I can understand??
thanks a lot
when i run the programmer, it corrupt, and generate a file "core", I use gdb -c core, and type "where", but it just show some address, how can i let it show somthing I can understand??
thanks a lot
|
generally speaking, core is a evil, remove it !
compile your program with command
g++ -Wall -p your_program_name.c -o whatever_name_you_want
then run gdb what_ever_name_you_want
then
>b main /*set break point*/
then
>run /*run the program*/
then
>n /star executing, then press enter after each step is executed*/
hope this can help you out =)
compile your program with command
g++ -Wall -p your_program_name.c -o whatever_name_you_want
then run gdb what_ever_name_you_want
then
>b main /*set break point*/
then
>run /*run the program*/
then
>n /star executing, then press enter after each step is executed*/
hope this can help you out =)