Originally Posted by
mack99
I was expecting to get info on where the program created the fault but it seems it was caused in one of the c libraries. Not sure where to go with this as I was following along with a debug tutorial and am now in (for me) uncharted waters.
Use the bt (backtrace) command in gdb:
Code:
$ gdb -q ./test
Reading symbols from test...done.
(gdb) r
Starting program: test
Program received signal SIGSEGV, Segmentation fault.
0x00167590 in __GI_____strtol_l_internal (nptr=0x0, endptr=0x0, base=10,
group=0, loc=0x2d48c0) at strtol_l.c:298
298 strtol_l.c: No such file or directory.
(gdb) bt
#0 0x00167590 in __GI_____strtol_l_internal (nptr=0x0, endptr=0x0, base=10,
group=0, loc=0x2d48c0) at strtol_l.c:298
#1 0x00167347 in __GI_strtol (nptr=0x0, endptr=0x0, base=10) at strtol.c:110
#2 0x0016464f in atoi (nptr=0x0) at atoi.c:28
#3 0x080484e4 in main (argc=1, argv=0xbffff304) at test.c:17
(gdb) help bt
Print backtrace of all stack frames, or innermost COUNT frames.
With a negative argument, print outermost -COUNT frames.
Use of the 'full' qualifier also prints the values of the local variables.
So your program crashes on line 17.
You're are only interested in the innermost frame of your own code, which in this case is frame #3.
See also Debugging with GDB - Examining the Stack
Bye, Andreas