From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org, binutils@sourceware.org
Subject: [PATCH 2/2] gdb, btrace: use cpuident.h to implement btrace_this_cpu
Date: Tue, 8 Nov 2022 06:45:30 +0100 [thread overview]
Message-ID: <20221108054530.796968-2-markus.t.metzger@intel.com> (raw)
In-Reply-To: <20221108054530.796968-1-markus.t.metzger@intel.com>
---
gdb/nat/linux-btrace.c | 39 ++++++++++++---------------------------
1 file changed, 12 insertions(+), 27 deletions(-)
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index a951f3b56aa..108a4a10ecb 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -23,7 +23,7 @@
#include "linux-btrace.h"
#include "gdbsupport/common-regcache.h"
#include "gdbsupport/gdb_wait.h"
-#include "x86-cpuid.h"
+#include "include/cpuident.h"
#include "gdbsupport/filestuff.h"
#include "gdbsupport/scoped_fd.h"
#include "gdbsupport/scoped_mmap.h"
@@ -65,38 +65,23 @@ static struct btrace_cpu
btrace_this_cpu (void)
{
struct btrace_cpu cpu;
- unsigned int eax, ebx, ecx, edx;
- int ok;
-
memset (&cpu, 0, sizeof (cpu));
- ok = x86_cpuid (0, &eax, &ebx, &ecx, &edx);
- if (ok != 0)
+ unsigned int vendor = cpuid_getvendor ();
+ switch (vendor)
{
- if (ebx == signature_INTEL_ebx && ecx == signature_INTEL_ecx
- && edx == signature_INTEL_edx)
- {
- unsigned int cpuid, ignore;
-
- ok = x86_cpuid (1, &cpuid, &ignore, &ignore, &ignore);
- if (ok != 0)
- {
- cpu.vendor = CV_INTEL;
-
- cpu.family = (cpuid >> 8) & 0xf;
- if (cpu.family == 0xf)
- cpu.family += (cpuid >> 20) & 0xff;
+ case X86_VENDOR_Intel:
+ cpu.vendor = CV_INTEL;
+ break;
- cpu.model = (cpuid >> 4) & 0xf;
- if ((cpu.family == 0x6) || ((cpu.family & 0xf) == 0xf))
- cpu.model += (cpuid >> 12) & 0xf0;
- }
- }
- else if (ebx == signature_AMD_ebx && ecx == signature_AMD_ecx
- && edx == signature_AMD_edx)
- cpu.vendor = CV_AMD;
+ case X86_VENDOR_AMD:
+ cpu.vendor = CV_AMD;
+ break;
}
+ cpu.family = (unsigned short) cpuid_getfamily ();
+ cpu.model = (unsigned char) cpuid_getmodel ();
+
return cpu;
}
--
2.37.3
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
prev parent reply other threads:[~2022-11-08 6:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 5:45 [PATCH 1/2] gprofng: make cpu identification available to others Markus Metzger
2022-11-08 5:45 ` Markus Metzger [this message]
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=20221108054530.796968-2-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=binutils@sourceware.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).