]> 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 2a9e7dbf384101675432c8b74558677277020d19..9f036178bd1c9e18949ef25e215ddcd31a7abe5a 100644 (file)
@@ -1,5 +1,5 @@
 /* Tracing functionality for remote targets in custom GDB protocol
-   Copyright 1997 Free Software Foundation, Inc.
+   Copyright 1997, 1998 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -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);
@@ -847,7 +828,7 @@ read_actions (t)
   if (job_control)
     signal (STOP_SIGNAL, stop_sig);
 #endif
-  old_chain = make_cleanup (free_actions, (void *) t);
+  old_chain = make_cleanup ((make_cleanup_func) free_actions, (void *) t);
   while (1)
     {
       /* Make sure that all output has been output.  Some machines may let
@@ -969,7 +950,8 @@ validate_actionline (line, t)
            /* else fall thru, treat p as an expression and parse it! */
          }
        exp   = parse_exp_1 (&p, block_for_pc (t->address), 1);
-       old_chain = make_cleanup (free_current_contents, &exp);
+       old_chain = make_cleanup ((make_cleanup_func) free_current_contents, 
+                                  &exp);
 
        if (exp->elts[0].opcode == OP_VAR_VALUE)
          if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
@@ -988,8 +970,8 @@ 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);
-       (void) make_cleanup (free_agent_expr, aexpr);
+       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)
          error ("expression too complicated, try simplifying");
@@ -1175,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;
@@ -1218,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",
@@ -1241,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",
@@ -1274,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;
@@ -1299,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:
@@ -1311,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);
              }
          }
        }
@@ -1469,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);
@@ -1477,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 */
@@ -1506,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
@@ -1522,7 +1520,8 @@ encode_actions (t, tdp_actions, stepping_actions)
                struct agent_reqs areqs;
 
                exp = parse_exp_1 (&action_exp, block_for_pc (t->address), 1);
-               old_chain = make_cleanup (free_current_contents, &exp);
+               old_chain = make_cleanup ((make_cleanup_func) 
+                                          free_current_contents, &exp);
 
                switch (exp->elts[0].opcode) {
                case OP_REGISTER:
@@ -1541,13 +1540,17 @@ 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 (free_agent_expr, aexpr);
+                 old_chain1 = make_cleanup ((make_cleanup_func) 
+                                             free_agent_expr, aexpr);
 
                  ax_reqs (aexpr, &areqs);
                  if (areqs.flaw != agent_flaw_none)
@@ -1764,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.");
@@ -1782,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.");
@@ -1944,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)
@@ -2299,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");
@@ -2342,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 ");
@@ -2352,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:
@@ -2369,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");
@@ -2390,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);