user defined function and passing types

Pawel K
Fri Sep 10 14:41:00 GMT 2010

Hallo Group Members.

I have following user defined function:

define my_stl_list
  set $list = ($arg0)
  set $list_size = 0
  set $firstNode = $list._M_head
  set $curNode = $list._M_head._M_next
  while ($curNode != 0)
    printf "List Element %d: ", $list_size
    p ((const __gnu_cxx::_Slist_node<int> *)$curNode)->_M_data
    set $curNode = ($curNode)->_M_next
    set $list_size++

As You can see, it displays contents of slist.
It's drawback is that it has hard coded type of list (const
__gnu_cxx::_Slist_node<int> *).
Is there a way to pass it as parameter to this macro?

best regards,

More information about the Gdb mailing list