+2018-03-14  Tom Tromey  <tom@tromey.com>
+
+       PR cli/14977:
+       * printcmd.c (printf_c_string, printf_wide_c_string): Special case
+       for NULL.
+
 2018-03-14  Tom Tromey  <tom@tromey.com>
 
        PR cli/19918:
 
+2018-03-14  Tom Tromey  <tom@tromey.com>
+
+       PR cli/14977:
+       * ax.c (ax_printf): Special case for NULL.
+
 2018-03-08  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * linux-low.c (linux_qxfer_libraries_svr4): Use
 
            int j;
 
            tem = args[i];
+           if (tem == 0)
+             {
+               printf (current_substring, "(null)");
+               break;
+             }
 
            /* This is a %s argument.  Find the length of the string.  */
            for (j = 0;; j++)
 
   int j;
 
   tem = value_as_address (value);
+  if (tem == 0)
+    {
+      fprintf_filtered (stream, format, "(null)");
+      return;
+    }
 
   /* This is a %s argument.  Find the length of the string.  */
   for (j = 0;; j++)
   gdb_byte *buf = (gdb_byte *) alloca (wcwidth);
 
   tem = value_as_address (value);
+  if (tem == 0)
+    {
+      fprintf_filtered (stream, format, "(null)");
+      return;
+    }
 
   /* This is a %s argument.  Find the length of the string.  */
   for (j = 0;; j += wcwidth)
 
+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.
+
 2018-03-14  Tom Tromey  <tom@tromey.com>
 
        PR cli/19918:
 
     # 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
 
 
 gdb_test "print repeat_p" "= $hex L\"A$cent$cent\"\.\.\." \
     "print repeat_p (print elements 3)"
+
+# From PR cli/14977, but here because it requires wchar_t.
+gdb_test "printf \"%ls\\n\", 0" "\\(null\\)"