Is there any gcc option I can set that will give me the line number of the segmentation fault?
I know I can:
- Debug line by line
- Put printfs in the code to narrow down.
Edits:
bt/whereon gdb give No stack.- Helpful suggestion
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t know of a gcc option, but you should be able to run the application with gdb and then when it crashes, type
whereto take a look at the stack when it exited, which should get you close.Edit for completeness:
You should also make sure to build the application with debug flags on using the
-ggcc option to include line numbers in the executable.Another option is to use the
bt(backtrace) command.