Re: [patch rfc] push_dummy_call return a frame ID; eliminate need for read_fp

Andrew Cagney
2003-04-23T14:37:14Z

Hmm,

Patch withdrawn. I've just figured out a more straight forward way of
doing this. The `else' comment:

> + re-identify the dummy breakpoint. Code using
> + push_dummy_call() will have previously computed the dummy
> + frame's ID (and hence set "code_addr" to something
> + non-zero. */
> + id = frame_id_build (read_fp (), sal.pc);
> + /* else ... is the sal.pc the frame ID's code_addr? */
> +

gives the hint.

The frame ID's code_addr is always be the address of the breakpoint, so
instead of having push_dummy_call() return the frame ID, it can return
the ID's stack_addr, and then the hand function call code can explicitly
construct the frame ID from that and the sap.pc.

I'll just need to check the Arm.

Andrew

> Now that the inferior function call code is all in a single function, more, and significant, cleanups become possible.
>
> This patch modifies the architecture method push_dummy_call() so that it returns a frame ID, and not just a stack pointer. That frame ID is then used:
>
> - to create the breakpoint (the ID identifies the breakpoint's frame)
>
> - to identify the dummy (somewhat indirectly at present as it still goes via SAVE_DUMMY_FRAME_TOS() and generic_save_call_dummy_addr())
>
> This means that:
>
> - push_dummy_call(regcache, ...) creates the dummy frame's ID
>
> - unwind_dummy_id(frame, ...) is then expected to return that same value
>
> so the need for one to match the other is hopefully both clear and easy ...
>
> Future changes will involve:
>
> - deprecating read_fp / TARGET_READ_FP, as core GDB no longer contains any legitimate calls
>
> - merging SAVE_DUMMY_FRAME_TOS and generic_save_call_dummy_addr() into a single method that receives the full frame ID, and can not be overridden by the architecture.
>
> Someone studying this carefully will probably realise that instead of having push_dummy_call() return the ID, the code could simply use:
>
> flush cached frames;
> id = get_frame_id (get_current_frame ());
>
> but that would incure additional overhead.
>
> Mark,
> I think this patch resolves the i386's FP/SP frame ID problem. It makes push_dummy_call responsible for computing the ID, and then just passes it through.
>
> Richard,
> For the ARM, I've pulled a quick hack. I'm not sure what would happen if the ARM started returning a full frame ID.
>
> I'll leave this one sit for a week.
>
> Andrew
>
>
>
> 2003-04-22 Andrew Cagney <cagney@redhat.com>
>
> * d10v-tdep.c (d10v_push_dummy_call): Return a frame ID.
> (d10v_gdbarch_init): Do not set read_fp.
> (d10v_read_fp): Delete function.
> * arm-tdep.c (arm_push_dummy_call): Return the SP in a frame ID.
> * infcall.c (call_function_by_hand): New variable "id".
> Initialize using gdbarch_push_dummy_call when possible. For
> legacy code, use the the frame ID's "stack_addr" instead of "sp"
> to track the stack's inner most address.
> * gdbarch.sh (PUSH_DUMMY_CALL): Return the frame ID instead of the
> stack's inner most address.
> * gdbarch.h, gdbarch.c: Re-generate.
>
> Index: doc/ChangeLog
> 2003-04-22 Andrew Cagney <cagney@redhat.com>
>
> * gdbint.texinfo (Target Architecture Definition): Update
> "push_dummy_call", returns a frame ID. Cross reference
> "push_dummy_call" and "unwind_dummy_id". Drop reference to
> SAVE_DUMMY_FRAME_TOS.
>