* gdb.base/attach.exp (do_attach_tests): Don't forget to kill second
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index 855a5b23b422bbcb8f4a9b3930b034b59da898f0..a6d700df045f89d6f112ce1fbd6e01c92249d323 100644 (file)
@@ -1,7 +1,7 @@
 /* Tracing functionality for remote targets in custom GDB protocol
 
-   Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
-   Foundation, Inc.
+   Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "completer.h"
 #include "gdb-events.h"
 #include "block.h"
+#include "dictionary.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
 
 /* readline include files */
-#include <readline/readline.h>
-#include <readline/history.h>
+#include "readline/readline.h"
+#include "readline/history.h"
 
 /* readline defines this.  */
 #undef savestring
@@ -64,9 +65,9 @@
 #define MAX_AGENT_EXPR_LEN     184
 
 
-extern void (*readline_begin_hook) (char *, ...);
-extern char *(*readline_hook) (char *);
-extern void (*readline_end_hook) (void);
+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? */
 
@@ -265,7 +266,7 @@ set_traceframe_context (CORE_ADDR trace_pc)
       set_internalvar (lookup_internalvar ("trace_file"),
                       value_from_pointer (charstar, (LONGEST) 0));
       set_internalvar (lookup_internalvar ("trace_line"),
-                      value_from_pointer (builtin_type_int, (LONGEST) - 1));
+                      value_from_longest (builtin_type_int, (LONGEST) - 1));
       return;
     }
 
@@ -333,7 +334,7 @@ set_traceframe_context (CORE_ADDR trace_pc)
 static struct tracepoint *
 set_raw_tracepoint (struct symtab_and_line sal)
 {
-  register struct tracepoint *t, *tc;
+  struct tracepoint *t, *tc;
   struct cleanup *old_chain;
 
   t = (struct tracepoint *) xmalloc (sizeof (struct tracepoint));
@@ -391,7 +392,7 @@ trace_command (char *arg, int from_tty)
     printf_filtered ("TRACE %s\n", arg);
 
   addr_start = arg;
-  sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical);
+  sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical, NULL);
   addr_end = arg;
   if (!sals.nelts)
     return;                    /* ??? Presumably decode_line_1 has already warned? */
@@ -786,8 +787,8 @@ trace_actions_command (char *args, int from_tty)
 
       if (from_tty)
        {
-         if (readline_begin_hook)
-           (*readline_begin_hook) ("%s  %s\n", tmpbuf, end_msg);
+         if (deprecated_readline_begin_hook)
+           (*deprecated_readline_begin_hook) ("%s  %s\n", tmpbuf, end_msg);
          else if (input_from_terminal_p ())
            printf_filtered ("%s\n%s\n", tmpbuf, end_msg);
        }
@@ -796,8 +797,8 @@ trace_actions_command (char *args, int from_tty)
       t->step_count = 0;       /* read_actions may set this */
       read_actions (t);
 
-      if (readline_end_hook)
-       (*readline_end_hook) ();
+      if (deprecated_readline_end_hook)
+       (*deprecated_readline_end_hook) ();
       /* tracepoints_changed () */
     }
   /* else just return */
@@ -841,8 +842,8 @@ read_actions (struct tracepoint *t)
       gdb_flush (gdb_stdout);
       gdb_flush (gdb_stderr);
 
