Fix MI crash with Ada string access
authorTom Tromey <tromey@adacore.com>
Mon, 17 Aug 2020 15:21:40 +0000 (09:21 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 17 Aug 2020 15:21:40 +0000 (09:21 -0600)
commit3ae7ab999277b5d668d89fed5a7707f7778f5e6b
tree6a91d725cf865015651c722d9f544b37c40cde48
parentb017825fabd0ff6f6ff2a8526d50d0b7218606d0
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.
gdb/ChangeLog
gdb/ada-varobj.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/mi_var_access.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/mi_var_access/mi_access.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/mi_var_access/pck.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/mi_var_access/pck.ads [new file with mode: 0644]