public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Cc: thiago.bauermann@linaro.org
Subject: Re: [PATCH v7 15/18] [gdb/generic] corefile/bug: Add hook to control the use of target description notes from corefiles
Date: Wed, 20 Sep 2023 06:49:35 +0100	[thread overview]
Message-ID: <f45c544f-d983-b66a-de05-d095b1604428@arm.com> (raw)
In-Reply-To: <957943ea-a51a-4cdb-b86e-68d2fb85de9d@polymtl.ca>

On 9/19/23 21:49, Simon Marchi wrote:
> On 9/18/23 17:26, Luis Machado wrote:
>> New entry in v7.
>>
>> ---
> 
> Note: when you use `---` in a commit message, git-am drops whatever
> comes after that, so here we lose the commit message when applying.  I
> think the intention is that you'd put whatever you don't want to appear
> in the commit message (like the "new in version X" notes) after the
> `---`.  I'll try to do that from now on.
> 

Yeah, that's a bad marker indeed. Is that configuration-specific though?

>>
>> Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread
>> can potentially have distinct target descriptions/gdbarches.
>>
>> When loading a gcore-generated core file, at the moment GDB gives priority
>> to the target description dumped to NT_GDB_TDESC.  Though technically correct
>> for most targets, it doesn't work correctly for AArch64 with SVE or SME
>> support.
>>
>> The correct approach for AArch64/Linux is to either have per-thread target
>> description notes in the corefiles or to rely on the
>> gdbarch_core_read_description hook, so it can figure out the proper target
>> description for a given thread based on the various available register notes.
>>
>> The former, although more correct, doesn't address the case of existing gdb's
>> that only output a single target description note.
>>
>> This patch goes for the latter, and adds a new gdbarch hook to conditionalize
>> the use of the corefile target description note. The hook is called
>> use_target_description_from_corefile_notes.
>>
>> The hook defaults to returning true, meaning targets will use the corefile
>> target description note.  AArch64 Linux overrides the hook to return false
>> when it detects any of the SVE or SME register notes in the corefile.
>>
>> Otherwise it should be fine for AArch64 Linux to use the corefile target
>> description note.
>>
>> When we support per-thread target description notes, then we can augment
>> the AArch64 Linux hook to rely on those notes.
>>
>> Regression-tested on aarch64-linux Ubuntu 22.04/20.04.
> 
> The question that came to mind when reading this is (I already asked you
> on IRC, but perhaps someone else has an idea): if GDB has to know how to
> infer target descriptions from the core file contents (the
> kernel-generated core files don't include target description notes, only
> GDB-generated core files do), what advantage do we have of storing and
> reading the target description in the core?  Are there any scenarios
> where the target description note conveys something that GDB wouldn't
> figure out by analyzing the core file content?
> 

According to the original commit that added NT_GDB_TDESC, there are potential use case around
dumping a core file from a remote session. That remote target may potentially have more registers
than what gdb might be able to infer.

>> diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
>> index 846467b8d83..bbb9b188286 100644
>> --- a/gdb/gdbarch_components.py
>> +++ b/gdb/gdbarch_components.py
>> @@ -2732,3 +2732,22 @@ Read core file mappings
>>      predefault="default_read_core_file_mappings",
>>      invalid=False,
>>  )
>> +
>> +Method(
>> +    comment="""
>> +Return true if the target description for all threads should be read from the
>> +target description core file note(s).  Return false if the target description
>> +for all threads should be inferred from the core file contents/sections.
>> +
>> +The corefile's bfd is passed through OBFD.
>> +
>> +This hook should be used by targets that can have distinct target descriptions
>> +for each thread when the core file only holds a single target description
>> +note.
> 
> I think the last paragraph should be left out.  An arch could decide not
> to use the target description note for whatever reason it sees fit, this
> is just one example.  The reason for AArch64 appears to be sufficiently
> described in the AArch64-specific files.
> 

Will do, thanks.

>> +""",
>> +    type="bool",
>> +    name="use_target_description_from_corefile_notes",
>> +    params=[("struct bfd *", "obfd")],
> 
> Can you name the parameter core_bfd maybe?  Just a bit more precise.
> 

That was my first try, but unfortunately core_bfd seems to be a macro, and it doesn't
play well in this context. Maybe a longer name that dodges the core_bfd macro?

/* Binary File Diddler for the core file.  */

#define core_bfd (current_program_space->cbfd.get ())

> Otherwise:
> 
> Approved-By: Simon Marchi <simon.marchi@efficios.com>
> 
> Simon


  reply	other threads:[~2023-09-20  5:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 21:26 [PATCH v7 00/18] SME support for AArch64 gdb/gdbserver on Linux Luis Machado
2023-09-18 21:26 ` [PATCH v7 01/18] [gdb/aarch64] Fix register fetch/store order for native AArch64 Linux Luis Machado
2023-09-18 21:26 ` [PATCH v7 02/18] [gdb/aarch64] refactor: Rename SVE-specific files Luis Machado
2023-09-18 21:26 ` [PATCH v7 03/18] [gdb/gdbserver] refactor: Simplify SVE interface to read/write registers Luis Machado
2023-09-18 21:26 ` [PATCH v7 04/18] [gdb/aarch64] sve: Fix return command when using V registers in a SVE-enabled target Luis Machado
2023-09-18 21:26 ` [PATCH v7 05/18] [gdb/aarch64] sme: Enable SME registers and pseudo-registers Luis Machado
2023-10-13 13:06   ` Tom Tromey
2023-10-13 14:44     ` Luis Machado
2023-10-13 14:50       ` Luis Machado
2023-09-18 21:26 ` [PATCH v7 06/18] [gdbserver/generic] Convert tdesc's expedite_regs to a string vector Luis Machado
2023-09-18 21:26 ` [PATCH v7 07/18] [gdbserver/aarch64] refactor: Adjust expedited registers dynamically Luis Machado
2023-09-18 21:26 ` [PATCH v7 08/18] [gdbserver/aarch64] sme: Add support for SME Luis Machado
2023-09-18 21:26 ` [PATCH v7 09/18] [gdb/aarch64] sve: Fix signal frame z/v register restore Luis Machado
2023-09-18 21:26 ` [PATCH v7 10/18] [gdb/aarch64] sme: Signal frame support Luis Machado
2023-09-18 21:26 ` [PATCH v7 11/18] [gdb/aarch64] sme: Fixup sigframe gdbarch when vg/svg changes Luis Machado
2023-09-18 21:26 ` [PATCH v7 12/18] [gdb/aarch64] sme: Support TPIDR2 signal frame context Luis Machado
2023-09-18 21:26 ` [PATCH v7 13/18] [gdb/generic] Get rid of linux-core-thread-data Luis Machado
2023-09-18 21:26 ` [PATCH v7 14/18] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Luis Machado
2023-09-18 21:26 ` [PATCH v7 15/18] [gdb/generic] corefile/bug: Add hook to control the use of target description notes from corefiles Luis Machado
2023-09-19 20:49   ` Simon Marchi
2023-09-20  5:49     ` Luis Machado [this message]
2023-09-20 14:01       ` Luis Machado
2023-09-20 14:22   ` Andrew Burgess
2023-09-20 15:26     ` Andrew Burgess
2023-09-20 23:35       ` Luis Machado
2023-09-21 10:02         ` Andrew Burgess
2023-09-21 10:44           ` Luis Machado
2023-09-25  9:57             ` Andrew Burgess
2023-09-26 12:39               ` Luis Machado
2023-09-27 17:56                 ` Andrew Burgess
2023-09-28  8:23                   ` Luis Machado
2023-10-03 17:23                     ` Andrew Burgess
2023-10-04 15:27                       ` Luis Machado
2023-09-25 15:41             ` Simon Marchi
2023-09-27 17:44               ` Andrew Burgess
2023-09-18 21:26 ` [PATCH v7 16/18] [gdb/aarch64] sme: Core file support for Linux Luis Machado
2023-09-18 21:26 ` [PATCH v7 17/18] [gdb/testsuite] sme: Add SVE/SME testcases Luis Machado
2023-09-19 19:12   ` Simon Marchi
2023-09-19 20:02     ` Luis Machado
2023-09-18 21:26 ` [PATCH v7 18/18] [gdb/docs] sme: Document SME registers and features Luis Machado
2023-10-04 15:27 ` [PATCH v7 00/18] SME support for AArch64 gdb/gdbserver on Linux Luis Machado

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=f45c544f-d983-b66a-de05-d095b1604428@arm.com \
    --to=luis.machado@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=thiago.bauermann@linaro.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).