PR cli/19918 points out that a printf format like "%-5p" will cause a
gdb crash. The bug is problem is that printf_pointer doesn't take the
"-" flag into account.
gdb/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/19918:
* printcmd.c (printf_pointer): Allow "-" in format.
gdb/testsuite/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/19918:
* gdb.base/printcmds.exp (test_printf): Add printf test using '-'
flag.
+2018-03-14 Tom Tromey <tom@tromey.com>
+
+ PR cli/19918:
+ * printcmd.c (printf_pointer): Allow "-" in format.
+
2018-03-14 Tom Tromey <tom@tromey.com>
* printcmd.c (_initialize_printcmd): Add usage to printf.
if (val != 0)
*fmt_p++ = '#';
- /* Copy any width. */
- while (*p >= '0' && *p < '9')
+ /* Copy any width or flags. Only the "-" flag is valid for pointers
+ -- see the format_pieces constructor. */
+ while (*p == '-' || (*p >= '0' && *p < '9'))
*fmt_p++ = *p++;
gdb_assert (*p == 'p' && *(p + 1) == '\0');
+2018-03-14 Tom Tromey <tom@tromey.com>
+
+ PR cli/19918:
+ * gdb.base/printcmds.exp (test_printf): Add printf test using '-'
+ flag.
+
2018-03-08 Simon Marchi <simon.marchi@ericsson.com>
PR gdb/22841
"" \
"create hibob command"
gdb_test "hibob" "hi bob zzz.*y" "run hibob command"
+
+ # PR cli/19918.
+ gdb_test "printf \"%-16dq\\n\", 0" "0 q"
+ gdb_test "printf \"%-16pq\\n\", 0" "\\(nil\\) q"
}
#Test printing DFP values with printf