https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=205551 2006-09-10 Jan Kratochvil * printcmd.c (printf_command): Handle forgotten "%p". 2006-09-10 Jan Kratochvil * gdb.base/display.exp: New test of `printf' "%p" formatting. diff -u -r sources-clean/gdb/printcmd.c sources-custom/gdb/printcmd.c --- sources-clean/gdb/printcmd.c 2006-07-29 20:29:26.000000000 +0200 +++ sources-custom/gdb/printcmd.c 2006-09-12 16:18:55.000000000 +0200 @@ -43,6 +43,9 @@ #include "gdb_assert.h" #include "block.h" #include "disasm.h" +#ifdef HAVE_STDINT_H +#include +#endif #ifdef TUI #include "tui/tui.h" /* For tui_active et.al. */ @@ -2065,6 +2068,16 @@ #else error (_("long long not supported in printf")); #endif + case ptr_arg: +#ifdef HAVE_UINTPTR_T + { + void *val = (void *) (uintptr_t) value_as_address (val_args[i]); + printf_filtered (current_substring, val); + break; + } +#else + error (_("pointer not supported in printf")); +#endif case int_arg: { int val = value_as_long (val_args[i]); diff -u -r sources-clean/gdb/testsuite/gdb.base/display.exp sources-custom/gdb/testsuite/gdb.base/display.exp --- sources-clean/gdb/testsuite/gdb.base/display.exp 2006-08-13 02:53:36.000000000 +0200 +++ sources-custom/gdb/testsuite/gdb.base/display.exp 2006-09-12 16:17:24.000000000 +0200 @@ -179,6 +179,8 @@ gdb_test "printf \"\"" ".*" "re-set term" gdb_test "printf \"\\w\"" ".*Unrecognized escape character.*" gdb_test "printf \"%d\" j" ".*Invalid argument syntax.*" +# 0 or hex vs. dec printing may be platform dependent: +gdb_test "printf \"<%p>\\n\", (void *)7" ".*7>.*" # play with "print", too #