]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Update the core file architecture if a target description is present
authorLuis Machado <luis.machado@linaro.org>
Mon, 17 May 2021 14:41:09 +0000 (11:41 -0300)
committerLuis Machado <luis.machado@linaro.org>
Fri, 25 Jun 2021 13:08:38 +0000 (10:08 -0300)
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 reading the target description before fetching the core file's
gdbarch.

gdb/ChangeLog:

2021-06-25  Luis Machado  <luis.machado@linaro.org>

* corelow.c (core_target::core_target) Update to read target
description.

gdb/ChangeLog
gdb/corelow.c

index 5fb76d03f8529f49a2671672220264b86905497b..820a9d36b4523fc2cd9cf90a583489ebb21745fd 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-25  Luis Machado  <luis.machado@linaro.org>
+
+       * corelow.c (core_target::core_target) Update to read target
+       description.
+
 2021-06-22  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * python/lib/gdb/__init__.py: Format.
index a1943ab2ea6dc03f576d654bbc732c9acbabff8d..b762eaa0f2f4fff55234a47be588757a7eba1522 100644 (file)
@@ -154,8 +154,23 @@ private: /* per-core data */
 
 core_target::core_target ()
 {
+  /* Find a first arch based on the BFD.  We need the initial gdbarch so
+     we can setup the hooks to find a target description.  */
   m_core_gdbarch = gdbarch_from_bfd (core_bfd);
 
+  /* If the arch is able to read a target description from the core, it
+     could yield a more specific gdbarch.  */
+  const struct target_desc *tdesc = read_description ();
+
+  if (tdesc != nullptr)
+    {
+      struct gdbarch_info info;
+      gdbarch_info_init (&info);
+      info.abfd = core_bfd;
+      info.target_desc = tdesc;
+      m_core_gdbarch = gdbarch_find_by_info (info);
+    }
+
   if (!m_core_gdbarch
       || !gdbarch_iterate_over_regset_sections_p (m_core_gdbarch))
     error (_("\"%s\": Core file format not supported"),