This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/Ada] Fix printing address of packed array


When trying to print the address of a non-packed array, GDB
correctly prints the type name and address:

    (gdb) print &var
    $2 = (access pa.var) 0xbffff1d8

However, it is behaving differently when dealing with a packed
array:

    (gdb) p &var
    (access array (4 .. 8) of boolean <packed: 1-bit elements>) (4 =>
    false, false, false, true, false)

The type description isn't all that bad, but GDB shouldn't be
printing the array value!

This patch fixes the `print` and `ptype` command on packed and
non-packed array.  It also fixes a gdb.ada test to match with
the new ouput.

gdb/ChangeLog (Jean-Charles Delay):

        * ada-typeprint.c (ada_print_type): Fix both PAD type and
        pointer to constrained packed array type output.
        * ada-valprint.c (ada_val_print_1): Fix pointer to constrained
        packed array output.

gdb/testsuite/ChangeLog (Jean-Charles Delay):

        * gdb.ada/packed_array.exp: Fix expected outout.

Tested on x86_64-linux.  Checked in.

---
 gdb/ChangeLog                          |    7 +++++++
 gdb/ada-typeprint.c                    |   17 ++++-------------
 gdb/ada-valprint.c                     |    3 ++-
 gdb/testsuite/ChangeLog                |    4 ++++
 gdb/testsuite/gdb.ada/packed_array.exp |    2 +-
 5 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 572faa2..1d1eef5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2011-07-01  Jean-Charles Delay  <delay@adacore.com>
 
+	* ada-typeprint.c (ada_print_type): Fix both PAD type and
+	pointer to constrained packed array type output.
+	* ada-valprint.c (ada_val_print_1): Fix pointer to constrained
+	packed array output.
+
+2011-07-01  Jean-Charles Delay  <delay@adacore.com>
+
 	* ada-typeprint.c (print_array_type): removed if condition on show
 	being negative for bounds printing.
 
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index ff1b524..6bae634 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -761,7 +761,7 @@ ada_print_type (struct type *type0, const char *varstring,
     fprintf_filtered (stream, "%.*s: ",
 		      ada_name_prefix_len (varstring), varstring);
 
-  if (type_name != NULL && show <= 0)
+  if (type_name != NULL && show <= 0 && !ada_is_aligner_type (type))
     {
       fprintf_filtered (stream, "%.*s",
 			ada_name_prefix_len (type_name), type_name);
@@ -770,18 +770,9 @@ ada_print_type (struct type *type0, const char *varstring,
 
   if (ada_is_aligner_type (type))
     ada_print_type (ada_aligned_type (type), "", stream, show, level);
-  else if (ada_is_constrained_packed_array_type (type))
-    {
-      if (TYPE_CODE (type) == TYPE_CODE_PTR)
-        {
-          fprintf_filtered (stream, "access ");
-          print_array_type (TYPE_TARGET_TYPE (type), stream, show, level);
-        }
-      else
-        {
-          print_array_type (type, stream, show, level);
-        }
-    }
+  else if (ada_is_constrained_packed_array_type (type)
+	   && TYPE_CODE (type) != TYPE_CODE_PTR)
+    print_array_type (type, stream, show, level);
   else
     switch (TYPE_CODE (type))
       {
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index f0901a8..7b9e3ee 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -682,7 +682,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
   type = ada_check_typedef (type);
 
   if (ada_is_array_descriptor_type (type)
-      || ada_is_constrained_packed_array_type (type))
+      || (ada_is_constrained_packed_array_type (type)
+	  && TYPE_CODE (type) != TYPE_CODE_PTR))
     {
       int retn;
       struct value *mark = value_mark ();
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c684ee6..00a7a45 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2011-07-01  Jean-Charles Delay  <delay@adacore.com>
 
+	* gdb.ada/packed_array.exp: Fix expected outout.
+
+2011-07-01  Jean-Charles Delay  <delay@adacore.com>
+
 	* gdb.ada/packed_array.exp: fixed expected output.
 
 2011-07-01  Joel Brobecker  <brobecker@adacore.com>
diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp
index 3318873..ef7c8b4 100644
--- a/gdb/testsuite/gdb.ada/packed_array.exp
+++ b/gdb/testsuite/gdb.ada/packed_array.exp
@@ -48,7 +48,7 @@ gdb_test "ptype &var" \
          "ptype &var"
 
 gdb_test "print &var" \
-         "= \\(access array \\(4 \\.\\. 8\\) of boolean <packed: 1-bit elements>\\) \\(4 => true, false, true, false, true\\)" \
+         "= \\(access pa.packed_array\\) 0x.*" \
          "print &var"
 
 # Print the value of U_Var, an unconstrainted packed array.
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]