-      if (readline_hook && instream == NULL)
-       line = (*readline_hook) (prompt);
+      if (deprecated_readline_hook && instream == NULL)
+       line = (*deprecated_readline_hook) (prompt);
       else if (instream == stdin && ISATTY (instream))
        {
          line = gdb_readline_wrapper (prompt);
@@ -913,6 +914,10 @@ validate_actionline (char **line, struct tracepoint *t)
   struct cleanup *old_chain = NULL;
   char *p;
 
+  /* if EOF is typed, *line is NULL */
+  if (*line == NULL)
+    return END;
+
   for (p = *line; isspace ((int) *p);)
     p++;
 
@@ -1115,7 +1120,7 @@ memrange_sortmerge (struct collection_list *memranges)
        {
          if (memranges->list[a].type == memranges->list[b].type &&
              memranges->list[b].start - memranges->list[a].end <=
-             MAX_REGISTER_VIRTUAL_SIZE)
+             MAX_REGISTER_SIZE)
            {
              /* memrange b starts before memrange a ends; merge them.  */
              if (memranges->list[b].end > memranges->list[a].end)
@@ -1214,7 +1219,7 @@ collect_symbol (struct collection_list *collect, struct symbol *sym,
       /* check for doubles stored in two registers */
       /* FIXME: how about larger types stored in 3 or more regs? */
       if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT &&
-         len > REGISTER_RAW_SIZE (reg))
+         len > DEPRECATED_REGISTER_RAW_SIZE (reg))
        add_register (collect, reg + 1);
       break;
     case LOC_REF_ARG:
@@ -1289,13 +1294,14 @@ add_local_symbols (struct collection_list *collect, CORE_ADDR pc,
 {
   struct symbol *sym;
   struct block *block;
-  int i, count = 0;
+  struct dict_iterator iter;
+  int count = 0;
 
   block = block_for_pc (pc);
   while (block != 0)
     {
       QUIT;                    /* allow user to bail out with ^C */
-      ALL_BLOCK_SYMBOLS (block, i, sym)
+      ALL_BLOCK_SYMBOLS (block, iter, sym)
        {
          switch (SYMBOL_CLASS (sym))
            {
@@ -1687,7 +1693,7 @@ remote_set_transparent_ranges (void)
 
       anysecs = 1;
       lma = s->lma;
-      size = bfd_get_section_size_before_reloc (s);
+      size = bfd_get_section_size (s);
       sprintf_vma (tmp1, lma);
       sprintf_vma (tmp2, lma + size);
       sprintf (target_buf + strlen (target_buf), 
@@ -1798,8 +1804,8 @@ trace_start_command (char *args, int from_tty)
       set_tracepoint_num (-1);
       set_traceframe_context (-1);
       trace_running_p = 1;
-      if (trace_start_stop_hook)
-       trace_start_stop_hook (1, from_tty);
+      if (deprecated_trace_start_stop_hook)
+       deprecated_trace_start_stop_hook (1, from_tty);
 
     }
   else
@@ -1817,8 +1823,8 @@ trace_stop_command (char *args, int from_tty)
       if (strcmp (target_buf, "OK"))
        error ("Bogus reply from target: %s", target_buf);
       trace_running_p = 0;
-      if (trace_start_stop_hook)
-       trace_start_stop_hook (0, from_tty);
+      if (deprecated_trace_start_stop_hook)
+       deprecated_trace_start_stop_hook (0, from_tty);
     }
   else
     error ("Trace can only be run on remote targets.");
@@ -1929,7 +1935,7 @@ finish_tfind_command (char *msg,
 
   if (from_tty)
     {
-      int source_only;
+      enum print_what print_what;
 
       /* NOTE: in immitation of the step command, try to determine
          whether we have made a transition from one function to another.
@@ -1945,13 +1951,11 @@ finish_tfind_command (char *msg,
          (old_frame_addr == 0 ||
           get_frame_base (get_current_frame ()) == 0 ||
           old_frame_addr == get_frame_base (get_current_frame ())))
-       source_only = -1;
+       print_what = SRC_LINE;
       else
-       source_only = 1;
+       print_what = SRC_AND_LOC;
 
-      print_stack_frame (deprecated_selected_frame,
-                        frame_relative_level (deprecated_selected_frame),
-                        source_only);
+      print_stack_frame (get_selected_frame (), 1, print_what);
       do_displays ();
     }
 }
@@ -1979,8 +1983,8 @@ trace_find_command (char *args, int from_tty)
 
   if (target_is_remote ())
     {
-      if (trace_find_hook)
-       trace_find_hook (args, from_tty);
+      if (deprecated_trace_find_hook)
+       deprecated_trace_find_hook (args, from_tty);
 
       if (args == 0 || *args == 0)
        {                       /* TFIND with no args means find NEXT trace frame. */
@@ -2333,14 +2337,15 @@ scope_info (char *args, int from_tty)
   struct minimal_symbol *msym;
   struct block *block;
   char **canonical, *symname, *save_args = args;
-  int i, j, count = 0;
+  struct dict_iterator iter;
+  int j, count = 0;
 
   if (args == 0 || *args == 0)
     error ("requires an argument (function, line or *addr) to define a scope");
 
-  sals = decode_line_1 (&args, 1, NULL, 0, &canonical);
+  sals = decode_line_1 (&args, 1, NULL, 0, &canonical, NULL);
   if (sals.nelts == 0)
-    return;                    /* presumably decode_line_1 has already warned */
+    return;            /* presumably decode_line_1 has already warned */
 
   /* Resolve line numbers to PC */
   resolve_sal_pc (&sals.sals[0]);
@@ -2349,7 +2354,7 @@ scope_info (char *args, int from_tty)
   while (block != 0)
     {
       QUIT;                    /* allow user to bail out with ^C */
-      ALL_BLOCK_SYMBOLS (block, i, sym)
+      ALL_BLOCK_SYMBOLS (block, iter, sym)
        {
          QUIT;                 /* allow user to bail out with ^C */
          if (count == 0)
@@ -2382,7 +2387,8 @@ scope_info (char *args, int from_tty)
              break;
            case LOC_STATIC:
              printf_filtered ("in static storage at address ");
-             print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
+             print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 
+                                    1, gdb_stdout);
              break;
            case LOC_REGISTER:
              printf_filtered ("a local variable in register $%s",
@@ -2414,12 +2420,13 @@ scope_info (char *args, int from_tty)
              continue;
            case LOC_LABEL:
              printf_filtered ("a label at address ");
-             print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
+             print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 
+                                    1, gdb_stdout);
              break;
            case LOC_BLOCK:
              printf_filtered ("a function at address ");
-             print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), 1,
-                                    gdb_stdout);
+             print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
+                                    1, gdb_stdout);
              break;
            case LOC_BASEREG:
              printf_filtered ("a variable at offset %ld from register $%s",
@@ -2432,7 +2439,8 @@ scope_info (char *args, int from_tty)
                               REGISTER_NAME (SYMBOL_BASEREG (sym)));
              break;
            case LOC_UNRESOLVED:
-             msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, NULL);
+             msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), 
+                                           NULL, NULL);
              if (msym == NULL)
                printf_filtered ("Unresolved Static");
              else
@@ -2445,10 +2453,22 @@ scope_info (char *args, int from_tty)
            case LOC_OPTIMIZED_OUT:
              printf_filtered ("optimized out.\n");
              continue;
+           case LOC_HP_THREAD_LOCAL_STATIC:
+             printf_filtered ("HP thread local static ");
+             break;
+           case LOC_INDIRECT:
+             printf_filtered ("extern (local indirect) at address ");
+             print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 
+                                    1, gdb_stdout);
+             break;
+           case LOC_COMPUTED:
+           case LOC_COMPUTED_ARG:
+             SYMBOL_OPS (sym)->describe_location (sym, gdb_stdout);
+             break;
            }
          if (SYMBOL_TYPE (sym))
            printf_filtered (", length %d.\n",
-                          TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym))));
+                            TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym))));
        }
       if (BLOCK_FUNCTION (block))
        break;
@@ -2508,7 +2528,7 @@ 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 ());
+  stepping_frame = (t->address != (read_pc () - DECR_PC_AFTER_BREAK));
 
   for (action = t->actions; action; action = action->next)
     {
This page took 0.029078 seconds and 4 git commands to generate.