[01/10] btrace: Introduce auxiliary instructions.

Message ID 1559119673-30516-2-git-send-email-felix.willgerodt@intel.com
State New
Headers show
Series
  • Extensions for PTWRITE
Related show

Commit Message

felix.willgerodt@intel.com May 29, 2019, 8:47 a.m.
From: Felix Willgerodt <felix.willgerodt@intel.com>


Auxiliary instructions are pseudo instructions pointing to auxiliary data.
This auxiliary data can be printed in all commands displaying (record
function-call-history, record instruction-history) or stepping through
(stepi etc.) the execution history, which will be introduced in the next
commits.

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

2019-05-29  Felix Willgerodt  <felix.willgerodt@intel.com>

gdb/ChangeLog:
	* btrace.c (btrace_clear_history): Clear aux_data.
	* btrace.h (btrace_insn_class): Add BTRACE_INSN_AUX.
	(btrace_insn): New union.
	(btrace_thread_info): New member aux_data.

gdb/doc/ChangeLog:
	* gdb.texinfo (Process Record and Replay): Document printing of auxiliary
	information.

---
 gdb/btrace.c        |  2 ++
 gdb/btrace.h        | 25 +++++++++++++++++++++----
 gdb/doc/gdb.texinfo |  3 +++
 3 files changed, 26 insertions(+), 4 deletions(-)

-- 
2.20.1

Comments

Eli Zaretskii May 29, 2019, 2:39 p.m. | #1
> From: felix.willgerodt@intel.com

> Cc: markus.t.metzger@intel.com, Felix Willgerodt <felix.willgerodt@intel.com>

> Date: Wed, 29 May 2019 10:47:44 +0200

> 

> index 3c4535ec506..c31ed39b251 100644

> --- a/gdb/doc/gdb.texinfo

> +++ b/gdb/doc/gdb.texinfo

> @@ -6831,6 +6831,9 @@ Moxie, PowerPC, PowerPC64, S/390, and x86 (i386/amd64) running

>  GNU/Linux.  Process record and replay can be used both when native

>  debugging, and when remote debugging via @code{gdbserver}.

>  

> +When recording an inferior, GDB may print additional auxiliary information

                               ^^^
That should be "@value{GDBN}" instead.

Thanks.
Metzger, Markus T June 4, 2019, 12:35 p.m. | #2
Hello Felix,

> Auxiliary instructions are pseudo instructions pointing to auxiliary data.

> This auxiliary data can be printed in all commands displaying (record

> function-call-history, record instruction-history) or stepping through

> (stepi etc.) the execution history, which will be introduced in the next

> commits.

> 

> This patch is in preparation for the ptwrite feature, which is based on

> auxiliary instructions.

> 

> 2019-05-29  Felix Willgerodt  <felix.willgerodt@intel.com>

> 

> gdb/ChangeLog:

> 	* btrace.c (btrace_clear_history): Clear aux_data.

> 	* btrace.h (btrace_insn_class): Add BTRACE_INSN_AUX.

> 	(btrace_insn): New union.

> 	(btrace_thread_info): New member aux_data.

> 

> gdb/doc/ChangeLog:

> 	* gdb.texinfo (Process Record and Replay): Document printing of auxiliary

> 	information.

> 

> ---

>  gdb/btrace.c        |  2 ++

>  gdb/btrace.h        | 25 +++++++++++++++++++++----

>  gdb/doc/gdb.texinfo |  3 +++

>  3 files changed, 26 insertions(+), 4 deletions(-)


LGTM.

Markus.

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

Patch

diff --git a/gdb/btrace.c b/gdb/btrace.c
index c6d564e7062..d3e2f46c678 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1810,6 +1810,8 @@  btrace_clear_history (struct btrace_thread_info *btinfo)
   btinfo->insn_history = NULL;
   btinfo->call_history = NULL;
   btinfo->replay = NULL;
+
+  btinfo->aux_data.clear ();
 }
 
 /* Clear the branch trace maintenance histories in BTINFO.  */
diff --git a/gdb/btrace.h b/gdb/btrace.h
index 7b38b14ac01..2a0e8664bf8 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -52,7 +52,10 @@  enum btrace_insn_class
   BTRACE_INSN_RETURN,
 
   /* The instruction is an unconditional jump.  */
-  BTRACE_INSN_JUMP
+  BTRACE_INSN_JUMP,
+
+  /* The instruction is a pseudo instruction containing auxiliary data.  */
+  BTRACE_INSN_AUX
 };
 
 /* Instruction flags.  */
@@ -68,9 +71,19 @@  DEF_ENUM_FLAGS_TYPE (enum btrace_insn_flag, btrace_insn_flags);
    This represents a single instruction in a branch trace.  */
 struct btrace_insn
 {
-  /* The address of this instruction.  */
-  CORE_ADDR pc;
-
+  union
+  {
+    /* The address of this instruction.  Applies to btrace_insn with
+       iclass == BTRACE_INSN_OTHER or
+       iclass == BTRACE_INSN_CALL or
+       iclass == BTRACE_INSN_RETURN or
+       iclass == BTRACE_INSN_JUMP.  */
+    CORE_ADDR pc;
+
+    /* Index into btrace_info::aux_data.  Applies to btrace_insn with
+       iclass == BTRACE_INSN_AUX.  */
+    uint64_t aux_data_index;
+  };
   /* The size of this instruction in bytes.  */
   gdb_byte size;
 
@@ -333,6 +346,10 @@  struct btrace_thread_info
      function segment i will be at index (i - 1).  */
   std::vector<btrace_function> functions;
 
+  /* Optional auxiliary data that is printed in all commands displaying or
+     stepping through the execution history.  */
+  std::vector<std::string> aux_data;
+
   /* The function level offset.  When added to each function's LEVEL,
      this normalizes the function levels such that the smallest level
      becomes zero.  */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 3c4535ec506..c31ed39b251 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6831,6 +6831,9 @@  Moxie, PowerPC, PowerPC64, S/390, and x86 (i386/amd64) running
 GNU/Linux.  Process record and replay can be used both when native
 debugging, and when remote debugging via @code{gdbserver}.
 
+When recording an inferior, GDB may print additional auxiliary information
+during stepping commands and commands displaying the execution history.
+
 For architecture environments that support process record and replay,
 @value{GDBN} provides the following commands: