public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Carl Love <cel@us.ibm.com>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"luis.machado@arm.com" <luis.machado@arm.com>
Subject: Re: Questions on how best to fix two gdb tests gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp
Date: Mon, 26 Sep 2022 08:30:52 -0700	[thread overview]
Message-ID: <4bb7ce2d41f5623a8866a9e631e3cda48a6a0e04.camel@us.ibm.com> (raw)
In-Reply-To: <bd3a39ac8ae2e27e8a802d1d689246c904d1d0de.camel@de.ibm.com>

Ulrich, Luis:

On Mon, 2022-09-26 at 14:36 +0000, Ulrich Weigand wrote:
> Luis Machado <luis.machado@arm.com> wrote:
> 
> > gdbarch has a hook to adjust the breakpoint address
> > (gdbarch_adjust_breakpoint_address). Can this be used to bend
> > commands
> > like "b *func" so they behave the same as other architectures?
> 
> I don't think this works.  The problem is that "b *func" is a weird
> hack that combines two aspects: use of "func" as a value that at this
> point is just a plain symbol table lookup; and use of "*" to set a
> breakpoint at an explicitly specified absolute address.
> 
> Neither of these aspects is something we want to change on its own.
> We do want a plain symbol, if used as a value, to return the
> address that is in the symbol table.  Everything else would just
> be confusing, and could also break things if "if ptr == func"
> where "ptr" is a function pointer variable.
> 
> On the other hand, when using "b *<addr>" with some hard-coded
> address, we actually want the breakpoint to be exactly there
> and nowhere else; that is usually used by someone familiar with
> the platform who want to set the breakpoint exactly there. (Or,
> possibly, by clicking on "set breakpoint" in a GUI switched to
> the assembly view.) Automatically moving this to a different
> address would be weird, when the whole point of "*" is that it
> *isn't* trying to be clever, unlike say "b func".
> 
> It is an unfortunate fact that these two properties, which are
> each desired on their own, combine to yield an undesirable
> effect when used as "b *func" on Power.  But I think the root
> cause of this is that "b *func" is used here in a way that is
> not justified by the actual specification of those features.
> 
> Actually, I'm not seeing much use of this particular construct
> at all, outside of the GDB test suite.  And here, it is used
> in the idiosyncratic manner of "do a 'b func' but just without
> skipping the prolog", usually because of some GDB test suite
> internal reason why we want to avoid prolog skipping just here.
> 
> It seems to me that the real fix would be some new syntax that
> makes this goal explicit, maybe along the lines of
>   b -entrypoint func
> 
> (It would still be preferable to me to investigate use of this
> construct throughout the test suite to see if it is *really*
> necessary or if the tests can simply be rewritten in a way
> that they don't need the "skip prolog" feature anyway ...)

I looked at the suggestion from Luis.  In the end, I really didn't
think changing gdb to make the test work is really the best idea.  The
issue is that there are cases, as Ulrich said, where someone who knows
the details may actually want to set the breakpoint on the first
instruction.  If I change gdb, to fix the test by "adjusting" the
desired breakpoint then the user is no longer able to stop where they
want to.

I am not sure why the original test was concerned about the prolog. 
The original author doesn't seem to be around anymore.  I will think
about how to change the first test some more.

I don't see any issues with changing the second test to just break on
the function callee rather than *callee.  I will submit a patch to
change the second test.  

                               Carl 


  reply	other threads:[~2022-09-26 15:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 18:23 Carl Love
2022-09-23  9:13 ` Bruno Larsen
2022-09-23 10:48 ` Luis Machado
2022-09-23 10:56   ` Luis Machado
2022-09-26 14:36   ` Ulrich Weigand
2022-09-26 15:30     ` Carl Love [this message]
2022-09-26 16:08       ` Bruno Larsen

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=4bb7ce2d41f5623a8866a9e631e3cda48a6a0e04.camel@us.ibm.com \
    --to=cel@us.ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@arm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).