Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ulrich Weigand via Gdb-patches <gdb-patches@sourceware.org>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"luis.machado@arm.com" <luis.machado@arm.com>,
	"tdevries@suse.de" <tdevries@suse.de>,
	"cel@us.ibm.com" <cel@us.ibm.com>
Subject: Re: [PATCH][gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp
Date: Wed, 17 Aug 2022 12:01:21 +0000	[thread overview]
Message-ID: <dd3070465841f4edfb3c19a4fb6a1d222e39374c.camel@de.ibm.com> (raw)
In-Reply-To: <6a7bdae3c17ffddd49843215537b9d480f85b2cf.camel@us.ibm.com>

Carl Love <cel@us.ibm.com> wrote:

>PowerPC has two entry points, local and global.  The test used to set
>the breakpoint for the function at the local entry point.  With your
>changes, the breakpoint is now being set at the global breakpoint
which
>is before the local breakpoint.  The function is actually entered at
>the local breakpoint thus gdb never "sees" the breakpoint that was
set.
>Specfically, here is the objdump for the test:

>00000000100006e0 <compdir_missing__ldir_missing__file_basename>:
>    100006e0:   02 10 40 3c     lis     r2,4098                      <-
>Global entry point
>    100006e4:   00 7f 42 38     addi    r2,r2,32512
The local enty point is actually here:
>    100006e8:   f8 ff e1 fb     std     r31,-8(r1)
>    100006ec:   d1 ff 21 f8     stdu    r1,-48(r1)
>    100006f0:   78 0b 3f 7c     mr      r31,r1
>    100006f4:   00 00 00 60     nop                                  <-
>Local entry point
>    100006f8:   28 81 22 39     addi    r9,r2,-32472

Not here. This point might be the end of the prologue, which is a
separate question from the local vs. global entry point issue.

>Perhaps Ulrich has some ideas???

This:
+       gdb_breakpoint *$func
is nearly always wrong, and test cases shouldn't be using it.

I know that in the past, this construct was sometimes used with an
intended meaning of "set a breakpoint at the start of a function
without skipping the prologue", but it does *not* actually mean that.

The "*" operator tells the breakpoint logic to set a breakpoint on an
absolute address.  If followed by a symbol, that symbol's value is used
as that absolute address.  Now, on many platform, that symbol value
matches the address of the first instruction of a function, so the
"break *func" does more or less what's intended above.

But there are other platforms where this is not true, and the
relationship between the function symbol value and the address of the
first executed instruction is more complex.  This specifically applies
to targets that implement gdbarch_deprecated_function_start_offset
and/or gdbarch_skip_entrypoint.  (ppc64le uses the latter.)

Note that these are *independent* of prologue skipping, and on
platforms where it matters, they have to be used even when avoiding
prologue skipping, in order to correctly find the first instruction of
a function to set a breakpoint on.   "break *func" ignores this,
leading to failures on such platforms.


As I said initially, I think this construct should never be used in
test cases (at least not in scenerios where it is intended to set a
breakpoint that will actually be hit).

For this specific test, if the underlying problem is a bug in some
architecture's prologue parser, then ideally this bug simply should be
fixed.  If we need to actually avoid prologue skipping for some real
underlying reason, we should use a way that still handles function
start offsets and entrypoint skipping.  For example, in a function with
debug info including valid location lists, GDB will always avoid
prologue skipping.  We could also think of adding an explicit linespec
modifier that would allow to explicitly set a breakpoint on the first
instruction of a function without skipping prologue ...


Bye,
Ulrich


  parent reply	other threads:[~2022-08-17 12:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 11:58 Tom de Vries via Gdb-patches
2022-08-12  9:33 ` Luis Machado via Gdb-patches
2022-08-15 16:01   ` Carl Love via Gdb-patches
2022-08-15 16:54     ` Carl Love via Gdb-patches
2022-08-15 19:12       ` will schmidt via Gdb-patches
2022-08-15 19:31         ` Thiago Jung Bauermann via Gdb-patches
2022-08-15 21:33           ` will schmidt via Gdb-patches
2022-08-16  7:43         ` Luis Machado via Gdb-patches
2022-08-16 16:00           ` will schmidt via Gdb-patches
2022-08-17 12:01       ` Ulrich Weigand via Gdb-patches [this message]
2022-09-01 14:40         ` Tom de Vries via Gdb-patches
2022-09-01 14:16       ` Tom de Vries via Gdb-patches

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=dd3070465841f4edfb3c19a4fb6a1d222e39374c.camel@de.ibm.com \
    --to=gdb-patches@sourceware.org \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=cel@us.ibm.com \
    --cc=luis.machado@arm.com \
    --cc=tdevries@suse.de \
    /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