This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Command to break before exiting stack frame?

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

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]