public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"luis.machado@arm.com" <luis.machado@arm.com>,
	"cel@us.ibm.com" <cel@us.ibm.com>
Cc: "palves@redhat.com" <palves@redhat.com>,
	"pedro@codesourcery.com" <pedro@codesourcery.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 14:36:11 +0000	[thread overview]
Message-ID: <bd3a39ac8ae2e27e8a802d1d689246c904d1d0de.camel@de.ibm.com> (raw)
In-Reply-To: <1398bb10-2ed9-c074-0627-43d7e2feddea@arm.com>

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 ...)

Bye,
Ulrich


  parent reply	other threads:[~2022-09-26 14:36 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 [this message]
2022-09-26 15:30     ` Carl Love
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=bd3a39ac8ae2e27e8a802d1d689246c904d1d0de.camel@de.ibm.com \
    --to=ulrich.weigand@de.ibm.com \
    --cc=cel@us.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@arm.com \
    --cc=palves@redhat.com \
    --cc=pedro@codesourcery.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).