old-cross-binutils/gdb/testsuite/gdb.ada
Joel Brobecker 0acf8b658c Fix DW_OP_GNU_regval_type with FP registers
Consider the following code, compiled at -O2 on ppc-linux:

    procedure Increment (Val : in out Float; Msg : String);

The implementation does not really matter in this case). In our example,
this function is being called from a function with Param_1 set to 99.0.
Trying to break inside that function, and running until reaching that
breakpoint yields:

    (gdb) b increment
    Breakpoint 1 at 0x100014b4: file callee.adb, line 6.
    (gdb) run
    Starting program: /[...]/foo

    Breakpoint 1, callee.increment (val=99.0, val@entry=0.0, msg=...)
        at callee.adb:6
    6             if Val > 200.0 then

The @entry value for parameter "val" is incorrect, it should be 99.0.

The associated call-site parameter DIE looks like this:

        .uleb128 0xc     # (DIE (0x115) DW_TAG_GNU_call_site_parameter)
        .byte   0x2      # DW_AT_location
        .byte   0x90     # DW_OP_regx
        .uleb128 0x21
        .byte   0x3      # DW_AT_GNU_call_site_value
        .byte   0xf5     # DW_OP_GNU_regval_type
        .uleb128 0x3f
        .uleb128 0x25

The DW_AT_GNU_call_site_value uses a DW_OP_GNU_regval_type
operation, referencing register 0x3f=63, which is $f31,
an 8-byte floating register. In that register, the value is
stored using the usual 8-byte float format:

    (gdb) info float
    f31            99.0 (raw 0x4058c00000000000)

The current code evaluating DW_OP_GNU_regval_type operations
currently is (dwarf2expr.c:execute_stack_op):

            result = (ctx->funcs->read_reg) (ctx->baton, reg);
            result_val = value_from_ulongest (address_type, result);
            result_val = value_from_contents (type,
                                              value_contents_all (result_val));

What the ctx->funcs->read_reg function does is read the contents
of the register as if it contained an address. The rest of the code
continues that assumption, thinking it's OK to then use that to
create an address/ulongest struct value, which we then re-type
to the type specified by DW_OP_GNU_regval_type.

We're getting 0.0 above because the read_reg implementations
end up treating the contents of the FP register as an integral,
reading only 4 out of the 8 bytes. Being a big-endian target,
we read the high-order ones, which gives us zero.

This patch fixes the problem by introducing a new callback to
read the contents of a register as a given type, and then adjust
the handling of DW_OP_GNU_regval_type to use that new callback.

gdb/ChangeLog:

        * dwarf2expr.h (struct dwarf_expr_context_funcs) <read_reg>:
        Extend the documentation a bit.
        <get_reg_value>: New field.
        * dwarf2loc.c (dwarf_expr_get_reg_value)
        (needs_frame_get_reg_value): New functions.
        (dwarf_expr_ctx_funcs, needs_frame_ctx_funcs): Add "get_reg_value"
        callback.
        * dwarf2-frame.c (get_reg_value): New function.
        (dwarf2_frame_ctx_funcs): Add "get_reg_value" callback.
        * dwarf2expr.c (execute_stack_op) <DW_OP_GNU_regval_type>:
        Use new callback to compute result_val.

gdb/testsuite/ChangeLog:

        * gdb.ada/O2_float_param: New testcase.
2013-11-14 22:38:48 -05:00
..
aliased_array Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
array_bounds Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
array_return Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
array_subscript_addr Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
arrayidx Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
arrayparam Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
arrayptr [testsuite/Ada] Add testing of access to packed arrays. 2013-07-10 00:35:01 +00:00
atomic_enum Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bad-task-bp-keyword Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_enum_homonym Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_on_var Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_range_type Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_reset Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
call_pn Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
catch_ex Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
char_enum Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
char_param Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
complete Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cond_lang Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
dyn_loc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
enum_idx_packed Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
exec_changed Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
expr_delims Allow 'thread' to be used as a variable name in expressions. 2013-03-12 09:03:11 +00:00
exprs Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fixed_cmp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fixed_points Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
float_param [dwarf] Mark all functions as prototyped except C functions. 2013-05-20 09:45:13 +00:00
formatted_ref Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
frame_args Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fullname_bp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fun_addr Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fun_in_declare Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
funcall_param Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
homonym Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
info_exc Add command to list Ada exceptions 2013-11-12 06:45:29 +04:00
info_locals_renaming Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
int_deref Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
interface Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
iwide Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
lang_switch Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi_catch_ex Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi_ex_cond Dandling memory pointers in Ada catchpoints with GDB/MI. 2013-11-11 19:19:07 +04:00
mi_exc_info Implement GDB/MI equivalent of "info exceptions" CLI command. 2013-11-12 06:47:16 +04:00
mi_task_arg Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi_task_info Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mod_from_name Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nested Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
null_array Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
null_record Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
O2_float_param Fix DW_OP_GNU_regval_type with FP registers 2013-11-14 22:38:48 -05:00
operator_bp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
optim_drec Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
packed_array Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
packed_tagged Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
print_chars Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptr_typedef Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype_field Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype_tagged_param Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rdv_wait Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rec_return Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ref_param Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ref_tick_size Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
same_enum Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
set_pckd_arr_elt Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
set_wstr Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
small_reg_param Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
start Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
str_ref_cmp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
sym_print_name Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
taft_type Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tagged Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tagged_not_init Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
task_bp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tasks Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tick_last_segv Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
type_coercion Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
unc_arr_ptr_in_var_rec Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
uninitialized_vars Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
variant_record_packed_array Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
watch_arg Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
whatis_array_val Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
widewide Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
win_fu_syms Ignore __fu<digits>__ symbols from COFF symbol tables 2013-03-29 02:04:15 +00:00
aliased_array.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
array_bounds.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
array_return.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
array_subscript_addr.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
arrayidx.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
arrayparam.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
arrayptr.exp [testsuite/Ada] Add testing of access to packed arrays. 2013-07-10 00:35:01 +00:00
assign_1.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
atomic_enum.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bad-task-bp-keyword.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
boolean_expr.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_enum_homonym.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_on_var.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_range_type.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bp_reset.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
call_pn.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
catch_ex.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
char_enum.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
char_param.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
complete.exp gdb.ada/complete.exp: Fix FIXME. 2013-05-16 10:13:33 +00:00
cond_lang.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
dyn_loc.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
enum_idx_packed.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
exec_changed.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
expr_delims.exp Allow 'thread' to be used as a variable name in expressions. 2013-03-12 09:03:11 +00:00
exprs.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fixed_cmp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fixed_points.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
float_param.exp [dwarf] Mark all functions as prototyped except C functions. 2013-05-20 09:45:13 +00:00
formatted_ref.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
frame_args.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fullname_bp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fun_addr.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fun_in_declare.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
funcall_param.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gnat_ada.gpr Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
homonym.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
info_exc.exp Add command to list Ada exceptions 2013-11-12 06:45:29 +04:00
info_locals_renaming.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
info_types.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
info_types.exp simple test suite fix in gdb.ada 2013-07-16 18:52:18 +00:00
int_deref.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
interface.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
iwide.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
lang_switch.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
Makefile.in * Makefile.in (clean): Remove Fission .dwo and .dwp files. 2012-05-17 19:03:59 +00:00
mi_catch_ex.exp Adjust gdb.ada/mi_catch_ex.exp to use GDB/MI catch commands... 2013-10-11 13:49:36 +00:00
mi_ex_cond.exp Dandling memory pointers in Ada catchpoints with GDB/MI. 2013-11-11 19:19:07 +04:00
mi_exc_info.exp Implement GDB/MI equivalent of "info exceptions" CLI command. 2013-11-12 06:47:16 +04:00
mi_task_arg.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mi_task_info.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mod_from_name.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nested.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
null_array.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
null_record.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
O2_float_param.exp Fix DW_OP_GNU_regval_type with FP registers 2013-11-14 22:38:48 -05:00
operator_bp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
optim_drec.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
packed_array.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
packed_tagged.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
print_chars.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
print_pc.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptr_typedef.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype_arith_binop.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype_field.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype_tagged_param.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rdv_wait.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rec_return.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ref_param.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ref_tick_size.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
same_enum.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
set_pckd_arr_elt.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
set_wstr.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
small_reg_param.exp Fix FAIL: gdb.ada/small_reg_param.exp: continue to call_me 2013-07-10 00:10:37 +00:00
start.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
str_ref_cmp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
sym_print_name.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
taft_type.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tagged.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tagged_not_init.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
task_bp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tasks.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
tick_last_segv.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
type_coercion.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
unc_arr_ptr_in_var_rec.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
uninitialized_vars.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
variant_record_packed_array.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
watch_arg.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
whatis_array_val.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
widewide.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
win_fu_syms.exp Ignore __fu<digits>__ symbols from COFF symbol tables 2013-03-29 02:04:15 +00:00