[1/2] gdb: add maintenance set/show gcore xml-target-description command
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
From: Felix Willgerodt <felix.willgerodt@intel.com>
This command will allow to enable/disable creating the NT_GDB_TDESC note
in corefiles. While GDB writes and reads this node, there aren't really many
other pieces of software that create this node (e.g. the Linux kernel doesn't).
To be able to test the code path in GDB that is used when NT_GDB_TDESC is not
there, add a maintenance command which tests can use to test both cases.
Co-authored-by: Christina Schimpe <christina.schimpe@intel.com>
---
gdb/NEWS | 6 ++++++
gdb/doc/gdb.texinfo | 7 +++++++
gdb/elf-none-tdep.c | 16 +++++++++-------
gdb/fbsd-tdep.c | 15 +++++++++------
gdb/gcore.c | 40 ++++++++++++++++++++++++++++++++++++++++
gdb/gcore.h | 3 +++
gdb/linux-tdep.c | 15 +++++++++------
7 files changed, 83 insertions(+), 19 deletions(-)
Comments
> From: Christina Schimpe <christina.schimpe@intel.com>
> Cc: hjl.tools@gmail.com,
> keiths@redhat.com
> Date: Tue, 2 Jun 2026 11:11:21 +0000
>
> From: Felix Willgerodt <felix.willgerodt@intel.com>
>
> This command will allow to enable/disable creating the NT_GDB_TDESC note
> in corefiles. While GDB writes and reads this node, there aren't really many
> other pieces of software that create this node (e.g. the Linux kernel doesn't).
> To be able to test the code path in GDB that is used when NT_GDB_TDESC is not
> there, add a maintenance command which tests can use to test both cases.
>
> Co-authored-by: Christina Schimpe <christina.schimpe@intel.com>
> ---
> gdb/NEWS | 6 ++++++
> gdb/doc/gdb.texinfo | 7 +++++++
> gdb/elf-none-tdep.c | 16 +++++++++-------
> gdb/fbsd-tdep.c | 15 +++++++++------
> gdb/gcore.c | 40 ++++++++++++++++++++++++++++++++++++++++
> gdb/gcore.h | 3 +++
> gdb/linux-tdep.c | 15 +++++++++------
> 7 files changed, 83 insertions(+), 19 deletions(-)
Thanks.
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 7c8cf9af4c2..eef1924c9f0 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -97,6 +97,12 @@ AArch64 MinGW aarch64-*-mingw*
>
> * New commands
>
> +maintenance set/show gcore xml-target-description
> + With this command you can control whether or not the generate-core-file
> + command emits the NT_GDB_TDESC note. This is mainly useful for testing
> + how GDB handles corefiles without this note, as not all software that
> + creates corefiles generates it.
> +
If this command controls the emission of NT_GDB_TDESC note, then why
its name mentions a more general XML target description? Am I right
in assuming that NT_GDB_TDESC is just part of the target description?
If so, perhaps the xml-target-description part should be renamed, or
maybe the NEWS text should be modified to say that the entire target
description is emitted as XML?
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -42077,6 +42077,13 @@ buffer.
> Control whether @value{GDBN} will skip PAD packets when computing the
> packet history.
>
> +@kindex maint set gcore xml-target-description
> +@item maint set gcore xml-target-description
> +@kindex maint show gcore xml-target-description
> +@item maint show gcore xml-target-description
> +Control whether @value{GDBN} will create the NT_GDB_TDESC note when using
> +the @samp{generate-core-file} command.
NT_GDB_TDESC should be in @code or @samp.
> + add_setshow_boolean_cmd ("xml-target-description", class_obscure,
> + &maint_gcore_emit_xml_tdesc, _("\
> +Set whether gcore emits a xml-target-description."), _("\
> +Show whether gore emits a xml-target-description."), _("\
> +By default, gcore emits the note NT_GDB_TDESC.\n\
> +Disabling this setting will cause gcore to no longer emit this note."),
This doc string has the same issue: it say GDB will emit the XML
target description, but then goes on to say that NT_GDB_TDESC note is
emitted.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Hi Eli,
Thank you for the quick review.
> -----Original Message-----
> From: Eli Zaretskii <eliz@gnu.org>
> Sent: Dienstag, 2. Juni 2026 14:22
> To: Schimpe, Christina <christina.schimpe@intel.com>
> Cc: gdb-patches@sourceware.org; hjl.tools@gmail.com; keiths@redhat.com
> Subject: Re: [PATCH 1/2] gdb: add maintenance set/show gcore xml-target-
> description command
>
> > From: Christina Schimpe <christina.schimpe@intel.com>
> > Cc: hjl.tools@gmail.com,
> > keiths@redhat.com
> > Date: Tue, 2 Jun 2026 11:11:21 +0000
> >
> > From: Felix Willgerodt <felix.willgerodt@intel.com>
> >
> > This command will allow to enable/disable creating the NT_GDB_TDESC
> > note in corefiles. While GDB writes and reads this node, there aren't
> > really many other pieces of software that create this node (e.g. the Linux
> kernel doesn't).
> > To be able to test the code path in GDB that is used when NT_GDB_TDESC
> > is not there, add a maintenance command which tests can use to test both
> cases.
> >
> > Co-authored-by: Christina Schimpe <christina.schimpe@intel.com>
> > ---
> > gdb/NEWS | 6 ++++++
> > gdb/doc/gdb.texinfo | 7 +++++++
> > gdb/elf-none-tdep.c | 16 +++++++++-------
> > gdb/fbsd-tdep.c | 15 +++++++++------
> > gdb/gcore.c | 40 ++++++++++++++++++++++++++++++++++++++++
> > gdb/gcore.h | 3 +++
> > gdb/linux-tdep.c | 15 +++++++++------
> > 7 files changed, 83 insertions(+), 19 deletions(-)
>
> Thanks.
>
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index 7c8cf9af4c2..eef1924c9f0 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -97,6 +97,12 @@ AArch64 MinGW aarch64-*-mingw*
> >
> > * New commands
> >
> > +maintenance set/show gcore xml-target-description
> > + With this command you can control whether or not the
> > +generate-core-file
> > + command emits the NT_GDB_TDESC note. This is mainly useful for
> > +testing
> > + how GDB handles corefiles without this note, as not all software
> > +that
> > + creates corefiles generates it.
> > +
>
> If this command controls the emission of NT_GDB_TDESC note, then why its
> name mentions a more general XML target description? Am I right in
> assuming that NT_GDB_TDESC is just part of the target description?
> If so, perhaps the xml-target-description part should be renamed, or maybe
> the NEWS text should be modified to say that the entire target description is
> emitted as XML?
You're right. I should have been more specific.
With the NT_GDB_TDESC note the core file contains a copy of GDB's target
description XML. Without this note the corefile does not contain the target
description (see commit "gdb: write target description into core file").
Should we better write:
"With this command you can control whether or not the generate-core-file command
emits the NT_GDB_TDESC note including a copy of GDB's target description XML."
Note that I could alternatively also generate a linux core file to test a corefile without
this note. Then this patch is not necessary. But since it's already implemented like
that, I wanted to get some feedback if this simplified alternative is acceptable, too.
I'm adding Andrew in cc here since he is the author of the patch
"gdb: write target description into core file" and might have some feedback on this.
>
> > --- a/gdb/doc/gdb.texinfo
> > +++ b/gdb/doc/gdb.texinfo
> > @@ -42077,6 +42077,13 @@ buffer.
> > Control whether @value{GDBN} will skip PAD packets when computing the
> > packet history.
> >
> > +@kindex maint set gcore xml-target-description @item maint set gcore
> > +xml-target-description @kindex maint show gcore
> > +xml-target-description @item maint show gcore xml-target-description
> > +Control whether @value{GDBN} will create the NT_GDB_TDESC note when
> > +using the @samp{generate-core-file} command.
>
> NT_GDB_TDESC should be in @code or @samp.
Thanks, will fix.
>
> > + add_setshow_boolean_cmd ("xml-target-description", class_obscure,
> > + &maint_gcore_emit_xml_tdesc, _("\ Set whether
> gcore emits a
> > +xml-target-description."), _("\ Show whether gore emits a
> > +xml-target-description."), _("\ By default, gcore emits the note
> > +NT_GDB_TDESC.\n\ Disabling this setting will cause gcore to no longer
> > +emit this note."),
>
> This doc string has the same issue: it say GDB will emit the XML target
> description, but then goes on to say that NT_GDB_TDESC note is emitted.
Is it better as follows:
"... gcore emits the NT_GDB_TDESC note including GDB's target description XML"
> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Christina
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
> From: "Schimpe, Christina" <christina.schimpe@intel.com>
> CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
> "hjl.tools@gmail.com" <hjl.tools@gmail.com>, "keiths@redhat.com"
> <keiths@redhat.com>, Andrew Burgess <aburgess@redhat.com>
> Date: Tue, 9 Jun 2026 21:02:12 +0000
>
> > If this command controls the emission of NT_GDB_TDESC note, then why its
> > name mentions a more general XML target description? Am I right in
> > assuming that NT_GDB_TDESC is just part of the target description?
> > If so, perhaps the xml-target-description part should be renamed, or maybe
> > the NEWS text should be modified to say that the entire target description is
> > emitted as XML?
>
> You're right. I should have been more specific.
> With the NT_GDB_TDESC note the core file contains a copy of GDB's target
> description XML. Without this note the corefile does not contain the target
> description (see commit "gdb: write target description into core file").
>
> Should we better write:
>
> "With this command you can control whether or not the generate-core-file command
> emits the NT_GDB_TDESC note including a copy of GDB's target description XML."
Yes, this would be much more clear.
> > > + add_setshow_boolean_cmd ("xml-target-description", class_obscure,
> > > + &maint_gcore_emit_xml_tdesc, _("\ Set whether
> > gcore emits a
> > > +xml-target-description."), _("\ Show whether gore emits a
> > > +xml-target-description."), _("\ By default, gcore emits the note
> > > +NT_GDB_TDESC.\n\ Disabling this setting will cause gcore to no longer
> > > +emit this note."),
> >
> > This doc string has the same issue: it say GDB will emit the XML target
> > description, but then goes on to say that NT_GDB_TDESC note is emitted.
>
> Is it better as follows:
> "... gcore emits the NT_GDB_TDESC note including GDB's target description XML"
Yes, thanks.
> -----Original Message-----
> From: Eli Zaretskii <eliz@gnu.org>
> Sent: Mittwoch, 10. Juni 2026 13:43
> To: Schimpe, Christina <christina.schimpe@intel.com>
> Cc: gdb-patches@sourceware.org; hjl.tools@gmail.com; keiths@redhat.com;
> aburgess@redhat.com
> Subject: Re: [PATCH 1/2] gdb: add maintenance set/show gcore xml-target-
> description command
>
> > From: "Schimpe, Christina" <christina.schimpe@intel.com>
> > CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
> > "hjl.tools@gmail.com" <hjl.tools@gmail.com>, "keiths@redhat.com"
> > <keiths@redhat.com>, Andrew Burgess <aburgess@redhat.com>
> > Date: Tue, 9 Jun 2026 21:02:12 +0000
> >
> > > If this command controls the emission of NT_GDB_TDESC note, then why
> > > its name mentions a more general XML target description? Am I right
> > > in assuming that NT_GDB_TDESC is just part of the target description?
> > > If so, perhaps the xml-target-description part should be renamed, or
> > > maybe the NEWS text should be modified to say that the entire target
> > > description is emitted as XML?
> >
> > You're right. I should have been more specific.
> > With the NT_GDB_TDESC note the core file contains a copy of GDB's
> > target description XML. Without this note the corefile does not
> > contain the target description (see commit "gdb: write target description
> into core file").
> >
> > Should we better write:
> >
> > "With this command you can control whether or not the
> > generate-core-file command emits the NT_GDB_TDESC note including a
> copy of GDB's target description XML."
>
> Yes, this would be much more clear.
>
> > > > + add_setshow_boolean_cmd ("xml-target-description", class_obscure,
> > > > + &maint_gcore_emit_xml_tdesc, _("\ Set whether
> > > gcore emits a
> > > > +xml-target-description."), _("\ Show whether gore emits a
> > > > +xml-target-description."), _("\ By default, gcore emits the note
> > > > +NT_GDB_TDESC.\n\ Disabling this setting will cause gcore to no
> > > > +longer emit this note."),
> > >
> > > This doc string has the same issue: it say GDB will emit the XML
> > > target description, but then goes on to say that NT_GDB_TDESC note is
> emitted.
> >
> > Is it better as follows:
> > "... gcore emits the NT_GDB_TDESC note including GDB's target description
> XML"
>
> Yes, thanks.
Thanks for the quick feedback.
I'll wait a couple of days, if someone has further comments, then I'll post the v2
with your comments fixed.
Christina
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
@@ -97,6 +97,12 @@ AArch64 MinGW aarch64-*-mingw*
* New commands
+maintenance set/show gcore xml-target-description
+ With this command you can control whether or not the generate-core-file
+ command emits the NT_GDB_TDESC note. This is mainly useful for testing
+ how GDB handles corefiles without this note, as not all software that
+ creates corefiles generates it.
+
set local-environment
show local-environment
unset local-environment
@@ -42077,6 +42077,13 @@ buffer.
Control whether @value{GDBN} will skip PAD packets when computing the
packet history.
+@kindex maint set gcore xml-target-description
+@item maint set gcore xml-target-description
+@kindex maint show gcore xml-target-description
+@item maint show gcore xml-target-description
+Control whether @value{GDBN} will create the NT_GDB_TDESC note when using
+the @samp{generate-core-file} command.
+
@kindex maint info jit
@item maint info jit
Print information about JIT code objects loaded in the current inferior.
@@ -109,13 +109,15 @@ elf_none_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
¬e_data, note_size);
}
-
- /* Include the target description when possible. Some architectures
- allow for per-thread gdbarch so we should really be emitting a tdesc
- per-thread, however, we don't currently support reading in a
- per-thread tdesc, so just emit the tdesc for the signalled thread. */
- gdbarch = target_thread_architecture (signalled_thr->ptid);
- gcore_elf_make_tdesc_note (gdbarch, obfd, ¬e_data, note_size);
+ if (maint_gcore_emit_xml_tdesc)
+ {
+ /* Include the target description when possible. Some architectures
+ allow for per-thread gdbarch so we should really be emitting a tdesc
+ per-thread, however, we don't currently support reading in a
+ per-thread tdesc, so just emit the tdesc for the signalled thread. */
+ gdbarch = target_thread_architecture (signalled_thr->ptid);
+ gcore_elf_make_tdesc_note (gdbarch, obfd, ¬e_data, note_size);
+ }
return note_data;
}
@@ -762,12 +762,15 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
return NULL;
}
- /* Include the target description when possible. Some architectures
- allow for per-thread gdbarch so we should really be emitting a tdesc
- per-thread, however, we don't currently support reading in a
- per-thread tdesc, so just emit the tdesc for the signalled thread. */
- gdbarch = target_thread_architecture (signalled_thr->ptid);
- gcore_elf_make_tdesc_note (gdbarch, obfd, ¬e_data, note_size);
+ if (maint_gcore_emit_xml_tdesc)
+ {
+ /* Include the target description when possible. Some architectures
+ allow for per-thread gdbarch so we should really be emitting a tdesc
+ per-thread, however, we don't currently support reading in a
+ per-thread tdesc, so just emit the tdesc for the signalled thread. */
+ gdbarch = target_thread_architecture (signalled_thr->ptid);
+ gcore_elf_make_tdesc_note (gdbarch, obfd, ¬e_data, note_size);
+ }
return note_data;
}
@@ -28,6 +28,7 @@
#include "completer.h"
#include "gcore.h"
#include "cli/cli-decode.h"
+#include "cli/cli-cmds.h"
#include <fcntl.h>
#include "regcache.h"
#include "regset.h"
@@ -919,6 +920,24 @@ gcore_find_signalled_thread ()
return nullptr;
}
+/* When true, emit NT_GDB_TDESC. */
+bool maint_gcore_emit_xml_tdesc = true;
+
+/* Command lists for gcore maintenance commands. */
+struct cmd_list_element *maint_gcore_cmdlist;
+struct cmd_list_element *maint_gcore_set_cmdlist;
+struct cmd_list_element *maint_gcore_show_cmdlist;
+
+/* "Show" callback for "maint set gcore xml-target-description". */
+static void
+show_gcore_xml_target_description (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ gdb_printf (file, _("Write NT_GDB_TDESC note into corefiles: %s.\n"),
+ value);
+}
+
INIT_GDB_FILE (gcore)
{
cmd_list_element *generate_core_file_cmd
@@ -928,4 +947,25 @@ Usage: generate-core-file [FILENAME]\n\
Argument is optional filename. Default filename is 'core.PROCESS_ID'."));
add_com_alias ("gcore", generate_core_file_cmd, class_files, 1);
+
+ add_basic_prefix_cmd ("gcore", class_maintenance,
+ _("gcore maintenance commands."),
+ &maint_gcore_cmdlist, 0, &maintenancelist);
+
+ add_setshow_prefix_cmd ("gcore", class_maintenance,
+ _("Set gcore specific variables."),
+ _("Show gcore specific variables."),
+ &maint_gcore_set_cmdlist, &maint_gcore_show_cmdlist,
+ &maintenance_set_cmdlist, &maintenance_show_cmdlist);
+
+ add_setshow_boolean_cmd ("xml-target-description", class_obscure,
+ &maint_gcore_emit_xml_tdesc, _("\
+Set whether gcore emits a xml-target-description."), _("\
+Show whether gore emits a xml-target-description."), _("\
+By default, gcore emits the note NT_GDB_TDESC.\n\
+Disabling this setting will cause gcore to no longer emit this note."),
+ nullptr,
+ show_gcore_xml_target_description,
+ &maint_gcore_set_cmdlist,
+ &maint_gcore_show_cmdlist);
}
@@ -37,4 +37,7 @@ extern bool objfile_find_memory_regions (struct target_ops *self,
extern thread_info *gcore_find_signalled_thread ();
+/* When true, emit NT_GDB_TDESC. */
+extern bool maint_gcore_emit_xml_tdesc;
+
#endif /* GDB_GCORE_H */
@@ -2495,12 +2495,15 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
/* File mappings. */
linux_make_mappings_corefile_notes (gdbarch, obfd, note_data, note_size);
- /* Include the target description when possible. Some architectures
- allow for per-thread gdbarch so we should really be emitting a tdesc
- per-thread, however, we don't currently support reading in a
- per-thread tdesc, so just emit the tdesc for the signalled thread. */
- gdbarch = target_thread_architecture (signalled_thr->ptid);
- gcore_elf_make_tdesc_note (gdbarch, obfd, ¬e_data, note_size);
+ if (maint_gcore_emit_xml_tdesc)
+ {
+ /* Include the target description when possible. Some architectures
+ allow for per-thread gdbarch so we should really be emitting a tdesc
+ per-thread, however, we don't currently support reading in a
+ per-thread tdesc, so just emit the tdesc for the signalled thread. */
+ gdbarch = target_thread_architecture (signalled_thr->ptid);
+ gcore_elf_make_tdesc_note (gdbarch, obfd, ¬e_data, note_size);
+ }
return note_data;
}