From: Justin Paston-Cooper <paston.cooper@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb@sourceware.org
Subject: Re: Command to break before exiting stack frame?
Date: Tue, 19 Mar 2019 20:44:00 -0000 [thread overview]
Message-ID: <CAEndGgTmELniW1Vana5SmX=Ys0mO_fR+OooijNnbe5PKgCa8XQ@mail.gmail.com> (raw)
In-Reply-To: <87mulqx44z.fsf@tromey.com>
Tom> It seems to me that a tail call means there just isn't a return value
Tom> from the calling function, only from the callee, because the caller
Tom> doesn't even really have a separate return statement.
That makes sense actually. Although I would hope that the break on
exit command would break after any tail-recursive call exits.
Tom> On the whole I think it would be better to start with the compiler. If
Tom> it emits epilogue markers, then the gdb work is not difficult.
Thanks for the tips. I've sent a message to the gcc mailing list.
On Tue, 19 Mar 2019 at 15:42, Tom Tromey <tom@tromey.com> wrote:
>
> Justin> Given its documentation, I would have expected the "finish" command to
> Justin> print the returned value at each tail call. It turns out that it
> Justin> prints the returned value only for the f(0) call. I would similarly
> Justin> expect a "break on exit" command to break on the exit of the frame in
> Justin> which it is called even if a tail-recursion occurs. Is there a reason
> Justin> that it doesn't?
>
> It seems to me that a tail call means there just isn't a return value
> from the calling function, only from the callee, because the caller
> doesn't even really have a separate return statement.
>
> I suppose, though, if it is like inlining, then this text from the
> manual also applies:
>
> * GDB cannot locate the return value of inlined calls after using the
> 'finish' command. This is a limitation of compiler-generated
> debugging information; after 'finish', you can step to the next
> line and print a variable where your program stored the return
> value.
>
> Justin> On the actual implementation of this command: Is the implementation of
> Justin> such a feature feasible? If so, how much work would it take?
>
> For the compiler, I couldn't say. For gdb, doing it without help from
> the compiler seems difficult, as you'd probably have to write an
> instruction decoder. gdb already has these for some architectures
> (various kinds, actually, for different things), but probably not in a
> useful form.
>
> On the whole I think it would be better to start with the compiler. If
> it emits epilogue markers, then the gdb work is not difficult.
>
> Tom
next prev parent reply other threads:[~2019-03-19 20:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-16 23:15 Justin Paston-Cooper
2019-03-17 0:01 ` Andreas Schwab
2019-03-17 0:23 ` Simon Marchi
2019-03-17 13:59 ` Justin Paston-Cooper
2019-03-19 15:42 ` Tom Tromey
2019-03-19 20:44 ` Justin Paston-Cooper [this message]
2019-03-19 15:35 ` Tom Tromey
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='CAEndGgTmELniW1Vana5SmX=Ys0mO_fR+OooijNnbe5PKgCa8XQ@mail.gmail.com' \
--to=paston.cooper@gmail.com \
--cc=gdb@sourceware.org \
--cc=tom@tromey.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