Explicit locations: use new location API
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index 23eba323b1c7bc103bed02b75526437f293176e5..af553a325ca61eb82f3aa36f2c20724900ba5701 100644 (file)
@@ -1,6 +1,6 @@
 /* Tracing functionality for remote targets in custom GDB protocol
 
-   Copyright (C) 1997-2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,7 +28,6 @@
 #include "target.h"
 #include "target-dcache.h"
 #include "language.h"
-#include <string.h>
 #include "inferior.h"
 #include "breakpoint.h"
 #include "tracepoint.h"
 #include "ax.h"
 #include "ax-gdb.h"
 #include "memrange.h"
-#include "exceptions.h"
 #include "cli/cli-utils.h"
 #include "probe.h"
 #include "ctf.h"
 #include "filestuff.h"
 #include "rsp-low.h"
 #include "tracefile.h"
+#include "location.h"
 
 /* readline include files */
 #include "readline/readline.h"
@@ -653,7 +652,7 @@ trace_actions_command (char *args, int from_tty)
   struct tracepoint *t;
   struct command_line *l;
 
-  t = get_tracepoint_by_number (&args, NULL, 1);
+  t = get_tracepoint_by_number (&args, NULL);
   if (t)
     {
       char *tmpbuf =
@@ -1155,7 +1154,7 @@ add_local_symbols (struct collection_list *collect,
                   long frame_regno, long frame_offset, int type,
                   int trace_string)
 {
-  struct block *block;
+  const struct block *block;
   struct add_local_symbols_data cb_data;
 
   cb_data.collect = collect;
@@ -1860,8 +1859,11 @@ start_tracing (char *notes)
       t->number_on_target = b->number;
 
       for (loc = b->loc; loc; loc = loc->next)
-       if (loc->probe != NULL)
-         loc->probe->pops->set_semaphore (loc->probe, loc->gdbarch);
+       if (loc->probe.probe != NULL
+           && loc->probe.probe->pops->set_semaphore != NULL)
+         loc->probe.probe->pops->set_semaphore (loc->probe.probe,
+                                                loc->probe.objfile,
+                                                loc->gdbarch);
 
       if (bp_location_downloaded)
        observer_notify_breakpoint_modified (b);
@@ -1957,8 +1959,11 @@ stop_tracing (char *note)
             but we don't really care if this semaphore goes out of sync.
             That's why we are decrementing it here, but not taking care
             in other places.  */
-         if (loc->probe != NULL)
-           loc->probe->pops->clear_semaphore (loc->probe, loc->gdbarch);
+         if (loc->probe.probe != NULL
+             && loc->probe.probe->pops->clear_semaphore != NULL)
+           loc->probe.probe->pops->clear_semaphore (loc->probe.probe,
+                                                    loc->probe.objfile,
+                                                    loc->gdbarch);
        }
     }
 
@@ -2439,6 +2444,15 @@ tfind_1 (enum trace_find_type type, int num,
     }
 }
 
+/* Error on looking at traceframes while trace is running.  */
+
+void
+check_trace_running (struct trace_status *status)
+{
+  if (status->running && status->filename == NULL)
+    error (_("May not look at trace frames while trace is running."));
+}
+
 /* trace_find_command takes a trace frame number n, 
    sends "QTFrame:<n>" to the target, 
    and accepts a reply that may contain several optional pieces
@@ -2459,9 +2473,7 @@ trace_find_command (char *args, int from_tty)
 { /* This should only be called with a numeric argument.  */
   int frameno = -1;
 
