- Patches added (swo#28323):

gdb-ada-fix-assert-in-ada_is_unconstrained_packed_array_type.patch

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=314
This commit is contained in:
Tom de Vries 2021-12-07 06:41:53 +00:00 committed by Git OBS Bridge
parent 1b7b29bab9
commit 378293e684
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,48 @@
[gdb/ada] Fix assert in ada_is_unconstrained_packed_array_type
On openSUSE Leap 42.3, with system compiler gcc 4.8.5 I run into:
...
(gdb) print u_one_two_three^M
src/gdb/gdbtypes.h:1050: internal-error: field: \
Assertion `idx >= 0 && idx < num_fields ()' failed.^M
...
We run into trouble while doing this in
ada_is_unconstrained_packed_array_type:
...
1953 return TYPE_FIELD_BITSIZE (type, 0) > 0;
...
which tries to get field 0 from a type without fields:
...
(gdb) p type->num_fields ()
$6 = 0
...
which is the case because the type is a typedef:
...
(gdb) p type->code ()
$7 = TYPE_CODE_TYPEDEF
...
Fix this by using the type referenced by the typedef instead.
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28323
---
gdb/ada-lang.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b098991612d..9341c7b3677 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1927,6 +1927,8 @@ ada_is_unconstrained_packed_array_type (struct type *type)
/* The structure's first field is a pointer to an array, so this
fetches the array type. */
type = TYPE_TARGET_TYPE (type->field (0).type ());
+ if (type->code () == TYPE_CODE_TYPEDEF)
+ type = ada_typedef_target_type (type);
/* Now we can see if the array elements are packed. */
return TYPE_FIELD_BITSIZE (type, 0) > 0;
}

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Dec 6 17:19:44 UTC 2021 - Tom de Vries <tdevries@suse.com>
- Patches added (swo#28323):
gdb-ada-fix-assert-in-ada_is_unconstrained_packed_array_type.patch
-------------------------------------------------------------------
Tue Nov 30 10:45:32 UTC 2021 - Tom de Vries <tdevries@suse.com>

View File

@ -389,6 +389,8 @@ Patch2118: gdb-symtab-fix-segfault-in-search_one_symtab.patch
Patch2119: gdb-testsuite-fix-gdb.arch-i386-pkru.exp-on-linux.patch
# https://sourceware.org/pipermail/gdb-patches/2021-November/183960.html
Patch2120: gdb-tdep-fix-avx512-m32-support-in-gdbserver.patch
# https://sourceware.org/pipermail/gdb-patches/2021-December/184241.html
Patch2121: gdb-ada-fix-assert-in-ada_is_unconstrained_packed_array_type.patch
BuildRequires: bison
BuildRequires: flex
@ -815,6 +817,7 @@ find -name "*.info*"|xargs rm -f
%patch2118 -p1
%patch2119 -p1
%patch2120 -p1
%patch2121 -p1
#unpack libipt
%if 0%{have_libipt}