[PATCH 2/2] btrace: use i386-cpuid's cpu identifier

Markus Metzger markus.t.metzger@intel.com
Thu Feb 13 12:30:00 GMT 2014


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



More information about the Gdb-patches mailing list