From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24725 invoked by alias); 14 Aug 2012 13:27:43 -0000 Received: (qmail 24713 invoked by uid 22791); 14 Aug 2012 13:27:41 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Aug 2012 13:27:19 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id q7EDR9kq004727; Tue, 14 Aug 2012 15:27:09 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id q7EDR7TC017727; Tue, 14 Aug 2012 15:27:07 +0200 (CEST) Date: Tue, 14 Aug 2012 13:27:00 -0000 Message-Id: <201208141327.q7EDR7TC017727@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: markus.t.metzger@intel.com CC: gdb-patches@sourceware.org, markus.t.metzger@gmail.com, jan.kratochvil@redhat.com, palves@redhat.com, tromey@redhat.com, markus.t.metzger@intel.com In-reply-to: <1344949171-9545-17-git-send-email-markus.t.metzger@intel.com> Subject: Re: [patch v3 16/16] btrace, x86: restrict to Atom References: <1344949171-9545-1-git-send-email-markus.t.metzger@intel.com> <1344949171-9545-17-git-send-email-markus.t.metzger@intel.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00403.txt.bz2 > From: markus.t.metzger@intel.com > Date: Tue, 14 Aug 2012 14:59:31 +0200 > > From: Markus Metzger > > Restrict branch tracing support to Atom processors. Did you explain anywhere why this is restricted to Atom? Even with such an explanation, the approach taken here is wrong: > diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c > index 8475d7a..b0f7b43 100644 > --- a/gdb/i386-linux-tdep.c > +++ b/gdb/i386-linux-tdep.c > @@ -37,6 +37,7 @@ > #include "symtab.h" > #include "arch-utils.h" > #include "xml-syscall.h" > +#include "linux-btrace.h" > > #include "i387-tdep.h" > #include "i386-xstate.h" > @@ -704,6 +705,39 @@ i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, > return closure; > } > > +/* See i386-linux-tdep.h. */ > +int > +i386_linux_supports_btrace (void) > +{ > + unsigned int cpuid, model, family; > + > + if (!linux_supports_btrace ()) > + return 0; > + > + __asm__ __volatile__ ("movl $1, %%eax;" > + "cpuid;" > + : "=a" (cpuid) > + :: "%ebx", "%ecx", "%edx"); > + > + family = (cpuid >> 8) & 0xf; > + model = (cpuid >> 4) & 0xf; > + > + switch (family) > + { > + case 6: > + model += (cpuid >> 12) & 0xf0; > + > + switch (model) > + { > + case 28: /* Atom. */ > + case 38: > + return 1; > + } > + } > + > + return 0; > +} You can't have this function in a -tdep.c, since this file needs to be compilable everywhere (not just on i386/amd64). But even in a -nat.c file you shouldn't use inline assembly, since it isn't a standardized C feature. I can only guess why you want to restrict this feature to Atom only, but I suspect that the proper solution is to query the target whether branch tracing is supported. That means the -nat.c code should have code to query for support in the Linux kernel.