From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Project Archer <archer@sourceware.org>, Oleg Nesterov <oleg@redhat.com>
Subject: Re: ptrace improvement ideas
Date: Tue, 08 Feb 2011 20:41:00 -0000 [thread overview]
Message-ID: <20110208204050.GA15482@host1.dyn.jankratochvil.net> (raw)
In-Reply-To: <20110208015844.B994A1814A4@magilla.sf.frob.com>
On Tue, 08 Feb 2011 02:58:44 +0100, Roland McGrath wrote:
> > linux_proc_pending_signals (/proc/PID/status) -> now 2x sigset_t
> > -> PTRACE_IS_SIGNUM_PENDING or PTRACE_GET_PENDING_SIGSET etc.
> > (GDB is only interested in SIGINT from that sigset_t now.)
>
> I'm surprised that GDB wants to know such a thing. It makes me suspect
> there is a deeper problem to which looking that up is a workaround.
> Can you explain?
-> linux_nat_has_pending_sigint -> maybe_clear_ignore_sigint
http://sourceware.org/ml/gdb-patches/2005-04/msg00041.html
without it single CTRL-C gets reported for each process in a process group:
echo 'main(){ fork(); pause(); }' | gcc -x c -; patched-gdb -nx ./a.out
(gdb) set detach-on-fork off
(gdb) set target-async on
(gdb) set non-stop on
(gdb) run
Starting program: .../a.out
[New process 19546]
^C <----------------------------------------------------
Program received signal SIGINT, Interrupt.
0x00000032a1cadb40 in __pause_nocancel () at ../sysdeps/unix/syscall-template.S:82
[...]
Program received signal SIGINT, Interrupt.
0x00000032a1cadb40 in __pause_nocancel () at ../sysdeps/unix/syscall-template.S:82
(Not reproducible with NPTL threads.)
> > linux_nat_core_of_thread_1 (/proc/%d/task/%ld/stat)
> > -> PTRACE_GET_CPUCORE -> long return value as the CPU #
>
> I had no idea GDB cared about such a thing at all. Why does it?
It may be generally useless on normal platforms but Ericsson exchanges use
some CPU-affinities of tasks and Eclipse displays it for that purpose.
I failed to display the CPU core # now in Eclipse.
The MI protocol has to provide it as FE (Front End) does not explicitly ask
for it.
> > [nitpick] or PTRACE_GETSIGINFO after waitpid, as GDB does.
>
> This is a misunderstanding.
OK, sorry, got it now.
> The point of using waitid is that you can see the new si_tgid field, and
> hence receive both the thread-specific ID and the process-wide TGID for a
> tracee that you haven't seen before.
GDB has linux_proc_get_tgid :-) but only to workaround nptl/5983 fixed by you,
again reading "/proc/%d/status", for "Tgid".
> Otherwise, PTRACE_O_INHERIT results
> in spontaneous reports for new IDs that you know nothing about and have no
> way to associate with where they came from. The si_tgid idea addresses the
> problem for the case of new threads (standard NPTL threads, that
> is--CLONE_THREAD thread creations in the kernel's terms). It doesn't help
> at all for other kinds of creations, such as a normal fork or vfork.
> That is why I suggested it might actually not be desireable to have
> PTRACE_O_INHERIT apply to all new creations, but instead make it limited to
> CLONE_THREAD creations.
PTRACE_O_INHERIT cannot be used for fork/vfork with `set detach-on-fork on'
(the default mode, so that it is not multi-inferior) as GDB needs to remove
software breakpoints. But the goal is multi-inferior `set detach-on-fork off'
anyway so in that mode PTRACE_O_INHERIT could apply even for fork/vfork.
> I'm interested in your thoughts on the issue of
> how GDB deals with the first report of an ID it hasn't seen before. With
> current kernels, the only such situation that's possible is the brief race
> between a new PTRACE_O_TRACE{CLONE,FORK,VFORK} child reporting its first
> stop, and its parent reporting the PTRACE_EVENT_{CLONE,FORK,VFORK} stop for
> that child's creation (at which time PTRACE_GETEVENTMSG tells you the
> association between that parent's creation attempt and the new child).
`stopped_pids' tracks tasks which got reported as stopped before the parent's
PTRACE_EVENT_{CLONE,FORK,VFORK} has been seen.
With multi-inferior `set detach-on-fork off', with no
PTRACE_O_TRACE{CLONE,FORK,VFORK} and using PTRACE_O_INHERIT it could apply for
both clones and forks/vforks, couldn't it? There is no longer any need to
track `stopped_pids'.
PTRACE_O_TRACEEXEC still needs to stop the inferior as GDB needs to reinsert
all the software breakpoints to their newly computed addresses.
Thanks,
Jan
next prev parent reply other threads:[~2011-02-08 20:41 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-03 22:39 Roland McGrath
2011-02-04 18:56 ` Oleg Nesterov
2011-02-04 18:58 ` Roland McGrath
2011-02-07 21:11 ` Jan Kratochvil
2011-02-08 1:58 ` Roland McGrath
2011-02-08 20:41 ` Jan Kratochvil [this message]
2011-02-09 2:48 ` Roland McGrath
2011-02-08 21:07 ` Oleg Nesterov
2011-02-08 23:18 ` hw_breakpoint userland interface Roland McGrath
2011-02-10 21:03 ` Oleg Nesterov
2011-02-10 21:14 ` Roland McGrath
2011-02-11 20:17 ` Oleg Nesterov
2011-02-10 20:00 ` ptrace improvement: PTRACE_O_INHERIT Oleg Nesterov
2011-02-11 19:24 ` Roland McGrath
2011-02-11 20:46 ` Oleg Nesterov
2011-02-12 0:59 ` Roland McGrath
2011-02-12 19:11 ` Oleg Nesterov
2011-02-14 19:31 ` Roland McGrath
2011-02-14 19:46 ` Oleg Nesterov
2011-02-15 0:36 ` Roland McGrath
2011-02-15 13:16 ` Oleg Nesterov
2011-02-15 21:43 ` Jan Kratochvil
2011-02-15 21:56 ` Roland McGrath
2011-02-16 19:42 ` Oleg Nesterov
2011-02-16 19:45 ` Roland McGrath
2011-02-16 20:09 ` Oleg Nesterov
2011-02-16 20:16 ` Roland McGrath
2011-02-19 19:48 ` Jan Kratochvil
2011-02-19 20:37 ` Oleg Nesterov
2011-02-20 8:18 ` Jan Kratochvil
2011-02-20 21:05 ` Oleg Nesterov
2011-02-21 19:54 ` Roland McGrath
2011-02-22 19:39 ` Oleg Nesterov
2011-02-22 20:49 ` Roland McGrath
2011-02-22 21:10 ` Oleg Nesterov
2011-02-22 22:16 ` Roland McGrath
2011-02-21 19:44 ` Roland McGrath
2011-02-15 22:02 ` Roland McGrath
2011-02-16 16:02 ` Jan Kratochvil
2011-02-16 18:28 ` Roland McGrath
2011-02-16 20:00 ` Oleg Nesterov
2011-02-16 20:07 ` Roland McGrath
2011-02-16 20:32 ` Oleg Nesterov
2011-02-16 19:48 ` Oleg Nesterov
2011-02-16 20:02 ` Roland McGrath
2011-02-16 20:15 ` Oleg Nesterov
2011-02-16 20:31 ` Roland McGrath
2011-02-16 21:04 ` Oleg Nesterov
2011-02-16 21:51 ` Roland McGrath
2011-02-16 19:38 ` Oleg Nesterov
2011-02-16 19:40 ` Roland McGrath
2011-02-15 22:17 ` Roland McGrath
2011-02-16 20:48 ` Oleg Nesterov
2011-02-16 11:31 ` ptrace improvement ideas (QPassSignals) Jan Kratochvil
2011-02-16 18:36 ` Roland McGrath
2011-02-16 20:21 ` Oleg Nesterov
2011-02-18 20:24 ` Oleg Nesterov
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=20110208204050.GA15482@host1.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=archer@sourceware.org \
--cc=oleg@redhat.com \
--cc=roland@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).