Author Topic: Viewing Linked Lists in C::B  (Read 3724 times)

Offline bamf226

  • Single posting newcomer
  • *
  • Posts: 2
Viewing Linked Lists in C::B
« on: December 06, 2014, 01:32:45 am »
I've tried everything I can think of to get a linked list to appear in the Watches window.  It's easy enough to dereference head and see the contents of the node, but I can't seem to get past the head node except by hardcoding all the next pointers.  It gets to be pretty tiresome to type head->next->next->next to look at the fourth node in the list.  Is there any easier way that I can get the node contents to appear in the Watches window without a string of dereferenced next pointers?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Viewing Linked Lists in C::B
« Reply #1 on: December 06, 2014, 03:23:52 am »
You need to write your own GDB python pretty printers, see: STLSupport - GDB Wiki - Free software! and Debugging with GDB : Writing a Pretty - Printer
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline bamf226

  • Single posting newcomer
  • *
  • Posts: 2
Re: Viewing Linked Lists in C::B
« Reply #2 on: December 06, 2014, 05:29:36 am »
That is well outside my area of expertise.  Is there a plug-in that someone else has already written that will do that?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Viewing Linked Lists in C::B
« Reply #3 on: December 06, 2014, 12:18:59 pm »
It depends on the library. If it is your own library then no - you have to do it yourself.

BTW: Never use linked lists they are sloooow:)
(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!]