aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-02-29 19:44:12 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-02-29 19:44:12 +0000
commit41246937ec25e4d69802ee153ce8c562882126a1 (patch)
treeb3f95acb66db0e47c129b88d83c58c58d13e0561
parentffde82bff0610b4c4d9e047489303649acf7c6ea (diff)
downloadgdb-41246937ec25e4d69802ee153ce8c562882126a1.zip
gdb-41246937ec25e4d69802ee153ce8c562882126a1.tar.gz
gdb-41246937ec25e4d69802ee153ce8c562882126a1.tar.bz2
[Ada] New functions to decode Ada types and values
This patch introduces two new functions that will be used to support the implementation of the ada-varobj effort. The function descriptions should say it all... gdb/ChangeLog: * ada-lang.h (ada_get_decoded_value, ada_get_decoded_type): Add declaration. * ada-lang.c (ada_get_decoded_value, ada_get_decoded_type): New function.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/ada-lang.c40
-rw-r--r--gdb/ada-lang.h4
3 files changed, 51 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e2fe0a3..a937673 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2012-02-29 Joel Brobecker <brobecker@adacore.com>
+ * ada-lang.h (ada_get_decoded_value, ada_get_decoded_type): Add
+ declaration.
+ * ada-lang.c (ada_get_decoded_value, ada_get_decoded_type): New
+ function.
+
+2012-02-29 Joel Brobecker <brobecker@adacore.com>
+
* ada-lang.c (ada_is_ignored_field): Rewrite wrong comment.
2012-02-29 Joel Brobecker <brobecker@adacore.com>
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 6382369..430e706 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -733,6 +733,46 @@ get_base_type (struct type *type)
}
return type;
}
+
+/* Return a decoded version of the given VALUE. This means returning
+ a value whose type is obtained by applying all the GNAT-specific
+ encondings, making the resulting type a static but standard description
+ of the initial type. */
+
+struct value *
+ada_get_decoded_value (struct value *value)
+{
+ struct type *type = ada_check_typedef (value_type (value));
+
+ if (ada_is_array_descriptor_type (type)
+ || (ada_is_constrained_packed_array_type (type)
+ && TYPE_CODE (type) != TYPE_CODE_PTR))
+ {
+ if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) /* array access type. */
+ value = ada_coerce_to_simple_array_ptr (value);
+ else
+ value = ada_coerce_to_simple_array (value);
+ }
+ else
+ value = ada_to_fixed_value (value);
+
+ return value;
+}
+
+/* Same as ada_get_decoded_value, but with the given TYPE.
+ Because there is no associated actual value for this type,
+ the resulting type might be a best-effort approximation in
+ the case of dynamic types. */
+
+struct type *
+ada_get_decoded_type (struct type *type)
+{
+ type = to_static_fixed_type (type);
+ if (ada_is_constrained_packed_array_type (type))
+ type = ada_coerce_to_simple_array_type (type);
+ return type;
+}
+
/* Language Selection */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 2a6cd57..d11a624 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -210,6 +210,10 @@ extern LONGEST ada_discrete_type_low_bound (struct type *);
extern LONGEST ada_discrete_type_high_bound (struct type *);
+extern struct value *ada_get_decoded_value (struct value *value);
+
+extern struct type *ada_get_decoded_type (struct type *type);
+
extern char *ada_decode_symbol (const struct general_symbol_info*);
extern const char *ada_decode (const char*);