Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Luis Machado <luis.machado@arm.com>, 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: Tue, 19 Sep 2023 16:49:57 -0400	[thread overview]
Message-ID: <957943ea-a51a-4cdb-b86e-68d2fb85de9d@polymtl.ca> (raw)
In-Reply-To: <20230918212651.660141-16-luis.machado@arm.com>

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.

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

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

> +""",
> +    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.

Otherwise:

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

Simon

  reply	other threads:[~2023-09-19 20: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 via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 01/18] [gdb/aarch64] Fix register fetch/store order for native AArch64 Linux Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 02/18] [gdb/aarch64] refactor: Rename SVE-specific files Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 03/18] [gdb/gdbserver] refactor: Simplify SVE interface to read/write registers Luis Machado via Gdb-patches
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 via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 05/18] [gdb/aarch64] sme: Enable SME registers and pseudo-registers Luis Machado via Gdb-patches
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 via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 07/18] [gdbserver/aarch64] refactor: Adjust expedited registers dynamically Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 08/18] [gdbserver/aarch64] sme: Add support for SME Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 09/18] [gdb/aarch64] sve: Fix signal frame z/v register restore Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 10/18] [gdb/aarch64] sme: Signal frame support Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 11/18] [gdb/aarch64] sme: Fixup sigframe gdbarch when vg/svg changes Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 12/18] [gdb/aarch64] sme: Support TPIDR2 signal frame context Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 13/18] [gdb/generic] Get rid of linux-core-thread-data Luis Machado via Gdb-patches
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 via Gdb-patches
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 via Gdb-patches
2023-09-19 20:49   ` Simon Marchi via Gdb-patches [this message]
2023-09-20  5:49     ` Luis Machado via Gdb-patches
2023-09-20 14:01       ` Luis Machado via Gdb-patches
2023-09-20 14:22   ` Andrew Burgess via Gdb-patches
2023-09-20 15:26     ` Andrew Burgess via Gdb-patches
2023-09-20 23:35       ` Luis Machado via Gdb-patches
2023-09-21 10:02         ` Andrew Burgess via Gdb-patches
2023-09-21 10:44           ` Luis Machado via Gdb-patches
2023-09-25  9:57             ` Andrew Burgess via Gdb-patches
2023-09-26 12:39               ` Luis Machado via Gdb-patches
2023-09-27 17:56                 ` Andrew Burgess via Gdb-patches
2023-09-28  8:23                   ` Luis Machado via Gdb-patches
2023-10-03 17:23                     ` Andrew Burgess via Gdb-patches
2023-10-04 15:27                       ` Luis Machado via Gdb-patches
2023-09-25 15:41             ` Simon Marchi via Gdb-patches
2023-09-27 17:44               ` Andrew Burgess via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 16/18] [gdb/aarch64] sme: Core file support for Linux Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 17/18] [gdb/testsuite] sme: Add SVE/SME testcases Luis Machado via Gdb-patches
2023-09-19 19:12   ` Simon Marchi via Gdb-patches
2023-09-19 20:02     ` Luis Machado via Gdb-patches
2023-09-18 21:26 ` [PATCH v7 18/18] [gdb/docs] sme: Document SME registers and features Luis Machado via Gdb-patches
2023-10-04 15:27 ` [PATCH v7 00/18] SME support for AArch64 gdb/gdbserver on Linux Luis Machado 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=957943ea-a51a-4cdb-b86e-68d2fb85de9d@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=luis.machado@arm.com \
    --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