* doc/binutils.texi (c++filt): Remove spurious description of
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index dcd3df79016499e185b9f05e33e7e8dc19f99fdc..0d439efd3f81d13a3731586e366cc3902f8565eb 100644 (file)
@@ -19,6 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "symtab.h"
 #include "frame.h"
 #include "gdbtypes.h"
@@ -32,6 +33,7 @@
 #include "breakpoint.h"
 #include "tracepoint.h"
 #include "remote.h"
+extern int remote_supports_cond_tracepoints (void);
 #include "linespec.h"
 #include "regcache.h"
 #include "completer.h"
@@ -722,6 +724,7 @@ add_memrange (struct collection_list *memranges,
 static void
 collect_symbol (struct collection_list *collect, 
                struct symbol *sym,
+               struct gdbarch *gdbarch,
                long frame_regno, long frame_offset)
 {
   unsigned long len;
@@ -754,7 +757,7 @@ collect_symbol (struct collection_list *collect,
       add_memrange (collect, memrange_absolute, offset, len);
       break;
     case LOC_REGISTER:
-      reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, current_gdbarch);
+      reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
       if (info_verbose)
        printf_filtered ("LOC_REG[parm] %s: ", 
                         SYMBOL_PRINT_NAME (sym));
@@ -762,7 +765,7 @@ collect_symbol (struct collection_list *collect,
       /* 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_size (current_gdbarch, reg))
+         len > register_size (gdbarch, reg))
        add_register (collect, reg + 1);
       break;
     case LOC_REF_ARG:
@@ -819,7 +822,8 @@ collect_symbol (struct collection_list *collect,
 
 /* Add all locals (or args) symbols to collection list */
 static void
-add_local_symbols (struct collection_list *collect, CORE_ADDR pc,
+add_local_symbols (struct collection_list *collect,
+                  struct gdbarch *gdbarch, CORE_ADDR pc,
                   long frame_regno, long frame_offset, int type)
 {
   struct symbol *sym;
@@ -838,8 +842,8 @@ add_local_symbols (struct collection_list *collect, CORE_ADDR pc,
              : type == 'L')    /* collecting Locals */
            {
              count++;
-             collect_symbol (collect, sym, frame_regno, 
-                             frame_offset);
+             collect_symbol (collect, sym, gdbarch,
+                             frame_regno, frame_offset);
            }
        }
       if (BLOCK_FUNCTION (block))
@@ -1025,7 +1029,7 @@ encode_actions (struct breakpoint *t, char ***tdp_actions,
   *tdp_actions = NULL;
   *stepping_actions = NULL;
 
-  gdbarch_virtual_frame_pointer (current_gdbarch, 
+  gdbarch_virtual_frame_pointer (t->gdbarch,
                                 t->loc->address, &frame_reg, &frame_offset);
 
   for (action = t->actions; action; action = action->next)
@@ -1052,13 +1056,14 @@ encode_actions (struct breakpoint *t, char ***tdp_actions,
 
              if (0 == strncasecmp ("$reg", action_exp, 4))
                {
-                 for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
+                 for (i = 0; i < gdbarch_num_regs (t->gdbarch); i++)
                    add_register (collect, i);
                  action_exp = strchr (action_exp, ',');        /* more? */
                }
              else if (0 == strncasecmp ("$arg", action_exp, 4))
                {
                  add_local_symbols (collect,
+                                    t->gdbarch,
                                     t->loc->address,
                                     frame_reg,
                                     frame_offset,
@@ -1068,6 +1073,7 @@ encode_actions (struct breakpoint *t, char ***tdp_actions,
              else if (0 == strncasecmp ("$loc", action_exp, 4))
                {
                  add_local_symbols (collect,
+                                    t->gdbarch,
                                     t->loc->address,
                                     frame_reg,
                                     frame_offset,
@@ -1091,7 +1097,7 @@ encode_actions (struct breakpoint *t, char ***tdp_actions,
                      {
                        const char *name = &exp->elts[2].string;
 
-                       i = user_reg_map_name_to_regnum (current_gdbarch,
+                       i = user_reg_map_name_to_regnum (t->gdbarch,
                                                         name, strlen (name));
                        if (i == -1)
                          internal_error (__FILE__, __LINE__,
@@ -1114,6 +1120,7 @@ encode_actions (struct breakpoint *t, char ***tdp_actions,
                    case OP_VAR_VALUE:
                      collect_symbol (collect,
                                      exp->elts[2].symbol,
+                                     t->gdbarch,
                                      frame_reg,
                                      frame_offset);
                      break;
@@ -1305,12 +1312,31 @@ download_tracepoint (struct breakpoint *t)
   char **stepping_actions;
   int ndx;
   struct cleanup *old_chain = NULL;
+  struct agent_expr *aexpr;
+  struct cleanup *aexpr_chain = NULL;
 
   sprintf_vma (tmp, (t->loc ? t->loc->address : 0));
   sprintf (buf, "QTDP:%x:%s:%c:%lx:%x", t->number, 
           tmp, /* address */
           (t->enable_state == bp_enabled ? 'E' : 'D'),
           t->step_count, t->pass_count);
+  /* If the tracepoint has a conditional, make it into an agent
+     expression and append to the definition.  */
+  if (t->loc->cond)
+    {
+      /* Only test support at download time, we may not know target
+        capabilities at definition time.  */
+      if (remote_supports_cond_tracepoints ())
+       {
+         aexpr = gen_eval_for_expr (t->loc->address, t->loc->cond);
+         aexpr_chain = make_cleanup_free_agent_expr (aexpr);
+         sprintf (buf + strlen (buf), ":X%x,", aexpr->len);
+         mem2hex (aexpr->buf, buf + strlen (buf), aexpr->len);
+         do_cleanups (aexpr_chain);
+       }
+      else
+       warning (_("Target does not support conditional tracepoints, ignoring tp %d cond"), t->number);
+    }
 
   if (t->actions)
     strcat (buf, "-");
@@ -1663,6 +1689,8 @@ trace_find_line_command (char *args, int from_tty)
       old_chain = make_cleanup (xfree, sals.sals);
       if (sal.symtab == 0)
        {
+         struct gdbarch *gdbarch = get_current_arch ();
+
          printf_filtered ("TFIND: No line number information available");
          if (sal.pc != 0)
            {
@@ -1671,7 +1699,7 @@ trace_find_line_command (char *args, int from_tty)
                 have the symbolic address.  */
              printf_filtered (" for address ");
              wrap_here ("  ");
-             print_address (sal.pc, gdb_stdout);
+             print_address (gdbarch, sal.pc, gdb_stdout);
              printf_filtered (";\n -- will attempt to find by PC. \n");
            }
          else
@@ -1683,13 +1711,15 @@ trace_find_line_command (char *args, int from_tty)
       else if (sal.line > 0
               && find_line_pc_range (sal, &start_pc, &end_pc))
        {
+         struct gdbarch *gdbarch = get_objfile_arch (sal.symtab->objfile);
+
          if (start_pc == end_pc)
            {
              printf_filtered ("Line %d of \"%s\"",
                               sal.line, sal.symtab->filename);
              wrap_here ("  ");
              printf_filtered (" is at address ");
-             print_address (start_pc, gdb_stdout);
+             print_address (gdbarch, start_pc, gdb_stdout);
              wrap_here ("  ");
              printf_filtered (" but contains no code.\n");
              sal = find_pc_line (start_pc, 0);
@@ -1868,7 +1898,8 @@ scope_info (char *args, int from_tty)
              break;
            case LOC_STATIC:
              printf_filtered ("in static storage at address ");
-             printf_filtered ("%s", paddress (SYMBOL_VALUE_ADDRESS (sym)));
+             printf_filtered ("%s", paddress (gdbarch,
+                                              SYMBOL_VALUE_ADDRESS (sym)));
              break;
            case LOC_REGISTER:
              /* GDBARCH is the architecture associated with the objfile
@@ -1910,11 +1941,13 @@ scope_info (char *args, int from_tty)
              continue;
            case LOC_LABEL:
              printf_filtered ("a label at address ");
-             printf_filtered ("%s", paddress (SYMBOL_VALUE_ADDRESS (sym)));
+             printf_filtered ("%s", paddress (gdbarch,
+                                              SYMBOL_VALUE_ADDRESS (sym)));
              break;
            case LOC_BLOCK:
              printf_filtered ("a function at address ");
-             printf_filtered ("%s", paddress (BLOCK_START (SYMBOL_BLOCK_VALUE (sym))));
+             printf_filtered ("%s",
+               paddress (gdbarch, BLOCK_START (SYMBOL_BLOCK_VALUE (sym))));
              break;
            case LOC_UNRESOLVED:
              msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym),
@@ -1924,7 +1957,8 @@ scope_info (char *args, int from_tty)
              else
                {
                  printf_filtered ("static storage at address ");
-                 printf_filtered ("%s", paddress (SYMBOL_VALUE_ADDRESS (msym)));
+                 printf_filtered ("%s",
+                   paddress (gdbarch, SYMBOL_VALUE_ADDRESS (msym)));
                }
              break;
            case LOC_OPTIMIZED_OUT:
This page took 0.026295 seconds and 4 git commands to generate.