From: "Dennis Lambe Jr." <malsyned@malsyned.net>
To: gdb-patches@sourceware.org
Subject: [RFC][PATCH 3/5] [PR gdb/33469] mi_ui_out: redirect: push separator state when async = true
Date: Mon, 22 Sep 2025 19:18:18 -0400 [thread overview]
Message-ID: <20250922231820.2667505-4-malsyned@malsyned.net> (raw)
In-Reply-To: <20250922231820.2667505-1-malsyned@malsyned.net>
* Convert m_suppress_field_separator from a bool to a std::vector<bool>.
* When do_redirect() is called with async = true, push a new value onto
m_suppress_field_separator.
---
gdb/mi/mi-out.c | 28 +++++++++++++++++++++-------
gdb/mi/mi-out.h | 4 +++-
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 6adf108b1cc..1aafbb39f32 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -187,18 +187,32 @@ mi_ui_out::do_flush ()
void
mi_ui_out::do_redirect (ui_file *outstream)
+{
+ do_redirect (outstream, false);
+}
+
+void
+mi_ui_out::do_redirect (ui_file *outstream, bool async)
{
if (outstream != NULL)
- m_streams.push_back (outstream);
+ {
+ m_streams.push_back (outstream);
+ if (async)
+ m_suppress_field_separator.push_back (false);
+ }
else
- m_streams.pop_back ();
+ {
+ m_streams.pop_back ();
+ if (async)
+ m_suppress_field_separator.pop_back ();
+ }
}
void
mi_ui_out::field_separator ()
{
- if (m_suppress_field_separator)
- m_suppress_field_separator = false;
+ if (m_suppress_field_separator.back ())
+ m_suppress_field_separator.back () = false;
else
gdb_putc (',', m_streams.back ());
}
@@ -209,7 +223,7 @@ mi_ui_out::open (const char *name, ui_out_type type)
ui_file *stream = m_streams.back ();
field_separator ();
- m_suppress_field_separator = true;
+ m_suppress_field_separator.back () = true;
if (name)
gdb_printf (stream, "%s=", name);
@@ -248,7 +262,7 @@ mi_ui_out::close (ui_out_type type)
internal_error (_("bad switch"));
}
- m_suppress_field_separator = false;
+ m_suppress_field_separator.back () = false;
}
string_file *
@@ -322,11 +336,11 @@ mi_ui_out::version ()
mi_ui_out::mi_ui_out (int mi_version)
: ui_out (make_flags (mi_version)),
- m_suppress_field_separator (false),
m_mi_version (mi_version)
{
string_file *stream = new string_file ();
m_streams.push_back (stream);
+ m_suppress_field_separator.push_back (false);
}
mi_ui_out::~mi_ui_out ()
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index ec3de74ab60..2a64d8f08d1 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -84,6 +84,8 @@ class mi_ui_out : public ui_out
virtual void do_wrap_hint (int indent) override;
virtual void do_flush () override;
virtual void do_redirect (struct ui_file *outstream) override;
+ virtual void do_redirect (struct ui_file *outstream,
+ bool push_state) override;
virtual bool do_is_mi_like_p () const override
{ return true; }
@@ -138,7 +140,7 @@ class mi_ui_out : public ui_out
return flags;
}
- bool m_suppress_field_separator;
+ std::vector<bool> m_suppress_field_separator;
int m_mi_version;
std::vector<ui_file *> m_streams;
};
--
2.51.0
next prev parent reply other threads:[~2025-09-22 23:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 23:18 [RFC][PATCH 0/5] [PR gdb/33469] mi, python: Fix comma location when unwinder emits async records Dennis Lambe Jr.
2025-09-22 23:18 ` [RFC][PATCH 1/5] [PR gdb/33469] ui_out: add optional async param to redirect() Dennis Lambe Jr.
2025-09-22 23:18 ` [RFC][PATCH 2/5] [PR gdb/33469] ui_out_redirect_pop: add optional async param Dennis Lambe Jr.
2025-09-22 23:18 ` Dennis Lambe Jr. [this message]
2025-09-22 23:18 ` [RFC][PATCH 4/5] [PR gdb/33469] mi-interp: on_param_changed: pass async = true to redirect() Dennis Lambe Jr.
2025-09-22 23:18 ` [RFC][PATCH 5/5] [PR gdb/33469] testsuite: framefilters-mi: async records from unwinder Dennis Lambe Jr.
2025-10-03 18:39 ` [RFC][PATCH 0/5] [PR gdb/33469] mi, python: Fix comma location when unwinder emits async records Tom Tromey
2025-10-03 21:43 ` Dennis Lambe Jr.
2025-10-04 17:31 ` Tom Tromey
2026-02-19 18:27 ` Tom Tromey
2026-02-19 18:58 ` Dennis Lambe Jr.
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=20250922231820.2667505-4-malsyned@malsyned.net \
--to=malsyned@malsyned.net \
--cc=gdb-patches@sourceware.org \
/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