This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch v3 16/16] btrace, x86: restrict to Atom
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: markus dot t dot metzger at intel dot com
- Cc: mark dot kettenis at xs4all dot nl, gdb-patches at sourceware dot org, markus dot t dot metzger at gmail dot com, jan dot kratochvil at redhat dot com, palves at redhat dot com, tromey at redhat dot com
- Date: Fri, 28 Sep 2012 04:39:39 +0200 (CEST)
- 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> <201208141327.q7EDR7TC017727@glazunov.sibelius.xs4all.nl> <A78C989F6D9628469189715575E55B2307ACF558@IRSMSX102.ger.corp.intel.com> <A78C989F6D9628469189715575E55B2307AEDD71@IRSMSX102.ger.corp.intel.com>
> From: "Metzger, Markus T" <markus.t.metzger@intel.com>
> Date: Mon, 24 Sep 2012 12:22:42 +0000
>
> Ping.
Native code can only go into -nat.c files.
But I still think putting CPU model specific checks anywhere in GDB is
wrong. If there are broken kernels out there, figure out a way to
detect them.
> > -----Original Message-----
> > From: Metzger, Markus T
> > Sent: Tuesday, August 14, 2012 3:42 PM
> > To: Mark Kettenis
> > Cc: gdb-patches@sourceware.org; markus.t.metzger@gmail.com; jan.kratochvil@redhat.com; palves@redhat.com;
> > tromey@redhat.com
> > Subject: RE: [patch v3 16/16] btrace, x86: restrict to Atom
> >
> > > -----Original Message-----
> > > From: Mark Kettenis [mailto:mark.kettenis@xs4all.nl]
> > > Sent: Tuesday, August 14, 2012 3:27 PM
> >
> > Thanks for your feedback!
> >
> >
> > > > +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");
> > > > +
> >
> > [...]
> >
> > > 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.
> >
> > I agree that it would be better to have this check done in the kernel. The problem is that such a patch will take very long before
> > it becomes available in distributions. And even then, we would need to handle kernels without the patch, so we would need
> > something
> > similar to this in gdb, as well.
> >
> > I took the cpuid bits from gdb/go32-nat.c. I have not seen any compilation guard around it.
> >
> > I thought that the i386-tdep files are meant to contain i386 specific code, that's why I put the code there. Where would be the
> > right place to put such code?
> >
> > Thanks,
> > Markus.
> Intel GmbH
> Dornacher Strasse 1
> 85622 Feldkirchen/Muenchen, Deutschland
> Sitz der Gesellschaft: Feldkirchen bei Muenchen
> Geschaeftsfuehrer: Peter Gleissner, Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
> Registergericht: Muenchen HRB 47456
> Ust.-IdNr./VAT Registration No.: DE129385895
> Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
>
>
>