From: Roland McGrath <roland@redhat.com>
To: Daniel Jacobowitz <dan@debian.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>
Subject: Re: PTRACE_GET_THREAD_AREA
Date: Fri, 20 Dec 2002 13:27:49 -0800 [thread overview]
Message-ID: <200212202127.gBKLRnB32749@magilla.sf.frob.com> (raw)
In-Reply-To: Daniel Jacobowitz's message of Friday, 20 December 2002 10:48:29 -0500 <20021220154829.GB17007@nevyn.them.org>
> In general, I like this. However, I have to ask one question: how much
> of the i386-centrism of this patch is actually necessary? What
> information does GDB _use_ from this, and is there some way we can expose
> it that will be useful in other places?
GDB uses this only at the behest of NPTL's libthread_db, and it only ever
wants the base address of a descriptor presumed to be a flat 4GB data
segment. So that is just one word per index that you might really be using
in practice. The reason I made all the information available was the
simple principle that that's what ptrace is for--ideally gdb ought to fetch
the descriptors itself whenever a segment register has a nonstandard value,
and show the user the full details so as not to presume what is going on in
the program. But I don't have a direct practical need to care about that.
It is also unusual to i386 that there are multiple slots you might want to
ask about, and that the number of potential slots actually available is a
kernel implementation detail rather than an instrinsic architecture limit,
and that the slot indices you know about from register state have a nonzero
origin whose value is also a kernel implementation detail. Using
PTRACE_PEEKUSR, whether to access just the base-address word or all three
words of each virtual segment descriptor, would encode GDT_ENTRY_TLS_ENTRIES
into the struct user layout and require the user to know GDT_ENTRY_TLS_MIN.
> Eventually most or all targets will have thread-specific data
> implemented; I don't want to have to redo this for each one.
Most architectures use a normal register. The only other architectures
that do something different AFAIK are x86-64 and Alpha. I don't know of
anything other than i386 where there is anything other than a plain word
for each slot. On x86-64 there are exactly two possible slots in the
architecture (fs_base, gs_base); these are already in struct user, so
nothing new is needed. On Alpha, I suppose anything could be possible
since it's implemented in PAL code, but in reality there is exactly one
slot and if that's not in struct user then it could be.
> Your choice of numbers is fine if this remains i386-centric; if we
> expect there to be a common interface then it should go in
> <linux/ptrace.h> and the 0x4200 range instead.
The interface in my patches is i386-specific. If we choose a common
interface, it probably won't look like that one or use those names.
A machine-independent interface without the problems cited above would be
something like ptrace(PTRACE_GET_TLS, idx, &word), where IDX is a
machine-dependent selector such as segment register value on i386, 0/1 for
fs/gs on x86-64, and ignored on Alpha. (For i386, that could also fetch
LDT values I suppose.)
next prev parent reply other threads:[~2002-12-20 21:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-20 8:32 PTRACE_GET_THREAD_AREA Roland McGrath
2002-12-20 10:24 ` PTRACE_GET_THREAD_AREA Christoph Hellwig
2002-12-20 15:44 ` PTRACE_GET_THREAD_AREA Daniel Jacobowitz
2002-12-20 17:36 ` PTRACE_GET_THREAD_AREA Linus Torvalds
2002-12-20 15:48 ` PTRACE_GET_THREAD_AREA Daniel Jacobowitz
2002-12-20 15:55 ` PTRACE_GET_THREAD_AREA Jakub Jelinek
2002-12-20 16:08 ` PTRACE_GET_THREAD_AREA Daniel Jacobowitz
2002-12-20 21:27 ` Roland McGrath [this message]
2002-12-20 17:42 ` PTRACE_GET_THREAD_AREA Linus Torvalds
2003-01-13 3:51 ` PTRACE_GET_THREAD_AREA Roland McGrath
2003-01-13 4:03 ` PTRACE_GET_THREAD_AREA Linus Torvalds
2003-01-13 5:29 ` PTRACE_GET_THREAD_AREA Roland McGrath
[not found] <3E22B2F0.31397.E719685@localhost>
2003-01-14 3:15 ` PTRACE_GET_THREAD_AREA Roland McGrath
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=200212202127.gBKLRnB32749@magilla.sf.frob.com \
--to=roland@redhat.com \
--cc=dan@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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
all inboxes | Powered by JetHome®