aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-10-17 18:29:28 +0000
committerTom Tromey <tromey@redhat.com>2013-10-17 18:29:28 +0000
commit50b34a18edaf0f2112d03f62f2816b920203ac07 (patch)
treef5bc54821953807e163447e281b3966cbe407110
parent5c4c8a591172c0f427f3bf118f5beaaa0b2b7c39 (diff)
downloadgdb-50b34a18edaf0f2112d03f62f2816b920203ac07.zip
gdb-50b34a18edaf0f2112d03f62f2816b920203ac07.tar.gz
gdb-50b34a18edaf0f2112d03f62f2816b920203ac07.tar.bz2
fix for PR gdb/15995
This patch fixes PR gdb/15995. The bug here is that gdb's printf command does not flush the output stream. This makes a printf that is not newline-terminated interleave incorrectly with other forms of output, such as that generated via a call to an external program using "shell". I note that the "output" command already does this flushing. The fix is to call gdb_flush in printf_command. Built and regtested on x86-64 Fedora 18. New test case included. PR gdb/15995: * printcmd.c (printcmd): Call gdb_flush. * gdb.base/printcmds.exp (test_printf): Test printf flushing.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/printcmd.c1
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp6
4 files changed, 16 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index adf5dcc..d6200fa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2013-10-17 Tom Tromey <tromey@redhat.com>
+ PR gdb/15995:
+ * printcmd.c (printcmd): Call gdb_flush.
+
+2013-10-17 Tom Tromey <tromey@redhat.com>
+
* elfread.c (struct elfinfo) <stabindexsect>: Remove.
(elf_locate_sections): Update.
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 751cd2b..9bca6dd 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2458,6 +2458,7 @@ static void
printf_command (char *arg, int from_tty)
{
ui_printf (arg, gdb_stdout);
+ gdb_flush (gdb_stdout);
}
/* Implement the "eval" command. */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 886338e..634184a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-10-17 Tom Tromey <tromey@redhat.com>
+
+ * gdb.base/printcmds.exp (test_printf): Test printf flushing.
+
2013-10-14 Tom Tromey <tromey@redhat.com>
* gdb.dwarf2/dwzbuildid.exp (write_dwarf_file): Pass explicit test
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 60e4a7f..6d65107 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -740,6 +740,12 @@ proc test_printf {} {
gdb_test "printf \"% p\", 0" "Inappropriate modifiers to format specifier 'p' in printf"
gdb_test "printf \"%0p\", 0" "Inappropriate modifiers to format specifier 'p' in printf"
gdb_test "printf \"%+p\", 0" "Inappropriate modifiers to format specifier 'p' in printf"
+
+
+ gdb_test "define hibob\nprintf \"hi bob \"\nshell echo zzz\nprintf \"y\\n\"\nend" \
+ "" \
+ "create hibob command"
+ gdb_test "hibob" "hi bob zzz.*y" "run hibob command"
}
#Test printing DFP values with printf