public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"luis.machado@arm.com" <luis.machado@arm.com>,
	"cel@us.ibm.com" <cel@us.ibm.com>
Subject: Re: [PATCH][gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp
Date: Thu, 1 Sep 2022 16:40:17 +0200	[thread overview]
Message-ID: <61b1893d-144b-7627-d5c3-50d4bdafdc84@suse.de> (raw)
In-Reply-To: <dd3070465841f4edfb3c19a4fb6a1d222e39374c.camel@de.ibm.com>

On 8/17/22 14:01, Ulrich Weigand wrote:
> 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.
> 

Ack, I've posted a fix that doesn't use that construct anymore.

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

I think we could add a note to the docs explaining this.

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

Yes, it should, and a test-case should be added for that.

In this test-case, we try to test a feature that has nothing to do with 
architecture-specific prologue skipping, so given that there can be 
problems with it on various targets, the test-case should simply skip it.

Thanks,
- Tom

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

  reply	other threads:[~2022-09-01 14:40 UTC|newest]

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

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=61b1893d-144b-7627-d5c3-50d4bdafdc84@suse.de \
    --to=tdevries@suse.de \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=cel@us.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).