From 9e87a40907128affbb3c7bbfe2bee68fdd34fa0a Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 29 Dec 2010 08:02:59 +0000 Subject: [Ada] print null array pointer as `0x0' rather than `(null)' Trying to print a variable defined as an access to an unconstrained array: type String_Access is access String; S1 : String_Access; If that variable is null, then GDB prints its value in an odd way: (gdb) print S1 $1 = (string_bug.string_access) (null) ^^^^^^ This patch changes the debugger behavior to print the pointer using the same output we'd use for any null pointer: (gdb) print S1 $1 = (string_bug.string_access) 0x0 It also adds an assert, helping us verify an assumption. gdb/ChangeLog: * ada-valprint.c (ada_val_print_1): Print null array pointers as `0x0' rather than `(null)'. Add assertion. gdb/testsuite/ChangeLog: * gdb.ada/arrayptr/foo.adb: Add new local variable Null_String. * gdb.ada/arrayptr.exp: Add test printing that new variable. --- gdb/ada-valprint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gdb/ada-valprint.c') diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index b5d4b02..7c74838 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -690,7 +690,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0, val = ada_coerce_to_simple_array (val); if (val == NULL) { - fprintf_filtered (stream, "(null)"); + gdb_assert (TYPE_CODE (type) == TYPE_CODE_TYPEDEF); + fprintf_filtered (stream, "0x0"); retn = 0; } else -- cgit v1.1