This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa:ppc64] Use target in convert_from_func_ptr_addr
- From: Kevin Buettner <kevinb at redhat dot com>
- To: Andrew Cagney <ac131313 at redhat dot com>, gdb-patches at sources dot redhat dot com
- Date: Thu, 23 Oct 2003 09:00:17 -0700
- Subject: Re: [rfa:ppc64] Use target in convert_from_func_ptr_addr
- References: <3F9730C3.1040308@redhat.com>
On Oct 22, 9:37pm, Andrew Cagney wrote:
> The attached rewrites the PPC64 GNU/Linux convert_from_func_ptr_addr
> method so that it makes use of the explicit "struct target_ops"
> parameter I recently added (previously it was indirectly using
> current_target).
[...]
> Index: ppc-linux-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
> retrieving revision 1.44
> diff -u -r1.44 ppc-linux-tdep.c
> --- ppc-linux-tdep.c 22 Oct 2003 23:54:11 -0000 1.44
> +++ ppc-linux-tdep.c 23 Oct 2003 01:32:51 -0000
> @@ -936,14 +936,14 @@
> CORE_ADDR addr,
> struct target_ops *targ)
> {
> - struct obj_section *s;
> -
> - s = find_pc_section (addr);
> -
> - /* Check if ADDR points to a function descriptor. */
> - if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
> - return read_memory_unsigned_integer (addr, 8);
> -
> + struct section_table *s = target_section_by_addr (targ, addr);
> + if (s != NULL && s->the_bfd_section != NULL
> + && strcmp (s->the_bfd_section->name, ".opd") == 0)
> + {
> + char desc[8];
> + target_read (targ, TARGET_OBJECT_MEMORY, NULL, desc, addr, 8);
> + return extract_unsigned_integer (desc, 8);
> + }
> return addr;
> }
IMO, this version of the code is harder to read than the old version.
Can you explain what using an explicit `struct target_ops'' parameter
buys us?
Kevin