]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/tracepoint.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / tracepoint.c
index 39309eb70f7e985cf8f5cf034aeaf20fd44b5971..3ad005f1cabf3bd713948f9b08f4cd0763479465 100644 (file)
@@ -1,7 +1,7 @@
 /* Tracing functionality for remote targets in custom GDB protocol
 
-   Copyright 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.
 
@@ -17,8 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "symtab.h"
@@ -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')
@@ -1700,7 +1701,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 +1744,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 +1770,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 +1787,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 +1811,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 +1828,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 +1842,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 +1864,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 +1884,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 +1899,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 +1911,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 +2056,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 +2099,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 +2124,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 +2222,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 +2263,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 +2302,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."));
@@ -2318,7 +2320,7 @@ tracepoint_save_command (char *args, int from_tty)
   char tmp[40];
 
   if (args == 0 || *args == 0)
-    error (_("Argument required (file name in which to save tracepoints"));
+    error (_("Argument required (file name in which to save tracepoints)"));
 
   if (tracepoint_chain == 0)
     {
@@ -2694,11 +2696,6 @@ _initialize_tracepoint (void)
   traceframe_number = -1;
   tracepoint_number = -1;
 
-  set_internalvar (lookup_internalvar ("tpnum"),
-                  value_from_longest (builtin_type_int, (LONGEST) 0));
-  set_internalvar (lookup_internalvar ("trace_frame"),
-                  value_from_longest (builtin_type_int, (LONGEST) - 1));
-
   if (tracepoint_list.list == NULL)
     {
       tracepoint_list.listsize = 128;
@@ -2872,4 +2869,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);
 }