Previous: About Dummy Frames, Up: Inferior Call Setup [Contents][Index]
The following functions provide the functionality to set up such dummy stack frames.
This function sets up a dummy stack frame for the function about to be
called. push_dummy_call
is given the arguments to be passed
and must copy them into registers or push them on to the stack as
appropriate for the ABI.
function is a pointer to the function that will be called and regcache the register cache from which values should be obtained. bp_addr is the address to which the function should return (which is breakpointed, so GDB can regain control, hence the name). nargs is the number of arguments to pass and args an array containing the argument values. struct_return is non-zero (true) if the function returns a structure, and if so struct_addr is the address in which the structure should be returned.
After calling this function, GDB will pass control to the target at the address of the function, which will find the stack and registers set up just as expected.
The default value of this function is NULL
(undefined). If the
function is not defined, then GDB will not allow the user to
call functions within the target being debugged.
This is the inverse of push_dummy_call
which restores the stack
pointer and program counter after a call to evaluate a function using
a dummy stack frame. The result is a struct frame_id
, which
contains the value of the stack pointer and program counter to be
used.
The NEXT frame pointer is provided as argument, next_frame. THIS frame is the frame of the dummy function, which can be unwound, to yield the required stack pointer and program counter from the PREVIOUS frame.
The default value is NULL
(undefined). If push_dummy_call
is
defined, then this function should also be defined.
If this function is not defined (its default value is NULL
), a dummy
call will use the entry point of the currently loaded code on the
target as its return address. A temporary breakpoint will be set
there, so the location must be writable and have room for a
breakpoint.
It is possible that this default is not suitable. It might not be writable (in ROM possibly), or the ABI might require code to be executed on return from a call to unwind the stack before the breakpoint is encountered.
If either of these is the case, then push_dummy_code should be defined to push an instruction sequence onto the end of the stack to which the dummy call should return.
The arguments are essentially the same as those to
push_dummy_call
. However the function is provided with the
type of the function result, value_type, bp_addr is used
to return a value (the address at which the breakpoint instruction
should be inserted) and real pc is used to specify the resume
address when starting the call sequence. The function should return
the updated innermost stack address.
Note: This does require that code in the stack can be executed. Some Harvard architectures may not allow this.
Previous: About Dummy Frames, Up: Inferior Call Setup [Contents][Index]