Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Justin Paston-Cooper <paston.cooper@gmail.com>
To: gdb@sourceware.org
Subject: Command to break before exiting stack frame?
Date: Sat, 16 Mar 2019 23:15:00 -0000	[thread overview]
Message-ID: <CAEndGgToidTsVOhwvV=9RFf=nYWwK+3_qWheYJ8JtoNez3Pq8w@mail.gmail.com> (raw)

Hello,

I would be interested to see a command which breaks just before exiting the
current stack frame. I have so far seen this implemented as a custom
command in Python, which searches for 'retq' instructions in the current
stack frame. I am not an ASM expert, but I imagine that this might not work
for all architectures.

In any case, you might ask why I can't just use that instead of expecting
it as a native command in gdb. You might also ask why I don't just give the
line number of the returns of the function in question. There are a few
reasons:

1. We already have a command to break at the beginning of a function given
its name (break).
2. We already have a command to continue to the end of the current stack
frame and then exit it (finish).
3. Analysing C/C++/other code with gcc is difficult. grep can tell me the
line numbers of returns in C/C++, but there might be other languages where
such a simple solution is not so readily available. In any case, it's still
an extra step.
4. rbreak breaks at the beginning of all functions matching a regex. It
would be simple and useful to add a "break on frame exit" command to the
commands part of an rbreak command to see the ending state of all chosen
functions.

I can't imagine that I am the first person to suggest or request this. Are
there any architectural or practical reasons as to why this is might be
difficult? I was not able to find any, but are there any existing,
equivalent and native solutions?

Thanks in advance,

Justin


             reply	other threads:[~2019-03-16 23:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-16 23:15 Justin Paston-Cooper [this message]
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
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='CAEndGgToidTsVOhwvV=9RFf=nYWwK+3_qWheYJ8JtoNez3Pq8w@mail.gmail.com' \
    --to=paston.cooper@gmail.com \
    --cc=gdb@sourceware.org \
    /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