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.
0x0072a9a3 in _int_malloc () from /lib/tls/libc.so.6
(gdb) up
#1 0x0072c1e1 in malloc () from /lib/tls/libc.so.6
(gdb) up
#2 0x00766460 in re_compile_internal () from /lib/tls/libc.so.6
(gdb) up
#3 0x0076876c in regcomp () from /lib/tls/libc.so.6
(gdb) up
#4 0x0804acc3 in mput (filearg=0xfeedadb4, argc=1, list=0xfeedada8) at ezftp.c:1106
1106 if( regcomp(®obj[i],regfile,0)!=0){