Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC][PATCH 0/5] [PR gdb/33469] mi, python: Fix comma location when unwinder emits async records
@ 2025-09-22 23:18 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.
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Dennis Lambe Jr. @ 2025-09-22 23:18 UTC (permalink / raw)
  To: gdb-patches

When frame filters are enabled and a stack unwinder does something to
cause an async record to be emitted, -stack-list-frames output is
incorrect. A comma is missing from the first async record, and a
spurious comma is inserted before the first frame= of the frame list.

Example:

-stack-list-frames
=cmd-param-changedparam="language",value="c++"
=cmd-param-changed,param="language",value="auto"
^done,stack=[,frame={level="0",addr="0x0000555555555148",func="main",file="/home/malsyned/projects/gdb-comma-bug/main.c",line="4",arch="i386:x86-64"}]

This happens because async record emitters like
mi_interp::on_param_changed() are written as though calling
mi_out::do_redirect() ensures that a comma will be emitted by the next
following mi_ui_out::field_string() call. It's not guaranteed, though.
It usually works out by coincidence because the emitter methods are
called when no other output record is mid-creation.

Emitting async records from a Python unwinder definitely breaks that
assumption, but it wouldn't surprise me if there were other ways to
violate it. The way async record emitter methods are written implies to
me that they are meant to be able to operate correctly in this context,
but when emitted by stack unwinders, they don't always.

This patch set works by adding an optional `bool async` parameter to
ui_out::redirect() and related methods. Most classes derived from ui_out
ignore this parameter, but mi_ui_out uses it to decide whether to push a
new m_suppress_field_separator onto a stack.

RFC: This version of the patch set only changes
mi_interp::on_param_changed(), because that's the async record my code
was emitting when I found this bug and that I have good test cases for.
I'm interested in revving this patch set to change other async record
emitters in mi-interp.c based on comments on this version.

Dennis Lambe Jr. (5):
  [PR gdb/33469] ui_out: add optional async param to redirect()
  [PR gdb/33469] ui_out_redirect_pop: add optional async param
  [PR gdb/33469] mi_ui_out: redirect: push separator state when async =
    true
  [PR gdb/33469] mi-interp: on_param_changed: pass async = true to
    redirect()
  [PR gdb/33469] testsuite: framefilters-mi: async records from unwinder

 gdb/mi/mi-interp.c                            |  3 +-
 gdb/mi/mi-out.c                               | 28 ++++++++++++++-----
 gdb/mi/mi-out.h                               |  4 ++-
 .../gdb.python/py-framefilter-mi.exp          |  6 ++++
 gdb/testsuite/gdb.python/py-framefilter.py    | 15 ++++++++++
 gdb/ui-out.h                                  | 14 ++++++----
 6 files changed, 56 insertions(+), 14 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-02-19 19:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [RFC][PATCH 3/5] [PR gdb/33469] mi_ui_out: redirect: push separator state when async = true Dennis Lambe Jr.
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.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox