gdb调试无法定位段错误 求救
写了一段程序,总是出现段错误,于是gdb调试,结果无法找到段错误的位置。
gdb调试结果如下
[root@localhost udp_server4.9.3]# gcc -g -rdynamic -o server udp_server4.9.3.c
[root@localhost udp_server4.9.3]# gdb ./server
GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 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"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) r
Starting program: /home/zyy/udp_socket/udp_server4.9.3/server
Program received signal SIGSEGV, Segmentation fault.
0x39313030 in ?? ()
(gdb) bt
#0 0x39313030 in ?? ()
#1 0x3839392e in ?? ()
#2 0x302c562c in ?? ()
#3 0x2e303030 in ?? ()
#4 0x30303030 in ?? ()
#5 0x302c4e2c in ?? ()
#6 0x30303030 in ?? ()
#7 0x3030302e in ?? ()
#8 0x2c452c30 in ?? ()
#9 0x30332c2c in ?? ()
#10 0x32323130 in ?? ()
#11 0x312a2c2c in ?? ()
#12 0x240a0d36 in ?? ()
#13 0x54565047 in ?? ()
#14 0x542c2c47 in ?? ()
#15 0x2c4d2c2c in ?? ()
#16 0x2c2c4e2c in ?? ()
#17 0x45342a4b in ?? ()
#18 0x47240a0d in ?? ()
#19 0x41474750 in ?? ()
#20 0x3030302c in ?? ()
#21 0x2e303230 in ?? ()
#22 0x2c383939 in ?? ()
---Type <return> to continue, or q <return> to quit---
关键位置全是问号,情何以堪?这可怎么看啊
代码有点长,先不帖了。
各位大侠指点。
[解决办法]
你可以先设置断点,break main,然后单步调试step,这样能够知道哪一行出错。
[解决办法]
这个段错误一般不好调试哦,建议你先run一下,看看段错误大概停在什么地方,然后再看看逻辑是不是出错了,或者内存出现了问题呢等。
[解决办法]
gcc -g3 -fno-omit-frame-pointer -rdynamic -o server udp_server4.9.3.c
再调试下看看
不行再把-g3换成-ggdb3
要不然就随便设置断点,run,直到第一个断点时段错误为止
[解决办法]