aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dwarf2
diff options
context:
space:
mode:
authorBernhard Heckel <bernhard.heckel@intel.com>2022-10-13 15:17:23 +0200
committerIjaz, Abdul B <abdul.b.ijaz@intel.com>2024-02-02 08:57:16 +0100
commitf18fc7e56fbb605aa38643881eb0228313466551 (patch)
treed97a46d5aa4592514b7842f84a9a541371fed236 /gdb/testsuite/gdb.dwarf2
parent2e07108364e2c8494a41919a56ca4a40092c9d58 (diff)
downloadgdb-f18fc7e56fbb605aa38643881eb0228313466551.zip
gdb-f18fc7e56fbb605aa38643881eb0228313466551.tar.gz
gdb-f18fc7e56fbb605aa38643881eb0228313466551.tar.bz2
gdb, types: Resolve pointer types dynamically
This commit allows pointers to be dynamic types (on the outmost level). Similar to references, a pointer is considered a dynamic type if its target type is a dynamic type and it is on the outmost level. Also this commit removes the redundant code inside function "value_check_printable" for handling of DW_AT_associated type. The pointer resolution follows the one of references. This change generally makes the GDB output more verbose. We are able to print more details about a pointer's target like the dimension of an array. In Fortran, if we have a pointer to a dynamic type type buffer real, dimension(:), pointer :: ptr end type buffer type(buffer), pointer :: buffer_ptr allocate (buffer_ptr) allocate (buffer_ptr%ptr (5)) which then gets allocated, we now resolve the dynamic type before printing the pointer's type: Before: (gdb) ptype buffer_ptr type = PTR TO -> ( Type buffer real(kind=4) :: alpha(:) End Type buffer ) After: (gdb) ptype buffer_ptr type = PTR TO -> ( Type buffer real(kind=4) :: alpha(5) End Type buffer ) Similarly in C++ we can dynamically resolve e.g. pointers to arrays: int len = 3; int arr[len]; int (*ptr)[len]; int ptr = &arr; Once the pointer is assigned one gets: Before: (gdb) p ptr $1 = (int (*)[variable length]) 0x123456 (gdb) ptype ptr type = int (*)[variable length] After: (gdb) p ptr $1 = (int (*)[3]) 0x123456 (gdb) ptype ptr type = int (*)[3] For more examples see the modified/added test cases. Tested-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org> Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r--gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp16
1 files changed, 8 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
index 232f4e2..3b7fb72 100644
--- a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
@@ -154,7 +154,7 @@ gdb_test "print foo.three_ptr.all'length" \
" = 3"
gdb_test "ptype foo.three_ptr.all" \
- " = array \\(<>\\) of integer"
+ " = array \\(1 \\.\\. 3\\) of integer"
# foo.three_ptr
@@ -177,7 +177,7 @@ gdb_test "print foo.three_ptr'length" \
" = 3"
gdb_test "ptype foo.three_ptr" \
- " = access array \\(<>\\) of integer"
+ " = access array \\(1 \\.\\. 3\\) of integer"
# foo.three_ptr_tdef.all
@@ -203,7 +203,7 @@ gdb_test "print foo.three_ptr_tdef.all'length" \
" = 3"
gdb_test "ptype foo.three_ptr_tdef.all" \
- " = array \\(<>\\) of integer"
+ " = array \\(1 \\.\\. 3\\) of integer"
# foo.three_ptr_tdef
@@ -226,7 +226,7 @@ gdb_test "print foo.three_ptr_tdef'length" \
" = 3"
gdb_test "ptype foo.three_ptr_tdef" \
- " = access array \\(<>\\) of integer"
+ " = access array \\(1 \\.\\. 3\\) of integer"
# foo.five_ptr.all
@@ -258,7 +258,7 @@ gdb_test "print foo.five_ptr.all'length" \
" = 5"
gdb_test "ptype foo.five_ptr.all" \
- " = array \\(<>\\) of integer"
+ " = array \\(2 \\.\\. 6\\) of integer"
# foo.five_ptr
@@ -287,7 +287,7 @@ gdb_test "print foo.five_ptr'length" \
" = 5"
gdb_test "ptype foo.five_ptr" \
- " = access array \\(<>\\) of integer"
+ " = access array \\(2 \\.\\. 6\\) of integer"
# foo.five_ptr_tdef.all
@@ -319,7 +319,7 @@ gdb_test "print foo.five_ptr_tdef.all'length" \
" = 5"
gdb_test "ptype foo.five_ptr_tdef.all" \
- " = array \\(<>\\) of integer"
+ " = array \\(2 \\.\\. 6\\) of integer"
# foo.five_ptr_tdef
@@ -348,4 +348,4 @@ gdb_test "print foo.five_ptr_tdef'length" \
" = 5"
gdb_test "ptype foo.five_ptr_tdef" \
- " = access array \\(<>\\) of integer"
+ " = access array \\(2 \\.\\. 6\\) of integer"