summaryrefslogtreecommitdiff
path: root/gdb/ada-varobj.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-08-17 09:21:40 -0600
committerTom Tromey <tromey@adacore.com>2020-08-17 09:21:40 -0600
commit3ae7ab999277b5d668d89fed5a7707f7778f5e6b (patch)
tree6a91d725cf865015651c722d9f544b37c40cde48 /gdb/ada-varobj.c
parentb017825fabd0ff6f6ff2a8526d50d0b7218606d0 (diff)
downloadbinutils-gdb-3ae7ab999277b5d668d89fed5a7707f7778f5e6b.tar.gz
Fix MI crash with Ada string access
I happened to notice that using -var-create at a certain spot in an Ada program caused a crash. This happens because ada_get_decoded_value can return NULL -- in particular, deeper in the code it can hit this return in ada_type_of_array: descriptor = desc_bounds (arr); if (value_as_long (descriptor) == 0) return NULL; This patch avoids the crash by handling this NULL return. gdb/ChangeLog 2020-08-17 Tom Tromey <tromey@adacore.com> * ada-varobj.c (ada_varobj_decode_var): Handle case where ada_get_decoded_value returns NULL. gdb/testsuite/ChangeLog 2020-08-17 Tom Tromey <tromey@adacore.com> * gdb.ada/mi_var_access.exp: New file. * gdb.ada/mi_var_access/mi_access.adb: New file. * gdb.ada/mi_var_access/pck.adb: New file. * gdb.ada/mi_var_access/pck.ads: New file.
Diffstat (limited to 'gdb/ada-varobj.c')
-rw-r--r--gdb/ada-varobj.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index f67fe5002a3..a72653af37a 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -63,10 +63,10 @@ static void
ada_varobj_decode_var (struct value **value_ptr, struct type **type_ptr)
{
if (*value_ptr)
- {
- *value_ptr = ada_get_decoded_value (*value_ptr);
- *type_ptr = ada_check_typedef (value_type (*value_ptr));
- }
+ *value_ptr = ada_get_decoded_value (*value_ptr);
+
+ if (*value_ptr != nullptr)
+ *type_ptr = ada_check_typedef (value_type (*value_ptr));
else
*type_ptr = ada_get_decoded_type (*type_ptr);
}