diff options
author | Tom Tromey <tom@tromey.com> | 2018-02-14 20:11:16 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-03-14 09:44:34 -0600 |
commit | 3ae9ce5dd7d1119ca2c94c63a07b04921048ebe3 (patch) | |
tree | 9f4dd07f3fb68d454f5718f1c1816996a0a4441e /gdb/testsuite/gdb.base/printcmds.exp | |
parent | b8c2339b2f46d4885b933b832fc5b37c7ca101a6 (diff) | |
download | gdb-3ae9ce5dd7d1119ca2c94c63a07b04921048ebe3.zip gdb-3ae9ce5dd7d1119ca2c94c63a07b04921048ebe3.tar.gz gdb-3ae9ce5dd7d1119ca2c94c63a07b04921048ebe3.tar.bz2 |
Special case NULL when using printf's %s format
This changes the printf command's %s and %ls formats to special-case
NULL, and print "(null)" for these. This is PR cli/14977. This
behavior seems a bit friendlier; I was undecided on whether other
invalid pointers should be handled specially somehow, so for the time
being I've left those out.
gdb/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/14977:
* printcmd.c (printf_c_string, printf_wide_c_string): Special case
for NULL.
gdb/gdbserver/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/14977:
* ax.c (ax_printf): Special case for NULL.
gdb/testsuite/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/14977:
* gdb.base/printcmds.exp (test_printf): Add printf test of %s with
a null pointer.
* gdb.base/wchar.exp: Likewise.
Diffstat (limited to 'gdb/testsuite/gdb.base/printcmds.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/printcmds.exp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 56cedb9..635bd62 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -780,6 +780,9 @@ proc test_printf {} { # PR cli/19918. gdb_test "printf \"%-16dq\\n\", 0" "0 q" gdb_test "printf \"%-16pq\\n\", 0" "\\(nil\\) q" + + # PR cli/14977. + gdb_test "printf \"%s\\n\", 0" "\\(null\\)" } #Test printing DFP values with printf |