Re: Command to break before exiting stack frame?

Justin Paston-Cooper <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAEndGgTmELniW1Vana5SmX=Ys0mO_fR+OooijNnbe5PKgCa8XQ@mail.gmail.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 <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.