[RFA,05/13] Make a few calls in *-tdep.c for effect
Commit Message
In a few cases, there were calls in *-tdep.c that I did not want to
remove because I was not certain that it was safe -- perhaps the side
effect of the function (generally throwing an error) was desired.
2018-07-12 Tom Tromey <tom@tromey.com>
* tic6x-tdep.c (tic6x_push_dummy_call): Call find_function_addr
for effect.
* sparc64-tdep.c (adi_examine_command): Call get_adi_info_proc for
effect.
* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Call
find_function_addr for effect.
* nios2-tdep.c (nios2_push_dummy_call): Call find_function_addr
for effect.
* mep-tdep.c (mep_push_dummy_call): Call find_function_addr for
effect.
---
gdb/ChangeLog | 13 +++++++++++++
gdb/mep-tdep.c | 4 +++-
gdb/nios2-tdep.c | 4 +++-
gdb/rs6000-lynx178-tdep.c | 4 +++-
gdb/sparc64-tdep.c | 3 ++-
gdb/tic6x-tdep.c | 4 +++-
6 files changed, 27 insertions(+), 5 deletions(-)
Comments
On 2018-07-12 04:52 PM, Tom Tromey wrote:
> In a few cases, there were calls in *-tdep.c that I did not want to
> remove because I was not certain that it was safe -- perhaps the side
> effect of the function (generally throwing an error) was desired.
I am fairly confident that the find_function_addr calls are not necessary.
If you look at call_function_by_hand_dummy, it calls find_function_addr
with the same function argument before calling push_dummy_call:
CORE_ADDR funaddr = find_function_addr (function, &values_type, &ftype);
So if the function has to throw, it will be in this invocation. The fact
that no widely tested architecture does that also leads me to think it's
unnecessary.
I don't think the get_adi_info_proc call is useful either. All it does
is return the sparc64_adi_info belonging to inferior_ptid. If it already
exists, the call does nothing. If it does not already exist, it will be
created. The call adi_available just before will have created it, if it
didn't already.
Simon
>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
Simon> I am fairly confident that the find_function_addr calls are not necessary.
[...]
I'll just merge this into the first patch.
Tom
On 07/12/2018 10:58 PM, Simon Marchi wrote:
> On 2018-07-12 04:52 PM, Tom Tromey wrote:
>> In a few cases, there were calls in *-tdep.c that I did not want to
>> remove because I was not certain that it was safe -- perhaps the side
>> effect of the function (generally throwing an error) was desired.
>
> I am fairly confident that the find_function_addr calls are not necessary.
> If you look at call_function_by_hand_dummy, it calls find_function_addr
> with the same function argument before calling push_dummy_call:
>
> CORE_ADDR funaddr = find_function_addr (function, &values_type, &ftype);
>
> So if the function has to throw, it will be in this invocation. The fact
> that no widely tested architecture does that also leads me to think it's
> unnecessary.
>
> I don't think the get_adi_info_proc call is useful either. All it does
> is return the sparc64_adi_info belonging to inferior_ptid. If it already
> exists, the call does nothing. If it does not already exist, it will be
> created. The call adi_available just before will have created it, if it
> didn't already.
Agreed.
Thanks,
Pedro Alves
@@ -2264,9 +2264,11 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR *copy = (CORE_ADDR *) alloca (argc * sizeof (copy[0]));
- CORE_ADDR func_addr = find_function_addr (function, NULL);
int i;
+ /* Call for side effects. */
+ find_function_addr (function, NULL);
+
/* The number of the next register available to hold an argument. */
int arg_reg;
@@ -1820,9 +1820,11 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argnum;
int len = 0;
int stack_offset = 0;
- CORE_ADDR func_addr = find_function_addr (function, NULL);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ /* Call for side effects. */
+ find_function_addr (function, NULL);
+
/* Set the return address register to point to the entry point of
the program, where a breakpoint lies in wait. */
regcache_cooked_write_signed (regcache, NIOS2_RA_REGNUM, bp_addr);
@@ -44,7 +44,9 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch,
gdb_byte tmp_buffer[50];
int f_argno = 0; /* current floating point argno */
int wordsize = gdbarch_tdep (gdbarch)->wordsize;
- CORE_ADDR func_addr = find_function_addr (function, NULL);
+
+ /* Call for side effects. */
+ find_function_addr (function, NULL);
struct value *arg = 0;
struct type *type;
@@ -462,7 +462,8 @@ adi_examine_command (const char *args, int from_tty)
error (_("No ADI information"));
pid_t pid = inferior_ptid.pid ();
- sparc64_adi_info *proc = get_adi_info_proc (pid);
+ /* Call for side effects. */
+ get_adi_info_proc (pid);
int cnt = 1;
const char *p = args;
if (p && *p == '/')
@@ -882,13 +882,15 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argnum;
int stack_offset = 4;
int references_offset = 4;
- CORE_ADDR func_addr = find_function_addr (function, NULL);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct type *func_type = value_type (function);
/* The first arg passed on stack. Mostly the first 10 args are passed by
registers. */
int first_arg_on_stack = 10;
+ /* Call for side effects. */
+ find_function_addr (function, NULL);
+
/* Set the return address register to point to the entry point of
the program, where a breakpoint lies in wait. */
regcache_cooked_write_unsigned (regcache, TIC6X_RA_REGNUM, bp_addr);