作者kylehsnu (kyle)
看板EE_DSnP
標題[問題] gdb找crash的地方
時間Fri Nov 8 03:21:01 2013
我的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)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.218.115
1F:推 arsenefrog:其實what()後面的東西就是出問題的函數了 11/08 04:20
2F:→ arsenefrog:只需檢查你寫的substr()裡面的開始跟結束pointer位置 11/08 04:21
3F:→ arsenefrog:這時候手動丟幾個不同長度的cmd測測看好像比較直觀(? 11/08 04:23
4F:→ kylehsnu:已解決,謝謝! 11/08 10:36