From: Luis Machado <luis.machado@linaro.org>
To: gdb-patches@sourceware.org
Subject: [PING][PATCH] Update the core file architecture if a target description is present
Date: Thu, 10 Jun 2021 08:48:52 -0300 [thread overview]
Message-ID: <157f5ee5-b8d9-a6bd-58cc-b7615b57cdd5@linaro.org> (raw)
In-Reply-To: <20210518202015.3492089-1-luis.machado@linaro.org>
On 5/18/21 5:20 PM, Luis Machado wrote:
> At the moment, the core target has its own gdbarch (m_core_gdbarch), and that
> gets set from the core_bfd on the core target's constructor.
>
> That gdbarch doesn't contain a target description because it is constructed
> before we get a chance to fetch the target description.
>
> As a result, some hooks that depend on the target description being set are
> not set, and that leads to problems. One of the examples is
> gdbarch_report_signal_info, which is used to show AArch64 tag violation
> information.
>
> Fix this by updating the core file gdbarch after fetching the target
> description.
>
> gdb/ChangeLog:
>
> YYYY-MM-DD Luis Machado <luis.machado@linaro.org>
>
> * corelow.c: Include "observable.h".
> (class core_target) <set_core_gdbarch>: New method.
> (core_on_new_gdbarch): New function.
> (_initialize_corelow): Register with observer "architecture_changed".
> ---
> gdb/corelow.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/gdb/corelow.c b/gdb/corelow.c
> index a1943ab2ea6..452b4dd4f9a 100644
> --- a/gdb/corelow.c
> +++ b/gdb/corelow.c
> @@ -50,6 +50,7 @@
> #include <unordered_set>
> #include "gdbcmd.h"
> #include "xml-tdesc.h"
> +#include "observable.h"
>
> #ifndef O_LARGEFILE
> #define O_LARGEFILE 0
> @@ -107,6 +108,12 @@ class core_target final : public process_stratum_target
> return m_core_gdbarch;
> }
>
> + /* Setter, see variable definition. */
> + void set_core_gdbarch (gdbarch *arch)
> + {
> + m_core_gdbarch = arch;
> + }
> +
> /* See definition. */
> void get_core_register_section (struct regcache *regcache,
> const struct regset *regset,
> @@ -1185,6 +1192,30 @@ maintenance_print_core_file_backed_mappings (const char *args, int from_tty)
> targ->info_proc_mappings (targ->core_gdbarch ());
> }
>
> +static void
> +core_on_new_gdbarch (struct gdbarch *newarch)
> +{
> + /* The target architecture has changed. Attempt to update the core
> + target's architecture with NEWARCH's target description. */
> + struct gdbarch_info info;
> +
> + gdbarch_info_init (&info);
> + info.abfd = core_bfd;
> + info.target_desc = gdbarch_target_desc (newarch);
> +
> + struct gdbarch *new_core_arch = gdbarch_find_by_info (info);
> +
> + /* If we've found a valid architecture, update the core target. */
> + if (new_core_arch != nullptr)
> + {
> + /* Update the core file architecture. */
> + struct core_target *target = get_current_core_target ();
> +
> + if (target != nullptr)
> + target->set_core_gdbarch (new_core_arch);
> + }
> +}
> +
> void _initialize_corelow ();
> void
> _initialize_corelow ()
> @@ -1194,4 +1225,8 @@ _initialize_corelow ()
> maintenance_print_core_file_backed_mappings,
> _("Print core file's file-backed mappings."),
> &maintenanceprintlist);
> +
> + /* Register observer to listen to architecture changes. */
> + gdb::observers::architecture_changed.attach (core_on_new_gdbarch,
> + "py-unwind");
> }
>
next prev parent reply other threads:[~2021-06-10 11:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 20:20 [PATCH] " Luis Machado
2021-05-27 11:32 ` [PING] " Luis Machado
2021-06-10 11:48 ` Luis Machado [this message]
2021-06-15 14:10 ` [PING][PATCH] " Luis Machado
2021-06-17 3:26 ` [PATCH] " Simon Marchi
2021-06-21 13:28 ` Luis Machado
2021-06-22 1:39 ` [PATCH, v2] " Luis Machado
2021-06-22 21:23 ` Simon Marchi
2021-06-23 1:22 ` Luis Machado
2021-06-23 2:42 ` [PATCH, v3] " Luis Machado
2021-06-23 16:37 ` Simon Marchi
2021-06-23 17:22 ` 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=157f5ee5-b8d9-a6bd-58cc-b7615b57cdd5@linaro.org \
--to=luis.machado@linaro.org \
--cc=gdb-patches@sourceware.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).