NS2中最讨厌的莫过于Segmentation Fault,可以说是Faint to Death啊.
今天调试NAM(最近我可能会推出有关的开源软件,请稍候)的时候,就遇到这个问题,想想一定是可以用GDB调试的,于是查了一下,下面是方法。
在Makefile里找到 CCOPT = -Wall 加上 CCOPT = -Wall -g
然后重新make一遍。
启动GDB gdb xxx (这里就没有参数了,可以参考看看怎么带参数)
(gdb) run Starting program: /home/fang/ns-allinone-2.31/nam-1.13/nam
Program received signal SIGSEGV, Segmentation fault. 0x4034e6f4 in __after_morecore_hook () from /lib/libc.so.6
错误了,没有关系,输入bt(这个命令...)
#0 0x4034e6f4 in __after_morecore_hook () from /lib/libc.so.6 #1 0x0807e028 in EditView::cmdDeleteObj (this=0x8388980, cx=549.78125, cy=597.90625) at editview.cc:809 #2 0x0807f35f in EditView::command (cd=0x8388980, tcl=0x826dc80, argc=4, argv=0xbfffb98c) at editview.cc:204 #3 0x08141d2c in TclInvokeStringCommand () #4 0x0814383b in TclEvalObjvInternal () #5 0x0816de67 in TclExecuteByteCode () #6 0x08171bb8 in TclCompEvalObj () #7 0x081448a4 in Tcl_EvalObjEx () #8 0x08153a0e in Tcl_SwitchObjCmd () #9 0x0814383b in TclEvalObjvInternal () #10 0x0816de67 in TclExecuteByteCode () #11 0x08171bb8 in TclCompEvalObj () #12 0x0819a5c5 in TclObjInterpProc () #13 0x0819a9d9 in TclProcInterpProc () #14 0x0809d080 in OTclDispatch (cd=0x8372700, in=0x826dc80, argc=4, argv=0xbfffc76c) at otcl.c:434 #15 0x08141d2c in TclInvokeStringCommand () #16 0x0814383b in TclEvalObjvInternal () #17 0x08143dbd in Tcl_EvalEx () #18 0x0812b688 in Tk_BindEvent () #19 0x0812f953 in TkBindEventProc () ---Type <return> to continue, or q <return> to quit---
这样就找到具体是何处出现了错误,排错就要靠自己了。 |