This is the mail archive of the
mailing list for the GDB project.
Re: Multi-arch question
- To: David Smith <dsmith at redhat dot com>, gdb at sources dot redhat dot com
- Subject: Re: Multi-arch question
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Wed, 7 Feb 2001 10:51:42 -0700
- References: <3A817713.A546FB59@redhat.com>
On Feb 7, 10:25am, David Smith wrote:
> So, my function foo_gdbarch_init() (in foo-tdep.c) calls all the
> set_gdbarch_* functions to fill in the architecture vector.
> In one of the functions in foo-tdep.c, I need to know the current value
> of the PC. So, which of the following to I do?
> 1) Call the TARGET_READ_PC macro, which really calls gdbarch_read_pc(),
> which ends up calling my foo_read_pc(). (The normal thing to do.)
> 2) Call foo_read_pc() directly. (Since I'm inside foo-tdep.c, I could
> cut to the chase and call foo_read_pc() directly.)
> Is there a standard here? Does it matter?
It's probably better to call TARGET_READ_PC. It is definitely less
efficient, but your code will be in better shape if there ever comes
a time when alternate definitions of foo_read_pc() become necessary.
A good example of this is the use of FRAME_CHAIN in rs6000-tdep.c.
When I finally got around to integrating the Linux/PPC support (about
a year ago), I defined an alternate FRAME_CHAIN method,
ppc_linux_frame_chain, for use on that target. IIRC, rs6000-tdep.c
contained a number of direct calls to rs6000_frame_chain(). These had
to be changed to call FRAME_CHAIN() instead so that the correct frame
chain method would be found for that target.
Having said that, there may still be cases where it is desirable to
call the target specific method directly. (Look at ppc_linux_frame_chain