2003-02-19 David Carlton <carlton@math.stanford.edu>
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index 7e2f112daaaba444eb0d2eb6403c186a9f96ba8b..58ca98fbb3035f383037571a613a0251e185b9cc 100644 (file)
@@ -1,5 +1,7 @@
 /* Tracing functionality for remote targets in custom GDB protocol
-   Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,6 +37,7 @@
 #include "regcache.h"
 #include "completer.h"
 #include "gdb-events.h"
+#include "block.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
@@ -71,16 +74,6 @@ extern int addressprint;     /* Print machine addresses? */
  */  
 
 extern void output_command (char *, int);
-extern void registers_info (char *, int);
-extern void args_info (char *, int);
-extern void locals_info (char *, int);
-
-
-/* If this definition isn't overridden by the header files, assume
-   that isatty and fileno exist on this system.  */
-#ifndef ISATTY
-#define ISATTY(FP)     (isatty (fileno (FP)))
-#endif
 
 /* 
    Tracepoint.c:
@@ -188,7 +181,7 @@ trace_error (char *buf)
       if (*++buf == '0')       /*   general case: */
        error ("tracepoint.c: error in outgoing packet.");
       else
-       error ("tracepoint.c: error in outgoing packet at field #%d.",
+       error ("tracepoint.c: error in outgoing packet at field #%ld.",
               strtol (buf, NULL, 16));
     case '2':
       error ("trace API error 0x%s.", ++buf);
@@ -500,11 +493,11 @@ tracepoints_info (char *tpnum_exp, int from_tty)
          char *tmp;
 
          if (TARGET_ADDR_BIT <= 32)
-           tmp = longest_local_hex_string_custom (t->address
-                                                  & (CORE_ADDR) 0xffffffff, 
-                                                  "08l");
+           tmp = local_hex_string_custom (t->address
+                                          & (CORE_ADDR) 0xffffffff, 
+                                          "08l");
          else
-           tmp = longest_local_hex_string_custom (t->address, "016l");
+           tmp = local_hex_string_custom (t->address, "016l");
 
          printf_filtered ("%s ", tmp);
        }
@@ -852,7 +845,7 @@ read_actions (struct tracepoint *t)
        line = (*readline_hook) (prompt);
       else if (instream == stdin && ISATTY (instream))
        {
-         line = readline (prompt);
+         line = gdb_readline_wrapper (prompt);
          if (line && *line)    /* add it to command history */
            add_history (line);
        }
@@ -937,7 +930,7 @@ validate_actionline (char **line, struct tracepoint *t)
       return BADLINE;
     }
 
-  if (c->function.cfunc == collect_pseudocommand)
+  if (cmd_cfunc_eq (c, collect_pseudocommand))
     {
       struct agent_expr *aexpr;
       struct agent_reqs areqs;
@@ -1004,7 +997,7 @@ validate_actionline (char **line, struct tracepoint *t)
       while (p && *p++ == ',');
       return GENERIC;
     }
-  else if (c->function.cfunc == while_stepping_pseudocommand)
+  else if (cmd_cfunc_eq (c, while_stepping_pseudocommand))
     {
       char *steparg;           /* in case warning is necessary */
 
@@ -1020,7 +1013,7 @@ validate_actionline (char **line, struct tracepoint *t)
        }
       return STEPPING;
     }
-  else if (c->function.cfunc == end_actions_pseudocommand)
+  else if (cmd_cfunc_eq (c, end_actions_pseudocommand))
     return END;
   else
     {
@@ -1518,7 +1511,7 @@ encode_actions (struct tracepoint *t, char ***tdp_actions,
       if (cmd == 0)
        error ("Bad action list item: %s", action_exp);
 
-      if (cmd->function.cfunc == collect_pseudocommand)
+      if (cmd_cfunc_eq (cmd, collect_pseudocommand))
        {
          do
            {                   /* repeat over a comma-separated list */
@@ -1628,11 +1621,11 @@ encode_actions (struct tracepoint *t, char ***tdp_actions,
            }
          while (action_exp && *action_exp++ == ',');
        }                       /* if */
-      else if (cmd->function.cfunc == while_stepping_pseudocommand)
+      else if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
        {
          collect = &stepping_list;
        }
-      else if (cmd->function.cfunc == end_actions_pseudocommand)
+      else if (cmd_cfunc_eq (cmd, end_actions_pseudocommand))
        {
          if (collect == &stepping_list)        /* end stepping actions */
            collect = &tracepoint_list;
@@ -1864,7 +1857,7 @@ finish_tfind_command (char *msg,
   struct symbol *old_func;
   char *reply;
 
-  old_frame_addr = FRAME_FP (get_current_frame ());
+  old_frame_addr = get_frame_base (get_current_frame ());
   old_func = find_pc_function (read_pc ());
 
   putpkt (msg);
@@ -1926,7 +1919,7 @@ finish_tfind_command (char *msg,
 
   flush_cached_frames ();
   registers_changed ();
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
   set_traceframe_num (target_frameno);
   set_tracepoint_num (target_tracept);
   if (target_frameno == -1)
@@ -1950,13 +1943,15 @@ finish_tfind_command (char *msg,
 
       if (old_func == find_pc_function (read_pc ()) &&
          (old_frame_addr == 0 ||
-          FRAME_FP (get_current_frame ()) == 0 ||
-          old_frame_addr == FRAME_FP (get_current_frame ())))
+          get_frame_base (get_current_frame ()) == 0 ||
+          old_frame_addr == get_frame_base (get_current_frame ())))
        source_only = -1;
       else
        source_only = 1;
 
-      print_stack_frame (selected_frame, selected_frame_level, source_only);
+      print_stack_frame (deprecated_selected_frame,
+                        frame_relative_level (deprecated_selected_frame),
+                        source_only);
       do_displays ();
     }
 }
@@ -2068,10 +2063,12 @@ trace_find_tracepoint_command (char *args, int from_tty)
   if (target_is_remote ())
     {
       if (args == 0 || *args == 0)
-       if (tracepoint_number == -1)
-         error ("No current tracepoint -- please supply an argument.");
-       else
-         tdp = tracepoint_number;      /* default is current TDP */
+       {
+         if (tracepoint_number == -1)
+           error ("No current tracepoint -- please supply an argument.");
+         else
+           tdp = tracepoint_number;    /* default is current TDP */
+       }
       else
        tdp = parse_and_eval_long (args);
 
@@ -2103,7 +2100,7 @@ trace_find_line_command (char *args, int from_tty)
     {
       if (args == 0 || *args == 0)
        {
-         sal = find_pc_line ((get_current_frame ())->pc, 0);
+         sal = find_pc_line (get_frame_pc (get_current_frame ()), 0);
          sals.nelts = 1;
          sals.sals = (struct symtab_and_line *)
            xmalloc (sizeof (struct symtab_and_line));
@@ -2263,7 +2260,7 @@ tracepoint_save_command (char *args, int from_tty)
   struct action_line *line;
   FILE *fp;
   char *i1 = "    ", *i2 = "      ";
-  char *indent, *actionline;
+  char *indent, *actionline, *pathname;
   char tmp[40];
 
   if (args == 0 || *args == 0)
@@ -2275,9 +2272,12 @@ tracepoint_save_command (char *args, int from_tty)
       return;
     }
 
-  if (!(fp = fopen (args, "w")))
-    error ("Unable to open file '%s' for saving tracepoints");
-
+  pathname = tilde_expand (args);
+  if (!(fp = fopen (pathname, "w")))
+    error ("Unable to open file '%s' for saving tracepoints (%s)",
+          args, safe_strerror (errno));
+  xfree (pathname);
+  
   ALL_TRACEPOINTS (tp)
   {
     if (tp->addr_string)
@@ -2310,9 +2310,9 @@ tracepoint_save_command (char *args, int from_tty)
                cmd = lookup_cmd (&actionline, cmdlist, "", -1, 1);
                if (cmd == 0)
                  error ("Bad action list item: %s", actionline);
-               if (cmd->function.cfunc == while_stepping_pseudocommand)
+               if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
                  indent = i2;
-               else if (cmd->function.cfunc == end_actions_pseudocommand)
+               else if (cmd_cfunc_eq (cmd, end_actions_pseudocommand))
                  indent = i1;
              }
          }
@@ -2529,11 +2529,11 @@ trace_dump_command (char *args, int from_tty)
       if (cmd == 0)
        error ("Bad action list item: %s", action_exp);
 
-      if (cmd->function.cfunc == while_stepping_pseudocommand)
+      if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
        stepping_actions = 1;
-      else if (cmd->function.cfunc == end_actions_pseudocommand)
+      else if (cmd_cfunc_eq (cmd, end_actions_pseudocommand))
        stepping_actions = 0;
-      else if (cmd->function.cfunc == collect_pseudocommand)
+      else if (cmd_cfunc_eq (cmd, collect_pseudocommand))
        {
          /* Display the collected data.
             For the trap frame, display only what was collected at the trap.
@@ -2658,7 +2658,7 @@ _initialize_tracepoint (void)
   add_info ("scope", scope_info,
            "List the variables local to a scope");
 
-  add_cmd ("tracepoints", class_trace, NO_FUNCTION,
+  add_cmd ("tracepoints", class_trace, NULL,
           "Tracing of program execution without stopping the program.",
           &cmdlist);
 
@@ -2672,7 +2672,7 @@ last tracepoint set.");
   c = add_com ("save-tracepoints", class_trace, tracepoint_save_command,
               "Save current tracepoint definitions as a script.\n\
 Use the 'source' command in another debug session to restore them.");
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_com ("tdump", class_trace, trace_dump_command,
           "Print everything collected at the current tracepoint.");
@@ -2795,7 +2795,7 @@ Argument may be a line number, function name, or '*' plus an address.\n\
 For a line number or function, trace at the start of its code.\n\
 If an address is specified, trace at that exact address.\n\n\
 Do \"help tracepoints\" for info on other tracepoint commands.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_com_alias ("tp", "trace", class_alias, 0);
   add_com_alias ("tr", "trace", class_alias, 1);
This page took 0.031982 seconds and 4 git commands to generate.