This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
avr register types
- From: "Theodore A. Roth" <troth at openavr dot org>
- To: gdb at sources dot redhat dot com
- Date: Sat, 31 May 2003 19:06:39 -0700 (PDT)
- Subject: avr register types
Hi,
I'm trying to update the avr port to use the new regcache and frame
code.
I'm not sure how to handle the register_type() method.
For the avr, the first 32 registers are general purpose, unsigned
8-bit, reg 33 is the status register (also 8 bit unsigned), reg 34 is
the stack ptr (16-bit unsigned) and the last register is the PC.
The PC is 16 bit on the target, but that value is a index into what is
basically an array of 16-bit wide values. Thus allowing access of up
to 128K _bytes_ of space with a 16-bit addr, so gdb needs to use a 32
bit value to store it to get at the 17-bits to access all 128K. Icky.
So, given this in my gdbarch_init:
set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_int_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 32);
I wrote this register_type which I came up with based on looking at
the d10v code:
static struct type *
avr_register_type (struct gdbarch *gdbarch, int reg_nr)
{
if (reg_nr == AVR_PC_REGNUM)
return builtin_type_void_func_ptr;
if (reg_nr == AVR_SP_REGNUM)
return builtin_type_void_data_ptr;
else
return builtin_type_uint8;
}
Alas this doesn't seem to work correctly since I need a total of 39
bytes for storing all the registers, while I get this now:
(gdb) print *current_regcache->descr
$2 = {
gdbarch = 0x8238be0,
legacy_p = 0,
nr_raw_registers = 35,
sizeof_raw_registers = 37,
sizeof_raw_register_valid_p = 35,
nr_cooked_registers = 35,
sizeof_cooked_registers = 37,
sizeof_cooked_register_valid_p = 35,
register_offset = 0x82409d0,
sizeof_register = 0x8240940,
register_type = 0x82408b0
}
I expect sizeof_raw_registers and sizeof_cooked_registers to be 39
instead of 37. Not sure what to expect though for
sizeof_raw_register_valid_p.
Here's what my arch setup for the register stuff looks like:
set_gdbarch_num_regs (gdbarch, AVR_NUM_REGS);
set_gdbarch_num_pseudo_regs (gdbarch, 0);
set_gdbarch_sp_regnum (gdbarch, AVR_SP_REGNUM);
set_gdbarch_pc_regnum (gdbarch, AVR_PC_REGNUM);
set_gdbarch_register_name (gdbarch, avr_register_name);
set_gdbarch_register_type (gdbarch, avr_register_type);
#if 0
set_gdbarch_register_byte (gdbarch, avr_register_byte);
set_gdbarch_register_raw_size (gdbarch, avr_register_raw_size);
set_gdbarch_register_virtual_size (gdbarch, avr_register_virtual_size);
set_gdbarch_register_virtual_type (gdbarch, avr_register_virtual_type);
#endif
One other question, are the methods in the '#if 0' truely not needed
if I use the register_type method?
Thanks. I still got a lot of studying to do to figure out this new
regcache and frame stuff...
Ted Roth