]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: clean up x86 cpuid implementations
authorMike Frysinger <vapier@gentoo.org>
Wed, 19 Jun 2013 22:29:36 +0000 (22:29 +0000)
committerMike Frysinger <vapier@gentoo.org>
Wed, 19 Jun 2013 22:29:36 +0000 (22:29 +0000)
commit4d157a3dbec7c227678793daba16f2972d1f85d5
treedb60be68b6c6e76ceae802ed2430cba2fd47ca09
parent1ce4db08a4b344e9c7ff5bbe2bc0361656652cb4
gdb: clean up x86 cpuid implementations

We've currently got 3 files doing open coded implementations of cpuid.
Each has its own set of workarounds and varying levels of how well
they're written and are generally hardcoded to specific cpuid functions.
If you try to build the latest gdb as a PIE on an i386 system, the build
will fail because one of them lacks PIC workarounds (wrt ebx).

Specifically, we have:
common/linux-btrace.c:
two copies of cpuid asm w/specific args, one has no workarounds
while the other implicitly does to avoid memcpy
go32-nat.c:
two copies of cpuid asm w/specific args, one has workarounds to
avoid memcpy
gdb/testsuite/gdb.arch/i386-cpuid.h:
one general cpuid asm w/many workarounds copied from older gcc

Fortunately, that last header there is pretty damn good -- it handles
lots of edge cases, the code is nice & tight (uses gcc asm operands
rather than manual movs), and is already almost a general library type
header.  It's also the basis of what is now the public cpuid.h that is
shipped with gcc-4.3+.

So what I've done is pull that test header out and into gdb/common/
(not sure if there's a better place), synced to the version found in
gcc-4.8.0, put a wrapper API around it, and then cut over all the
existing call points to this new header.

Since the func already has support for "is cpuid supported on this proc",
it makes it trivial to push the i386/x86_64 ifdefs down into this wrapper
API too.  Now it can be safely used for all targets and gcc will elide
the unused code for us.

I've verified the gdb.arch testsuite still passes, and this code compiles
for an armv7a host as well as x86_64.  The go32-nat code has been left
ifdef-ed out until someone can test & verify the new stuff works (and if
it doesn't, figure out how to make the new code work).

URL: https://bugs.gentoo.org/467806
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
gdb/ChangeLog
gdb/Makefile.in
gdb/common/i386-cpuid.h [new file with mode: 0644]
gdb/common/i386-gcc-cpuid.h [moved from gdb/testsuite/gdb.arch/i386-cpuid.h with 59% similarity]
gdb/common/linux-btrace.c
gdb/go32-nat.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/i386-avx.c
gdb/testsuite/gdb.arch/i386-avx.exp
gdb/testsuite/gdb.arch/i386-sse.c
gdb/testsuite/gdb.arch/i386-sse.exp