Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org
Subject: [PATCH 2/2] btrace: use i386-cpuid's cpu identifier
Date: Thu, 13 Feb 2014 12:30:00 -0000	[thread overview]
Message-ID: <1392294615-16416-2-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1392294615-16416-1-git-send-email-markus.t.metzger@intel.com>

2014-02-13  Markus Metzger  <markus.t.metzger@intel.com>

	* common/linux-btrace.c (intel_supports_btrace): Update parameters.
	(cpu_supports_btrace): Call i386_this_cpu.


---
 gdb/common/linux-btrace.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c
index 218e0ce..46b28bd 100644
--- a/gdb/common/linux-btrace.c
+++ b/gdb/common/linux-btrace.c
@@ -348,22 +348,12 @@ kernel_supports_btrace (void)
 /* Check whether an Intel cpu supports branch tracing.  */
 
 static int
-intel_supports_btrace (void)
+intel_supports_btrace (const struct i386_cpu *cpu)
 {
-  unsigned int cpuid, model, family;
-
-  if (!i386_cpuid (1, &cpuid, NULL, NULL, NULL))
-    return 0;
-
-  family = (cpuid >> 8) & 0xf;
-  model = (cpuid >> 4) & 0xf;
-
-  switch (family)
+  switch (cpu->family)
     {
     case 0x6:
-      model += (cpuid >> 12) & 0xf0;
-
-      switch (model)
+      switch (cpu->model)
 	{
 	case 0x1a: /* Nehalem */
 	case 0x1f:
@@ -391,17 +381,18 @@ intel_supports_btrace (void)
 static int
 cpu_supports_btrace (void)
 {
-  unsigned int ebx, ecx, edx;
+  struct i386_cpu cpu;
 
-  if (!i386_cpuid (0, NULL, &ebx, &ecx, &edx))
-    return 0;
-
-  if (ebx == signature_INTEL_ebx && ecx == signature_INTEL_ecx
-      && edx == signature_INTEL_edx)
-    return intel_supports_btrace ();
+  cpu = i386_this_cpu ();
+  switch (cpu.vendor)
+    {
+    default:
+      /* Don't know about others.  Let's assume they do.  */
+      return 1;
 
-  /* Don't know about others.  Let's assume they do.  */
-  return 1;
+    case CV_INTEL:
+      return intel_supports_btrace (&cpu);
+    }
 }
 
 /* See linux-btrace.h.  */
-- 
1.8.3.1


  reply	other threads:[~2014-02-13 12:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 12:30 [PATCH 1/2] i386-cpuid: add support for identifying a processor Markus Metzger
2014-02-13 12:30 ` Markus Metzger [this message]
2014-02-13 13:29 ` Mark Kettenis
2014-02-13 13:34   ` Metzger, Markus T
2014-02-13 18:32     ` Pedro Alves
2014-02-14  8:30       ` Metzger, Markus T
2014-02-14 17:29 ` Mike Frysinger
2014-02-17  8:04   ` Metzger, Markus T

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=1392294615-16416-2-git-send-email-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /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