From cfd77fa13ec760bb2f8bc653b29cade7f958bbf8 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Tue, 17 Jan 2006 14:11:16 +0000 Subject: [PATCH] * remote-fileio.c (remote_fileio_return_success): Take a gdb_byte argument. (remote_fileio_func_open, remote_fileio_func_rename) (remote_fileio_func_unlink, remote_fileio_func_stat) (remote_fileio_func_fstat, remote_fileio_func_gettimeofday) (remote_fileio_func_system): Cast the arguments to remote_read_bytes and remote_write_bytes. (remote_fileio_func_read, remote_fileio_func_write): Use a gdb_byte buffer. * remote.h (remote_read_bytes, remote_write_bytes): Update prototypes. * remote.c (hex2bin, bin2hex): Use gdb_byte for the BIN argument. (threadref_to_int): Replace bogus char * cast. (remote_unpack_thread_info_response): Use int for tag. (remote_threads_extra_info, remote_check_symbols): Cast string arguments to hex2bin. (remote_wait): Use a char buffer for packets and a gdb_byte buffer for registers. (remote_async_wait): Likewise. (remote_prepare_to_store, store_register_using_P) (remote_store_registers): Use gdb_byte buffers. (remote_write_bytes, remote_read_bytes): Use a gdb_byte pointer for MYADDR and char buffers for strings. (remote_xfer_partial): Add casts for string operations on READBUF. (remote_rcmd): Cast strings passed to bin2hex. --- gdb/ChangeLog | 28 ++++++++++++++++ gdb/remote-fileio.c | 36 ++++++++++----------- gdb/remote.c | 78 ++++++++++++++++++++++----------------------- gdb/remote.h | 4 +-- 4 files changed, 87 insertions(+), 59 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6acebaaaa3e..b08fa23d484 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,31 @@ +2006-01-17 Daniel Jacobowitz + + * remote-fileio.c (remote_fileio_return_success): Take a gdb_byte + argument. + (remote_fileio_func_open, remote_fileio_func_rename) + (remote_fileio_func_unlink, remote_fileio_func_stat) + (remote_fileio_func_fstat, remote_fileio_func_gettimeofday) + (remote_fileio_func_system): Cast the arguments to + remote_read_bytes and remote_write_bytes. + (remote_fileio_func_read, remote_fileio_func_write): Use a + gdb_byte buffer. + * remote.h (remote_read_bytes, remote_write_bytes): Update + prototypes. + * remote.c (hex2bin, bin2hex): Use gdb_byte for the BIN argument. + (threadref_to_int): Replace bogus char * cast. + (remote_unpack_thread_info_response): Use int for tag. + (remote_threads_extra_info, remote_check_symbols): Cast string + arguments to hex2bin. + (remote_wait): Use a char buffer for packets and a gdb_byte + buffer for registers. + (remote_async_wait): Likewise. + (remote_prepare_to_store, store_register_using_P) + (remote_store_registers): Use gdb_byte buffers. + (remote_write_bytes, remote_read_bytes): Use a gdb_byte pointer + for MYADDR and char buffers for strings. + (remote_xfer_partial): Add casts for string operations on READBUF. + (remote_rcmd): Cast strings passed to bin2hex. + 2006-01-16 Mark Mitchell * aclocal.m4: Regenerate. diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 0bde49b5c60..e94b4282cd7 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -570,7 +570,7 @@ remote_fileio_return_success (int retcode) write only one packet, regardless of the requested number of bytes to transfer. This wrapper calls remote_write_bytes() as often as needed. */ static int -remote_fileio_write_bytes (CORE_ADDR memaddr, char *myaddr, int len) +remote_fileio_write_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len) { int ret = 0, written; @@ -618,7 +618,7 @@ remote_fileio_func_open (char *buf) /* Request pathname using 'm' packet */ pathname = alloca (length); - retlength = remote_read_bytes (ptrval, pathname, length); + retlength = remote_read_bytes (ptrval, (gdb_byte *) pathname, length); if (retlength != length) { remote_fileio_ioerror (); @@ -688,7 +688,7 @@ remote_fileio_func_read (char *buf) LONGEST lnum; CORE_ADDR ptrval; int fd, ret, retlength; - char *buffer; + gdb_byte *buffer; size_t length; off_t old_offset, new_offset; @@ -729,7 +729,7 @@ remote_fileio_func_read (char *buf) static char *remaining_buf = NULL; static int remaining_length = 0; - buffer = (char *) xmalloc (32768); + buffer = (gdb_byte *) xmalloc (32768); if (remaining_buf) { remote_fio_no_longjmp = 1; @@ -751,7 +751,7 @@ remote_fileio_func_read (char *buf) } else { - ret = ui_file_read (gdb_stdtargin, buffer, 32767); + ret = ui_file_read (gdb_stdtargin, (char *) buffer, 32767); remote_fio_no_longjmp = 1; if (ret > 0 && (size_t)ret > length) { @@ -764,7 +764,7 @@ remote_fileio_func_read (char *buf) } break; default: - buffer = (char *) xmalloc (length); + buffer = (gdb_byte *) xmalloc (length); /* POSIX defines EINTR behaviour of read in a weird way. It's allowed for read() to return -1 even if "some" bytes have been read. It has been corrected in SUSv2 but that doesn't help us much... @@ -806,7 +806,7 @@ remote_fileio_func_write (char *buf) LONGEST lnum; CORE_ADDR ptrval; int fd, ret, retlength; - char *buffer; + gdb_byte *buffer; size_t length; /* 1. Parameter: file descriptor */ @@ -836,7 +836,7 @@ remote_fileio_func_write (char *buf) } length = (size_t) num; - buffer = (char *) xmalloc (length); + buffer = (gdb_byte *) xmalloc (length); retlength = remote_read_bytes (ptrval, buffer, length); if (retlength != length) { @@ -852,8 +852,8 @@ remote_fileio_func_write (char *buf) remote_fileio_badfd (); return; case FIO_FD_CONSOLE_OUT: - ui_file_write (target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr, buffer, - length); + ui_file_write (target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr, + (char *) buffer, length); gdb_flush (target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr); ret = length; break; @@ -943,7 +943,7 @@ remote_fileio_func_rename (char *buf) } /* Request oldpath using 'm' packet */ oldpath = alloca (length); - retlength = remote_read_bytes (ptrval, oldpath, length); + retlength = remote_read_bytes (ptrval, (gdb_byte *) oldpath, length); if (retlength != length) { remote_fileio_ioerror (); @@ -957,7 +957,7 @@ remote_fileio_func_rename (char *buf) } /* Request newpath using 'm' packet */ newpath = alloca (length); - retlength = remote_read_bytes (ptrval, newpath, length); + retlength = remote_read_bytes (ptrval, (gdb_byte *) newpath, length); if (retlength != length) { remote_fileio_ioerror (); @@ -1034,7 +1034,7 @@ remote_fileio_func_unlink (char *buf) } /* Request pathname using 'm' packet */ pathname = alloca (length); - retlength = remote_read_bytes (ptrval, pathname, length); + retlength = remote_read_bytes (ptrval, (gdb_byte *) pathname, length); if (retlength != length) { remote_fileio_ioerror (); @@ -1076,7 +1076,7 @@ remote_fileio_func_stat (char *buf) } /* Request pathname using 'm' packet */ pathname = alloca (length); - retlength = remote_read_bytes (ptrval, pathname, length); + retlength = remote_read_bytes (ptrval, (gdb_byte *) pathname, length); if (retlength != length) { remote_fileio_ioerror (); @@ -1110,7 +1110,7 @@ remote_fileio_func_stat (char *buf) remote_fileio_to_fio_stat (&st, &fst); remote_fileio_to_fio_uint (0, fst.fst_dev); - retlength = remote_fileio_write_bytes (ptrval, (char *) &fst, sizeof fst); + retlength = remote_fileio_write_bytes (ptrval, (gdb_byte *) &fst, sizeof fst); if (retlength != sizeof fst) { remote_fileio_return_errno (-1); @@ -1193,7 +1193,7 @@ remote_fileio_func_fstat (char *buf) { remote_fileio_to_fio_stat (&st, &fst); - retlength = remote_fileio_write_bytes (ptrval, (char *) &fst, sizeof fst); + retlength = remote_fileio_write_bytes (ptrval, (gdb_byte *) &fst, sizeof fst); if (retlength != sizeof fst) { remote_fileio_return_errno (-1); @@ -1245,7 +1245,7 @@ remote_fileio_func_gettimeofday (char *buf) { remote_fileio_to_fio_timeval (&tv, &ftv); - retlength = remote_fileio_write_bytes (ptrval, (char *) &ftv, sizeof ftv); + retlength = remote_fileio_write_bytes (ptrval, (gdb_byte *) &ftv, sizeof ftv); if (retlength != sizeof ftv) { remote_fileio_return_errno (-1); @@ -1297,7 +1297,7 @@ remote_fileio_func_system (char *buf) } /* Request commandline using 'm' packet */ cmdline = alloca (length); - retlength = remote_read_bytes (ptrval, cmdline, length); + retlength = remote_read_bytes (ptrval, (gdb_byte *) cmdline, length); if (retlength != length) { remote_fileio_ioerror (); diff --git a/gdb/remote.c b/gdb/remote.c index 1b5a9ef97d8..a162d32642c 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -172,9 +172,9 @@ static void record_currthread (int currthread); static int fromhex (int a); -static int hex2bin (const char *hex, char *bin, int count); +static int hex2bin (const char *hex, gdb_byte *bin, int count); -static int bin2hex (const char *bin, char *hex, int count); +static int bin2hex (const gdb_byte *bin, char *hex, int count); static int putpkt_binary (char *buf, int cnt); @@ -1409,7 +1409,7 @@ threadref_to_int (threadref *ref) int i, value = 0; unsigned char *scan; - scan = (char *) ref; + scan = *ref; scan += 4; i = 4; while (i-- > 0) @@ -1487,7 +1487,7 @@ remote_unpack_thread_info_response (char *pkt, threadref *expectedref, { struct remote_state *rs = get_remote_state (); int mask, length; - unsigned int tag; + int tag; threadref ref; char *limit = pkt + rs->remote_packet_size; /* Plausible parsing limit. */ int retval = 1; @@ -1876,7 +1876,7 @@ remote_threads_extra_info (struct thread_info *tp) if (bufp[0] != 0) { n = min (strlen (bufp) / 2, sizeof (display_buf)); - result = hex2bin (bufp, display_buf, n); + result = hex2bin (bufp, (gdb_byte *) display_buf, n); display_buf [result] = '\0'; return display_buf; } @@ -2134,7 +2134,7 @@ remote_check_symbols (struct objfile *objfile) while (strncmp (reply, "qSymbol:", 8) == 0) { tmp = &reply[8]; - end = hex2bin (tmp, msg, strlen (tmp) / 2); + end = hex2bin (tmp, (gdb_byte *) msg, strlen (tmp) / 2); msg[end] = '\0'; sym = lookup_minimal_symbol (msg, NULL, NULL); if (sym == NULL) @@ -2375,7 +2375,7 @@ fromhex (int a) } static int -hex2bin (const char *hex, char *bin, int count) +hex2bin (const char *hex, gdb_byte *bin, int count) { int i; @@ -2405,12 +2405,12 @@ tohex (int nib) } static int -bin2hex (const char *bin, char *hex, int count) +bin2hex (const gdb_byte *bin, char *hex, int count) { int i; /* May use a length, or a nul-terminated string as input. */ if (count == 0) - count = strlen (bin); + count = strlen ((char *) bin); for (i = 0; i < count; i++) { @@ -2830,7 +2830,7 @@ static ptid_t remote_wait (ptid_t ptid, struct target_waitstatus *status) { struct remote_state *rs = get_remote_state (); - unsigned char *buf = alloca (rs->remote_packet_size); + char *buf = alloca (rs->remote_packet_size); ULONGEST thread_num = -1; ULONGEST addr; @@ -2839,7 +2839,7 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status) while (1) { - unsigned char *p; + char *p; ofunc = signal (SIGINT, remote_interrupt); getpkt (buf, rs->remote_packet_size, 1); @@ -2862,7 +2862,7 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status) continue; case 'T': /* Status with PC, SP, FP, ... */ { - char regs[MAX_REGISTER_SIZE]; + gdb_byte regs[MAX_REGISTER_SIZE]; /* Expedited reply, containing Signal, {regno, reg} repeat. */ /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where @@ -2874,7 +2874,7 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status) while (*p) { - unsigned char *p1; + char *p1; char *p_temp; int fieldsize; LONGEST pnum = 0; @@ -2890,14 +2890,14 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status) { /* Read the ``P'' register number. */ pnum = strtol (p, &p_temp, 16); - p1 = (unsigned char *) p_temp; + p1 = p_temp; } else p1 = p; if (p1 == p) /* No register number present here. */ { - p1 = (unsigned char *) strchr (p, ':'); + p1 = strchr (p, ':'); if (p1 == NULL) warning (_("Malformed packet(a) (missing colon): %s\n\ Packet: '%s'\n"), @@ -2906,7 +2906,7 @@ Packet: '%s'\n"), { p_temp = unpack_varlen_hex (++p1, &thread_num); record_currthread (thread_num); - p = (unsigned char *) p_temp; + p = p_temp; } else if ((strncmp (p, "watch", p1 - p) == 0) || (strncmp (p, "rwatch", p1 - p) == 0) @@ -2921,7 +2921,7 @@ Packet: '%s'\n"), /* Silently skip unknown optional info. */ p_temp = strchr (p1 + 1, ';'); if (p_temp) - p = (unsigned char *) p_temp; + p = p_temp; } } else @@ -2939,7 +2939,7 @@ Packet: '%s'\n"), Packet: '%s'\n"), phex_nz (pnum, 0), p, buf); - fieldsize = hex2bin (p, regs, + fieldsize = hex2bin (p, regs, register_size (current_gdbarch, reg->regnum)); p += 2 * fieldsize; @@ -3019,7 +3019,7 @@ static ptid_t remote_async_wait (ptid_t ptid, struct target_waitstatus *status) { struct remote_state *rs = get_remote_state (); - unsigned char *buf = alloca (rs->remote_packet_size); + char *buf = alloca (rs->remote_packet_size); ULONGEST thread_num = -1; ULONGEST addr; @@ -3030,7 +3030,7 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status) while (1) { - unsigned char *p; + char *p; if (!target_is_async_p ()) ofunc = signal (SIGINT, remote_interrupt); @@ -3057,7 +3057,7 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status) continue; case 'T': /* Status with PC, SP, FP, ... */ { - char regs[MAX_REGISTER_SIZE]; + gdb_byte regs[MAX_REGISTER_SIZE]; /* Expedited reply, containing Signal, {regno, reg} repeat. */ /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where @@ -3069,7 +3069,7 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status) while (*p) { - unsigned char *p1; + char *p1; char *p_temp; int fieldsize; long pnum = 0; @@ -3085,14 +3085,14 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status) { /* Read the register number. */ pnum = strtol (p, &p_temp, 16); - p1 = (unsigned char *) p_temp; + p1 = p_temp; } else p1 = p; if (p1 == p) /* No register number present here. */ { - p1 = (unsigned char *) strchr (p, ':'); + p1 = strchr (p, ':'); if (p1 == NULL) error (_("Malformed packet(a) (missing colon): %s\n\ Packet: '%s'\n"), @@ -3101,7 +3101,7 @@ Packet: '%s'\n"), { p_temp = unpack_varlen_hex (++p1, &thread_num); record_currthread (thread_num); - p = (unsigned char *) p_temp; + p = p_temp; } else if ((strncmp (p, "watch", p1 - p) == 0) || (strncmp (p, "rwatch", p1 - p) == 0) @@ -3114,7 +3114,7 @@ Packet: '%s'\n"), else { /* Silently skip unknown optional info. */ - p_temp = (unsigned char *) strchr (p1 + 1, ';'); + p_temp = strchr (p1 + 1, ';'); if (p_temp) p = p_temp; } @@ -3134,7 +3134,7 @@ Packet: '%s'\n"), Packet: '%s'\n"), pnum, p, buf); - fieldsize = hex2bin (p, regs, + fieldsize = hex2bin (p, regs, register_size (current_gdbarch, reg->regnum)); p += 2 * fieldsize; @@ -3405,7 +3405,7 @@ remote_prepare_to_store (void) { struct remote_state *rs = get_remote_state (); int i; - char buf[MAX_REGISTER_SIZE]; + gdb_byte buf[MAX_REGISTER_SIZE]; /* Make sure the entire registers array is valid. */ switch (remote_protocol_P.support) @@ -3432,7 +3432,7 @@ store_register_using_P (int regnum) struct packet_reg *reg = packet_reg_from_regnum (rs, regnum); /* Try storing a single register. */ char *buf = alloca (rs->remote_packet_size); - char regp[MAX_REGISTER_SIZE]; + gdb_byte regp[MAX_REGISTER_SIZE]; char *p; xsnprintf (buf, rs->remote_packet_size, "P%s=", phex_nz (reg->pnum, 0)); @@ -3453,7 +3453,7 @@ remote_store_registers (int regnum) { struct remote_state *rs = get_remote_state (); char *buf; - char *regs; + gdb_byte *regs; char *p; set_thread (PIDGET (inferior_ptid), 1); @@ -3637,17 +3637,17 @@ check_binary_download (CORE_ADDR addr) error. Only transfer a single packet. */ int -remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len) +remote_write_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len) { - unsigned char *buf; - unsigned char *p; - unsigned char *plen; + char *buf; + char *p; + char *plen; long sizeof_buf; int plenlen; int todo; int nr_bytes; int payload_size; - unsigned char *payload_start; + char *payload_start; /* Verify that the target can support a binary download. */ check_binary_download (memaddr); @@ -3797,7 +3797,7 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len) handling partial reads. */ int -remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len) +remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len) { char *buf; int max_buf_size; /* Max size of packet output buffer. */ @@ -5078,9 +5078,9 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object, if (i < 0) return i; - getpkt (readbuf, len, 0); + getpkt ((char *) readbuf, len, 0); - return strlen (readbuf); + return strlen ((char *) readbuf); } static void @@ -5106,7 +5106,7 @@ remote_rcmd (char *command, error (_("\"monitor\" command ``%s'' is too long."), command); /* Encode the actual command. */ - bin2hex (command, p, 0); + bin2hex ((gdb_byte *) command, p, 0); if (putpkt (buf) < 0) error (_("Communication problem with target.")); diff --git a/gdb/remote.h b/gdb/remote.h index 65d2a1d6021..c457fc6a489 100644 --- a/gdb/remote.h +++ b/gdb/remote.h @@ -54,9 +54,9 @@ extern void remote_cisco_objfile_relocate (bfd_signed_vma text_off, extern void async_remote_interrupt_twice (void *arg); -extern int remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len); +extern int remote_write_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len); -extern int remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len); +extern int remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len); extern void (*deprecated_target_resume_hook) (void); extern void (*deprecated_target_wait_loop_hook) (void); -- 2.30.2