This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit/Ada] print var'address + 1 returns wrong type
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 19 Nov 2009 17:51:53 -0500
- Subject: [commit/Ada] print var'address + 1 returns wrong type
The problem:
Given a variable A, we're trying to verify address arithmetics, and
to verify that additions/subtractions produce a value of the right type
(system.address). However, we get the following output:
(gdb) p a'address + 1
$1 = (access character) 0xbfe4699f "["01"]["f4"]_["be"]["00"]"
The expected output is just a plain address:
(gdb) p a'address + 1
$2 = (system.address) 0xbfe4699d
There was a name resolution confusion when looking for possible user-level
implementation of the "+" function above. The debugger got confused by
functions which applied to different types:
function "+" (Left : chars_ptr; Right : Integer) return chars_ptr;
function "-" (Left : chars_ptr; Right : Integer) return chars_ptr;
As a result, instead of doing simple address arithmetics, the debugger
called the function "+" above and printed the result from the call,
which explains the "access character" type for the result.
The fix was to improve the routine searching for functions whose
profile matches the arguments.
Tested on x86_64-linux. Checked in.
--
Joel
gdb/
Wrong function used to perform address addition/subtraction.
* ada-lang.c (ada_type_match): Stop making TYPE_CODE_VOID
a wildcard matching any type. For types that we don't already
handle specifically, make sure that both types have the same code.
---
gdb/ada-lang.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 5dc4ca1..173eb09 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2980,10 +2980,9 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
/* Return non-zero if formal type FTYPE matches actual type ATYPE. If
MAY_DEREF is non-zero, the formal may be a pointer and the actual
- a non-pointer. A type of 'void' (which is never a valid expression type)
- by convention matches anything. */
+ a non-pointer. */
/* The term "match" here is rather loose. The match is heuristic and
- liberal. FIXME: TOO liberal, in fact. */
+ liberal. */
static int
ada_type_match (struct type *ftype, struct type *atype, int may_deref)
@@ -2996,14 +2995,10 @@ ada_type_match (struct type *ftype, struct type *atype, int may_deref)
if (TYPE_CODE (atype) == TYPE_CODE_REF)
atype = TYPE_TARGET_TYPE (atype);
- if (TYPE_CODE (ftype) == TYPE_CODE_VOID
- || TYPE_CODE (atype) == TYPE_CODE_VOID)
- return 1;
-
switch (TYPE_CODE (ftype))
{
default:
- return 1;
+ return TYPE_CODE (ftype) == TYPE_CODE (atype);
case TYPE_CODE_PTR:
if (TYPE_CODE (atype) == TYPE_CODE_PTR)
return ada_type_match (TYPE_TARGET_TYPE (ftype),
--
1.6.0.4