31i73 / atom-dbg-gdb

An Atom package - A GDB debugger
https://atom.io/packages/dbg-gdb
MIT License
16 stars 10 forks source link

GDB problem during debug #8

Open janosimas opened 7 years ago

janosimas commented 7 years ago

I was debugging the main() of my program, when I tried to step into a method from a shared_ptr I got this error.

...gdb-src/gdb/cp-namespace.c:816: internal-error: cp_lookup_nested_symbol called on a non-aggregate type.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

The shared_ptr code was shown. I other ide debuggers I would have step into, step out, step into to go to my code.

ProPuke commented 7 years ago

Hmm.. looks like this is probably a bug with GDB. Do you know what version you're running?

It sounds like this old bug, here: https://sourceware.org/bugzilla/show_bug.cgi?id=15203 Does you method happen to contain static variables?

I'd recommend updating GDB to 7.7+. This is likely the culprit.

If that doesn't fix it and you're still having the issue - would you be able to paste a simple code example that triggers the bug (with as few lines of code as possible)?

janosimas commented 7 years ago

I'm using GDB 7.7.1

here is an example:


#include <memory>

class MyClass
{
public:
  MyClass() = default;

  ~MyClass() = default;
  MyClass(const MyClass& other) = default;
  MyClass(MyClass&& other) = default;
  MyClass& operator=(const MyClass& other) = default;
  MyClass& operator=(MyClass&& other) = default;

  int foo(int b)
  {
    int a = 1;

    a+=b;
    return b;
  }

};

int main(int argc, char* argv[])
{
  std::shared_ptr<MyClass> p = std::make_shared<MyClass>();

  int c = p->foo(5);

  return 0;
}

When I try to debug the foo function the error occurs.

ProPuke commented 7 years ago

I'm not able to duplicate that problem this end with gdb 7.7.1. Stepping into that method and all others works fine for me.

I'll add in a debug log option to the next option, so that you can hopefully (or anyone with problems) send across the full log of gdb communications. Maybe that will shed some light on it.

ProPuke commented 7 years ago

Okay, I've pushed the latest version of dbg-gdb live with this addition.

Would you be able to go into dbg-gdb package settings, enable "Log to developer console", then debug that test case until it fails?

If you then view the Developer Tools (ctrl-shift-i), Console there should be a log of all the GDB communications. Could you copy-paste the dbg-gdb events here?

janosimas commented 7 years ago

Here is the log:

