From: Kevin Buettner <kevinb@redhat.com>
To: Joel Brobecker <brobecker@gnat.com>, gdb-patches@sources.redhat.com
Subject: Re: native or target?
Date: Thu, 05 Sep 2002 17:47:00 -0000 [thread overview]
Message-ID: <1020906004649.ZM29212@localhost.localdomain> (raw)
In-Reply-To: Joel Brobecker <brobecker@gnat.com> "native or target?" (Sep 5, 4:29pm)
[I see Daniel J already answered. I'll try not to overlap...]
On Sep 5, 4:29pm, Joel Brobecker wrote:
> I think part of it is due to the fact that I don't have a clear
> definition of what a native port is. I suppose native is when host and
> target are the same? I don't have a recent cross-debugger handy to check
> that: if I am running on a x86-linux machine cross ppc, is the code in
> i386-nat.c used?
No.
> Let's take an example of where I am confused:
>
> On interix, the PC_IN_SIGTRAMP method works by comparing the
> PC address against a set of addresses. These addresses are actually
> to computed at the time when the comparison is made, but were
> cached earlier.
>
> One of the places where these addresses are computed is in the
> procfs module (ie we deduct these addresses from the proc info).
> Right now, our code looks like this:
>
> proc_get_status (procinfo *pi)
> {
> [a. normal processing]
> #ifdef __INTERIX
> [b. compute sigtramp-related addresses from proc info]
> #endif
> [c. rest of normal processing]
> }
>
> I would like to move the code in [b.] to the right place, and then
> remplace the #ifdef __INTERIX section by the proper runtime test.
> But I am confused as to where the right place for this code would
> be. On one hand the procinfo stuff seem to pertain to the native
> side (hence the -nat module), but on the other hand, the addresses
> themselves belong to the interix-tdep module... What would you do?
IMO, [b.] belongs in the tdep module. However, native ports
frequently make it difficult to do the right thing because the
underlying OS provides ways (via ptrace(), /proc, or other system
dependent methods) to determine certain information which isn't
normally available when using the remote protocol. It may be the case
that determining sigtramp related addresses can only be done by
examining procfs data structures. (I don't know anything about
interix and you didn't provide enough code for me to make a
determination. I'll assume though that since the code in question is
in proc_get_status(), you had a good reason for putting it there.)
Before proceeding, you should study the code in rs6000-tdep.c
which uses rs6000_find_toc_address_hook. I think this hook is
solving the same kind of problem that you need to solve. In this
case, there's some code in rs6000-tdep.c which needs to determine the
TOC value for a particular function. The value in question can't be
determined by examining registers, memory, or information that gdb has
loaded in object files. The information in question may only be
obtained by making special ptrace() calls. The mechanism works by
having rs6000-nat.c set the hook to the address of a
(native-dependent) function which'll do the lookup. The the target
side (i.e. in the tdep file), you check the hook to see if it's
non-null. If so, you call the hook to obtain the necessary value. If
the hook is null, then you fall back as best as possible.
I should note that the gdbarch_data() / set_gdbarch_data() methods
probably ought to be used to manage the hook. Getting things
initialized correctly can be tricky though so you may want to try it
with a simple global first. (The global in rs6000-tdep.c ought to be
eliminated at some point. Note, however, that the mechanism which'll
replace it *won't* be simpler, but it will be able to correctly handle
several different target dependent methods. It's not clear to me, however,
if this additional complexity will ever actually be useful.)
You may also wish to take a look at native_find_global_pointer in
ia64-tdep.c. It's solving essentially the same problem, but throws
in another twist. (See the tdep->find_global_pointer code.)
Kevin
prev parent reply other threads:[~2002-09-06 0:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20020905232440.GV1169@gnat.com>
2002-09-05 16:29 ` Joel Brobecker
2002-09-05 16:35 ` Daniel Jacobowitz
2002-09-05 17:15 ` Michael Snyder
2002-09-05 18:02 ` Joel Brobecker
2002-09-06 11:00 ` Michael Snyder
2002-09-06 12:48 ` Mark Kettenis
2002-09-09 12:14 ` Andrew Cagney
2002-09-05 17:47 ` Kevin Buettner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1020906004649.ZM29212@localhost.localdomain \
--to=kevinb@redhat.com \
--cc=brobecker@gnat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox