August 22, 2006

[C] Debugging Segment Error with gdb in Linux

Filed under: Programming, Uncategorized — HanaDaddy @ 10:22 pm

1. Compile the source with -g option.

2. run gdb

(gdb) file exefile
(gdb) run [arg is optional]

After segment error occurs, type ‘up’ until you see the proper source file & line where the segment occurs.

(gdb) up


[root@editracker from_edisvr]# gdb
GNU gdb Red Hat Linux (6.1post-1.20040607.41rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i386-redhat-linux-gnu”.
(gdb) file ezftp
Reading symbols from ezftp…done.
Using host libthread_db library “/lib/tls/libthread_db.so.1″.
(gdb) run test.cfg
Starting program: ezftp test.cfg

Program received signal SIGSEGV, Segmentation fault.
0×0072a9a3 in _int_malloc () from /lib/tls/libc.so.6
(gdb) up
#1 0×0072c1e1 in malloc () from /lib/tls/libc.so.6
(gdb) up
#2 0×00766460 in re_compile_internal () from /lib/tls/libc.so.6
(gdb) up
#3 0×0076876c in regcomp () from /lib/tls/libc.so.6
(gdb) up
#4 0×0804acc3 in mput (filearg=0xfeedadb4, argc=1, list=0xfeedada8) at ezftp.c:1106
1106 if( regcomp(&regobj[i],regfile,0)!=0){

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

 

50 queries. 0.467 seconds. Powered by WordPress