public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] gdb/mi: Remove extra \n from tsv and and traceframe notifications
@ 2021-02-25 16:33 Jan Vrany
  0 siblings, 0 replies; only message in thread
From: Jan Vrany @ 2021-02-25 16:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Vrany

An extra \n in calls to fprintf_unfiltered() caused invalid MI records
to be emitted:

   > gdb -i mi3 -ex "target remote :7000"
   =thread-group-added,id="i1"
   ~"GNU gdb (GDB) 11.0.50.20201019-git\n"
   ~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
   ...
   ~"Remote debugging using :7001\n"
   =tsv-created,name="trace_timestamp",initial="0"\n
   =thread-group-started,id="i1",pid="304973"

This commit fixes the problem.

gdb/ChangeLog:

        * gdb/mi/mi-interp.c (mi_traceframe_changed): Remove trailing \n from output.
        (mi_tsv_created): Likewise.
        (mi_tsv_deleted): Likewise.
---
 gdb/ChangeLog      | 6 ++++++
 gdb/mi/mi-interp.c | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 019e7ac447e..27b0e0cfec0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2021-02-25  Jan Vrany  <jan.vrany@labware.com>
+
+	* gdb/mi/mi-interp.c (mi_traceframe_changed): Remove trailing \n from output.
+	(mi_tsv_created): Likewise.
+	(mi_tsv_deleted): Likewise.
+
 2021-02-25  Tom de Vries  <tdevries@suse.de>
 
 	PR symtab/27354
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 563b94d5b71..4c5612ee9ee 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -731,7 +731,7 @@ mi_traceframe_changed (int tfnum, int tpnum)
 
       if (tfnum >= 0)
 	fprintf_unfiltered (mi->event_channel, "traceframe-changed,"
-			    "num=\"%d\",tracepoint=\"%d\"\n",
+			    "num=\"%d\",tracepoint=\"%d\"",
 			    tfnum, tpnum);
       else
 	fprintf_unfiltered (mi->event_channel, "traceframe-changed,end");
@@ -756,7 +756,7 @@ mi_tsv_created (const struct trace_state_variable *tsv)
       target_terminal::ours_for_output ();
 
       fprintf_unfiltered (mi->event_channel, "tsv-created,"
-			  "name=\"%s\",initial=\"%s\"\n",
+			  "name=\"%s\",initial=\"%s\"",
 			  tsv->name.c_str (), plongest (tsv->initial_value));
 
       gdb_flush (mi->event_channel);
@@ -780,9 +780,9 @@ mi_tsv_deleted (const struct trace_state_variable *tsv)
 
       if (tsv != NULL)
 	fprintf_unfiltered (mi->event_channel, "tsv-deleted,"
-			    "name=\"%s\"\n", tsv->name.c_str ());
+			    "name=\"%s\"", tsv->name.c_str ());
       else
-	fprintf_unfiltered (mi->event_channel, "tsv-deleted\n");
+	fprintf_unfiltered (mi->event_channel, "tsv-deleted");
 
       gdb_flush (mi->event_channel);
     }
-- 
2.30.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-25 16:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25 16:33 [pushed] gdb/mi: Remove extra \n from tsv and and traceframe notifications Jan Vrany

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).