dbg-gdb >  file-exec-and-symbols /home/MyUser/MyProject/test
dbg-gdb <  = thread-group-added Object {id: "i1"}
dbg-gdb <  ^ done Object {}
dbg-gdb >  file-exec-and-symbols /home/MyUser/MyProject/test
dbg-gdb <  = thread-group-added Object {id: "i1"}
dbg-gdb <  ^ done Object {}
dbg-gdb >  gdb-set mi-async on
dbg-gdb <  ^ error Object {msg: "No symbol "mi" in current context."}
dbg-gdb >  gdb-set target-async on
dbg-gdb <  ^ done Object {}
dbg-gdb >  break-insert /home/MyUser/MyProject/Test.cpp:28
dbg-gdb <  ^ done Object {bkpt: Object}
dbg-gdb >  exec-arguments 
dbg-gdb <  ^ done Object {}
dbg-gdb >  exec-run
dbg-gdb <  = thread-group-started Object {id: "i1", pid: "8218"}
dbg-gdb <  = thread-created Object {id: "1", group-id: "i1"}
dbg-gdb <  ^ running Object {}
dbg-gdb <  * running Object {thread-id: "all"}
dbg-gdb <  = library-loaded Object {id: "/lib64/ld-linux-x86-64.so.2", target-name: "/lib64/ld-linux-x86-64.so.2", host-name: "/lib64/ld-linux-x86-64.so.2", symbols-loaded: "0", thread-group: "i1"}
dbg-gdb <  = library-loaded Object {id: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", target-name: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", host-name: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", symbols-loaded: "0", thread-group: "i1"}
dbg-gdb <  = library-loaded Object {id: "/lib/x86_64-linux-gnu/libm.so.6", target-name: "/lib/x86_64-linux-gnu/libm.so.6", host-name: "/lib/x86_64-linux-gnu/libm.so.6", symbols-loaded: "0", thread-group: "i1"}
dbg-gdb <  = library-loaded Object {id: "/lib/x86_64-linux-gnu/libgcc_s.so.1", target-name: "/lib/x86_64-linux-gnu/libgcc_s.so.1", host-name: "/lib/x86_64-linux-gnu/libgcc_s.so.1", symbols-loaded: "0", thread-group: "i1"}
dbg-gdb <  = library-loaded Object {id: "/lib/x86_64-linux-gnu/libc.so.6", target-name: "/lib/x86_64-linux-gnu/libc.so.6", host-name: "/lib/x86_64-linux-gnu/libc.so.6", symbols-loaded: "0", thread-group: "i1"}
dbg-gdb <  = breakpoint-modified Object {bkpt: Object}
dbg-gdb <  * stopped Object {reason: "breakpoint-hit", disp: "keep", bkptno: "1", frame: Object, thread-id: "1"…}
dbg-gdb >  stack-list-frames --thread 1
dbg-gdb <  ^ done Object {stack: Array[1]}
dbg-gdb >  stack-list-variables --thread 1 --frame 0 1
dbg-gdb <  ^ done Object {variables: Array[4]}
dbg-gdb >  var-create - * argc
dbg-gdb <  ^ done Object {name: "var1", numchild: "0", value: "1", type: "int", thread-id: "1"…}
dbg-gdb >  var-create - * argv
dbg-gdb <  ^ done Object {name: "var2", numchild: "1", value: "0x7fffffffe0f8", type: "char **", thread-id: "1"…}
dbg-gdb >  var-create - * p
dbg-gdb <  ^ done Object {name: "var3", numchild: "1", value: "{...}", type: "std::shared_ptr<MyClass>", thread-id: "1"…}
dbg-gdb >  var-create - * c
dbg-gdb <  ^ done Object {name: "var4", numchild: "0", value: "0", type: "int", thread-id: "1"…}
dbg-gdb >  var-delete var1
dbg-gdb <  ^ done Object {ndeleted: "1"}
dbg-gdb >  var-delete var2
dbg-gdb <  ^ done Object {ndeleted: "1"}
dbg-gdb >  var-delete var3
dbg-gdb <  ^ done Object {ndeleted: "1"}
dbg-gdb >  var-delete var4
dbg-gdb <  ^ done Object {ndeleted: "1"}
dbg-gdb >  exec-step
dbg-gdb <  ^ running Object {}
dbg-gdb <  * running Object {thread-id: "1"}
dbg-gdb <  * stopped Object {reason: "end-stepping-range", frame: Object, thread-id: "1", stopped-threads: "all", core: "7"}
dbg-gdb >  stack-list-frames --thread 1
dbg-gdb <  ^ done Object {stack: Array[2]}
dbg-gdb >  stack-list-variables --thread 1 --frame 0 1
dbg-gdb <  ^ done Object {variables: Array[1]}
dbg-gdb >  var-create - * this
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated
Uncaught (in promise) Debugger terminated

These last Uncaught exceptions expand to:

(anonymous function)    @   /home/jsimas/.atom/packages/dbg-gdb/lib/main.coffee:585
module.exports.Emitter.simpleDispatch   @   /opt/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:25
module.exports.Emitter.emit @   /opt/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:129
process.BufferedProcess.exit    @   /home/jsimas/.atom/packages/dbg-gdb/lib/main.coffee:347
triggerExitCallback @   /home/andrei/atom-1.11.1/out/app/src/buffered-process.coffee:215
(anonymous function)    @   /home/andrei/atom-1.11.1/out/app/src/buffered-process.coffee:229
(anonymous function)    @   /home/andrei/atom-1.11.1/out/app/src/buffered-process.coffee:100
emitOne @   events.js:101
emit    @   events.js:188
_handle.close   @   net.js:493
janosimas commented 7 years ago

I edit the answer running the debug in a different window of the project I'm working on, there were some errors not from the example I posted.

When I ran the example alone the exceptions were empty, in the end, I left the exception content from my other test.