Author Topic: gdb, shared_ptr and code::blocks  (Read 4069 times)

Offline babis

  • Single posting newcomer
  • *
  • Posts: 3
gdb, shared_ptr and code::blocks
« on: January 19, 2016, 12:13:12 am »
Hi,

I'm using code::blocks 13.12 in Linux Mint.
I have both gdb 7.10.1 and 7.7.1, and I've downloaded the python code for pretty printing -- both exhibit the below problem.
Sometimes, when I'm trying to print a shared_ptr ( using either "print (*ptr.get())" or "print *ptr" or "print *ptr._M_ptr") I get no output; it just halts there and I have to kill gdb, sometimes code::blocks too. I've tried the same thing in Eclipse, but I didn't get such a problem. The structure that I'm trying to print (or equivalently, display in the watch window) is complex; several STL vectors and sets and maps and so on.

I created a test application with a shared_ptr of a very simple structure, and it works as expected.
If I print a variable within the structure, it also works ok.
I'm suspecting a "maximum size" of sorts, that I'm exceeding.

Anybody have any ideas?

Thanks.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: gdb, shared_ptr and code::blocks
« Reply #1 on: January 19, 2016, 12:20:03 am »
If the vectors are containing lots of data then probably this is causing the problem.
At the moment nothing could be done as far as I know.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline babis

  • Single posting newcomer
  • *
  • Posts: 3
Re: gdb, shared_ptr and code::blocks
« Reply #2 on: January 19, 2016, 12:41:36 am »
Thanks! Quick and spot on :)

I'm pretty sure I've seen a post somewhere to add some line in the python code to clamp the displayed number of elements, but I've lost it now dammit...

Offline babis

  • Single posting newcomer
  • *
  • Posts: 3
Re: gdb, shared_ptr and code::blocks
« Reply #3 on: January 19, 2016, 10:58:05 am »
Ok, for reference, it's fixed by just setting a limit to how many elements shall be printed, for example using the below:

set print elements 100

in .gdbinit or the debugger initialization commands