简体   繁体   中英

unable to step into a class method gdb

I am trying to step into a method within a class through gdb. So currently, my gdb works for standalone functions. I can step into them fine, however, when I try to step into a method, it doesn't step into it. Here's my script:

#include <iostream>
using namespace std;

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

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

Here's what gdb spits out right after I press run the "run" command.

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"

Here's what happens when I try stepping:

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]

If it makes any difference, when I run g++ --version, I get Apple LLVM version 7.0.0. Thanks.

By default, GDB steps over functions which contain no debug information. But it is clear that you have it, since you see "at test.cpp:13" when you break on main().

My guess is that you have an older version of GDB that does not fully understand symbols generated by your compiler, and thus fails to step into member functions.

If I were you, I would first try to debug your program with lldb (since you already have it on your system) and see if it goes well. And if it does, then the issue is indeed with an old GDB, so I would upgrade to a later version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM