]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/tracepoint.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gdb / tracepoint.c
index d7978ddbb1d180cc3cfecb5518a4d42a0ff207ca..9f036178bd1c9e18949ef25e215ddcd31a7abe5a 100644 (file)
@@ -33,8 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "ax-gdb.h"
 
 /* readline include files */
-#include "readline.h"
-#include "history.h"
+#include <readline/readline.h>
+#include <readline/history.h>
 
 /* readline defines this.  */
 #undef savestring
@@ -332,30 +332,11 @@ set_raw_tracepoint (sal)
   if (sal.symtab == NULL)
     t->source_file = NULL;
   else
-    {
-      if (sal.symtab->dirname == NULL)
-       {
-         t->source_file = (char *) xmalloc (strlen (sal.symtab->filename) + 1);
-         strcpy (t->source_file, sal.symtab->filename);
-       }
-      else
-       {
-         char *p;
-
-         t->source_file = (char *) xmalloc (strlen (sal.symtab->filename) +
-                                            strlen (sal.symtab->dirname) + 2);
-         
-         strcpy (t->source_file, sal.symtab->dirname);
-         p = t->source_file;
-         while (*p)
-           p++;
-         if (*(--p) != '/')            /* Will this work on Windows? */
-           strcat (t->source_file, "/");
-         strcat (t->source_file, sal.symtab->filename);
-       }
-    }
+    t->source_file = savestring (sal.symtab->filename, 
+                                strlen (sal.symtab->filename));
 
-  t->language = current_language->la_language;
+  t->section     = sal.section;
+  t->language    = current_language->la_language;
   t->input_radix = input_radix;
   t->line_number = sal.line;
   t->enabled     = enabled;
@@ -503,7 +484,7 @@ tracepoints_info (tpnum_exp, from_tty)
 
        if (t->source_file)
          {
-           sym = find_pc_function (t->address);
+           sym = find_pc_sect_function (t->address, t->section);
            if (sym)
              {
                fputs_filtered ("in ", gdb_stdout);
@@ -989,7 +970,7 @@ validate_actionline (line, t)
 
        /* we have something to collect, make sure that the expr to
           bytecode translator can handle it and that it's not too long */
-       aexpr = gen_trace_for_expr(exp);
+       aexpr = gen_trace_for_expr (t->address, exp);
        (void) make_cleanup ((make_cleanup_func) free_agent_expr, aexpr);
 
        if (aexpr->len > MAX_AGENT_EXPR_LEN)
@@ -1176,9 +1157,11 @@ add_memrange (memranges, type, base, len)
 
 /* Add a symbol to a collection list */
 static void
-collect_symbol (collect, sym)
+collect_symbol (collect, sym, frame_regno, frame_offset)
      struct collection_list *collect;
      struct symbol *sym;
+     long frame_regno;
+     long frame_offset;
 {
   unsigned long  len;
   unsigned long  reg;
@@ -1219,8 +1202,8 @@ collect_symbol (collect, sym)
                     SYMBOL_NAME (sym));
     break;
   case LOC_ARG:
-    offset = SYMBOL_VALUE (sym);
-    reg = FP_REGNUM;
+    reg    = frame_regno;
+    offset = frame_offset + SYMBOL_VALUE (sym);
     if (info_verbose)
       {
        printf_filtered ("LOC_LOCAL %s: Collect %d bytes at offset",
@@ -1242,8 +1225,8 @@ collect_symbol (collect, sym)
     break;
   case LOC_LOCAL:
   case LOC_LOCAL_ARG:
-    offset = SYMBOL_VALUE (sym);
-    reg = FP_REGNUM;
+    reg    = frame_regno;
+    offset = frame_offset + SYMBOL_VALUE (sym);
     if (info_verbose)
       {
        printf_filtered ("LOC_LOCAL %s: Collect %d bytes at offset",
@@ -1275,9 +1258,11 @@ collect_symbol (collect, sym)
 
 /* Add all locals (or args) symbols to collection list */
 static void
-add_local_symbols (collect, pc, type)
+add_local_symbols (collect, pc, frame_regno, frame_offset, type)
      struct collection_list *collect;
      CORE_ADDR pc;
+     long frame_regno;
+     long frame_offset;
      int type;
 {
   struct symbol *sym;
@@ -1300,7 +1285,7 @@ add_local_symbols (collect, pc, type)
            if (type == 'L')    /* collecting Locals */
              {
                count++;
-               collect_symbol (collect, sym);
+               collect_symbol (collect, sym, frame_regno, frame_offset);
              }
            break;
          case LOC_ARG:
@@ -1312,7 +1297,7 @@ add_local_symbols (collect, pc, type)
            if (type == 'A')    /* collecting Arguments */
              {
                count++;
-               collect_symbol (collect, sym);
+               collect_symbol (collect, sym, frame_regno, frame_offset);
              }
          }
        }
@@ -1470,6 +1455,8 @@ encode_actions (t, tdp_actions, stepping_actions)
   struct collection_list  *collect;
   struct cmd_list_element *cmd;
   struct agent_expr *aexpr;
+  long                frame_reg, frame_offset;
+
 
   clear_collection_list (&tracepoint_list);
   clear_collection_list (&stepping_list);
@@ -1478,6 +1465,8 @@ encode_actions (t, tdp_actions, stepping_actions)
   *tdp_actions = NULL;
   *stepping_actions = NULL;
 
+  TARGET_VIRTUAL_FRAME_POINTER (t->address, &frame_reg, &frame_offset);
+
   for (action = t->actions; action; action = action->next)
     {
       QUIT;                    /* allow user to bail out with ^C */
@@ -1507,12 +1496,20 @@ encode_actions (t, tdp_actions, stepping_actions)
              }
            else if (0 == strncasecmp ("$arg", action_exp, 4))
              {
-               add_local_symbols (collect, t->address, 'A');
+               add_local_symbols (collect, 
+                                  t->address, 
+                                  frame_reg,
+                                  frame_offset,
+                                  'A');
                action_exp = strchr (action_exp, ','); /* more? */
              }
            else if (0 == strncasecmp ("$loc", action_exp, 4))
              {
-               add_local_symbols (collect, t->address, 'L');
+               add_local_symbols (collect, 
+                                  t->address, 
+                                  frame_reg,
+                                  frame_offset,
+                                  'L');
                action_exp = strchr (action_exp, ','); /* more? */
              }
            else
@@ -1543,11 +1540,14 @@ encode_actions (t, tdp_actions, stepping_actions)
                  break;
 
                case OP_VAR_VALUE:
-                 collect_symbol (collect, exp->elts[2].symbol);
+                 collect_symbol (collect, 
+                                 exp->elts[2].symbol,
+                                 frame_reg,
+                                 frame_offset);
                  break;
 
                default:        /* full-fledged expression */
-                 aexpr = gen_trace_for_expr (exp);
+                 aexpr = gen_trace_for_expr (t->address, exp);
 
                  old_chain1 = make_cleanup ((make_cleanup_func) 
                                              free_agent_expr, aexpr);
@@ -1767,6 +1767,9 @@ trace_start_command (args, 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);
+      
     }
   else
     error ("Trace can only be run on remote targets.");
@@ -1785,6 +1788,8 @@ trace_stop_command (args, 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);
     }
   else
     error ("Trace can only be run on remote targets.");
@@ -1947,6 +1952,9 @@ trace_find_command (args, from_tty)
 
   if (target_is_remote ())
     {
+      if (trace_find_hook)
+       trace_find_hook (args, from_tty);  
+      
       if (args == 0 || *args == 0)
        { /* TFIND with no args means find NEXT trace frame. */
          if (traceframe_number == -1)
@@ -2302,7 +2310,7 @@ scope_info (args, from_tty)
   struct minimal_symbol *msym;
   struct block *block;
   char **canonical, *symname, *save_args = args;
-  int i, nsyms, count = 0;
+  int i, j, nsyms, count = 0;
 
   if (args == 0 || *args == 0)
     error ("requires an argument (function, line or *addr) to define a scope");
@@ -2345,9 +2353,9 @@ scope_info (args, from_tty)
          case LOC_CONST_BYTES:
            printf_filtered ("constant bytes: ");
            if (SYMBOL_TYPE (sym))
-             for (i = 0; i < TYPE_LENGTH (SYMBOL_TYPE (sym)); i++)
+             for (j = 0; j < TYPE_LENGTH (SYMBOL_TYPE (sym)); j++)
                fprintf_filtered (gdb_stdout, " %02x",
-                                 (unsigned) SYMBOL_VALUE_BYTES (sym) [i]);
+                                 (unsigned) SYMBOL_VALUE_BYTES (sym) [j]);
            break;
          case LOC_STATIC:
            printf_filtered ("in static storage at address ");
@@ -2355,7 +2363,7 @@ scope_info (args, from_tty)
            break;
          case LOC_REGISTER:
            printf_filtered ("a local variable in register $%s",
-                            reg_names [SYMBOL_VALUE (sym)]);
+                            REGISTER_NAME (SYMBOL_VALUE (sym)));
            break;
          case LOC_ARG:
          case LOC_LOCAL_ARG:
@@ -2372,11 +2380,11 @@ scope_info (args, from_tty)
            break;
          case LOC_REGPARM:
            printf_filtered ("an argument in register $%s",
-                            reg_names[SYMBOL_VALUE (sym)]);
+                            REGISTER_NAME (SYMBOL_VALUE (sym)));
            break;
          case LOC_REGPARM_ADDR:
            printf_filtered ("the address of an argument, in register $%s",
-                            reg_names[SYMBOL_VALUE (sym)]);
+                            REGISTER_NAME (SYMBOL_VALUE (sym)));
            break;
          case LOC_TYPEDEF:
            printf_filtered ("a typedef.\n");
@@ -2393,12 +2401,12 @@ scope_info (args, from_tty)
          case LOC_BASEREG:
            printf_filtered ("a variable at offset %d from register $%s",
                             SYMBOL_VALUE (sym),
-                            reg_names [SYMBOL_BASEREG (sym)]);
+                            REGISTER_NAME  (SYMBOL_BASEREG (sym)));
            break;
          case LOC_BASEREG_ARG:
            printf_filtered ("an argument at offset %d from register $%s",
                             SYMBOL_VALUE (sym),
-                            reg_names [SYMBOL_BASEREG (sym)]);
+                            REGISTER_NAME  (SYMBOL_BASEREG (sym)));
            break;
          case LOC_UNRESOLVED:
            msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, NULL);