Re: PATCH: Enable x86 XML target descriptions

H.J. Lu
2010-02-22T15:39:53Z

On Mon, Feb 22, 2010 at 7:29 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Mon, Feb 22, 2010 at 07:27:30AM -0800, H.J. Lu wrote:
>> It works fine. amd64_linux_read_description is called via
>
> Does it work fine for the right reason?  gdbarch has not been set yet.
> How can the gdbarch know if the PID is a 32-bit or 64-bit process?
>

From

(gdb) att 20196
Attaching to process 20196
Reading symbols from /export/home/hjl/bugs/gdb/xml/p...done.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Detaching after fork from child process 20207.

Breakpoint 3, amd64_linux_read_description (ops=0xa94900)
at /export/gnu/import/git/gdb-avx/gdb/amd64-linux-nat.c:681
681 {
Missing separate debuginfos, use: debuginfo-install
expat-2.0.1-8.fc12.x86_64 ncurses-libs-5.7-3.20090207.fc12.x86_64
python-2.6.2-2.fc12.x86_64 python-libs-2.6.2-2.fc12.x86_64
zlib-1.2.3-23.fc12.x86_64
(top-gdb) p target_gdbarch
$1 = (struct gdbarch *) 0xbb3660
(top-gdb) p *target_gdbarch
$2 = {initialized_p = 1, obstack = 0xbb35f0, bfd_arch_info = 0x7bd0a0,
byte_order = 1, byte_order_for_code = 1, osabi = GDB_OSABI_LINUX,
target_desc = 0x0, tdep = 0xbb3500, dump_tdep = 0, nr_data = 18,
data = 0xbb3a30, swap = 0x0, bits_big_endian = 0, short_bit = 16,
int_bit = 32, long_bit = 32, long_long_bit = 64, float_bit = 32,
float_format = 0xa4e6e0, double_bit = 64, double_format = 0xa4e6f0,
long_double_bit = 96, long_double_format = 0xa4e710, ptr_bit = 32,
addr_bit = 32, char_signed = 1, read_pc = 0,
write_pc = 0x4758b0 <i386_linux_write_pc>,
virtual_frame_pointer = 0x5418a0 <legacy_virtual_frame_pointer>,
pseudo_register_read = 0x46c1d0 <i386_pseudo_register_read>,
pseudo_register_write = 0x46c110 <i386_pseudo_register_write>,
num_regs = 42, num_pseudo_regs = 8, sp_regnum = 4, pc_regnum = 8,
ps_regnum = 9, fp0_regnum = 16,
stab_reg_to_regnum = 0x46aef0 <i386_svr4_reg_to_regnum>,
ecoff_reg_to_regnum = 0x540a60 <no_op_reg_to_regnum>,
sdb_reg_to_regnum = 0x46ae40 <i386_dbx_reg_to_regnum>,
dwarf2_reg_to_regnum = 0x46aef0 <i386_svr4_reg_to_regnum>,
register_name = 0x5c46f0 <tdesc_register_name>,
register_type = 0x5c4df0 <tdesc_register_type>,
dummy_id = 0x46b810 <i386_dummy_id>, deprecated_fp_regnum = -1,
push_dummy_call = 0x46c6f0 <i386_push_dummy_call>, call_dummy_location = 4,
push_dummy_code = 0,
---Type <return> to continue, or q <return> to quit---q
print_registers_info = 0x51dcb0 <default_print_registers_Quit
(top-gdb) p *target_gdbarch->bfd_arch_info
$3 = {bits_per_word = 32, bits_per_address = 32, bits_per_byte = 8,
arch = bfd_arch_i386, mach = 1, arch_name = 0x7b3bb2 "i386",
printable_name = 0x7b3bb2 "i386", section_align_power = 3, the_default = 1,
compatible = 0x609fa0 <bfd_default_compatible>,
scan = 0x60a110 <bfd_default_scan>, next = 0x7bd100}
(top-gdb)

Gdb will load executable before calling amd64_linux_read_description
At this point, target_gdbarch is set and knows inferior is 32bit or not.

--
H.J.