This page was produced by an automated import process, and may have formatting errors; feel free to fix.

Functions Creating Dummy Frames

The following functions provide the functionality to set up such dummy stack frames.

Architecture Function: ''CORE_ADDR'' push_dummy_call ''(struct gdbarch *''gdbarch'', struct value *''function'', struct regcache *''regcache'', CORE_ADDR ''bp_addr'', int ''nargs'', struct value **''args'', CORE_ADDR ''sp'', int ''struct_return'', CORE_ADDR ''struct_addr'')''

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.

Architecture Function: ''struct frame_id'' unwind_dummy_id ''(struct gdbarch *''gdbarch'', struct frame_info *''next_frame'') ''

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.

Architecture Function: ''CORE_ADDR'' push_dummy_code ''(struct gdbarch *''gdbarch'', CORE_ADDR ''sp'', CORE_ADDR ''funaddr'', struct value **''args'', int ''nargs'', struct type *''value_type'', CORE_ADDR *''real_pc'', CORE_ADDR *''bp_addr'', struct regcache *''regcache'')''

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.

None: Internals Functions-Creating-Dummy-Frames (last edited 2013-08-20 23:40:45 by StanShebs)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.