gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using Variables for debugging STL lists?


From: Christoph Seifert
Subject: Using Variables for debugging STL lists?
Date: Mon, 30 Jul 2007 12:24:34 +0200

Hi,

at the moment, I am working on getting a working set of macros for debugging 
std::list etc. with gcc 4.2.1. The problem I face is that I don't know how to 
get a symbol for translating a list node into a value-type - it is probably not 
available at all.

Working from a previously posted example by somebody else, I have this:

define p_stl_list
    set $list = ($arg0)
    set $list_size = 0
    set $curNode = $list->_M_impl._M_node._M_next
    set $endNode = $list->_M_impl._M_node
    while ($curNode->_M_next != $endNode->_M_next)
        printf "%d: ", $list_size
        print (('std::_List_node<int>'*) $curNode)->_M_data
        set $curNode = ($curNode)->_M_next
        set $list_size++
    end
end

The problematic line is of course:
print (('std::_List_node<int>'*) $curNode)->_M_data

1) Is there a way to either get a symbol for casting right to the right value 
type right away instead e.g. (made up) listname::iterator::value_type?
2) I am trying to use a second argument which translates to 
print (('std::_List_node<int>'*) $curNode)->_M_data, but I am failing to use it 
like a string expansion. Usage should be something like p_stl_list listname 
int. The macro in the current form is working only when written down literally 
unfortunately.

Any way to do this?

Thanks in advance,

Christoph

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger




reply via email to

[Prev in Thread] Current Thread [Next in Thread]