-  if (current_trace_status ()->running
-      && current_trace_status ()->filename == NULL)
-    error (_("May not look at trace frames while trace is running."));
+  check_trace_running (current_trace_status ());
   
   if (args == 0 || *args == 0)
     { /* TFIND with no args means find NEXT trace frame.  */
@@ -2511,9 +2523,7 @@ trace_find_pc_command (char *args, int from_tty)
 {
   CORE_ADDR pc;
 
-  if (current_trace_status ()->running
-      && current_trace_status ()->filename == NULL)
-    error (_("May not look at trace frames while trace is running."));
+  check_trace_running (current_trace_status ());
 
   if (args == 0 || *args == 0)
     pc = regcache_read_pc (get_current_regcache ());
@@ -2530,9 +2540,7 @@ trace_find_tracepoint_command (char *args, int from_tty)
   int tdp;
   struct tracepoint *tp;
 
-  if (current_trace_status ()->running
-      && current_trace_status ()->filename == NULL)
-    error (_("May not look at trace frames while trace is running."));
+  check_trace_running (current_trace_status ());
 
   if (args == 0 || *args == 0)
     {
@@ -2570,9 +2578,7 @@ trace_find_line_command (char *args, int from_tty)
   struct symtab_and_line sal;
   struct cleanup *old_chain;
 
-  if (current_trace_status ()->running
-      && current_trace_status ()->filename == NULL)
-    error (_("May not look at trace frames while trace is running."));
+  check_trace_running (current_trace_status ());
 
   if (args == 0 || *args == 0)
     {
@@ -2636,9 +2642,7 @@ trace_find_range_command (char *args, int from_tty)
   static CORE_ADDR start, stop;
   char *tmp;
 
-  if (current_trace_status ()->running
-      && current_trace_status ()->filename == NULL)
-    error (_("May not look at trace frames while trace is running."));
+  check_trace_running (current_trace_status ());
 
   if (args == 0 || *args == 0)
     { /* XXX FIXME: what should default behavior be?  */
@@ -2701,22 +2705,30 @@ scope_info (char *args, int from_tty)
 {
   struct symtabs_and_lines sals;
   struct symbol *sym;
-  struct minimal_symbol *msym;
-  struct block *block;
+  struct bound_minimal_symbol msym;
+  const struct block *block;
   const char *symname;
   char *save_args = args;
   struct block_iterator iter;
   int j, count = 0;
   struct gdbarch *gdbarch;
   int regno;
+  struct event_location *location;
+  struct cleanup *back_to;
 
   if (args == 0 || *args == 0)
     error (_("requires an argument (function, "
             "line or *addr) to define a scope"));
 
-  sals = decode_line_1 (&args, DECODE_LINE_FUNFIRSTLINE, NULL, 0);
+  location = string_to_event_location (&args, current_language);
+  back_to = make_cleanup_delete_event_location (location);
+  sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, NULL, 0);
   if (sals.nelts == 0)
-    return;            /* Presumably decode_line_1 has already warned.  */
+    {
+      /* Presumably decode_line_1 has already warned.  */
+      do_cleanups (back_to);
+      return;
+    }
 
   /* Resolve line numbers to PC.  */
   resolve_sal_pc (&sals.sals[0]);
@@ -2736,7 +2748,7 @@ scope_info (char *args, int from_tty)
          if (symname == NULL || *symname == '\0')
            continue;           /* Probably botched, certainly useless.  */
 
-         gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
+         gdbarch = symbol_arch (sym);
 
          printf_filtered ("Symbol %s is ", symname);
 
@@ -2824,14 +2836,14 @@ scope_info (char *args, int from_tty)
                case LOC_UNRESOLVED:
                  msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym),
                                                NULL, NULL);
-                 if (msym == NULL)
+                 if (msym.minsym == NULL)
                    printf_filtered ("Unresolved Static");
                  else
                    {
                      printf_filtered ("static storage at address ");
                      printf_filtered ("%s",
                                       paddress (gdbarch,
-                                                SYMBOL_VALUE_ADDRESS (msym)));
+                                                BMSYMBOL_VALUE_ADDRESS (msym)));
                    }
                  break;
                case LOC_OPTIMIZED_OUT:
@@ -2853,6 +2865,7 @@ scope_info (char *args, int from_tty)
   if (count <= 0)
     printf_filtered ("Scope for %s contains no locals or arguments.\n",
                     save_args);
+  do_cleanups (back_to);
 }
 
 /* Helper for trace_dump_command.  Dump the action list starting at
@@ -3075,7 +3088,7 @@ trace_dump_command (char *args, int from_tty)
 
 extern int
 encode_source_string (int tpnum, ULONGEST addr,
-                     char *srctype, char *src, char *buf, int buf_size)
+                     char *srctype, const char *src, char *buf, int buf_size)
 {
   if (80 + strlen (srctype) > buf_size)
     error (_("Buffer too small for source encoding"));
@@ -3213,15 +3226,6 @@ set_current_traceframe (int num)
   clear_traceframe_info ();
 }
 
-/* Make the traceframe NUM be the current trace frame, and do nothing
-   more.  */
-
-void
-set_traceframe_number (int num)
-{
-  traceframe_number = num;
-}
-
 /* A cleanup used when switching away and back from tfind mode.  */
 
 struct current_traceframe_cleanup
@@ -3258,12 +3262,6 @@ make_cleanup_restore_current_traceframe (void)
                            restore_current_traceframe_cleanup_dtor);
 }
 
-struct cleanup *
-make_cleanup_restore_traceframe_number (void)
-{
-  return make_cleanup_restore_integer (&traceframe_number);
-}
-
 /* Given a number and address, return an uploaded tracepoint with that
    number, creating if necessary.  */
 
@@ -3842,11 +3840,11 @@ parse_tracepoint_definition (char *line, struct uploaded_tp **utpp)
       end = hex2bin (p, (gdb_byte *) buf, strlen (p) / 2);
       buf[end] = '\0';
 
-      if (strncmp (srctype, "at:", strlen ("at:")) == 0)
+      if (startswith (srctype, "at:"))
        utp->at_string = xstrdup (buf);
-      else if (strncmp (srctype, "cond:", strlen ("cond:")) == 0)
+      else if (startswith (srctype, "cond:"))
        utp->cond_string = xstrdup (buf);
-      else if (strncmp (srctype, "cmd:", strlen ("cmd:")) == 0)
+      else if (startswith (srctype, "cmd:"))
        VEC_safe_push (char_ptr, utp->cmd_strings, xstrdup (buf));
     }
   else if (piece == 'V')
This page took 0.028433 seconds and 4 git commands to generate.