Explicit locations: use new location API
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index c5221938e70a82db0184789ee0da0dda14f5b4c9..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"
@@ -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,7 +1859,8 @@ start_tracing (char *notes)
       t->number_on_target = b->number;
 
       for (loc = b->loc; loc; loc = loc->next)
-       if (loc->probe.probe != NULL)
+       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);
@@ -1959,7 +1959,8 @@ 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.probe != NULL)
+         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);
@@ -2705,21 +2706,29 @@ scope_info (char *args, int from_tty)
   struct symtabs_and_lines sals;
   struct symbol *sym;
   struct bound_minimal_symbol msym;
-  struct block *block;
+  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]);
@@ -2739,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);
 
@@ -2856,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
@@ -3078,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"));
@@ -3830,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.034044 seconds and 4 git commands to generate.