diff options
author | Joel Brobecker <brobecker@gnat.com> | 2010-04-20 22:26:56 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2010-04-20 22:26:56 +0000 |
commit | 36ccd968aa12f631c23256b314822943f1e4ac22 (patch) | |
tree | c1a3b93dc3195ffa6a41b452d021f29f19dc66aa /gdb/ada-lang.h | |
parent | c0fe155d4ef80977ebeab93976d0f1f25516e783 (diff) | |
download | gdb-36ccd968aa12f631c23256b314822943f1e4ac22.tar.gz |
Wrong value printed by info locals for dynamic object.
The problem is printing the wrong value for dynamic local variables
when using the "info locals" command. Consider the following code:
procedure Print (I1 : Positive; I2 : Positive) is
type My_String is array (I1 .. I2) of Character;
I : My_String := (others => 'A');
S : String (1 .. I2 + 3) := (others => ' ');
begin
S (I1 .. I2) := String (I); -- BREAK
Put_Line (S);
end Print;
After the debugger stopped at BREAK, we try printing all local variables.
Here is what we get:
(gdb) info locals
i = "["00"]["00"]"
s = "["00"]["00"]["00"]["00"]["00"]["00"]["00"]["00"]"
Curiously, printing their value using the "print" command works:
(gdb) print i
$1 = "AA"
(gdb) print s
$2 = " "
We traced the problem to trying to get the contents of a variable
(call to value_contents) before "fix'ing" it. For those not familiar
with the Ada language support, "fixing" a value consists of swapping
the value's dynamic type with a static version that is appropriate
for our actual value. As a result, the dynamic type was used to
determine the value size, which is zero, and thus the value contents
was empty.
gdb/ChangeLog:
* valprint.c (common_val_print): Fix the value before extracting
its contents.
* ada-lang.c (ada_to_fixed_value): Make this function extern.
* ada-lang.h (ada_to_fixed_value): New function declaration.
* ada-valprint.c (ada_value_print): Use ada_to_fixed_value
to avoid code duplication and fix a bug in the handling of
fixed types contents.
gdb/testsuite/ChangeLog:
* gdb.ada/dyn_loc: New testcase.
Diffstat (limited to 'gdb/ada-lang.h')
-rw-r--r-- | gdb/ada-lang.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 77a63b74b5e..017cff2548b 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -312,6 +312,8 @@ extern struct type *ada_to_fixed_type (struct type *, const gdb_byte *, CORE_ADDR, struct value *, int check_tag); +extern struct value *ada_to_fixed_value (struct value *val); + extern struct type *ada_template_to_fixed_record_type_1 (struct type *type, const gdb_byte *valaddr, CORE_ADDR address, |