Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@igalia.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches <gdb-patches@sourceware.org>,
	 Alexander Smundak <asmundak@google.com>,
	 Doug Evans <xdje42@gmail.com>
Subject: Re: Frame sniffers in Python/Guile/*
Date: Mon, 09 Mar 2015 19:19:00 -0000	[thread overview]
Message-ID: <87lhj6q8rl.fsf@igalia.com> (raw)
In-Reply-To: <54FDBE7B.9070405@redhat.com> (Pedro Alves's message of "Mon, 09	Mar 2015 15:38:35 +0000")

Hi Pedro,

Thanks for the detailed comments!  Comments inline and a brief summary
at the end.

On Mon 09 Mar 2015 16:38, Pedro Alves <palves@redhat.com> writes:

> On 03/02/2015 01:28 PM, Andy Wingo wrote:
>
>> Unfortunately, the unwind callback is really squirrely -- you can't do
>> much there.
>
> You mean the "unwind->sniffer" callback, right?  If so, that's (so far) by
> design.  The sniffer callback is only supposed to identify whether
> the unwinder can unwind, not do any unwinding at all.  :-/

Unfortunately you have to do some unwinding in order to compute a frame
ID, and the "unwind->this_id" callback runs in approximately the same
environment as the sniffer.

> See here for example:
>
>   https://www.sourceware.org/ml/gdb-patches/2013-11/msg00602.html

Is it important to use frame_unwind_got_memory et al for results?  (IIUC
links between values and frames was part of the issue in that mail.)  In
my unwinders I am just returning values using e.g.

  (value-dereference
   (value-cast (ephemeral-frame-read-register ef "rbp") void**-type))

or something similar.  If this is important, we will need to provide an
interface that looks much more like the unwind interface instead of a
simple Maybe<UnwindInfo> :(

> But imagine the case of:
>
>   #0 frame0  <<<< current
>   #1 frame1  <<<< selected
>   #2 frame2
>
> So what context does make sense for symbol look ups at that point?

Oh, agreed very much.  I was looking up global symbols, like global
constants, and in that case the block is NULL.  But, I was having issues
that I didn't understand using lookup_global_symbol, and lookup_symbol
worked otherwise outside of the sniffer...

Is the issue in the Guile bindings, that they should assume that it's
sensible to get the current architecture, or the selected or current
frame?

> Isn't the correct answer that the sniffer should pass in an explicit
> block to lookup-symbol?

Yes, or in this case lookup-global-symbol.

>>   * You can't value-call, which is not unexpected in general, but the
>>     reason is unexpected: because call_function_by_hand calls
>>     get_current_arch and that doesn't work
>
> Where is that?  I think you meant that the guile wrapper calls
> get_current_arch, not call_function_by_hand.

Yes, I see that now.  I think I was confused.

> Why would the unwinder want to access user / pseudo registers?
> Shouldn't it be working only with raw registers?

Because the user is ignorant? :)  I was pleased that $pc, $sp, and $fp
"worked" otherwise, so I hoped to avoid encoding architecture-specific
things.  Alas.  (Incidentally, my patch still has the problem that
passing in a pseudo register will barf.)

In summary:

  * Is is possible to make a Maybe<UnwindInfo>-style interface to
    sniffers, or should extension languages expose the callbacks
    instead because they really need to be called within their specific
    dynamic environments?

  * Regarding recursion and selected frames -- what do you think about
    the hack in v2 of this patch, which adds
    frame_unwinder_is_unwinding() ?  It is a hack but it has somewhat
    reasonable semantics.

Andy


  reply	other threads:[~2015-03-09 19:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 13:28 Andy Wingo
2015-03-08 20:04 ` Doug Evans
2015-03-09  8:27   ` Andy Wingo
2015-03-09 15:39 ` Pedro Alves
2015-03-09 19:19   ` Andy Wingo [this message]
2015-03-10 16:36     ` Pedro Alves
2015-03-10 17:36       ` Andy Wingo

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=87lhj6q8rl.fsf@igalia.com \
    --to=wingo@igalia.com \
    --cc=asmundak@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=xdje42@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