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]

[pushed 3/4] [Ada] "ptype" of array where bound value uses DW_OP_push_object_address


Consider an Ada array type where the DWARF debugging info for
at least one of the bounds involves an expression containing
a DW_OP_push_object_address operation. Trying to "ptype" that
type currently yields:

    (gdb) ptype foo.array_type
    type = array (Location address is not set.

This patch improves ada-typeprint by adding handling of the situation
where an array range type has dynamic bounds.  In that case, it prints
the array bounds using Ada's typical syntax for unbounded ranges "<>":

    (gdb) ptype array_type
    type = array (<>) of integer

gdb/ChangeLog:

        * ada-typeprint.c (type_is_full_subrange_of_target_type):
        Return 0 if TYPE is dynamic.
        (print_range): Add handling of dynamic ranges.
---
 gdb/ChangeLog       |  6 ++++++
 gdb/ada-typeprint.c | 31 ++++++++++++++++++++++++++-----
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1d35ac3..c14fd5c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-18  Joel Brobecker  <brobecker@adacore.com>
+
+	* ada-typeprint.c (type_is_full_subrange_of_target_type):
+	Return 0 if TYPE is dynamic.
+	(print_range): Add handling of dynamic ranges.
+
 2014-08-18  Keven Boell  <keven.boell@intel.com>
 	    Joel Brobecker  <brobecker@adacore.com>
 
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 305e39c..57c8d93 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -115,6 +115,9 @@ type_is_full_subrange_of_target_type (struct type *type)
   if (subtype == NULL)
     return 0;
 
+  if (is_dynamic_type (type))
+    return 0;
+
   if (ada_discrete_type_low_bound (type)
       != ada_discrete_type_low_bound (subtype))
     return 0;
@@ -156,15 +159,33 @@ print_range (struct type *type, struct ui_file *stream,
     case TYPE_CODE_ENUM:
       {
 	struct type *target_type;
+	volatile struct gdb_exception e;
+	LONGEST lo, hi;
 
 	target_type = TYPE_TARGET_TYPE (type);
 	if (target_type == NULL)
 	  target_type = type;
-	ada_print_scalar (target_type, ada_discrete_type_low_bound (type),
-			  stream);
-	fprintf_filtered (stream, " .. ");
-	ada_print_scalar (target_type, ada_discrete_type_high_bound (type),
-			  stream);
+
+	TRY_CATCH (e, RETURN_MASK_ERROR)
+	  {
+	    lo = ada_discrete_type_low_bound (type);
+	    hi = ada_discrete_type_high_bound (type);
+	  }
+	if (e.reason < 0)
+	  {
+	    /* This can happen when the range is dynamic.  Sometimes,
+	       resolving dynamic property values requires us to have
+	       access to an actual object, which is not available
+	       when the user is using the "ptype" command on a type.
+	       Print the range as an unbounded range.  */
+	    fprintf_filtered (stream, "<>");
+	  }
+	else
+	  {
+	    ada_print_scalar (target_type, lo, stream);
+	    fprintf_filtered (stream, " .. ");
+	    ada_print_scalar (target_type, hi, stream);
+	  }
       }
       break;
     default:
-- 
1.9.1


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