diff options
-rw-r--r-- | gdb/ChangeLog | 31 | ||||
-rw-r--r-- | gdb/corelow.c | 4 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 4 | ||||
-rw-r--r-- | gdb/regcache.c | 89 | ||||
-rw-r--r-- | gdb/regcache.h | 23 | ||||
-rw-r--r-- | gdb/tracepoint.c | 2 | ||||
-rw-r--r-- | gdb/trad-frame.c | 8 |
7 files changed, 109 insertions, 52 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0aeb5b7..245ace6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,36 @@ 2011-01-25 Pedro Alves <pedro@codesourcery.com> + * regcache.c (struct regcache_descr): Rename + sizeof_raw_register_valid_p field to sizeof_raw_register_status, + and sizeof_cooked_register_valid_p to + sizeof_cooked_register_status. + (init_regcache_descr): Adjust. + (struct regcache): Rename register_valid_p field to + register_status. + (regcache_xmalloc_1, regcache_xfree, regcache_save) + (do_cooked_read): Adjust. + (regcache_valid_p): Rename to ... + (regcache_register_status): ... this. Adjust. + (regcache_invalidate): Adjust. + (regcache_raw_read, regcache_cooked_read, regcache_raw_write): + Adjust. + (regcache_raw_supply): Adjust. If buf i NULL, mark the register + as unavailable, not valid. + (regcache_dump): Adjust. + * regcache.h (enum register_status): New. + (regcache_register_status): Declare. + (regcache_invalidate): Delete declaration. + * corelow.c (get_core_registers): Adjust. + * tracepoint.c (tfile_fetch_registers): Adjust. + * trad-frame.c (REG_VALUE): Rename to ... + (TF_REG_VALUE): ... this. + (REG_UNKNOWN): Rename to ... + (TF_REG_UNKNOWN): ... this. + (trad_frame_set_value, trad_frame_set_unknown): Adjust. + * mi/mi-main.c (register_changed_p): Adjust. + +2011-01-25 Pedro Alves <pedro@codesourcery.com> + * regcache.c (struct regcache_descr): Remove outdated comment. (init_regcache_descr): Remove sizeof_raw_register_valid_p overallocate hack. diff --git a/gdb/corelow.c b/gdb/corelow.c index bfa2893..f65a89c 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -615,9 +615,9 @@ get_core_registers (struct target_ops *ops, ".reg2", 2, "floating-point", 0); } - /* Supply dummy value for all registers not found in the core. */ + /* Mark all registers not found in the core as unavailable. */ for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) - if (!regcache_valid_p (regcache, i)) + if (regcache_register_status (regcache, i) == REG_UNKNOWN) regcache_raw_supply (regcache, i, NULL); } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index c6694bc..366e494 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1023,13 +1023,13 @@ register_changed_p (int regnum, struct regcache *prev_regs, gdb_byte this_buffer[MAX_REGISTER_SIZE]; /* Registers not valid in this frame return count as unchanged. */ - if (!regcache_valid_p (this_regs, regnum)) + if (regcache_register_status (this_regs, regnum) == REG_UNKNOWN) return 0; /* First time through or after gdbarch change consider all registers as changed. Same for registers not valid in the previous frame. */ if (!prev_regs || get_regcache_arch (prev_regs) != gdbarch - || !regcache_valid_p (prev_regs, regnum)) + || regcache_register_status (prev_regs, regnum) == REG_UNKNOWN) return 1; /* Get register contents and compare. */ diff --git a/gdb/regcache.c b/gdb/regcache.c index c9c973e..53e0c59 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -53,7 +53,7 @@ struct regcache_descr cache. */ int nr_raw_registers; long sizeof_raw_registers; - long sizeof_raw_register_valid_p; + long sizeof_raw_register_status; /* The cooked register space. Each cooked register in the range [0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw @@ -63,7 +63,7 @@ struct regcache_descr gdbarch_pseudo_register_read and gdbarch_pseudo_register_write. */ int nr_cooked_registers; long sizeof_cooked_registers; - long sizeof_cooked_register_valid_p; + long sizeof_cooked_register_status; /* Offset and size (in 8 bit bytes), of reach register in the register cache. All registers (including those in the range @@ -92,9 +92,8 @@ init_regcache_descr (struct gdbarch *gdbarch) either mapped onto raw-registers or memory. */ descr->nr_cooked_registers = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); - descr->sizeof_cooked_register_valid_p = gdbarch_num_regs (gdbarch) - + gdbarch_num_pseudo_regs - (gdbarch); + descr->sizeof_cooked_register_status + = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); /* Fill in a table of register types. */ descr->register_type @@ -106,7 +105,7 @@ init_regcache_descr (struct gdbarch *gdbarch) /* Construct a strictly RAW register cache. Don't allow pseudo's into the register cache. */ descr->nr_raw_registers = gdbarch_num_regs (gdbarch); - descr->sizeof_raw_register_valid_p = gdbarch_num_regs (gdbarch); + descr->sizeof_raw_register_status = gdbarch_num_regs (gdbarch); /* Lay out the register cache. @@ -194,11 +193,8 @@ struct regcache full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write register cache can only hold [0 .. gdbarch_num_regs). */ gdb_byte *registers; - /* Register cache status: - register_valid_p[REG] == 0 if REG value is not in the cache - > 0 if REG value is in the cache - < 0 if REG value is permanently unavailable */ - signed char *register_valid_p; + /* Register cache status. */ + signed char *register_status; /* Is this a read-only cache? A read-only cache is used for saving the target's register state (e.g, across an inferior function call or just before forcing a function return). A read-only @@ -227,15 +223,15 @@ regcache_xmalloc_1 (struct gdbarch *gdbarch, struct address_space *aspace, { regcache->registers = XCALLOC (descr->sizeof_cooked_registers, gdb_byte); - regcache->register_valid_p - = XCALLOC (descr->sizeof_cooked_register_valid_p, gdb_byte); + regcache->register_status + = XCALLOC (descr->sizeof_cooked_register_status, gdb_byte); } else { regcache->registers = XCALLOC (descr->sizeof_raw_registers, gdb_byte); - regcache->register_valid_p - = XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte); + regcache->register_status + = XCALLOC (descr->sizeof_raw_register_status, gdb_byte); } regcache->aspace = aspace; regcache->ptid = minus_one_ptid; @@ -254,7 +250,7 @@ regcache_xfree (struct regcache *regcache) if (regcache == NULL) return; xfree (regcache->registers); - xfree (regcache->register_valid_p); + xfree (regcache->register_status); xfree (regcache); } @@ -306,8 +302,8 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read, gdb_assert (dst->readonly_p); /* Clear the dest. */ memset (dst->registers, 0, dst->descr->sizeof_cooked_registers); - memset (dst->register_valid_p, 0, - dst->descr->sizeof_cooked_register_valid_p); + memset (dst->register_status, 0, + dst->descr->sizeof_cooked_register_status); /* Copy over any registers (identified by their membership in the save_reggroup) and mark them as valid. The full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) range is checked since some architectures need @@ -322,7 +318,7 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read, { memcpy (register_buffer (dst, regnum), buf, register_size (gdbarch, regnum)); - dst->register_valid_p[regnum] = 1; + dst->register_status[regnum] = REG_VALID; } } } @@ -361,7 +357,7 @@ do_cooked_read (void *src, int regnum, gdb_byte *buf) { struct regcache *regcache = src; - if (!regcache->register_valid_p[regnum] && regcache->readonly_p) + if (regcache->register_status[regnum] == REG_UNKNOWN && regcache->readonly_p) /* Don't even think about fetching a register from a read-only cache when the register isn't yet valid. There isn't a target from which the register value can be fetched. */ @@ -393,14 +389,15 @@ regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src) gdb_assert (src != NULL && dst != NULL); gdb_assert (src->descr->gdbarch == dst->descr->gdbarch); /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough - move of data into the current regcache. Doing this would be - silly - it would mean that valid_p would be completely invalid. */ + move of data into a thread's regcache. Doing this would be silly + - it would mean that regcache->register_status would be + completely invalid. */ gdb_assert (dst->readonly_p && src->readonly_p); memcpy (dst->registers, src->registers, dst->descr->sizeof_cooked_registers); - memcpy (dst->register_valid_p, src->register_valid_p, - dst->descr->sizeof_cooked_register_valid_p); + memcpy (dst->register_status, src->register_status, + dst->descr->sizeof_cooked_register_status); } struct regcache * @@ -414,7 +411,7 @@ regcache_dup (struct regcache *src) } int -regcache_valid_p (const struct regcache *regcache, int regnum) +regcache_register_status (const struct regcache *regcache, int regnum) { gdb_assert (regcache != NULL); gdb_assert (regnum >= 0); @@ -423,7 +420,7 @@ regcache_valid_p (const struct regcache *regcache, int regnum) else gdb_assert (regnum < regcache->descr->nr_raw_registers); - return regcache->register_valid_p[regnum]; + return regcache->register_status[regnum]; } void @@ -433,7 +430,7 @@ regcache_invalidate (struct regcache *regcache, int regnum) gdb_assert (regnum >= 0); gdb_assert (!regcache->readonly_p); gdb_assert (regnum < regcache->descr->nr_raw_registers); - regcache->register_valid_p[regnum] = 0; + regcache->register_status[regnum] = REG_UNKNOWN; } @@ -586,7 +583,7 @@ regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) On the bright side, at least there is a regcache object. */ if (!regcache->readonly_p) { - if (!regcache_valid_p (regcache, regnum)) + if (regcache_register_status (regcache, regnum) == REG_UNKNOWN) { struct cleanup *old_chain = save_inferior_ptid (); @@ -601,7 +598,7 @@ regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) that a register is in one of the possible states: valid, undefined, unknown. The last of which isn't yet possible. */ - gdb_assert (regcache_valid_p (regcache, regnum)); + gdb_assert (regcache_register_status (regcache, regnum) == REG_VALID); #endif } /* Copy the value directly into the register cache. */ @@ -674,8 +671,8 @@ regcache_cooked_read (struct regcache *regcache, int regnum, gdb_byte *buf) regcache_raw_read (regcache, regnum, buf); else if (regcache->readonly_p && regnum < regcache->descr->nr_cooked_registers - && regcache->register_valid_p[regnum]) - /* Read-only register cache, perhaps the cooked value was cached? */ + && regcache->register_status[regnum] == REG_VALID) + /* Read-only register cache, and the cooked value was cached. */ memcpy (buf, register_buffer (regcache, regnum), regcache->descr->sizeof_register[regnum]); else @@ -758,7 +755,7 @@ regcache_raw_write (struct regcache *regcache, int regnum, /* If we have a valid copy of the register, and new value == old value, then don't bother doing the actual store. */ - if (regcache_valid_p (regcache, regnum) + if (regcache_register_status (regcache, regnum) == REG_VALID && (memcmp (register_buffer (regcache, regnum), buf, regcache->descr->sizeof_register[regnum]) == 0)) return; @@ -769,7 +766,7 @@ regcache_raw_write (struct regcache *regcache, int regnum, target_prepare_to_store (regcache); memcpy (register_buffer (regcache, regnum), buf, regcache->descr->sizeof_register[regnum]); - regcache->register_valid_p[regnum] = 1; + regcache->register_status[regnum] = REG_VALID; target_store_registers (regcache, regnum); do_cleanups (old_chain); @@ -893,12 +890,18 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf) size = regcache->descr->sizeof_register[regnum]; if (buf) - memcpy (regbuf, buf, size); + { + memcpy (regbuf, buf, size); + regcache->register_status[regnum] = REG_VALID; + } else - memset (regbuf, 0, size); - - /* Mark the register as cached. */ - regcache->register_valid_p[regnum] = 1; + { + /* This memset not strictly necessary, but better than garbage + in case the register value manages to escape somewhere (due + to a bug, no less). */ + memset (regbuf, 0, size); + regcache->register_status[regnum] = REG_UNAVAILABLE; + } } /* Collect register REGNUM from REGCACHE and store its contents in BUF. */ @@ -1022,8 +1025,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, regcache->descr->nr_cooked_registers); fprintf_unfiltered (file, "sizeof_raw_registers %ld\n", regcache->descr->sizeof_raw_registers); - fprintf_unfiltered (file, "sizeof_raw_register_valid_p %ld\n", - regcache->descr->sizeof_raw_register_valid_p); + fprintf_unfiltered (file, "sizeof_raw_register_status %ld\n", + regcache->descr->sizeof_raw_register_status); fprintf_unfiltered (file, "gdbarch_num_regs %d\n", gdbarch_num_regs (gdbarch)); fprintf_unfiltered (file, "gdbarch_num_pseudo_regs %d\n", @@ -1134,8 +1137,10 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, fprintf_unfiltered (file, "Raw value"); else if (regnum >= regcache->descr->nr_raw_registers) fprintf_unfiltered (file, "<cooked>"); - else if (!regcache_valid_p (regcache, regnum)) + else if (regcache_register_status (regcache, regnum) == REG_UNKNOWN) fprintf_unfiltered (file, "<invalid>"); + else if (regcache_register_status (regcache, regnum) == REG_UNAVAILABLE) + fprintf_unfiltered (file, "<unavailable>"); else { regcache_raw_read (regcache, regnum, buf); @@ -1153,6 +1158,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, fprintf_unfiltered (file, "Cooked value"); else { + /* FIXME: no way for cooked reads to signal unavailable + yet. */ regcache_cooked_read (regcache, regnum, buf); fprintf_unfiltered (file, "0x"); dump_endian_bytes (file, diff --git a/gdb/regcache.h b/gdb/regcache.h index e5ec1cc..7ae585a 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -42,6 +42,27 @@ extern struct gdbarch *get_regcache_arch (const struct regcache *regcache); extern struct address_space *get_regcache_aspace (const struct regcache *); +enum register_status + { + /* The register value is not in the cache, and we don't know yet + whether it's available in the target (or traceframe). */ + REG_UNKNOWN = 0, + + /* The register value is valid and cached. */ + REG_VALID = 1, + + /* The register value is unavailable. E.g., we're inspecting a + traceframe, and this register wasn't collected. Note that this + is different a different "unavailable" from saying the register + does not exist in the target's architecture --- in that case, + the target should have given us a target description that does + not include the register in the first place. */ + REG_UNAVAILABLE = -1 + }; + +enum register_status regcache_register_status (const struct regcache *regcache, + int regnum); + /* Transfer a raw register [0..NUM_REGS) between core-gdb and the regcache. */ @@ -65,8 +86,6 @@ void regcache_raw_read_part (struct regcache *regcache, int regnum, void regcache_raw_write_part (struct regcache *regcache, int regnum, int offset, int len, const gdb_byte *buf); -int regcache_valid_p (const struct regcache *regcache, int regnum); - void regcache_invalidate (struct regcache *regcache, int regnum); /* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index dcae841..a078de4 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3844,7 +3844,7 @@ tfile_fetch_registers (struct target_ops *ops, /* Make sure we stay within block bounds. */ if (offset + regsize >= trace_regblock_size) break; - if (!regcache_valid_p (regcache, regn)) + if (regcache_register_status (regcache, regn) == REG_UNKNOWN) { if (regno == regn) { diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c index e7ee504..8a0142f 100644 --- a/gdb/trad-frame.c +++ b/gdb/trad-frame.c @@ -66,12 +66,12 @@ trad_frame_alloc_saved_regs (struct frame_info *this_frame) return this_saved_regs; } -enum { REG_VALUE = -1, REG_UNKNOWN = -2 }; +enum { TF_REG_VALUE = -1, TF_REG_UNKNOWN = -2 }; int trad_frame_value_p (struct trad_frame_saved_reg this_saved_regs[], int regnum) { - return (this_saved_regs[regnum].realreg == REG_VALUE); + return (this_saved_regs[regnum].realreg == TF_REG_VALUE); } int @@ -95,7 +95,7 @@ trad_frame_set_value (struct trad_frame_saved_reg this_saved_regs[], { /* Make the REALREG invalid, indicating that the ADDR contains the register's value. */ - this_saved_regs[regnum].realreg = REG_VALUE; + this_saved_regs[regnum].realreg = TF_REG_VALUE; this_saved_regs[regnum].addr = val; } @@ -128,7 +128,7 @@ trad_frame_set_unknown (struct trad_frame_saved_reg this_saved_regs[], int regnum) { /* Make the REALREG invalid, indicating that the value is not known. */ - this_saved_regs[regnum].realreg = REG_UNKNOWN; + this_saved_regs[regnum].realreg = TF_REG_UNKNOWN; this_saved_regs[regnum].addr = -1; } |