2015-10-15 25 views
0

我試圖通過GDB類中步入一個方法。所以目前,我的gdb適用於獨立函數。但是,當我嘗試進入某種方法時,我可以將它們融入其中,但它並未涉足。這裏是我的腳本:無法步入一個類的方法GDB

#include <iostream> 
using namespace std; 

class test{ 
    public: 
     void say_hello(){ 
      cout<< "hello"; 
     } 
}; 

int main(){ 
    test t; 
    t.say_hello(); 
    return 0; 
} 

這是gdb在我按下運行「運行」命令後吐出的東西。

warning: `/BinaryCache/coreTLS/coreTLS-35.40.1~1/Objects/coretls.build/coretls.build/Objects-normal/x86_64/system_coretls_vers.o': can't open to read symbols: No such file or directory. 
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_ciphersuites.a" 
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_handshake.a" 
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_record.a" 
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_stream_parser.a" 

這裏發生了什麼,當我嘗試步:

Breakpoint 1, main() at test.cpp:13 
13  t.say_hello(); 
(gdb) s 
14  return 0; 
(gdb) 
0x00007fff91eec5c9 in start() from /usr/lib/system/libdyld.dylib 
(gdb) 
Single stepping until exit from function start, 
which has no line number information. 
hello[Inferior 1 (process 9896) exited normally] 

如果這有什麼差別,當我運行的g ++ --version,我得到蘋果LLVM 7.0.0版。 謝謝。

+0

不熟悉的g ++,但簡單的成員函數的特定版本特意去內聯。你在編譯優化嗎? –

+0

沒有,我做的是G ++ -g TEST.CPP,然後GDB的a.out –

+0

使用與Fedora Linux系統我看它一步成員函數的cout語句G ++ --version 5.1.1您編譯行。對不起,如此有用。 –

回答

0

默認情況下,GDB步驟在其中不包含調試信息的功能。但是很明顯,你已經擁有了它,因爲當你在main()上打破時,你會看到「at test.cpp:13」。

我的猜測是,你有GDB不完全瞭解你的編譯器產生的符號的舊版本,並因此不能踏入成員函數。

如果我是你,我會先嚐試LLDB調試程序(因爲你已經擁有它您的系統上),看看它是否順利。如果確實如此,那麼問題確實與舊的GDB有關,所以我會升級到更高版本。

+0

好,所以lldb適用於我,我已經使用brew刪除並重新安裝了gdb,但仍然無法步入方法。奇怪。 –

+0

這就是你的問題。不要在自制軟件中使用gdb。它壞了。使用系統提供的一個或lldb。 –