[RFA] fix "ptype $pc" internal-error
Joel Brobecker
brobecker@adacore.com
Fri Jan 4 10:50:00 GMT 2008
> Indentation is off here.
>
> if (noside == EVAL_AVOID_SIDE_EFFECTS
> && regno < (gdbarch_num_regs (current_gdbarch)
> + gdbarch_num_pseudo_regs (current_gdbarch)))
Oops, you are right, of course. Thanks!
Fixed in the attached patch.
2008-01-04 Joel Brobecker <brobecker@adacore.com>
* eval.c (evaluate_subexp_standard): Add handling of user
registers when in EVAL_AVOID_SIDE_EFFECTS mode.
2008-01-04 Joel Brobecker <brobecker@adacore.com>
* gdb.base/ptype.exp: Add testing of "ptype $pc".
--
Joel
-------------- next part --------------
Index: eval.c
===================================================================
--- eval.c (revision 65)
+++ eval.c (revision 68)
@@ -512,7 +512,15 @@ evaluate_subexp_standard (struct type *e
name, strlen (name));
if (regno == -1)
error (_("Register $%s not available."), name);
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
+
+ /* In EVAL_AVOID_SIDE_EFFECTS mode, we only need to return
+ a value with the appropriate register type. Unfortunately,
+ we don't have easy access to the type of user registers.
+ So for these registers, we fetch the register value regardless
+ of the evaluation mode. */
+ if (noside == EVAL_AVOID_SIDE_EFFECTS
+ && regno < (gdbarch_num_regs (current_gdbarch)
+ + gdbarch_num_pseudo_regs (current_gdbarch)))
val = value_zero (register_type (current_gdbarch, regno), not_lval);
else
val = value_of_register (regno, get_selected_frame (NULL));
Index: testsuite/gdb.base/ptype.exp
===================================================================
--- testsuite/gdb.base/ptype.exp (revision 65)
+++ testsuite/gdb.base/ptype.exp (revision 68)
@@ -639,4 +639,7 @@ if [runto_main] then {
gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]"
gdb_test "ptype {4,5,6}\[2\]" "type = int"
gdb_test "ptype *&{4,5,6}\[1\]" "type = int"
+
+ # Test ptype of user register
+ gdb_test "ptype \$pc" "void \\(\\*\\)\\(\\)" "ptype \$pc"
}
More information about the Gdb-patches
mailing list