printf command parses the format string and prints arguments one by one. If it happens that you want to print just a "%%" and there are no arguments anymore (or there were no any arguments) then the remainder of format string is printed with puts_filtered (last_arg); puts does not know anything about special escape sequence for "%%" and instead of printing just one '%' it prints both of them. The fix is trivial. Just replace: puts_filtered (last_arg); with: printf_filtered (last_arg); in gdb/printcmd.c printf_command() Test like this: printf "%% %d %%\n", 1 Should produce: % 1 % The same problem was in 6.8.
Created attachment 4640 [details] Fix. Change fputs_unfiltered to fprintf_unfiltered
Created attachment 4641 [details] Fix. Change puts_unfiltered to fprintf_unfiltered
I'm handling this. The patch looks fine to me. I'm writing a regression test & testing it, then I'll commit it.
Subject: Bug 11345 CVSROOT: /cvs/src Module name: src Changes by: tromey@sourceware.org 2010-03-03 18:05:05 Modified files: gdb : ChangeLog printcmd.c gdb/testsuite : ChangeLog gdb/testsuite/gdb.base: printcmds.exp Log message: gdb 2010-03-03 Dainis Jonitis <jonitis@gmail.com> PR gdb/11345: * printcmd.c (printf_command): Print end of format string using printf_filtered. gdb/testsuite 2010-03-03 Tom Tromey <tromey@redhat.com> PR gdb/11345: * gdb.base/printcmds.exp (test_printf): Add test. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11417&r2=1.11418 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/printcmd.c.diff?cvsroot=src&r1=1.170&r2=1.171 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2159&r2=1.2160 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/printcmds.exp.diff?cvsroot=src&r1=1.29&r2=1.30
Fixed in CVS.
Subject: Bug 11345 CVSROOT: /cvs/src Module name: src Branch: gdb_7_1-branch Changes by: tromey@sourceware.org 2010-03-03 18:22:59 Modified files: gdb : ChangeLog printcmd.c gdb/testsuite : ChangeLog gdb/testsuite/gdb.base: printcmds.exp Log message: gdb 2010-03-03 Dainis Jonitis <jonitis@gmail.com> PR gdb/11345: * printcmd.c (printf_command): Print end of format string using printf_filtered. gdb/testsuite 2010-03-03 Tom Tromey <tromey@redhat.com> PR gdb/11345: * gdb.base/printcmds.exp (test_printf): Add test. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_1-branch&r1=1.11378.2.14&r2=1.11378.2.15 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/printcmd.c.diff?cvsroot=src&only_with_tag=gdb_7_1-branch&r1=1.170&r2=1.170.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_1-branch&r1=1.2147.2.1&r2=1.2147.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/printcmds.exp.diff?cvsroot=src&only_with_tag=gdb_7_1-branch&r1=1.29&r2=1.29.2.1
I also pushed it into the 7.1 branch