diff options
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 4b911723ed..8484dafeb6 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -194,13 +194,15 @@ trace_error (char *buf) /* Utility: wait for reply from stub, while accepting "O" packets. */ static char * -remote_get_noisy_reply (char *buf, - long sizeof_buf) +remote_get_noisy_reply (char **buf_p, + long *sizeof_buf) { do /* Loop on reply from remote stub. */ { + char *buf; QUIT; /* allow user to bail out with ^C */ - getpkt (buf, sizeof_buf, 0); + getpkt (buf_p, sizeof_buf, 0); + buf = *buf_p; if (buf[0] == 0) error (_("Target does not support this command.")); else if (buf[0] == 'E') @@ -1700,7 +1702,8 @@ add_aexpr (struct collection_list *collect, struct agent_expr *aexpr) collect->next_aexpr_elt++; } -static char target_buf[2048]; +static char *target_buf; +static long target_buf_size; /* Set "transparent" memory ranges @@ -1742,7 +1745,7 @@ remote_set_transparent_ranges (void) if (anysecs) { putpkt (target_buf); - getpkt (target_buf, sizeof (target_buf), 0); + getpkt (&target_buf, &target_buf_size, 0); } } @@ -1768,7 +1771,7 @@ trace_start_command (char *args, int from_tty) if (target_is_remote ()) { putpkt ("QTinit"); - remote_get_noisy_reply (target_buf, sizeof (target_buf)); + remote_get_noisy_reply (&target_buf, &target_buf_size); if (strcmp (target_buf, "OK")) error (_("Target does not support this command.")); @@ -1785,7 +1788,7 @@ trace_start_command (char *args, int from_tty) if (t->actions) strcat (buf, "-"); putpkt (buf); - remote_get_noisy_reply (target_buf, sizeof (target_buf)); + remote_get_noisy_reply (&target_buf, &target_buf_size); if (strcmp (target_buf, "OK")) error (_("Target does not support tracepoints.")); @@ -1809,8 +1812,8 @@ trace_start_command (char *args, int from_tty) ((tdp_actions[ndx + 1] || stepping_actions) ? '-' : 0)); putpkt (buf); - remote_get_noisy_reply (target_buf, - sizeof (target_buf)); + remote_get_noisy_reply (&target_buf, + &target_buf_size); if (strcmp (target_buf, "OK")) error (_("Error on target while setting tracepoints.")); } @@ -1826,8 +1829,8 @@ trace_start_command (char *args, int from_tty) stepping_actions[ndx], (stepping_actions[ndx + 1] ? "-" : "")); putpkt (buf); - remote_get_noisy_reply (target_buf, - sizeof (target_buf)); + remote_get_noisy_reply (&target_buf, + &target_buf_size); if (strcmp (target_buf, "OK")) error (_("Error on target while setting tracepoints.")); } @@ -1840,7 +1843,7 @@ trace_start_command (char *args, int from_tty) remote_set_transparent_ranges (); /* Now insert traps and begin collecting data. */ putpkt ("QTStart"); - remote_get_noisy_reply (target_buf, sizeof (target_buf)); + remote_get_noisy_reply (&target_buf, &target_buf_size); if (strcmp (target_buf, "OK")) error (_("Bogus reply from target: %s"), target_buf); set_traceframe_num (-1); /* All old traceframes invalidated. */ @@ -1862,7 +1865,7 @@ trace_stop_command (char *args, int from_tty) if (target_is_remote ()) { putpkt ("QTStop"); - remote_get_noisy_reply (target_buf, sizeof (target_buf)); + remote_get_noisy_reply (&target_buf, &target_buf_size); if (strcmp (target_buf, "OK")) error (_("Bogus reply from target: %s"), target_buf); trace_running_p = 0; @@ -1882,7 +1885,7 @@ trace_status_command (char *args, int from_tty) if (target_is_remote ()) { putpkt ("qTStatus"); - remote_get_noisy_reply (target_buf, sizeof (target_buf)); + remote_get_noisy_reply (&target_buf, &target_buf_size); if (target_buf[0] != 'T' || (target_buf[1] != '0' && target_buf[1] != '1')) @@ -1897,8 +1900,8 @@ trace_status_command (char *args, int from_tty) /* Worker function for the various flavors of the tfind command. */ static void -finish_tfind_command (char *msg, - long sizeof_msg, +finish_tfind_command (char **msg, + long *sizeof_msg, int from_tty) { int target_frameno = -1, target_tracept = -1; @@ -1909,7 +1912,7 @@ finish_tfind_command (char *msg, old_frame_addr = get_frame_base (get_current_frame ()); old_func = find_pc_function (read_pc ()); - putpkt (msg); + putpkt (*msg); reply = remote_get_noisy_reply (msg, sizeof_msg); while (reply && *reply) @@ -2054,7 +2057,7 @@ trace_find_command (char *args, int from_tty) error (_("invalid input (%d is less than zero)"), frameno); sprintf (target_buf, "QTFrame:%x", frameno); - finish_tfind_command (target_buf, sizeof (target_buf), from_tty); + finish_tfind_command (&target_buf, &target_buf_size, from_tty); } else error (_("Trace can only be run on remote targets.")); @@ -2097,7 +2100,7 @@ trace_find_pc_command (char *args, int from_tty) sprintf_vma (tmp, pc); sprintf (target_buf, "QTFrame:pc:%s", tmp); - finish_tfind_command (target_buf, sizeof (target_buf), from_tty); + finish_tfind_command (&target_buf, &target_buf_size, from_tty); } else error (_("Trace can only be run on remote targets.")); @@ -2122,7 +2125,7 @@ trace_find_tracepoint_command (char *args, int from_tty) tdp = parse_and_eval_long (args); sprintf (target_buf, "QTFrame:tdp:%x", tdp); - finish_tfind_command (target_buf, sizeof (target_buf), from_tty); + finish_tfind_command (&target_buf, &target_buf_size, from_tty); } else error (_("Trace can only be run on remote targets.")); @@ -2220,7 +2223,7 @@ trace_find_line_command (char *args, int from_tty) else sprintf (target_buf, "QTFrame:outside:%s:%s", startpc_str, endpc_str); - finish_tfind_command (target_buf, sizeof (target_buf), + finish_tfind_command (&target_buf, &target_buf_size, from_tty); do_cleanups (old_chain); } @@ -2261,7 +2264,7 @@ trace_find_range_command (char *args, int from_tty) sprintf_vma (start_str, start); sprintf_vma (stop_str, stop); sprintf (target_buf, "QTFrame:range:%s:%s", start_str, stop_str); - finish_tfind_command (target_buf, sizeof (target_buf), from_tty); + finish_tfind_command (&target_buf, &target_buf_size, from_tty); } else error (_("Trace can only be run on remote targets.")); @@ -2300,7 +2303,7 @@ trace_find_outside_command (char *args, int from_tty) sprintf_vma (start_str, start); sprintf_vma (stop_str, stop); sprintf (target_buf, "QTFrame:outside:%s:%s", start_str, stop_str); - finish_tfind_command (target_buf, sizeof (target_buf), from_tty); + finish_tfind_command (&target_buf, &target_buf_size, from_tty); } else error (_("Trace can only be run on remote targets.")); @@ -2867,4 +2870,7 @@ Do \"help tracepoints\" for info on other tracepoint commands.")); add_com_alias ("tr", "trace", class_alias, 1); add_com_alias ("tra", "trace", class_alias, 1); add_com_alias ("trac", "trace", class_alias, 1); + + target_buf_size = 2048; + target_buf = xmalloc (target_buf_size); } |