[问题] gdb找crash的地方

楼主: kylehsnu (kyle)   2013-11-08 03:21:01
我的hw3 complile会过,但是一执行就会crash,出现下面的错误讯息:
(gdb) run
Starting program: /home/playerk/Dropbox/DSnP/hw3/bin/modCalc
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr
Program received signal SIGABRT, Aborted.
0xb7fdd424 in __kernel_vsyscall ()
我想用where找是哪个pointer出问题(吗?),但是前面几个都看不太懂,请求指点,
感谢>//<
(gdb) where
#0 0xb7fdd424 in __kernel_vsyscall ()
#1 0xb7d3db1f in raise () from /lib/i386-linux-gnu/libc.so.6
#2 0xb7d410b3 in abort () from /lib/i386-linux-gnu/libc.so.6
#3 0xb7f2c91d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#4 0xb7f2a563 in ?? () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#5 0xb7f2a59f in std::terminate() () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#6 0xb7f2a82e in __cxa_throw () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#7 0xb7f850c4 in std::__throw_out_of_range(char const*) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#8 0xb7f9265f in std::string::substr(unsigned int, unsigned int) const () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#9 0x0804b402 in CmdParser::getCmd (this=0x805b020, cmd=...) at cmdParser.cpp:255
#10 0x0804ac93 in CmdParser::regCmd (this=0x805b020, cmd=..., nCmp=3, e=0x806b148) at cmdParser.cpp:60
#11 0x08049cd5 in initCommonCmd () at cmdCommon.cpp:19
#12 0x08049a70 in main (argc=1, argv=0xbffff154) at main.cpp:54
(gdb)
作者: arsenefrog (柯蛙)   2012-01-08 04:20:00
其实what()后面的东西就是出问题的函数了只需检查你写的substr()里面的开始跟结束pointer位置这时候手动丢几个不同长度的cmd测测看好像比较直观(?
楼主: kylehsnu (kyle)   2012-01-08 10:36:00
已解决,谢谢!

Links booklink

Contact Us: admin [ a t ] ucptt.com