[RFA] fix gdb.ada/null_record.exp
Joel Brobecker
brobecker@adacore.com
Tue Jan 2 11:30:00 GMT 2007
Hello,
Daniel reported that null_record.exp was failing. The test was failing
on my side as well, although not the same way (I was so intent on
finding out what the cause was that I didn't pay enough attention to
what Daniel posted - sorry).
Here is what I observed:
ptype empty
type = <void>
(gdb) FAIL: gdb.ada/null_record.exp: ptype on null record
The output is not a surprise when you look at what ada_evaluate_subexp
returns for OP_TYPE expressions:
case OP_TYPE:
/* The value is not supposed to be used. This is here to make it
easier to accommodate expressions that contain types. */
(*pos) += 2;
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
!!!-> return allocate_value (builtin_type_void);
else
error (_("Attempt to use a type name as an expression"));
The reason this was good enough is that, in GDB 6.4 (we are still
using this as our baseline), ptype_command was not doing a full
evaluation of the expression to get the type description. Rather,
it used a short-cut:
static struct type *
ptype_eval (struct expression *exp)
{
if (exp->elts[0].opcode == OP_TYPE)
{
return (exp->elts[1].type);
}
else
[...]
}
This was changed since then to call evaluate_type (expr) instead,
Knowing this, I discovered that calling ptype on probably any type
name would return this "<void>" type. I reproduced this with a non-
null record too, for instance.
The proposed fix is attached:
2007-01-02 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (ada_evaluate_subexp) [OP_TYPE]: Return a value with
the appropriate type rather than a bogus void type.
Tested on x86-linux, no regression. Fixes the null_record.exp on my side.
OK to apply?
Thanks,
--
Joel
-------------- next part --------------
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.85
diff -u -p -r1.85 ada-lang.c
--- ada-lang.c 1 Dec 2006 00:32:29 -0000 1.85
+++ ada-lang.c 2 Jan 2007 10:52:36 -0000
@@ -8576,7 +8576,7 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return allocate_value (builtin_type_void);
+ return allocate_value (exp->elts[pc + 1].type);
else
error (_("Attempt to use a type name as an expression"));
More information about the Gdb-patches
mailing list