Hello,
This patch gets 32 (i386) debugging working with an x86-64-pc-linux-gnu configured GDB.
I should note that there are several ways of doing this. The attached uses the technique of modifying x86-64 linux nat/tdep files so that they can supply values to either a 32 or 64 bit formatted register cache.
I know of two problems:
- corefiles
I noticed a combination of problems: i386 linux core file support is in i386-linux-nat.c so isn't linked into x86-64; x86-64-linux-tdep does include core file support but it fails to "do the right thing" with 32 bit core files (it should either reject it, or handle it completly).
- threads
The 64 bit libthread db gets loaded, it doesn't recognize the 32 bit libthread db target. The glibc maintainers know about this problem.
BTW, it also fixes a problem with the old code, the original map table included "CS" and "SS" but x86-64-pc-linux-gnu doesn't.
Thoughts? 6.0?
Attached is an update. It now also fixes x86-64 part of the core-file problem. The x86-64 code will only load an x86-64 corefile.
I'll follow up with a separate patch that lets x86-64 GDB load i386 core files.
thoughts?
Andrew
2003-07-31 Andrew Cagney <cagney@redhat.com>
* x86-64-tdep.h (enum x86_64_regnums): Replace #define of
X86_64_RAX_REGNUM, X86_64_RDX_REGNUM, X86_64_RDI_REGNUM,
X86_64_RBP_REGNUM, X86_64_RSP_REGNUM, X86_64_RIP_REGNUM,
X86_64_EFLAGS_REGNUM, X86_64_ST0_REGNUM, X86_64_XMM0_REGNUM,
X86_64_XMM1_REGNUM.
* x86-64-linux-tdep.h (x86_64_linux_greg_offset): Declare.
(x86_64_linux_supply_gregset): Add "sizeof_gregs" param.
(x86_64_linux_fill_gregset): Add "sizeof_gregs" param.
* x86-64-linux-tdep.c: Include "gdb_assert.h" and
"i386-linux-tdep.h".
(enum user_regs): Replace user reg #defines, add USER_ORIG_RAX,
USER_FS_BASE and USER_GS_BASE.
(struct regnum_map, struct regnum_to_user): Define.
(x86_64_linux_greg_offset): New function.
(user_to_gdb_regmap): Delete.
(x86_64_linux_supply_gregset, x86_64_linux_fill_gregset): Use
x86_64_linux_greg_offset.
(x86_64_core_sniffer): New function
(x86_64_core_fns): Set the sniffer to x86_64_core_sniffer.
(fetch_core_registers): Pass "core_reg_size" to the supply
functions.
* i386-tdep.h (i386_regnums): Replace I386_EAX_REGNUM,
I386_EDX_REGNUM, I386_ESP_REGNUM, I386_EBP_REGNUM,
I386_EIP_REGNUM, I386_EFLAGS_REGNUM, I386_ST0_REGNUM.
* x86-64-linux-nat.c (GETREGS_SUPPLIES): Delete macro.
(fetch_inferior_registers): Use x86_64_linux_greg_offset.
(store_inferior_registers): Ditto.
* Makefile.in (x86-64-linux-tdep.o): Update dependencies.