X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Ftracepoint.c;h=b9b9f5ee8c6ba2dbc46c9127d434aaee21407e95;hb=17a912b6825ef7feaad6d9b4f5419f045fe3c8d0;hp=4b911723edf8c02f6d48ccb9b06ba65e523ae91a;hpb=712e30207d7006ceaaad44ccffbc4ee6615c1e54;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 4b911723ed..b9b9f5ee8c 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1,7 +1,7 @@ /* Tracing functionality for remote targets in custom GDB protocol - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free - Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 Free Software Foundation, Inc. This file is part of GDB. @@ -68,7 +68,6 @@ extern void (*deprecated_readline_begin_hook) (char *, ...); extern char *(*deprecated_readline_hook) (char *); extern void (*deprecated_readline_end_hook) (void); -extern void x_command (char *, int); extern int addressprint; /* Print machine addresses? */ /* GDB commands implemented in other modules: @@ -194,13 +193,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') @@ -479,7 +480,7 @@ tracepoints_info (char *tpnum_exp, int from_tty) printf_filtered ("Num Enb "); if (addressprint) { - if (TARGET_ADDR_BIT <= 32) + if (gdbarch_addr_bit (current_gdbarch) <= 32) printf_filtered ("Address "); else printf_filtered ("Address "); @@ -489,7 +490,7 @@ tracepoints_info (char *tpnum_exp, int from_tty) strcpy (wrap_indent, " "); if (addressprint) { - if (TARGET_ADDR_BIT <= 32) + if (gdbarch_addr_bit (current_gdbarch) <= 32) strcat (wrap_indent, " "); else strcat (wrap_indent, " "); @@ -501,7 +502,7 @@ tracepoints_info (char *tpnum_exp, int from_tty) { char *tmp; - if (TARGET_ADDR_BIT <= 32) + if (gdbarch_addr_bit (current_gdbarch) <= 32) tmp = hex_string_custom (t->address & (CORE_ADDR) 0xffffffff, 8); else @@ -1538,7 +1539,8 @@ encode_actions (struct tracepoint *t, char ***tdp_actions, *tdp_actions = NULL; *stepping_actions = NULL; - TARGET_VIRTUAL_FRAME_POINTER (t->address, &frame_reg, &frame_offset); + gdbarch_virtual_frame_pointer (current_gdbarch, + t->address, &frame_reg, &frame_offset); for (action = t->actions; action; action = action->next) { @@ -1564,7 +1566,7 @@ encode_actions (struct tracepoint *t, char ***tdp_actions, if (0 == strncasecmp ("$reg", action_exp, 4)) { - for (i = 0; i < NUM_REGS; i++) + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) add_register (collect, i); action_exp = strchr (action_exp, ','); /* more? */ } @@ -1600,11 +1602,20 @@ encode_actions (struct tracepoint *t, char ***tdp_actions, switch (exp->elts[0].opcode) { case OP_REGISTER: - i = exp->elts[1].longconst; - if (info_verbose) - printf_filtered ("OP_REGISTER: "); - add_register (collect, i); - break; + { + const char *name = &exp->elts[2].string; + + i = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (), + name, strlen (name)); + if (i == -1) + internal_error (__FILE__, __LINE__, + _("Register $%s not available"), + name); + if (info_verbose) + printf_filtered ("OP_REGISTER: "); + add_register (collect, i); + break; + } case UNOP_MEMVAL: /* safe because we know it's a simple expression */ @@ -1700,7 +1711,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 +1754,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 +1780,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 +1797,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 +1821,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 +1838,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 +1852,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 +1874,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 +1894,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 +1909,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 +1921,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) @@ -1967,9 +1979,8 @@ finish_tfind_command (char *msg, error (_("Bogus reply from target: %s"), reply); } - flush_cached_frames (); + reinit_frame_cache (); registers_changed (); - select_frame (get_current_frame ()); set_traceframe_num (target_frameno); set_tracepoint_num (target_tracept); if (target_frameno == -1) @@ -2054,7 +2065,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 +2108,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 +2133,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 +2231,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 +2272,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 +2311,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.")); @@ -2442,7 +2453,8 @@ scope_info (char *args, int from_tty) break; case LOC_REGISTER: printf_filtered ("a local variable in register $%s", - REGISTER_NAME (SYMBOL_VALUE (sym))); + gdbarch_register_name + (current_gdbarch, SYMBOL_VALUE (sym))); break; case LOC_ARG: case LOC_LOCAL_ARG: @@ -2459,11 +2471,13 @@ scope_info (char *args, int from_tty) break; case LOC_REGPARM: printf_filtered ("an argument in register $%s", - REGISTER_NAME (SYMBOL_VALUE (sym))); + gdbarch_register_name + (current_gdbarch, SYMBOL_VALUE (sym))); break; case LOC_REGPARM_ADDR: printf_filtered ("the address of an argument, in register $%s", - REGISTER_NAME (SYMBOL_VALUE (sym))); + gdbarch_register_name + (current_gdbarch, SYMBOL_VALUE (sym))); break; case LOC_TYPEDEF: printf_filtered ("a typedef.\n"); @@ -2481,12 +2495,14 @@ scope_info (char *args, int from_tty) case LOC_BASEREG: printf_filtered ("a variable at offset %ld from register $%s", SYMBOL_VALUE (sym), - REGISTER_NAME (SYMBOL_BASEREG (sym))); + gdbarch_register_name + (current_gdbarch, SYMBOL_BASEREG (sym))); break; case LOC_BASEREG_ARG: printf_filtered ("an argument at offset %ld from register $%s", SYMBOL_VALUE (sym), - REGISTER_NAME (SYMBOL_BASEREG (sym))); + gdbarch_register_name + (current_gdbarch, SYMBOL_BASEREG (sym))); break; case LOC_UNRESOLVED: msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), @@ -2578,7 +2594,8 @@ trace_dump_command (char *args, int from_tty) to the tracepoint PC. If not, then the current frame was collected during single-stepping. */ - stepping_frame = (t->address != (read_pc () - DECR_PC_AFTER_BREAK)); + stepping_frame = (t->address != (read_pc () - gdbarch_decr_pc_after_break + (current_gdbarch))); for (action = t->actions; action; action = action->next) { @@ -2867,4 +2884,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); }