This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Wednesday, December 15, 2010 12:07:11 Mike Frysinger wrote: > On Wednesday, December 15, 2010 11:49:32 Pedro Alves wrote: > > Thanks for the explanations. This makes it so that the ASTAT.CC bit > > can easily end up out of sync with the CC register in gdb's > > regcache then, right? E.g., "p $cc = 1; p $asat" will still show the > > $asat.cc as 0, IIUC. Does the kernel actually store CC on its > > own slot in the register stack? I ask because I see it commented out > > in bfin_regmap in gdbserver. If $cc was a pseudo-register _managed_ by > > gdb (computed from ASAT), then this out-of-sync-ness would never happen. > > no, linux does not give CC dedicated space in the signal context. it does > look like setting $cc on the command line results in out-of-sync values > with $astat. i'll take a look at the pseudo helpers you referenced and > see if i cant figure out how they work. what do you think of this ? seems to work for me: (gdb) set $cc = 0 (gdb) printf "%x %x\n", $astat, $cc 2002002 0 (gdb) set $cc = 1 (gdb) printf "%x %x\n", $astat, $cc 2002022 1 (gdb) set $astat = 0 (gdb) printf "%x %x\n", $astat, $cc 0 0 (gdb) set $astat = 0x20 (gdb) printf "%x %x\n", $astat, $cc 20 1 -mike --- a/gdb/bfin-linux-tdep.c +++ b/gdb/bfin-linux-tdep.c @@ -88,7 +88,6 @@ static const int bfin_linux_sigcontext_reg_offset[BFIN_NUM_REGS] = -1, /* %retn */ -1, /* %rete */ 21 * 4, /* %pc */ - -1, /* %cc */ }; /* Signal trampolines. */ --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -116,16 +116,12 @@ /* The maximum bytes we search to skip the prologue. */ #define UPPER_LIMIT 40 -#define RETS_OFFSET 4 +/* ASTAT bits */ +#define ASTAT_CC_POS 5 +#define ASTAT_CC (1 << ASTAT_CC_POS) /* Initial value: Register names used in BFIN's ISA documentation. */ @@ -683,6 +683,36 @@ bfin_register_name (struct gdbarch *gdbarch, int i) return bfin_register_name_strings[i]; } +static void +bfin_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, + int regnum, gdb_byte *buffer) +{ + gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE); + + if (regnum != BFIN_CC_REGNUM) + internal_error (__FILE__, __LINE__, + _("invalid register number %d"), regnum); + + regcache_raw_read (regcache, BFIN_ASTAT_REGNUM, buf); + buffer[1] = buffer[2] = buffer[3] = 0; + buffer[0] = !!(buf[0] & ASTAT_CC); +} + +static void +bfin_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, + int regnum, const gdb_byte *buffer) +{ + gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE); + + if (regnum != BFIN_CC_REGNUM) + internal_error (__FILE__, __LINE__, + _("invalid register number %d"), regnum); + + regcache_raw_read (regcache, BFIN_ASTAT_REGNUM, buf); + buf[0] = (buf[0] & ~ASTAT_CC) | ((buffer[0] & 1) << ASTAT_CC_POS); + regcache_raw_write (regcache, BFIN_ASTAT_REGNUM, buf); +} + static CORE_ADDR bfin_frame_base_address (struct frame_info *this_frame, void **this_cache) { @@ -783,7 +813,9 @@ bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->bfin_abi = abi; set_gdbarch_num_regs (gdbarch, BFIN_NUM_REGS); - set_gdbarch_num_pseudo_regs (gdbarch, 0); + set_gdbarch_pseudo_register_read (gdbarch, bfin_pseudo_register_read); + set_gdbarch_pseudo_register_write (gdbarch, bfin_pseudo_register_write); + set_gdbarch_num_pseudo_regs (gdbarch, BFIN_NUM_PSEUDO_REGS); set_gdbarch_sp_regnum (gdbarch, BFIN_SP_REGNUM); set_gdbarch_pc_regnum (gdbarch, BFIN_PC_REGNUM); set_gdbarch_ps_regnum (gdbarch, BFIN_ASTAT_REGNUM); --- a/gdb/bfin-tdep.h +++ b/gdb/bfin-tdep.h @@ -74,13 +74,14 @@ enum gdb_regnum { BFIN_RETN_REGNUM, BFIN_RETE_REGNUM, - /* Pseudo Registers */ + /* Pseudo Registers managed remotely. */ BFIN_PC_REGNUM, - BFIN_CC_REGNUM, - /* LAST ENTRY SHOULD NOT BE CHANGED. */ - BFIN_NUM_REGS /* The number of all registers. */ + /* Pseudo Registers managed locally. */ + BFIN_CC_REGNUM }; +#define BFIN_NUM_REGS (BFIN_PC_REGNUM + 1) +#define BFIN_NUM_PSEUDO_REGS (1) /* The ABIs for Blackfin. */ enum bfin_abi
Attachment:
signature.asc
Description: This is a digitally signed message part.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |