2003-04-23 Andrew Cagney <cagney@redhat.com>
* infcall.c (call_function_by_hand): Move variables "start_sp", "dummy", "sizeof_dummy1" and "dummy1" and corresponding dummy call code to ON_STACK switch branch.
This commit is contained in:
parent
ef23021837
commit
158775dee3
@ -1,3 +1,9 @@
|
||||
2003-04-23 Andrew Cagney <cagney@redhat.com>
|
||||
|
||||
* infcall.c (call_function_by_hand): Move variables "start_sp",
|
||||
"dummy", "sizeof_dummy1" and "dummy1" and corresponding dummy call
|
||||
code to ON_STACK switch branch.
|
||||
|
||||
2003-04-23 Andrew Cagney <cagney@redhat.com>
|
||||
|
||||
* infcall.c (call_function_by_hand): Make declaration of "i",
|
||||
|
146
gdb/infcall.c
146
gdb/infcall.c
@ -238,24 +238,6 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
|
||||
{
|
||||
register CORE_ADDR sp;
|
||||
int rc;
|
||||
CORE_ADDR start_sp;
|
||||
/* CALL_DUMMY is an array of words (REGISTER_SIZE), but each word
|
||||
is in host byte order. Before calling FIX_CALL_DUMMY, we byteswap it
|
||||
and remove any extra bytes which might exist because ULONGEST is
|
||||
bigger than REGISTER_SIZE.
|
||||
|
||||
NOTE: This is pretty wierd, as the call dummy is actually a
|
||||
sequence of instructions. But CISC machines will have
|
||||
to pack the instructions into REGISTER_SIZE units (and
|
||||
so will RISC machines for which INSTRUCTION_SIZE is not
|
||||
REGISTER_SIZE).
|
||||
|
||||
NOTE: This is pretty stupid. CALL_DUMMY should be in strict
|
||||
target byte order. */
|
||||
|
||||
static ULONGEST *dummy;
|
||||
int sizeof_dummy1;
|
||||
char *dummy1;
|
||||
CORE_ADDR dummy_addr;
|
||||
struct type *value_type;
|
||||
unsigned char struct_return;
|
||||
@ -270,11 +252,6 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
|
||||
struct type *ftype = check_typedef (SYMBOL_TYPE (function));
|
||||
CORE_ADDR bp_addr;
|
||||
|
||||
dummy = alloca (SIZEOF_CALL_DUMMY_WORDS);
|
||||
sizeof_dummy1 = REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS / sizeof (ULONGEST);
|
||||
dummy1 = alloca (sizeof_dummy1);
|
||||
memcpy (dummy, CALL_DUMMY_WORDS, SIZEOF_CALL_DUMMY_WORDS);
|
||||
|
||||
if (!target_has_execution)
|
||||
noprocess ();
|
||||
|
||||
@ -371,24 +348,6 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
|
||||
sp = old_sp;
|
||||
}
|
||||
|
||||
if (INNER_THAN (1, 2))
|
||||
{
|
||||
/* Stack grows down */
|
||||
sp -= sizeof_dummy1;
|
||||
start_sp = sp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Stack grows up */
|
||||
start_sp = sp;
|
||||
sp += sizeof_dummy1;
|
||||
}
|
||||
|
||||
/* NOTE: cagney/2002-09-10: Don't bother re-adjusting the stack
|
||||
after allocating space for the call dummy. A target can specify
|
||||
a SIZEOF_DUMMY1 (via SIZEOF_CALL_DUMMY_WORDS) such that all local
|
||||
alignment requirements are met. */
|
||||
|
||||
funaddr = find_function_addr (function, &value_type);
|
||||
CHECK_TYPEDEF (value_type);
|
||||
|
||||
@ -404,47 +363,82 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
|
||||
struct_return = using_struct_return (function, funaddr, value_type,
|
||||
using_gcc);
|
||||
|
||||
/* Create a call sequence customized for this function
|
||||
and the number of arguments for it. */
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int) (SIZEOF_CALL_DUMMY_WORDS / sizeof (dummy[0])); i++)
|
||||
store_unsigned_integer (&dummy1[i * REGISTER_SIZE],
|
||||
REGISTER_SIZE,
|
||||
(ULONGEST) dummy[i]);
|
||||
}
|
||||
|
||||
switch (CALL_DUMMY_LOCATION)
|
||||
{
|
||||
case ON_STACK:
|
||||
/* NOTE: cagney/2003-04-22: This computation of REAL_PC, BP_ADDR
|
||||
and DUMMY_ADDR is pretty messed up. It comes from constant
|
||||
tinkering with the values. Instead a FIX_CALL_DUMMY
|
||||
replacement (PUSH_DUMMY_BREAKPOINT?) should just do
|
||||
everything. */
|
||||
#ifdef GDB_TARGET_IS_HPPA
|
||||
real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
|
||||
value_type, using_gcc);
|
||||
#else
|
||||
if (FIX_CALL_DUMMY_P ())
|
||||
{
|
||||
/* CALL_DUMMY is an array of words (REGISTER_SIZE), but each
|
||||
word is in host byte order. Before calling FIX_CALL_DUMMY,
|
||||
we byteswap it and remove any extra bytes which might exist
|
||||
because ULONGEST is bigger than REGISTER_SIZE. */
|
||||
/* NOTE: This is pretty wierd, as the call dummy is actually a
|
||||
sequence of instructions. But CISC machines will have to
|
||||
pack the instructions into REGISTER_SIZE units (and so will
|
||||
RISC machines for which INSTRUCTION_SIZE is not
|
||||
REGISTER_SIZE). */
|
||||
/* NOTE: This is pretty stupid. CALL_DUMMY should be in
|
||||
strict target byte order. */
|
||||
CORE_ADDR start_sp;
|
||||
ULONGEST *dummy = alloca (SIZEOF_CALL_DUMMY_WORDS);
|
||||
int sizeof_dummy1 = (REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS
|
||||
/ sizeof (ULONGEST));
|
||||
char *dummy1 = alloca (sizeof_dummy1);
|
||||
memcpy (dummy, CALL_DUMMY_WORDS, SIZEOF_CALL_DUMMY_WORDS);
|
||||
if (INNER_THAN (1, 2))
|
||||
{
|
||||
/* Stack grows down */
|
||||
sp -= sizeof_dummy1;
|
||||
start_sp = sp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Stack grows up */
|
||||
start_sp = sp;
|
||||
sp += sizeof_dummy1;
|
||||
}
|
||||
/* NOTE: cagney/2002-09-10: Don't bother re-adjusting the
|
||||
stack after allocating space for the call dummy. A target
|
||||
can specify a SIZEOF_DUMMY1 (via SIZEOF_CALL_DUMMY_WORDS)
|
||||
such that all local alignment requirements are met. */
|
||||
/* Create a call sequence customized for this function and the
|
||||
number of arguments for it. */
|
||||
{
|
||||
/* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true? */
|
||||
FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type,
|
||||
using_gcc);
|
||||
int i;
|
||||
for (i = 0; i < (int) (SIZEOF_CALL_DUMMY_WORDS / sizeof (dummy[0]));
|
||||
i++)
|
||||
store_unsigned_integer (&dummy1[i * REGISTER_SIZE],
|
||||
REGISTER_SIZE,
|
||||
(ULONGEST) dummy[i]);
|
||||
}
|
||||
real_pc = start_sp;
|
||||
/* NOTE: cagney/2003-04-22: This computation of REAL_PC,
|
||||
BP_ADDR and DUMMY_ADDR is pretty messed up. It comes from
|
||||
constant tinkering with the values. Instead a
|
||||
FIX_CALL_DUMMY replacement (PUSH_DUMMY_BREAKPOINT?) should
|
||||
just do everything. */
|
||||
#ifdef GDB_TARGET_IS_HPPA
|
||||
real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
|
||||
value_type, using_gcc);
|
||||
#else
|
||||
if (FIX_CALL_DUMMY_P ())
|
||||
{
|
||||
/* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true? */
|
||||
FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type,
|
||||
using_gcc);
|
||||
}
|
||||
real_pc = start_sp;
|
||||
#endif
|
||||
dummy_addr = start_sp;
|
||||
/* Yes, the offset is applied to the real_pc and not the dummy
|
||||
addr. Ulgh! Blame the HP/UX target. */
|
||||
bp_addr = real_pc + CALL_DUMMY_BREAKPOINT_OFFSET;
|
||||
/* Yes, the offset is applied to the real_pc and not the
|
||||
dummy_addr. Ulgh! Blame the HP/UX target. */
|
||||
real_pc += CALL_DUMMY_START_OFFSET;
|
||||
write_memory (start_sp, (char *) dummy1, sizeof_dummy1);
|
||||
if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
|
||||
generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1);
|
||||
break;
|
||||
dummy_addr = start_sp;
|
||||
/* Yes, the offset is applied to the real_pc and not the dummy
|
||||
addr. Ulgh! Blame the HP/UX target. */
|
||||
bp_addr = real_pc + CALL_DUMMY_BREAKPOINT_OFFSET;
|
||||
/* Yes, the offset is applied to the real_pc and not the
|
||||
dummy_addr. Ulgh! Blame the HP/UX target. */
|
||||
real_pc += CALL_DUMMY_START_OFFSET;
|
||||
write_memory (start_sp, (char *) dummy1, sizeof_dummy1);
|
||||
if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
|
||||
generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1);
|
||||
break;
|
||||
}
|
||||
case AT_ENTRY_POINT:
|
||||
real_pc = funaddr;
|
||||
dummy_addr = CALL_DUMMY_ADDRESS ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user