From: Tom Tromey <tom@tromey.com>
To: Justin Paston-Cooper <paston.cooper@gmail.com>
Cc: Simon Marchi <simon.marchi@polymtl.ca>, gdb@sourceware.org
Subject: Re: Command to break before exiting stack frame?
Date: Tue, 19 Mar 2019 15:42:00 -0000 [thread overview]
Message-ID: <87mulqx44z.fsf@tromey.com> (raw)
In-Reply-To: <CAEndGgRAyz0gUrDJGooE+AMWuugdLD1Fcef5QYaqcgUAs9yeqw@mail.gmail.com> (Justin Paston-Cooper's message of "Sun, 17 Mar 2019 13:58:48 +0000")
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 15:42 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 [this message]
2019-03-19 20:44 ` Justin Paston-Cooper
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=87mulqx44z.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb@sourceware.org \
--cc=paston.cooper@gmail.com \
--cc=simon.marchi@polymtl.ca \
/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