This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: user defined function and passing types


>>>>> "Pawel" == Pawel K <mafeusek@gmail.com> 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:

    http://sourceware.org/gdb/wiki/STLSupport


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.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]