Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Pawel K <mafeusek@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: user defined function and passing types
Date: Fri, 10 Sep 2010 15:59:00 -0000	[thread overview]
Message-ID: <m3iq2doahi.fsf@fleche.redhat.com> (raw)
In-Reply-To: <AANLkTik7GMe9GH5GkcFqGBvhxWezAPsNwaVa5a8qZ-3A@mail.gmail.com>	(Pawel K.'s message of "Fri, 10 Sep 2010 16:41:34 +0200")

>>>>> "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


      reply	other threads:[~2010-09-10 15:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-10 14:41 Pawel K
2010-09-10 15:59 ` Tom Tromey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3iq2doahi.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=mafeusek@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox