]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: move xcr0 == 0 check into i386_linux_core_read_description
authorAndrew Burgess <aburgess@redhat.com>
Wed, 27 Mar 2024 14:30:48 +0000 (14:30 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 14 Jun 2024 08:08:45 +0000 (09:08 +0100)
Currently, in i386_linux_core_read_description, if GDB fails to
extract an xcr0 value from the core file, then we will have a default
zero value for the xcr0 variable, we still call the
i386_linux_read_description function, which checks for this zero value
and returns nullptr.

Back in i386_linux_core_read_description we spot the nullptr return
value from i386_linux_read_description and call
i386_linux_read_description again, but this time passing a default
value for xcr0.

In the next commit I plan to rework i386_linux_read_description, and
in so doing I will remove the check for xcr0 == 0, this is inline with
how the amd64 code is written.

However, this means that the 'xcr0 == 0' check needs to move up the
stack to i386_linux_core_read_description, again, this brings the i386
code into line with the amd64 code.

This is just a refactor in preparation for the next commit, there
should be no user visible changes after this commit.

Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
Approved-By: John Baldwin <jhb@FreeBSD.org>
gdb/i386-linux-tdep.c

index a78f03fac8d11b838cdd13447abc7cd7e61ca3c4..511e43f3b6f765d3675f46763c183f3bbb4f5bb4 100644 (file)
@@ -714,15 +714,16 @@ i386_linux_core_read_description (struct gdbarch *gdbarch,
   /* Linux/i386.  */
   x86_xsave_layout layout;
   uint64_t xcr0 = i386_linux_core_read_xsave_info (abfd, layout);
-  const struct target_desc *tdesc = i386_linux_read_description (xcr0);
 
-  if (tdesc != NULL)
-    return tdesc;
+  if (xcr0 == 0)
+    {
+      if (bfd_get_section_by_name (abfd, ".reg-xfp") != nullptr)
+       xcr0 = X86_XSTATE_SSE_MASK;
+      else
+       xcr0 = X86_XSTATE_X87_MASK;
+    }
 
-  if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL)
-    return i386_linux_read_description (X86_XSTATE_SSE_MASK);
-  else
-    return i386_linux_read_description (X86_XSTATE_X87_MASK);
+  return i386_linux_read_description (xcr0);
 }
 
 /* Similar to i386_supply_fpregset, but use XSAVE extended state.  */