This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit/Ada] "info tasks" broken by typedefs in ATCB type definitions.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 15 Jan 2010 16:15:16 +0400
- Subject: [commit/Ada] "info tasks" broken by typedefs in ATCB type definitions.
From: botcazou <botcazou@f8352e7e-cb20-0410-8ce7-b5d9e71c585c>
Eric made a change in the compiler in Aug 2009 that uncovered a hole
in the way the debugger builds the type structures it then uses to
compute the Ada tasking info. The change itself was described by
Eric as follow:
> This change is aimed at unifying how pointers to
> unconstrained arrays are represented in the debug info, but this apparently
> exhibits a problem in the way ada-tasks.c builds the type of the ATCB.
>
> What has changed in the type of the fields "entry_names" and "open_accepts".
> They were duplicates of entry_names_array___XUP and accept_list___XUP
> respectively, now they are references to them through a DW_TAG_typedef
> [...]
In practice, we would get warnings, and often invalid data (due to
the wrong values being fetched):
(gdb) info tasks
warning: array or string index out of range
warning: array or string index out of range
warning: array or string index out of range
ID TID P-ID Pri State Name
1 642010 0 48 Child Termination Wait main_task
2 642d20 1 48 Accept or Select Term my_callee
* 3 646400 1 48 Runnable my_caller
Eric fixed the problem with the following patch.
gdb/ChangeLog:
"info tasks" broken by typedefs in ATCB type definitions.
* ada-lang.c (ada_template_to_fixed_record_type_1): Add call to
ada_check_typedef before retrieving the length of the type for
regular fields.
Tested on x86_64-linux. Checked in.
---
gdb/ada-lang.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 8f90711..2f16644 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -6929,14 +6929,16 @@ ada_template_to_fixed_record_type_1 (struct type *type,
}
else
{
- TYPE_FIELD_TYPE (rtype, f) = TYPE_FIELD_TYPE (type, f);
+ struct type *field_type = TYPE_FIELD_TYPE (type, f);
+
+ TYPE_FIELD_TYPE (rtype, f) = field_type;
TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f);
if (TYPE_FIELD_BITSIZE (type, f) > 0)
bit_incr = fld_bit_len =
TYPE_FIELD_BITSIZE (rtype, f) = TYPE_FIELD_BITSIZE (type, f);
else
bit_incr = fld_bit_len =
- TYPE_LENGTH (TYPE_FIELD_TYPE (type, f)) * TARGET_CHAR_BIT;
+ TYPE_LENGTH (ada_check_typedef (field_type)) * TARGET_CHAR_BIT;
}
if (off + fld_bit_len > bit_len)
bit_len = off + fld_bit_len;
--
1.6.3.3