public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ari Hannula <ari.hannula@intel.com>
To: gdb-patches@sourceware.org
Cc: Tim Wiederhake <tim.wiederhake@intel.com>,
	Ari Hannula <ari.hannula@intel.com>
Subject: [PATCH 3/5] [func_call] Fix MI output for function call history.
Date: Thu, 10 Feb 2022 14:52:41 +0100	[thread overview]
Message-ID: <20220210135243.3127629-4-ari.hannula@intel.com> (raw)
In-Reply-To: <20220210135243.3127629-1-ari.hannula@intel.com>

From: Tim Wiederhake <tim.wiederhake@intel.com>

"record function-call-history" formats its output as one single tuple with
the same keys for every line.  Fix by turning the output into a list of
tuples and the indentation into an optional "level" field.

gdb/ChangeLog:
2018-12-27  Tim Wiederhake  <tim.wiederhake@intel.com>

	* record-btrace.c (btrace_call_history): Emit individual tuples.
	(record_btrace_target::call_history): Emit list instead of tuple,
	fix field name.
	(record_btrace_target::call_history_range): Emit list instead of
	tuple.

Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>
Signed-off-by: Ari Hannula <ari.hannula@intel.com>
---
 gdb/record-btrace.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 3dfdf592dd..dd5f4b4dd7 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1156,6 +1156,7 @@ btrace_call_history (struct ui_out *uiout,
 
   for (it = *begin; btrace_call_cmp (&it, end) < 0; btrace_call_next (&it, 1))
     {
+      ui_out_emit_tuple tuple_emitter (uiout, nullptr);
       const struct btrace_function *bfun;
       struct minimal_symbol *msym;
       struct symbol *sym;
@@ -1185,10 +1186,13 @@ btrace_call_history (struct ui_out *uiout,
 
       if ((flags & RECORD_PRINT_INDENT_CALLS) != 0)
 	{
-	  int level = bfun->level + btinfo->level, i;
+	  const int level = bfun->level + btinfo->level;
 
-	  for (i = 0; i < level; ++i)
-	    uiout->text ("  ");
+	  if (uiout->is_mi_like_p ())
+	    uiout->field_signed ("level", level);
+	  else
+	    for (int i = 0; i < level; ++i)
+	      uiout->text ("  ");
 	}
 
       if (sym != NULL)
@@ -1229,7 +1233,7 @@ record_btrace_target::call_history (int size, record_print_flags flags)
   unsigned int context, covered;
 
   uiout = current_uiout;
-  ui_out_emit_tuple tuple_emitter (uiout, "insn history");
+  ui_out_emit_list list_emitter (uiout, "func history");
   context = abs (size);
   if (context == 0)
     error (_("Bad record function-call-history-size."));
@@ -1316,7 +1320,7 @@ record_btrace_target::call_history_range (ULONGEST from, ULONGEST to,
   int found;
 
   uiout = current_uiout;
-  ui_out_emit_tuple tuple_emitter (uiout, "func history");
+  ui_out_emit_list list_emitter (uiout, "func history");
   low = from;
   high = to;
 
-- 
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  parent reply	other threads:[~2022-02-10 13:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 13:52 [PATCH 0/5] Functions call history patches Ari Hannula
2022-02-10 13:52 ` [PATCH 1/5] [func_call] Add possible spelling of linker error message Ari Hannula
2022-03-17 17:58   ` Metzger, Markus T
2022-03-17 18:45     ` Keith Seitz
2022-02-10 13:52 ` [PATCH 2/5] [func_call] New tests for a btrace crash Ari Hannula
2022-03-17 17:58   ` Metzger, Markus T
2022-02-10 13:52 ` Ari Hannula [this message]
2022-03-17 17:58   ` [PATCH 3/5] [func_call] Fix MI output for function call history Metzger, Markus T
2022-02-10 13:52 ` [PATCH 4/5] [func_call] Add function-call-history-length command to MI Ari Hannula
2022-03-17 17:59   ` Metzger, Markus T
2022-02-10 13:52 ` [PATCH 5/5] [func_call] Add function-call-history " Ari Hannula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220210135243.3127629-4-ari.hannula@intel.com \
    --to=ari.hannula@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tim.wiederhake@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).