I'm exploring the difference in gdb behaviour on a executable compiled with and without -g option.
So,I have observed the following things which I don't understand:
1.I can't place breakpoint on a line in my code. Every time I try,it places in the file ../sysdeps/x86_64/start.S, line 63 Here's the image of what I see when I try to place breakpoint on line number 34 in my program
2.I can however place breakpoints using function names. So I placed breakpoint at the beginning of my main. But after that I can't go to the next line in my program. After typing 'next' the execution reaches the end of the program. Why does this happen? Is this expected behaviour?Is it because line number information is not available? Image for this case
Note: Posting links to the images since it's my first question here and I can't post images.Sorry about that.
I understand why line numbers are not visible or program name is not visible when I place the breakpoints and why 'info locals' does not display the symbols. Also,I understand that debugging information is not stored in DWARF format when I don't use -g , but shouldn't I still be able to debug my code? I don't understand why I can't traverse my code line by line or place line breakpoints.
I have checked similar questions but they don't mention the behaviors I observed. this this
My main function looks like this:
main(){
printf("Starting to build the linked list\n");
.
.
.
printf("Printing values of the list");
}
Are these expected behaviors or am I missing something? Are there documentations about gdb behavior without -g?