From: Iain Buclaw <ibuclaw@gdcproject.org>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH] gdb: Use puts_unfiltered instead of printf_unfiltered
Date: Tue, 26 Nov 2019 12:49:00 -0000 [thread overview]
Message-ID: <Bp1z1H0Uk-JcW1j7NMWgeijH4pFLAM5zyY6-OMDHyXwIBLc_qKy0LFyx15VMcg6gEd4IKqxbhN1mBXE5Hd0jY0U9qZj0-Poz4hQHHoYlKDc=@gdcproject.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]
Hi,
This patch fixes a regression, possibly introduced by 2a3c1174c3c0db1140180fb3fc56ac324d1c0a7c, in this part of the change:
---
@@ -2064,13 +2096,13 @@ vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args)
fputs_unfiltered (timestamp.c_str (), stream);
}
else
- fputs_unfiltered (linebuffer.c_str (), stream);
+ vfprintf_maybe_filtered (stream, format, args, false, true);
}
void
vprintf_filtered (const char *format, va_list args)
---
The significance of this is that printf_unfiltered writes messages to wrap_buffer, whereas puts_unfiltered pushes them immediately to stdout, resulting in "post-" messages being printed out of order.
Not sure about how to go about testing this, looking at the testsuite, such as gdb.base/annota1.exp, everything appears to be in order. Perhaps this is because the testsuite triggers one of these conditions in fputs_maybe_filtered() though.
---
if (stream != gdb_stdout
|| !pagination_enabled
|| pagination_disabled_for_command
|| batch_flag
|| (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
|| top_level_interpreter () == NULL
|| top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ())
---
However, the actual observed behaviour in gdb is:
---
Reading symbols from a.out...
(gdb) set annotate 2
\032\032pre-prompt
(gdb)
\032\032prompt
start
prompt\032\032post-
Temporary breakpoint 1 at 0x13716: file test.c, line 3.
---
With this patch applied, instead "\032\032post-prompt" is printed.
I think this can be applied as obvious, but wanted to have someone else have a quick check, just in case it would be preferred to change fputs_maybe_filtered instead to flush the buffer on scope exit for unfiltered messages.
--
Iain
---
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: postprompt.patch --]
[-- Type: text/x-patch; name="postprompt.patch", Size: 665 bytes --]
gdb/ChangeLog:
2019-11-26 Iain Buclaw <ibuclaw@gdcproject.org>
* gdb/event-top.c (handle_line_of_input): Use puts_unfiltered instead
of printf_unfiltered.
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 0396dbcc52..df6a4095fb 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -663,9 +663,9 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
if (from_tty && annotation_level > 1)
{
- printf_unfiltered (("\n\032\032post-"));
+ puts_unfiltered ("\n\032\032post-");
puts_unfiltered (annotation_suffix);
- printf_unfiltered (("\n"));
+ puts_unfiltered ("\n");
}
#define SERVER_COMMAND_PREFIX "server "
next reply other threads:[~2019-11-26 12:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 12:49 Iain Buclaw [this message]
2019-11-26 20:13 ` Christian Biesinger via gdb-patches
2019-11-26 20:25 ` Pedro Alves
2019-11-26 23:00 ` Iain Buclaw
2020-01-17 17:57 ` Joel Brobecker
2020-01-18 18:53 ` Iain Buclaw
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='Bp1z1H0Uk-JcW1j7NMWgeijH4pFLAM5zyY6-OMDHyXwIBLc_qKy0LFyx15VMcg6gEd4IKqxbhN1mBXE5Hd0jY0U9qZj0-Poz4hQHHoYlKDc=@gdcproject.org' \
--to=ibuclaw@gdcproject.org \
--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