Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Inspecting STL containers with GDB pretty print(GDB fails on accessing the container)
Inspecting STL containers with GDB pretty print [message #1230331] Sat, 11 January 2014 17:47 Go to next message
Jan Pohanka is currently offline Jan PohankaFriend
Messages: 29
Registered: June 2011
Junior Member
Hi all,

I'm trying to setup Eclipse to work with GDB stl pretty print. I have followed basic instructions, checkouted latest version of python prettyprinters from GNU website and inserted needed settings into .gdbinit.

Pretty printer works perfectly in standalone gdb. However when I try to debug the same simple testing application in Eclipse, it works only sometimes. The debugging fails very often with following output on the gdb console.

The target endianness is set automatically (currently little endian)
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
/home/zumbi/gdb-7.6.1/gdb/varobj.c:3532: internal-error: c_value_of_variable: Assertion `!value_lazy (var->value)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]
/home/zumbi/gdb-7.6.1/gdb/varobj.c:3532: internal-error: c_value_of_variable: Assertion `!value_lazy (var->value)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]


Does anyone have similar problem and know a solution?

Described situation is happening on Debian Jessie x64, GCC 4.8, GDB 7.6, Eclipse Kepler

BR
Jan

[Updated on: Sun, 12 January 2014 08:26]

Report message to a moderator

