]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
btrace: Enable auxiliary instructions in record function-call-history.
authorFelix Willgerodt <felix.willgerodt@intel.com>
Thu, 7 Jun 2018 08:38:10 +0000 (10:38 +0200)
committerFelix Willgerodt <felix.willgerodt@intel.com>
Wed, 14 Aug 2024 09:20:56 +0000 (11:20 +0200)
Print the auxiliary data when a btrace_insn of type BTRACE_INSN_AUX
is encountered in the function-call-history.  Printing is
active by default, it can be silenced with the /a modifier.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
gdb/btrace.c
gdb/btrace.h
gdb/doc/gdb.texinfo
gdb/record-btrace.c
gdb/record.c
gdb/record.h

index da219da6ad346bcd5e557eb19146d168c7db20ad..224341b6b2d820d6b04ee1051a718989dade6f52 100644 (file)
@@ -664,6 +664,9 @@ ftrace_update_insns (struct btrace_function *bfun, const btrace_insn &insn)
 {
   bfun->insn.push_back (insn);
 
+  if (insn.iclass == BTRACE_INSN_AUX)
+    bfun->flags |= BFUN_CONTAINS_AUX;
+
   if (record_debug > 1)
     ftrace_debug (bfun, "update insn");
 }
index 0086759257fa790d52d90e80f8b48c2da0578bec..0f9317302dda04c56ab07deda9d45938784f0884 100644 (file)
@@ -105,7 +105,11 @@ enum btrace_function_flag
 
   /* The 'up' link points to a tail call.  This obviously only makes sense
      if bfun_up_links_to_ret is clear.  */
-  BFUN_UP_LINKS_TO_TAILCALL = (1 << 1)
+  BFUN_UP_LINKS_TO_TAILCALL = (1 << 1),
+
+  /* Indicates that at least one auxiliary instruction is in the current
+     function segment.  */
+  BFUN_CONTAINS_AUX = (1 << 2)
 };
 DEF_ENUM_FLAGS_TYPE (enum btrace_function_flag, btrace_function_flags);
 
index 8d86823f8c11815de159d73466b3ea15fd1d2944..09eef92c5b12c9b108b9aca50e401acd61165ec0 100644 (file)
@@ -8258,8 +8258,9 @@ that function, the source lines for this instruction sequence (if the
 @code{/l} modifier is specified), and the instructions numbers that form
 the sequence (if the @code{/i} modifier is specified).  The function names
 are indented to reflect the call stack depth if the @code{/c} modifier is
-specified.  The @code{/l}, @code{/i}, and @code{/c} modifiers can be given
-together.
+specified.  Printing auxiliary information is enabled by default and can be
+omitted with the @code{/a} modifier.  The @code{/l}, @code{/i}, @code{/a},
+and @code{/c} modifiers can be given together.
 
 @smallexample
 (@value{GDBP}) @b{list 1, 10}
index 54c761d09847904aac86f5285508a04a0db14ef5..92c01dcf0157b6810178282d4deb796d568ea30a 100644 (file)
@@ -1161,6 +1161,31 @@ btrace_get_bfun_name (const struct btrace_function *bfun)
     return "??";
 }
 
+static void
+btrace_print_aux_insn (struct ui_out *uiout,
+                      const struct btrace_function *bfun,
+                      const struct btrace_thread_info *btinfo,
+                      int level)
+{
+  for (const btrace_insn &insn : bfun->insn)
+    {
+      if (insn.iclass == BTRACE_INSN_AUX)
+       {
+         /* Indent to the function level.  */
+         uiout->text ("\t");
+         /* Adjust for RECORD_PRINT_INDENT_CALLS and indent one
+            additional level.  */
+         for (int i = 0; i <= level; ++i)
+           uiout->text ("  ");
+
+         uiout->text ("[");
+         uiout->field_fmt ("aux-data", "%s",
+                           btinfo->aux_data.at (insn.aux_data_index).c_str ());
+         uiout->text ("]\n");
+       }
+    }
+}
+
 /* Disassemble a section of the recorded function trace.  */
 
 static void
@@ -1181,6 +1206,7 @@ btrace_call_history (struct ui_out *uiout,
       const struct btrace_function *bfun;
       struct minimal_symbol *msym;
       struct symbol *sym;
+      int level = 0;
 
       bfun = btrace_call_get (&it);
       sym = bfun->sym;
@@ -1207,9 +1233,9 @@ btrace_call_history (struct ui_out *uiout,
 
       if ((flags & RECORD_PRINT_INDENT_CALLS) != 0)
        {
-         int level = bfun->level + btinfo->level, i;
+         level = bfun->level + btinfo->level;
 
-         for (i = 0; i < level; ++i)
+         for (int i = 0; i < level; ++i)
            uiout->text ("  ");
        }
 
@@ -1236,6 +1262,10 @@ btrace_call_history (struct ui_out *uiout,
        }
 
       uiout->text ("\n");
+
+      if (((flags & RECORD_DONT_PRINT_AUX) == 0)
+         && ((bfun->flags & BFUN_CONTAINS_AUX) != 0))
+       btrace_print_aux_insn (uiout, bfun, btinfo, level);
     }
 }
 
index 55e136e75f4e3d192278060165dd50c9cfc3bee2..d84af60ac71496ae8048fa222b0f2034f4a11a13 100644 (file)
@@ -644,6 +644,9 @@ get_call_history_modifiers (const char **arg)
            case 'c':
              modifiers |= RECORD_PRINT_INDENT_CALLS;
              break;
+           case 'a':
+             modifiers |= RECORD_DONT_PRINT_AUX;
+             break;
            default:
              error (_("Invalid modifier: %c."), *args);
            }
@@ -886,6 +889,8 @@ Without modifiers, it prints the function name.\n\
 With a /l modifier, the source file and line number range is included.\n\
 With a /i modifier, the instruction number range is included.\n\
 With a /c modifier, the output is indented based on the call stack depth.\n\
+With a /a modifier, omits output of auxiliary data, which is enabled \
+by default.\n\
 With no argument, prints ten more lines after the previous ten-line print.\n\
 \"record function-call-history -\" prints ten lines before a previous ten-line \
 print.\n\
index f44b3952943b48a419c1c034070f0382e80c386a..aea6507c9471a1bc329ade1b732e799a2a4d8067 100644 (file)
@@ -62,7 +62,10 @@ enum record_print_flag
   RECORD_PRINT_INSN_RANGE = (1 << 1),
 
   /* Indent based on call stack depth (if applicable).  */
-  RECORD_PRINT_INDENT_CALLS = (1 << 2)
+  RECORD_PRINT_INDENT_CALLS = (1 << 2),
+
+  /* Deactivate printing auxiliary data (if applicable).  */
+  RECORD_DONT_PRINT_AUX = (1 << 3)
 };
 DEF_ENUM_FLAGS_TYPE (enum record_print_flag, record_print_flags);