user defined function and passing types

Tom Tromey
Fri Sep 10 15:59:00 GMT 2010

>>>>> "Pawel" == Pawel K <> writes:

Pawel> I have following user defined function:
Pawel> define my_stl_list

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

What you really want is to use the new Python pretty-printing support.
We have a full suite of printers for libstdc++, checked into the
libstdc++ repository.  On a recent Linux distro, it will all "just work"
without manual intervention.

If you do need to set it up manually, there is some info here:

To answer your original question, there are two ways to do complicated
scripting things in gdb.

One is use the Python scripting support.  This is usually simplest, if
you can use it, because it is easy to do all kinds of string
manipulations and whatnot in Python.

The other is to use a gross GDB scripting trick: use "set logging" to
redirect output to a file; print things to that file; use "shell" plus a
shell script (or external perl or python or sed or whatever) to convert
that to a gdb script; then finally "source" the result.


More information about the Gdb mailing list