Re: Inspecting STL containers with GDB pretty print [message #1230668 is a reply to message #1230331] Sun, 12 January 2014 19:00 Go to previous messageGo to next message
Jan Pohanka is currently offline Jan PohankaFriend
Messages: 29
Registered: June 2011
Junior Member
Hi,

today I discovered that the problem described in previous post is connected with using the std::list container.

Here is the minimal example that causes the problem. I have tried it on Debian jessie and Ubuntu 12.04. GDB in 80% of tries fails. It surprises me that standalone gdb in command line works well.

#include <list>

int main()
{
    list<int> x;
    list<int> y;

    x.push_back(1);
    x.push_back(2);
    
    y.push_back(1);
    y.push_back(1);

    return 0;
}


thanks
Jan
Re: Inspecting STL containers with GDB pretty print [message #1230986 is a reply to message #1230668] Mon, 13 January 2014 14:32 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
Eclipse uses GDB in a more complex fashion than what you do on command-line. It is possible that the sequence of commands sent from Eclipse to GDB cause the crash.

Can you give the steps to reproduce the crash? I cannot see it on my Ubuntu 11.10.
Also, to reproduce the crash from the command line only, you can look at the 'gdb traces' of eclipse and mimic the sequence.
You can then remove the unnecessary commands while continuing to see GDB crash.
http://wiki.eclipse.org/CDT/User/FAQ#I.27ve_been_asked_for_.27gdb_traces.27.2C_where_can_I_find_them.3F

Marc
Re: Inspecting STL containers with GDB pretty print [message #1231376 is a reply to message #1230986] Tue, 14 January 2014 14:11 Go to previous messageGo to next message
Jan Pohanka is currently offline Jan PohankaFriend
Messages: 29
Registered: June 2011
Junior Member
Marc Khouzam wrote on Mon, 13 January 2014 09:32

Can you give the steps to reproduce the crash?


Hi Marc,

surprisingly today it was not easy to me to reproduce the bug again. At last I have discovered that using following code

#include <list>

using namespace std;

struct Foo {
	int x;
	int y;
};

int main()
{
    list<int> x;
    list<int> y;
    list<Foo> z;

    x.push_back(1);
    x.push_back(2);

    y.push_back(1);
    y.push_back(1);

    z.push_back(Foo{1,0});
    z.push_back(Foo{1,0});

    return 0;
}


these steps lead to GDB crash in more that 50% of tries.

Variables or Expressions view has to be visible.

1. Set the breakpoint to the line with return
2. Start debug session
3. Run the application
4. GDB fails with returning -1, traces are attached as traces_log1

or

1. Start debug session
2. Step through the program
3. GDB hangs when accessing second or third line of the main(), traces are attached as traces_log2

I will try to reproduce it with GDB itself later this week.

thanks
Jan
  • Attachment: traces_log1
    (Size: 21.61KB, Downloaded 271 times)
  • Attachment: traces_log2
    (Size: 23.80KB, Downloaded 276 times)

[Updated on: Tue, 14 January 2014 14:11]

Report message to a moderator

Re: Inspecting STL containers with GDB pretty print [message #1231787 is a reply to message #1231376] Wed, 15 January 2014 11:59 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
I can reproduce the crash as well. In fact, I see it with the simpler program below. It looks like we need two lists to crash GDB.
This should be reported to the GDB community.

#include <list>
using namespace std;

int main()
{
list<int> x;
list<int> y;

x.push_back(1);
y.push_back(2);

return 0;
}
Re: Inspecting STL containers with GDB pretty print [message #1231804 is a reply to message #1231787] Wed, 15 January 2014 12:52 Go to previous messageGo to next message
Jan Pohanka is currently offline Jan PohankaFriend
Messages: 29
Registered: June 2011
Junior Member
Are you able to reproduce it with standalone GDB? I'm not, yet. I don't know how to reproduce Eclipse's way. It seems that it creates some temporary variables in each step to access STL container children and I cannot write the same in GDB's command line.
Re: Inspecting STL containers with GDB pretty print [message #1231816 is a reply to message #1231787] Wed, 15 January 2014 13:21 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
I cannot reproduce the gdb crash here (gdb 7.5 on Ubuntu 12.04, Eclipse 4.3.1). However, the python script I am using is from 2011 (but same source).


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Inspecting STL containers with GDB pretty print [message #1232265 is a reply to message #1231816] Thu, 16 January 2014 14:50 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
I can crash it from the command line. The minimal set of commands is below. Start gdb like this:

gdb -i mi -nx

Then copy paste the below after you put in your own gdbinit file and executable path:

-enable-pretty-printing
-gdb-set print object on
source /home/lmckhou/prettyPrint/gdbinit
-file-exec-and-symbols --thread-group i1 /home/lmckhou/testing/test
-break-insert --thread-group i1 -f /home/lmckhou/testing/test.cc:12
-break-insert --thread-group i1 -t -f main
-exec-run --thread-group i1

-var-create --thread-group i1 - * x
-var-create --thread 1 --frame 0 - * x
-var-list-children var2
-exec-continue --thread 1

-var-update 1 var2

Re: Inspecting STL containers with GDB pretty print [message #1232568 is a reply to message #1232265] Fri, 17 January 2014 08:21 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Marc Khouzam wrote on Thu, 16 January 2014 15:50
I can crash it from the command line. The minimal set of commands is below. Start gdb like this:

gdb -i mi -nx

Then copy paste the below after you put in your own gdbinit file and executable path:

-enable-pretty-printing
-gdb-set print object on
source /home/lmckhou/prettyPrint/gdbinit
-file-exec-and-symbols --thread-group i1 /home/lmckhou/testing/test
-break-insert --thread-group i1 -f /home/lmckhou/testing/test.cc:12
-break-insert --thread-group i1 -t -f main
-exec-run --thread-group i1

-var-create --thread-group i1 - * x
-var-create --thread 1 --frame 0 - * x
-var-list-children var2
-exec-continue --thread 1

-var-update 1 var2


OK, I can reproduce the crash from the command line. Did you report the bug to the GDB folks?


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Inspecting STL containers with GDB pretty print [message #1232633 is a reply to message #1232568] Fri, 17 January 2014 11:38 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
I have not reported due to lack of time. I'll let either one of you do it, if you can.

Thanks

Marc
Re: Inspecting STL containers with GDB pretty print [message #1233775 is a reply to message #1232633] Mon, 20 January 2014 12:51 Go to previous message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Marc Khouzam wrote on Fri, 17 January 2014 12:38
I have not reported due to lack of time. I'll let either one of you do it, if you can.

Thanks

Marc

I filed a bug report
https://sourceware.org/bugzilla/show_bug.cgi?id=16470


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Previous Topic:Eclipse remote debug cannot connect to X server
Next Topic:A problem with Remote Debugging
Goto Forum:
  


Current Time: Fri Apr 19 12:26:47 GMT 2024

Powered by FUDForum. Page generated in 0.02060 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top