X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fremote.c;h=3c544502a85a5db4c6ea52fc2aa56f6c8fa8477e;hb=d9fa87f4f6e732f5feb41f2fa7dc6faddb1fb627;hp=5e1745db44e2b45d24b0fa136c798763945d211d;hpb=85102364b2d1845fe9ae7d70096671a3ea4bccf3;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/remote.c b/gdb/remote.c index 5e1745db44..3c544502a8 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -75,6 +75,7 @@ #include "gdbsupport/scoped_restore.h" #include "gdbsupport/environ.h" #include "gdbsupport/byte-vector.h" +#include #include /* The remote target. */ @@ -1040,11 +1041,6 @@ static struct cmd_list_element *remote_show_cmdlist; static bool use_range_stepping = true; -/* The max number of chars in debug output. The rest of chars are - omitted. */ - -#define REMOTE_DEBUG_MAX_CHAR 512 - /* Private data that we'll store in (struct thread_info)->priv. */ struct remote_thread_info : public private_thread_info { @@ -1275,22 +1271,6 @@ show_remote_exec_file (struct ui_file *file, int from_tty, fprintf_filtered (file, "%s\n", remote_exec_file_var); } -static int -compare_pnums (const void *lhs_, const void *rhs_) -{ - const struct packet_reg * const *lhs - = (const struct packet_reg * const *) lhs_; - const struct packet_reg * const *rhs - = (const struct packet_reg * const *) rhs_; - - if ((*lhs)->pnum < (*rhs)->pnum) - return -1; - else if ((*lhs)->pnum == (*rhs)->pnum) - return 0; - else - return 1; -} - static int map_regcache_remote_table (struct gdbarch *gdbarch, struct packet_reg *regs) { @@ -1321,8 +1301,9 @@ map_regcache_remote_table (struct gdbarch *gdbarch, struct packet_reg *regs) if (regs[regnum].pnum != -1) remote_regs[num_remote_regs++] = ®s[regnum]; - qsort (remote_regs, num_remote_regs, sizeof (struct packet_reg *), - compare_pnums); + std::sort (remote_regs, remote_regs + num_remote_regs, + [] (const packet_reg *a, const packet_reg *b) + { return a->pnum < b->pnum; }); for (regnum = 0, offset = 0; regnum < num_remote_regs; regnum++) { @@ -1726,6 +1707,23 @@ show_hardware_breakpoint_limit (struct ui_file *file, int from_tty, "breakpoints is %s.\n"), value); } +/* Controls the maximum number of characters to display in the debug output + for each remote packet. The remaining characters are omitted. */ + +static int remote_packet_max_chars = 512; + +/* Show the maximum number of characters to display for each remote packet + when remote debugging is enabled. */ + +static void +show_remote_packet_max_chars (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("Number of remote packet characters to " + "display is %s.\n"), value); +} + long remote_target::get_memory_write_packet_size () { @@ -2843,7 +2841,7 @@ remote_target::thread_name (struct thread_info *info) /* About these extended threadlist and threadinfo packets. They are variable length packets but, the fields within them are often fixed - length. They are redundent enough to send over UDP as is the + length. They are redundant enough to send over UDP as is the remote protocol in general. There is a matching unit test module in libstub. */ @@ -5058,7 +5056,7 @@ remote_target::remote_packet_size (const protocol_feature *feature, rs->explicit_packet_size = packet_size; } -void +static void remote_packet_size (remote_target *remote, const protocol_feature *feature, enum packet_support support, const char *value) { @@ -5183,7 +5181,8 @@ register_remote_support_xml (const char *xml) else { char *copy = xstrdup (remote_support_xml + 13); - char *p = strtok (copy, ","); + char *saveptr; + char *p = strtok_r (copy, ",", &saveptr); do { @@ -5194,7 +5193,7 @@ register_remote_support_xml (const char *xml) return; } } - while ((p = strtok (NULL, ",")) != NULL); + while ((p = strtok_r (NULL, ",", &saveptr)) != NULL); xfree (copy); remote_support_xml = reconcat (remote_support_xml, @@ -5793,7 +5792,7 @@ extended_remote_target::attach (const char *args, int from_tty) if (from_tty) { - char *exec_file = get_exec_file (0); + const char *exec_file = get_exec_file (0); if (exec_file) printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file, @@ -6827,7 +6826,7 @@ remote_target::stop_reply_queue_length () return rs->stop_reply_queue.size (); } -void +static void remote_notif_stop_parse (remote_target *remote, struct notif_client *self, const char *buf, struct notif_event *event) @@ -9132,15 +9131,21 @@ remote_target::putpkt_binary (const char *buf, int cnt) *p = '\0'; int len = (int) (p - buf2); + int max_chars; + + if (remote_packet_max_chars < 0) + max_chars = len; + else + max_chars = remote_packet_max_chars; std::string str - = escape_buffer (buf2, std::min (len, REMOTE_DEBUG_MAX_CHAR)); + = escape_buffer (buf2, std::min (len, max_chars)); fprintf_unfiltered (gdb_stdlog, "Sending packet: %s", str.c_str ()); - if (len > REMOTE_DEBUG_MAX_CHAR) + if (len > max_chars) fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]", - len - REMOTE_DEBUG_MAX_CHAR); + len - max_chars); fprintf_unfiltered (gdb_stdlog, "..."); @@ -9576,16 +9581,23 @@ remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf, { if (remote_debug) { + int max_chars; + + if (remote_packet_max_chars < 0) + max_chars = val; + else + max_chars = remote_packet_max_chars; + std::string str = escape_buffer (buf->data (), - std::min (val, REMOTE_DEBUG_MAX_CHAR)); + std::min (val, max_chars)); fprintf_unfiltered (gdb_stdlog, "Packet received: %s", str.c_str ()); - if (val > REMOTE_DEBUG_MAX_CHAR) + if (val > max_chars) fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]", - val - REMOTE_DEBUG_MAX_CHAR); + val - max_chars); fprintf_unfiltered (gdb_stdlog, "\n"); } @@ -14736,6 +14748,14 @@ of time passes without a response from the target, an error occurs."), show_watchdog, &setlist, &showlist); + add_setshow_zuinteger_unlimited_cmd ("remote-packet-max-chars", no_class, + &remote_packet_max_chars, _("\ +Set the maximum number of characters to display for each remote packet."), _("\ +Show the maximum number of characters to display for each remote packet."), _("\ +Specify \"unlimited\" to display all the characters."), + NULL, show_remote_packet_max_chars, + &setdebuglist, &showdebuglist); + /* Eventually initialize fileio. See fileio.c */ initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist); }