This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] sparc-tdep.c: Fix `return' and `finish' from stop in call dummy


Peter.Schauer wrote:
> 
> `return' and `finish' after a stop in a call dummy are currently not
> handled correctly in sparc-tdep.c.
> 
> Here is a fix, it will be needed for the upcoming additional callfuncs
> testcases:
> 
>         * sparc-tdep.c (sparc_fix_call_dummy):  Improve comments.
>         Adjust call_dummy_breakpoint_offset, so that `finish' after a stop
>         in a call dummy works.

This is really two changes.  The above I will defer to David Taylor.
The below (sparc_gdbarch_init) is approved (since I wrote the code
that's being changed).

>         (sparc_gdbarch_init):  Fix setting of pc_in_call_dummy, it depends
>         on SPARC32/64_CALL_DUMMY_ON_STACK, not DO_CALL_DUMMY_ON_STACK.
> 
> *** ./sparc-tdep.c.orig Fri Sep 15 21:27:31 2000
> --- ./sparc-tdep.c      Fri Sep 22 22:16:59 2000
> ***************
> *** 2136,2149 ****
>                            | (((fun - (pc + CALL_DUMMY_CALL_OFFSET)) >> 2)
>                               & 0x3fffffff)));
> 
> !   /* Comply with strange Sun cc calling convention for struct-returning
> !      functions.  */
> !   if (!using_gcc
> !       && (TYPE_CODE (value_type) == TYPE_CODE_STRUCT
> !         || TYPE_CODE (value_type) == TYPE_CODE_UNION))
> !     store_unsigned_integer (dummy + CALL_DUMMY_CALL_OFFSET + 8, 4,
> !                           TYPE_LENGTH (value_type) & 0x1fff);
> 
>     if (!(GDB_TARGET_IS_SPARC64))
>       {
>         /* If this is not a simulator target, change the first four
> --- 2136,2163 ----
>                            | (((fun - (pc + CALL_DUMMY_CALL_OFFSET)) >> 2)
>                               & 0x3fffffff)));
> 
> !   /* If the called function returns an aggregate value, fill in the UNIMP
> !      instruction containing the size of the returned aggregate return value,
> !      which follows the call instruction.
> !      For details see the SPARC Architecture Manual Version 8, Appendix D.3.
> 
> +      Adjust the call_dummy_breakpoint_offset for the bp_call_dummy breakpoint
> +      to the proper address in the call dummy, so that `finish' after a stop
> +      in a call dummy works.
> +      Tweeking current_gdbarch is not an optimal solution, but the call to
> +      sparc_fix_call_dummy is immediately followed by a call to run_stack_dummy,
> +      which is the only function where dummy_breakpoint_offset is actually
> +      used, if it is non-zero.  */
> +   if (TYPE_CODE (value_type) == TYPE_CODE_STRUCT
> +        || TYPE_CODE (value_type) == TYPE_CODE_UNION)
> +     {
> +       store_unsigned_integer (dummy + CALL_DUMMY_CALL_OFFSET + 8, 4,
> +                             TYPE_LENGTH (value_type) & 0x1fff);
> +       set_gdbarch_call_dummy_breakpoint_offset (current_gdbarch, 0x30);
> +     }
> +   else
> +     set_gdbarch_call_dummy_breakpoint_offset (current_gdbarch, 0x2c);
> +
>     if (!(GDB_TARGET_IS_SPARC64))
>       {
>         /* If this is not a simulator target, change the first four
> ***************
> *** 2961,2971 ****
>     set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
>     set_gdbarch_max_register_raw_size (gdbarch, 8);
>     set_gdbarch_max_register_virtual_size (gdbarch, 8);
> - #ifdef DO_CALL_DUMMY_ON_STACK
> -   set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_on_stack);
> - #else
> -   set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_at_entry_point);
> - #endif
>     set_gdbarch_pop_frame (gdbarch, sparc_pop_frame);
>     set_gdbarch_push_return_address (gdbarch, sparc_push_return_address);
>     set_gdbarch_push_dummy_frame (gdbarch, sparc_push_dummy_frame);
> --- 2975,2980 ----
> ***************
> *** 2999,3004 ****
> --- 3008,3014 ----
>         /* 32-bit machine types: */
> 
>   #ifdef SPARC32_CALL_DUMMY_ON_STACK
> +       set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_on_stack);
>         set_gdbarch_call_dummy_address (gdbarch, sparc_call_dummy_address);
>         set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0x30);
>         set_gdbarch_call_dummy_length (gdbarch, 0x38);
> ***************
> *** 3005,3010 ****
> --- 3015,3021 ----
>         set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
>         set_gdbarch_call_dummy_words (gdbarch, call_dummy_32);
>   #else
> +       set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_at_entry_point);
>         set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
>         set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
>         set_gdbarch_call_dummy_length (gdbarch, 0);
> ***************
> *** 3053,3058 ****
> --- 3064,3070 ----
>       default:  /* Any new machine type is likely to be 64-bit.  */
> 
>   #ifdef SPARC64_CALL_DUMMY_ON_STACK
> +       set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_on_stack);
>         set_gdbarch_call_dummy_address (gdbarch, sparc_call_dummy_address);
>         set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 8 * 4);
>         set_gdbarch_call_dummy_length (gdbarch, 192);
> ***************
> *** 3060,3065 ****
> --- 3072,3078 ----
>         set_gdbarch_call_dummy_start_offset (gdbarch, 148);
>         set_gdbarch_call_dummy_words (gdbarch, call_dummy_64);
>   #else
> +       set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_at_entry_point);
>         set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
>         set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
>         set_gdbarch_call_dummy_length (gdbarch, 0);
> 
> --
> Peter Schauer                   pes@regent.e-technik.tu-muenchen.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]