Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Simeon S <simeon.simeonov.s@gmail.com>
To: gdb@sourceware.org
Subject: GDB Frame Filter - handling corrupt stack
Date: Tue, 09 Sep 2014 12:26:00 -0000	[thread overview]
Message-ID: <CAGwyPpEkdfuwFiS_afffoHk_1nGjMFjG+v3yKLhioiRyasdYyQ@mail.gmail.com> (raw)

Hi all,

I am trying to decorate the output of "backtrace" command. I have
written a simple gdb Frame Filter coupled with a Frame Decorator. I
have followed the official documentation tutorial
(https://sourceware.org/gdb/current/onlinedocs/gdb/Writing-a-Frame-Filter.html#Writing-a-Frame-Filter).
My gdb is compiled against Python 3.3.2 and my code looks like this:



    import gdb
    import itertools
    from gdb.FrameDecorator import FrameDecorator
    import copy

    class UpperCase_Decorator (FrameDecorator):
        def __init__(self, fobj):
            super(UpperCase_Decorator, self).__init__(fobj)
            self.fobj = fobj

        def function(self):
            frame = self.fobj.inferior_frame()

            if not frame.is_valid():
                return ""

            name = str(frame.name()).upper()
            return name


    class InlineFilter():
        def __init__(self):
            self.name = "InlinedFrameFilter"
            self.priority = 100
            self.enabled = True
            gdb.frame_filters[self.name] = self

        def filter(self, frame_iter):
            frame_iter = map(UpperCase_Decorator,
                             frame_iter)
            print(type(frame_iter))
            return frame_iter

    ff = InlineFilter()



When the gdb "backtrace" command is issued, frames are decorated
followed by a gdb crash. This is what the last output from gdb is:

    UNIX ERR:tcsetattr:Input/output error
    Segmentation fault (core dumped)

The stack seems to be corrupt which is what I suspect is causing the
crash. If the frame filter is disabled, the last line of the
"backtrace" command is:

    Backtrace stopped: previous frame inner to this frame (corrupt stack?)

I haven't looked into why the stack is corrupt - all the frames of
interest to me are there.  Is there a way to catch this condition to
avoid crashing? I am not interested in any of the corrupt frames -
what is in the stack is enough.

I guess I am looking for a mechanism to stop gdb iterating over
further frames if it detects a corrupt/invalid frame.  The
documentation does say that gdb has to iterate over all stack frames
though.

Regards,
Simeon


             reply	other threads:[~2014-09-09 12:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 12:26 Simeon S [this message]
2014-09-09 15:48 ` Phil Muldoon
2014-09-09 21:37   ` Simeon S

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=CAGwyPpEkdfuwFiS_afffoHk_1nGjMFjG+v3yKLhioiRyasdYyQ@mail.gmail.com \
    --to=simeon.simeonov.s@gmail.com \
    --cc=gdb@sourceware.org \
    /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