gdb/gdb-rhel-10464-xsave-update-4of21.patch
2024-04-11 20:23:56 -07:00

80 lines
2.2 KiB
Diff

From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: John Baldwin <jhb@FreeBSD.org>
Date: Thu, 11 Apr 2024 14:05:43 -0700
Subject: gdb-rhel-10464-xsave-update-4of21.patch
;; Backport "nat/x86--cpuid.h: Add x86_cpuid_count wrapper around
;; __get_cpuid_count."
;; (John Baldwin, RHEL-10464)
Approved-By: Simon Marchi <simon.marchi@efficios.com>
diff --git a/gdb/nat/x86-cpuid.h b/gdb/nat/x86-cpuid.h
--- a/gdb/nat/x86-cpuid.h
+++ b/gdb/nat/x86-cpuid.h
@@ -22,6 +22,12 @@
/* Always include the header for the cpu bit defines. */
#include "x86-gcc-cpuid.h"
+#ifndef __cplusplus
+/* This header file is also used in C code for some test-cases, so define
+ nullptr in C terms to avoid a compilation error. */
+#define nullptr ((void *) 0)
+#endif
+
#if defined(__i386__) || defined(__x86_64__)
/* Return cpuid data for requested cpuid level, as found in returned
@@ -48,6 +54,30 @@ x86_cpuid (unsigned int __level,
return __get_cpuid (__level, __eax, __ebx, __ecx, __edx);
}
+/* Return cpuid data for requested cpuid level and sub-level, as found
+ in returned eax, ebx, ecx and edx registers. The function checks
+ if cpuid is supported and returns 1 for valid cpuid information or
+ 0 for unsupported cpuid level. Pointers may be non-null. */
+
+static __inline int
+x86_cpuid_count (unsigned int __level, unsigned int __sublevel,
+ unsigned int *__eax, unsigned int *__ebx,
+ unsigned int *__ecx, unsigned int *__edx)
+{
+ unsigned int __scratch;
+
+ if (__eax == nullptr)
+ __eax = &__scratch;
+ if (__ebx == nullptr)
+ __ebx = &__scratch;
+ if (__ecx == nullptr)
+ __ecx = &__scratch;
+ if (__edx == nullptr)
+ __edx = &__scratch;
+
+ return __get_cpuid_count (__level, __sublevel, __eax, __ebx, __ecx, __edx);
+}
+
#else
static __inline int
@@ -58,6 +88,20 @@ x86_cpuid (unsigned int __level,
return 0;
}
+static __inline int
+x86_cpuid_count (unsigned int __level, unsigned int __sublevel,
+ unsigned int *__eax, unsigned int *__ebx,
+ unsigned int *__ecx, unsigned int *__edx)
+{
+ return 0;
+}
+
#endif /* i386 && x86_64 */
+#ifndef __cplusplus
+/* Avoid leaking this local definition beyond the scope of this header
+ file. */
+#undef nullptr
+#endif
+
#endif /* NAT_X86_CPUID_H */