summaryrefslogtreecommitdiffstats
path: root/gdb/tracepoint.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-03-30 16:25:06 +0000
committerDaniel Jacobowitz <drow@false.org>2006-03-30 16:25:06 +0000
commit6d820c5c12929725ad4fdc7e9e8b3b02af1df932 (patch)
tree258c9384fce4a9dc330f40c14c5ae3d190a55d12 /gdb/tracepoint.c
parentbd717df8b1f4a9e0786a229211df6b0c523fe5ce (diff)
downloadppe42-binutils-6d820c5c12929725ad4fdc7e9e8b3b02af1df932.tar.gz
ppe42-binutils-6d820c5c12929725ad4fdc7e9e8b3b02af1df932.zip
* remote.c (struct remote_state): Add BUF and BUF_SIZE.
(init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r--gdb/tracepoint.c52
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);
}
OpenPOWER on IntegriCloud