diff options
author | Michael Snyder <msnyder@vmware.com> | 2010-05-16 21:11:14 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2010-05-16 21:11:14 +0000 |
commit | 123f5f96b6f084af89436ac1efaf7b77ab66bbe5 (patch) | |
tree | 1a1404dc4f92f1e55533e57584b9f35aa43628b0 | |
parent | a744cf537ec1cf2e102bc63b83b820cd4dd48783 (diff) | |
download | gdb-123f5f96b6f084af89436ac1efaf7b77ab66bbe5.zip gdb-123f5f96b6f084af89436ac1efaf7b77ab66bbe5.tar.gz gdb-123f5f96b6f084af89436ac1efaf7b77ab66bbe5.tar.bz2 |
2010-05-16 Michael Snyder <msnyder@vmware.com>
* record.c: White space.
* regcache.c: White space.
* reggroups.c: White space.
* remote-fileio.c: White space.
* remote-m32r-sdi.c: White space.
* remote-mips.c: White space.
* remote-sim.c: White space.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/record.c | 161 | ||||
-rw-r--r-- | gdb/regcache.c | 33 | ||||
-rw-r--r-- | gdb/reggroups.c | 5 | ||||
-rw-r--r-- | gdb/remote-fileio.c | 2 | ||||
-rw-r--r-- | gdb/remote-m32r-sdi.c | 8 | ||||
-rw-r--r-- | gdb/remote-mips.c | 10 | ||||
-rw-r--r-- | gdb/remote-sim.c | 10 |
8 files changed, 154 insertions, 82 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e66e00f..2c4368f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2010-05-16 Michael Snyder <msnyder@vmware.com> + * record.c: White space. + * regcache.c: White space. + * reggroups.c: White space. + * remote-fileio.c: White space. + * remote-m32r-sdi.c: White space. + * remote-mips.c: White space. + * remote-sim.c: White space. * remote.c: White space. (process_g_packet): Remove orphan braces. diff --git a/gdb/record.c b/gdb/record.c index 4350637..546557d 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -544,6 +544,7 @@ record_check_insn_num (int set_terminal) if (record_stop_at_limit) { int q; + if (set_terminal) target_terminal_ours (); q = yquery (_("Do you want to auto delete previous execution " @@ -1396,6 +1397,7 @@ record_registers_change (struct regcache *regcache, int regnum) if (regnum < 0) { int i; + for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) { if (record_arch_list_add_reg (regcache, i)) @@ -1462,6 +1464,7 @@ record_store_registers (struct target_ops *ops, struct regcache *regcache, if (regno < 0) { int i; + for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) @@ -1747,85 +1750,84 @@ record_core_xfer_partial (struct target_ops *ops, enum target_object object, const gdb_byte *writebuf, ULONGEST offset, LONGEST len) { - if (object == TARGET_OBJECT_MEMORY) - { - if (record_gdb_operation_disable || !writebuf) - { - struct target_section *p; - for (p = record_core_start; p < record_core_end; p++) - { - if (offset >= p->addr) - { - struct record_core_buf_entry *entry; - ULONGEST sec_offset; - - if (offset >= p->endaddr) - continue; - - if (offset + len > p->endaddr) - len = p->endaddr - offset; - - sec_offset = offset - p->addr; - - /* Read readbuf or write writebuf p, offset, len. */ - /* Check flags. */ - if (p->the_bfd_section->flags & SEC_CONSTRUCTOR - || (p->the_bfd_section->flags & SEC_HAS_CONTENTS) == 0) - { - if (readbuf) - memset (readbuf, 0, len); - return len; - } - /* Get record_core_buf_entry. */ - for (entry = record_core_buf_list; entry; - entry = entry->prev) - if (entry->p == p) - break; - if (writebuf) - { - if (!entry) - { - /* Add a new entry. */ - entry - = (struct record_core_buf_entry *) - xmalloc - (sizeof (struct record_core_buf_entry)); - entry->p = p; - if (!bfd_malloc_and_get_section (p->bfd, - p->the_bfd_section, - &entry->buf)) - { - xfree (entry); - return 0; - } - entry->prev = record_core_buf_list; - record_core_buf_list = entry; - } - - memcpy (entry->buf + sec_offset, writebuf, - (size_t) len); - } - else - { - if (!entry) - return record_beneath_to_xfer_partial - (record_beneath_to_xfer_partial_ops, - object, annex, readbuf, writebuf, - offset, len); - - memcpy (readbuf, entry->buf + sec_offset, - (size_t) len); - } - - return len; - } - } - - return -1; - } - else - error (_("You can't do that without a process to debug.")); - } + if (object == TARGET_OBJECT_MEMORY) + { + if (record_gdb_operation_disable || !writebuf) + { + struct target_section *p; + + for (p = record_core_start; p < record_core_end; p++) + { + if (offset >= p->addr) + { + struct record_core_buf_entry *entry; + ULONGEST sec_offset; + + if (offset >= p->endaddr) + continue; + + if (offset + len > p->endaddr) + len = p->endaddr - offset; + + sec_offset = offset - p->addr; + + /* Read readbuf or write writebuf p, offset, len. */ + /* Check flags. */ + if (p->the_bfd_section->flags & SEC_CONSTRUCTOR + || (p->the_bfd_section->flags & SEC_HAS_CONTENTS) == 0) + { + if (readbuf) + memset (readbuf, 0, len); + return len; + } + /* Get record_core_buf_entry. */ + for (entry = record_core_buf_list; entry; + entry = entry->prev) + if (entry->p == p) + break; + if (writebuf) + { + if (!entry) + { + /* Add a new entry. */ + entry = (struct record_core_buf_entry *) + xmalloc (sizeof (struct record_core_buf_entry)); + entry->p = p; + if (!bfd_malloc_and_get_section (p->bfd, + p->the_bfd_section, + &entry->buf)) + { + xfree (entry); + return 0; + } + entry->prev = record_core_buf_list; + record_core_buf_list = entry; + } + + memcpy (entry->buf + sec_offset, writebuf, + (size_t) len); + } + else + { + if (!entry) + return record_beneath_to_xfer_partial + (record_beneath_to_xfer_partial_ops, + object, annex, readbuf, writebuf, + offset, len); + + memcpy (readbuf, entry->buf + sec_offset, + (size_t) len); + } + + return len; + } + } + + return -1; + } + else + error (_("You can't do that without a process to debug.")); + } return record_beneath_to_xfer_partial (record_beneath_to_xfer_partial_ops, object, annex, readbuf, writebuf, @@ -2318,6 +2320,7 @@ record_save_cleanups (void *data) { bfd *obfd = data; char *pathname = xstrdup (bfd_get_filename (obfd)); + bfd_close (obfd); unlink (pathname); xfree (pathname); diff --git a/gdb/regcache.c b/gdb/regcache.c index 6c91da3..5342586 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -123,6 +123,7 @@ init_regcache_descr (struct gdbarch *gdbarch) { long offset = 0; + descr->sizeof_register = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long); descr->register_offset @@ -161,6 +162,7 @@ struct type * register_type (struct gdbarch *gdbarch, int regnum) { struct regcache_descr *descr = regcache_descr (gdbarch); + gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers); return descr->register_type[regnum]; } @@ -173,6 +175,7 @@ register_size (struct gdbarch *gdbarch, int regnum) { struct regcache_descr *descr = regcache_descr (gdbarch); int size; + gdb_assert (regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch))); @@ -216,6 +219,7 @@ regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace) { struct regcache_descr *descr; struct regcache *regcache; + gdb_assert (gdbarch != NULL); descr = regcache_descr (gdbarch); regcache = XMALLOC (struct regcache); @@ -281,6 +285,7 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read, struct gdbarch *gdbarch = dst->descr->gdbarch; gdb_byte buf[MAX_REGISTER_SIZE]; int regnum; + /* The DST should be `read-only', if it wasn't then the save would end up trying to write the register values back out to the target. */ @@ -297,6 +302,7 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read, if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup)) { int valid = cooked_read (src, regnum, buf); + if (valid) { memcpy (register_buffer (dst, regnum), buf, @@ -315,6 +321,7 @@ regcache_restore (struct regcache *dst, struct gdbarch *gdbarch = dst->descr->gdbarch; gdb_byte buf[MAX_REGISTER_SIZE]; int regnum; + /* The dst had better not be read-only. If it is, the `restore' doesn't make much sense. */ gdb_assert (!dst->readonly_p); @@ -327,6 +334,7 @@ regcache_restore (struct regcache *dst, if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup)) { int valid = cooked_read (cooked_read_context, regnum, buf); + if (valid) regcache_cooked_write (dst, regnum, buf); } @@ -337,6 +345,7 @@ static int do_cooked_read (void *src, int regnum, gdb_byte *buf) { struct regcache *regcache = src; + if (!regcache->register_valid_p[regnum] && 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 @@ -382,6 +391,7 @@ struct regcache * regcache_dup (struct regcache *src) { struct regcache *newbuf; + newbuf = regcache_xmalloc (src->descr->gdbarch, get_regcache_aspace (src)); regcache_cpy (newbuf, src); return newbuf; @@ -391,6 +401,7 @@ struct regcache * regcache_dup_no_passthrough (struct regcache *src) { struct regcache *newbuf; + newbuf = regcache_xmalloc (src->descr->gdbarch, get_regcache_aspace (src)); regcache_cpy_no_passthrough (newbuf, src); return newbuf; @@ -573,6 +584,7 @@ regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) if (!regcache_valid_p (regcache, regnum)) { struct cleanup *old_chain = save_inferior_ptid (); + inferior_ptid = regcache->ptid; target_fetch_registers (regcache, regnum); do_cleanups (old_chain); @@ -596,6 +608,7 @@ void regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val) { gdb_byte *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -610,6 +623,7 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum, ULONGEST *val) { gdb_byte *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -623,6 +637,7 @@ void regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val) { void *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -636,6 +651,7 @@ regcache_raw_write_unsigned (struct regcache *regcache, int regnum, ULONGEST val) { void *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -667,6 +683,7 @@ regcache_cooked_read_signed (struct regcache *regcache, int regnum, LONGEST *val) { gdb_byte *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -681,6 +698,7 @@ regcache_cooked_read_unsigned (struct regcache *regcache, int regnum, ULONGEST *val) { gdb_byte *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -695,6 +713,7 @@ regcache_cooked_write_signed (struct regcache *regcache, int regnum, LONGEST val) { void *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -708,6 +727,7 @@ regcache_cooked_write_unsigned (struct regcache *regcache, int regnum, ULONGEST val) { void *buf; + gdb_assert (regcache != NULL); gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers); buf = alloca (regcache->descr->sizeof_register[regnum]); @@ -781,6 +801,7 @@ regcache_xfer_part (struct regcache *regcache, int regnum, { struct regcache_descr *descr = regcache->descr; gdb_byte reg[MAX_REGISTER_SIZE]; + gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]); gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]); /* Something to do? */ @@ -812,6 +833,7 @@ regcache_raw_read_part (struct regcache *regcache, int regnum, int offset, int len, gdb_byte *buf) { struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers); regcache_xfer_part (regcache, regnum, offset, len, buf, NULL, regcache_raw_read, regcache_raw_write); @@ -822,6 +844,7 @@ regcache_raw_write_part (struct regcache *regcache, int regnum, int offset, int len, const gdb_byte *buf) { struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers); regcache_xfer_part (regcache, regnum, offset, len, NULL, buf, regcache_raw_read, regcache_raw_write); @@ -832,6 +855,7 @@ regcache_cooked_read_part (struct regcache *regcache, int regnum, int offset, int len, gdb_byte *buf) { struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers); regcache_xfer_part (regcache, regnum, offset, len, buf, NULL, regcache_cooked_read, regcache_cooked_write); @@ -842,6 +866,7 @@ regcache_cooked_write_part (struct regcache *regcache, int regnum, int offset, int len, const gdb_byte *buf) { struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers); regcache_xfer_part (regcache, regnum, offset, len, NULL, buf, regcache_cooked_read, regcache_cooked_write); @@ -903,6 +928,7 @@ regcache_read_pc (struct regcache *regcache) else if (gdbarch_pc_regnum (gdbarch) >= 0) { ULONGEST raw_val; + regcache_cooked_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &raw_val); @@ -948,6 +974,7 @@ dump_endian_bytes (struct ui_file *file, enum bfd_endian endian, const unsigned char *buf, long len) { int i; + switch (endian) { case BFD_ENDIAN_BIG: @@ -1009,6 +1036,7 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, else { const char *p = gdbarch_register_name (gdbarch, regnum); + if (p == NULL) p = ""; else if (p[0] == '\0') @@ -1065,15 +1093,18 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, /* Type. */ { const char *t; + if (regnum < 0) t = "Type"; else { static const char blt[] = "builtin_type"; + t = TYPE_NAME (register_type (regcache->descr->gdbarch, regnum)); if (t == NULL) { char *n; + if (!footnote_register_type_name_null) footnote_register_type_name_null = ++footnote_nr; n = xstrprintf ("*%d", footnote_register_type_name_null); @@ -1133,6 +1164,7 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, { const char *sep = ""; struct reggroup *group; + for (group = reggroup_next (gdbarch, NULL); group != NULL; group = reggroup_next (gdbarch, group)) @@ -1171,6 +1203,7 @@ regcache_print (char *args, enum regcache_dump_what what_to_dump) { struct cleanup *cleanups; struct ui_file *file = gdb_fopen (args, "w"); + if (file == NULL) perror_with_name (_("maintenance print architecture")); cleanups = make_cleanup_ui_file_delete (file); diff --git a/gdb/reggroups.c b/gdb/reggroups.c index 01dbe34..fdc0575 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -41,6 +41,7 @@ struct reggroup * reggroup_new (const char *name, enum reggroup_type type) { struct reggroup *group = XMALLOC (struct reggroup); + group->name = name; group->type = type; return group; @@ -81,6 +82,7 @@ reggroups_init (struct gdbarch *gdbarch) { struct reggroups *groups = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct reggroups); + groups->last = &groups->first; return groups; } @@ -190,6 +192,7 @@ reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file) /* Group name. */ { const char *name; + if (group == NULL) name = "Group"; else @@ -200,6 +203,7 @@ reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file) /* Group type. */ { const char *type; + if (group == NULL) type = "Type"; else @@ -240,6 +244,7 @@ maintenance_print_reggroups (char *args, int from_tty) { struct cleanup *cleanups; struct ui_file *file = gdb_fopen (args, "w"); + if (file == NULL) perror_with_name (_("maintenance print reggroups")); cleanups = make_cleanup_ui_file_delete (file); diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 2166925..82a4fe9 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -109,6 +109,7 @@ static int remote_fileio_fd_to_targetfd (int fd) { int target_fd = remote_fileio_next_free_fd (); + remote_fio_data.fd_map[target_fd] = fd; return target_fd; } @@ -1477,6 +1478,7 @@ set_system_call_allowed (char *args, int from_tty) { char *arg_end; int val = strtoul (args, &arg_end, 10); + if (*args && *arg_end == '\0') { remote_fio_system_call_allowed = !!val; diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index a74075b..ad21774 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -231,6 +231,7 @@ static int send_cmd (unsigned char cmd) { unsigned char buf[1]; + buf[0] = cmd; return send_data (buf, 1); } @@ -239,6 +240,7 @@ static int send_one_arg_cmd (unsigned char cmd, unsigned char arg1) { unsigned char buf[2]; + buf[0] = cmd; buf[1] = arg1; return send_data (buf, 2); @@ -248,6 +250,7 @@ static int send_two_arg_cmd (unsigned char cmd, unsigned char arg1, unsigned long arg2) { unsigned char buf[6]; + buf[0] = cmd; buf[1] = arg1; store_long_parameter (buf + 2, arg2); @@ -259,6 +262,7 @@ send_three_arg_cmd (unsigned char cmd, unsigned long arg1, unsigned long arg2, unsigned long arg3) { unsigned char buf[13]; + buf[0] = cmd; store_long_parameter (buf + 1, arg1); store_long_parameter (buf + 5, arg2); @@ -270,6 +274,7 @@ static unsigned char recv_char_data (void) { unsigned char val; + recv_data (&val, 1); return val; } @@ -278,6 +283,7 @@ static unsigned long recv_long_data (void) { unsigned long val; + recv_data (&val, 4); return ntohl (val); } @@ -1463,6 +1469,7 @@ static int m32r_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p) { int rc = 0; + if (hit_watchpoint_addr != 0x00000000) { *addr_p = hit_watchpoint_addr; @@ -1475,6 +1482,7 @@ static int m32r_stopped_by_watchpoint (void) { CORE_ADDR addr; + return m32r_stopped_data_address (¤t_target, &addr); } diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index 3da1042..28d2ecb 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -648,7 +648,7 @@ mips_readchar (int timeout) static int state = 0; int mips_monitor_prompt_len = strlen (mips_monitor_prompt); - { + { /* FIXME this whole block is dead code! */ int i; i = timeout; @@ -1348,6 +1348,7 @@ mips_enter_debug (void) { char buff[DATA_MAXLEN + 1]; + if (mips_receive_packet (buff, 1, 3) < 0) mips_error ("Failed to initialize (didn't receive packet)."); } @@ -2014,6 +2015,7 @@ mips_fetch_registers (struct target_ops *ops, /* If PMON doesn't support this register, don't waste serial bandwidth trying to read it. */ int pmon_reg = mips_map_regno (gdbarch, regno); + if (regno != 0 && pmon_reg == 0) val = 0; else @@ -2182,6 +2184,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, for (i = 0; i < count; i++, addr += 4) { int word; + word = extract_unsigned_integer (&buffer[i * 4], 4, byte_order); status = mips_store_word (addr, word, NULL); /* Report each kilobyte (we download 32-bit words at a time) */ @@ -2467,6 +2470,7 @@ mips_check_lsi_error (CORE_ADDR addr, int rerrflg) if (monitor_warnings) { int found = 0; + for (err = lsi_warning_table; err->code != 0; err++) { if ((err->code & rerrflg) == err->code) @@ -2657,6 +2661,7 @@ mips_common_breakpoint: Bad response from remote board: %s", if (set) /* set a breakpoint */ { char *flags; + switch (type) { case BREAK_WRITE: /* write */ @@ -3095,6 +3100,7 @@ pmon_make_fastrec (char **outbuf, unsigned char *inbuf, int *inptr, else { unsigned int value = ((inbuf[*inptr + 0] << 16) | (inbuf[*inptr + 1] << 8) | inbuf[*inptr + 2]); + /* Simple check for zero data. TODO: A better check would be to check the last, and then the middle byte for being zero (if the first byte is not). We could then check for @@ -3203,6 +3209,7 @@ static void pmon_check_entry_address (char *entry_address, int final) { char hexnumber[9]; /* includes '\0' space */ + mips_expect_timeout (entry_address, tftp_in_use ? 15 : remote_timeout); sprintf (hexnumber, "%x", final); mips_expect (hexnumber); @@ -3217,6 +3224,7 @@ static int pmon_check_total (int bintotal) { char hexnumber[9]; /* includes '\0' space */ + mips_expect ("\r\ntotal = 0x"); sprintf (hexnumber, "%x", bintotal); mips_expect (hexnumber); diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index ac7b043..7875f77 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -123,6 +123,7 @@ dump_mem (char *buf, int len) if (len == 8 || len == 4) { long l[2]; + memcpy (l, buf, len); printf_filtered ("\t0x%lx", l[0]); if (len == 8) @@ -132,6 +133,7 @@ dump_mem (char *buf, int len) else { int i; + printf_filtered ("\t"); for (i = 0; i < len; i++) printf_filtered ("0x%x ", buf[i]); @@ -229,10 +231,9 @@ static void gdb_os_printf_filtered (host_callback * p, const char *format,...) { va_list args; - va_start (args, format); + va_start (args, format); vfprintf_filtered (gdb_stdout, format, args); - va_end (args); } @@ -258,6 +259,7 @@ static void gdb_os_error (host_callback * p, const char *format, ...) { va_list args; + va_start (args, format); verror (format, args); va_end (args); @@ -276,6 +278,7 @@ gdbsim_fetch_register (struct target_ops *ops, struct regcache *regcache, int regno) { struct gdbarch *gdbarch = get_regcache_arch (regcache); + if (regno == -1) { for (regno = 0; regno < gdbarch_num_regs (gdbarch); regno++) @@ -293,6 +296,7 @@ gdbsim_fetch_register (struct target_ops *ops, as an ``unavailable'' register. */ char buf[MAX_REGISTER_SIZE]; int nr_bytes; + memset (buf, 0, MAX_REGISTER_SIZE); regcache_raw_supply (regcache, regno, buf); break; @@ -303,6 +307,7 @@ gdbsim_fetch_register (struct target_ops *ops, static int warn_user = 1; char buf[MAX_REGISTER_SIZE]; int nr_bytes; + gdb_assert (regno >= 0 && regno < gdbarch_num_regs (gdbarch)); memset (buf, 0, MAX_REGISTER_SIZE); nr_bytes = sim_fetch_register (gdbsim_desc, @@ -355,6 +360,7 @@ gdbsim_store_register (struct target_ops *ops, { char tmp[MAX_REGISTER_SIZE]; int nr_bytes; + regcache_cooked_read (regcache, regno, tmp); nr_bytes = sim_store_register (gdbsim_desc, gdbarch_register_sim_regno |