Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Phil Muldoon <pmuldoon@redhat.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [patch][python] 5 of 5 - Frame filter documentation changes
Date: Fri, 22 Mar 2013 19:54:00 -0000	[thread overview]
Message-ID: <87k3ozxsoq.fsf@fleche.redhat.com> (raw)
In-Reply-To: <513E573C.7010502@redhat.com> (Phil Muldoon's message of "Mon, 11	Mar 2013 22:14:20 +0000")

>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> This patch/email address documentation changes for Python Frame
Phil> Filters.

Phil>  * Python scripting
 
Phil> +** Frame filters and frame decorators have been added.
Phil> +
Phil>    ** Vectors can be created with gdb.Type.vector.
 
The addition isn't indented properly.
You'll need to tweak this for trunk anyhow, since you'll be starting a
new "Python scripting" entry for 7.7.

Phil> +@node Frame Filter Management
Phil> +@section Management of Frame Filters.
Phil> +@cindex managing frame filters
Phil> +
Phil> +There are several commands available within @value{GDBN} to manage
Phil> +frame filters, detailed here.

I think this should first describe what a frame filter does, in a way
that ordinary users (not Python-writing users) will understand.

Phil> +@kindex set python frame-filter priority
Phil> +@item set python frame-filter priority @var{filter-dictionary} @var{filter-name} @var{priority}

Seeing this in the manual made me wonder why "python" appears here.
I don't think it matters to users.  It seems like it is more to type,
without a corresponding benefit.

What do you think of dropping the "python" sub-command?

Phil> +* Frame Filter API::            Filtering Frames.
Phil> +* Frame Decorator API::               Decorating Frames.
Phil> +* Writing a Frame Filter/Decorator::  Writing a Frame Filter and Decorator.

I think this node would be just as clear, and would look better, if it
were just named "Writing a Frame Filter".

Phil> +@node Frame Filter API
Phil> +@subsubsection Filtering Frames.
Phil> +@cindex frame filters api

Phil> +to the @code{priority} attribute in each filter.  Once the
Phil> +dictionaries are combined, pruned and sorted, @value{GDBN} then wraps
Phil> +all frames in the call-stack with a @code{FrameDecorator} object, and
Phil> +calls each filter in order.  The input to the first frame filter will

I think it should say:

    Once the dictionaries are combined, pruned and sorted, @value{GDBN}
    creates an iterator which wraps each frame in the call stack in a
    @code{FrameDecorator} object, and calls each filter in order.

That is, mention the iterator explicitly.  The current text makes it
sound as though the stack is pre-emptively unwound, but that isn't true,
and it is important that developers understand this.

Phil> +@defun FrameDecorator.elided ()

I think these methods should mention 'self'.
That is what we did in the pretty-printing API documentation.

Phil> +The @code{elided} method groups frames together in a hierarchical
Phil> +system.  An example would be an interpreter call that occurs over many
Phil> +frames but might be better represented as a group of frames distinct
Phil> +from the other frames.

I think the latter part of this is too vague.
How about -

    An example would be an interpreter, where multiple low-level frames make
    up a single call in the interpreted language.  In this example, the
    frame filter would elide the low-level frames and present a single
    high-level frame, representing the call in the interpreted language, to
    the user.


Phil> +frame decorator.  If there are no frames being elided in this frame
Phil> +decorator, this method must return @code{None}.  

What happens if it returns an empty iterable?

If that is ok, how about ", this method may return an empty iterable, or
@code{None}"?

Phil> +@defun FrameDecorator.frame_args ()
Phil> +@anchor{frame_args}
Phil> +
Phil> +This method must return an iterable or @code{None}.  This iterable
Phil> +must contain objects that implement two methods, described here.

What if it returns an empty iterable instead?

Phil> +The object must implement an @code{argument} method which takes no
Phil> +parameters and must return a @code{gdb.Symbol} (@pxref{Symbols In
Phil> +Python}), or a Python string.

I think it should say "a single @code{self} parameter" rather than "no
parameters".  Likewise for the other method.

Phil> +Even if the @code{frame_args} method returns only a single object, it
Phil> +must be iterable.

I would zap this sentence.

Phil> +Even if the @code{frame_locals} method returns only a single object, it
Phil> +must be iterable.

Here too.

Phil> +The second step is registering the frame filter with the dictionary or
Phil> +dictionaries that the frame filter has interest in.

I think this paragraph should xref to "Python Auto-loading" at some
point.

Phil>   The global dictionary is always
Phil> +present, and so will the frame filters registered in it.

This reads weirdly.

Phil> +well worth reflecting upon when designing a frame filter.  An issue
Phil> +that frame filters should avoid is unwinding the stack if possible.

I think the laziness issue should be pointed out in the main API
documentation somewhere.  It's very important; it is fine to repeat it
here, but it should also be somewhere other than in an example.

Phil> +@smallexample
Phil> +class InlinedFrameDecorator(FrameDecorator):
Phil> +
Phil> +    def __init__(self, fobj):
Phil> +        super(InlinedFrameDecorator, self).__init__(fobj)
Phil> +        self.fobj = fobj

self.fobj is never used.

FrameDecorator also stores this in an attribute, "base".
Should that attribute just be declared public?
And if not, shouldn't it be renamed to start with a "_"?

Phil> +    def function(self):
Phil> +        frame = self.inferior_frame()
Phil> +        name = str(frame.name())
Phil> +        function = str(frame.function())
Phil> +
Phil> +        if frame.type() == gdb.INLINE_FRAME:
Phil> +            name = name + " [inlined from "+ function +"]"

This actually violates the FrameDecorator guidelines, since it bypasses
self.base to get the name from the inferior_frame.

It seems like it should call self.base.name() instead.
And, it should have a comment explaining why it needs to use
inferior_frame to call function.

I'm a little surprised that calling the inferior frame's "function" does
what you want here.  That seems like a bug TBH.

Phil> +This example approaches the issue with the @code{elided} method.  This
Phil> +example is quite long, but very simplistic.  It is out-of-scope for

I would say, s/simplistic/simple/.

Phil> +        try:
Phil> +            eliding_frame = next(self.input_iterator)
Phil> +        except StopIteration:
Phil> +            return frame
Phil> +        return ElidingFrameDecorator(eliding_frame, [frame])

What if there are multiple inline frames in a row?
Wouldn't you want to elide all of them?
That will make the example trickier though.

Tom


  parent reply	other threads:[~2013-03-22 17:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11 22:14 Phil Muldoon
2013-03-12 17:24 ` Eli Zaretskii
2013-03-22 19:54 ` Tom Tromey [this message]
2013-04-19 14:24   ` Phil Muldoon
  -- strict thread matches above, loose matches on Subject: below --
2013-05-06  8:24 Phil Muldoon
2013-04-22 17:03 Phil Muldoon
2013-04-26 11:54 ` Tom Tromey
2013-05-10 10:52   ` Phil Muldoon
2012-11-30 14:32 Phil Muldoon
2012-12-01 10:59 ` Eli Zaretskii
2012-12-05 19:11   ` Tom Tromey
2012-12-07 14:35   ` Phil Muldoon
2012-12-07 15:04     ` Eli Zaretskii
2012-12-07 15:34       ` Phil Muldoon
2012-12-07 15:54       ` Eli Zaretskii
2012-12-05 20:49 ` Tom Tromey
2012-12-07 14:55   ` Phil Muldoon

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=87k3ozxsoq.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@redhat.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