[PATCH v2 10/13] btrace: use the new cpu identifier

Markus Metzger
2014-11-20T10:47:38Z

The preceding patch added a cpu identifier. Use it.

2014-11-20 Markus Metzger <markus.t.metzger@intel.com>

* nat/linux-btrace.c: Remove include x86-cpuid.h.
(intel_supports_bts): Update parameters.
(cpu_supports_bts): Call btrace_this_cpu.
---
gdb/nat/linux-btrace.c | 36 +++++++++++++-----------------------
1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 66f37ea..6948522 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -23,7 +23,6 @@
#include "linux-btrace.h"
#include "common-regcache.h"
#include "gdb_wait.h"
-#include "x86-cpuid.h"

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
@@ -302,22 +301,12 @@ kernel_supports_bts (void)
/* Check whether an Intel cpu supports BTS. */

static int
-intel_supports_bts (void)
+intel_supports_bts (const struct btrace_cpu *cpu)
{
- unsigned int cpuid, model, family;
-
- if (!x86_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:
@@ -345,17 +334,18 @@ intel_supports_bts (void)
static int
cpu_supports_bts (void)
{
- unsigned int ebx, ecx, edx;
+ struct btrace_cpu cpu;

- if (!x86_cpuid (0, NULL, &ebx, &ecx, &edx))
- return 0;
-
- if (ebx == signature_INTEL_ebx && ecx == signature_INTEL_ecx
- && edx == signature_INTEL_edx)
- return intel_supports_bts ();
+ cpu = btrace_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_bts (&cpu);
+ }
}

/* Check whether the linux target supports BTS. */
--
1.8.3.1