public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* RE: user kprobes vs debuggers
@ 2006-02-03 17:43 Stone, Joshua I
  2006-02-03 18:39 ` Vara Prasad
  0 siblings, 1 reply; 11+ messages in thread
From: Stone, Joshua I @ 2006-02-03 17:43 UTC (permalink / raw)
  To: Vara Prasad, Frank Ch. Eigler; +Cc: systemtap

Vara Prasad wrote:
> Well come to think of  this problem i am thinking this is very similar
> to the problem between Kprobes and kernel debuggers.
> I am thinking we can have a common interface that ptrace and userspace
> probes can use to register break points similar to the notifiers for
> kernel probes. The common interface stores the information about all
> the break points including the ones from the ptrace interface.  There
> is a tag on the breakpoint that specifies whether the breakpoint is
> inserted by the userspace probes or ptrace. Similar to kernel
> multiple probe handlers at a probe point, we could have multiple
> probe handlers for user space probes as well. One of the probe
> handler among the multiple could be to pass it to the debugger for
> the probes registered by ptrace. When the break point is hit
> userspace probes gets the control and checks if there is a userspace
> probe point at this location, if yes, runs the userspace probes
> handler and if there is a ptrace registered probe point at the same
> location pass it debugger as well.  Unregistering probes of both
> types requires updating the global registery of the probe points. 

Who will single-step the original instruction in this scenario?  It
seems that the only feasible answer is that the debugger will do it.
But, in the case of a probe inserted sooner than the debugger
breakpoint, the debugger doesn't know the original instruction.  And if
the debugger removes its breakpoint, the probe-management would have to
start single-stepping.

Someone mentioned solving this by presenting the debugger with a
virtualized address-space (where the probe doesn't exist).  This may be
possible, but in the keep-it-simple spirit I think it would be best to
just reject the second-comer.  At least with a common interface we can
detect the conflict, so I think it's fine to just disallow the
situation.


Josh

^ permalink raw reply	[flat|nested] 11+ messages in thread
* RE: user kprobes vs debuggers
@ 2006-02-03 20:29 Stone, Joshua I
  2006-02-03 21:08 ` James Dickens
  2006-02-03 22:00 ` Vara Prasad
  0 siblings, 2 replies; 11+ messages in thread
From: Stone, Joshua I @ 2006-02-03 20:29 UTC (permalink / raw)
  To: Vara Prasad; +Cc: Frank Ch. Eigler, systemtap

Vara Prasad wrote:
> Let us say if there is no user space probes involved debugger
> remembers the original instruction before replacing it is with
> breakpoint instruction. It single steps the original instruction that
> is stored in the userspace. Let us say if there is no debugger and
> there is only userspace probes userspace pobes does the same single
> stepping but in the kernel space. Another important distinction to
> remember here is each of them have their own handlers to run when the
> break point is hit. Based on the above background there is a global
> registry of the breakpoints in the kernel that is only used to notify
> who all would like to handle this breakpoint but it is up to each of
> the owners to run their own handlers and as well as handle single
> stepping. 

Sure, I see no issue when only a debugger or a userspace probe
instruments a given address - they just single-step it themselves.  The
issue I was referring to is when a debugger and a userspace probe try to
instrument the same address.  In that scenario it's not clear who should
single-step the original instruction and how.

It's made worse if probes & debuggers are registered & removed in an
interleaved fashion - e.g. probe A registers; debugger B registers; A is
removed; what happens to B?

> I think it would have been o.k to disallow but due to common uses like
> strace people might object to userspace probes  feature.

You only have to disallow probes & debugger breakpoints coexisting at
the same address - if they're at different addresses then there's no
problem.  If that's still too restrictive, then we need to resolve the
issues above.

Josh

^ permalink raw reply	[flat|nested] 11+ messages in thread
* user kprobes vs debuggers
@ 2006-02-02 19:22 Frank Ch. Eigler
  2006-02-03  6:37 ` Vara Prasad
  2006-02-06  9:58 ` Ananth N Mavinakayanahalli
  0 siblings, 2 replies; 11+ messages in thread
From: Frank Ch. Eigler @ 2006-02-02 19:22 UTC (permalink / raw)
  To: systemtap

Hi -

During the teleconference earlier today, we discussed the issue of
coexistence of user-mode kprobes (along the favoured #4 path) with
debuggers, manipulating the same tasks.

The core issue is that both systems insert breakpoints into pages
of the target text.  Ideally, we would like both systems to operate
independently, unaware of each other.  But:

Without synchronization over "ownership" of the text pages, two
systems may perform the insertion or removal interleaved in an
inconvenient way.  It may be possible to lose breakpoints, or even to
create spontaneous ones.  To perform sufficient synchronization, we
may need to (a) detect possible conflicts after the fact, (b) bluntly
block one system when the other is active, (c) hook user-kprobes into
ptrace and /proc/mem code paths to intercept debuggers' operations
and/or (d) provide a virtualization facility where the user-space
tools only see a kprobe-less image of the real text page.

A related problem is handling of breakpoints once triggered.  Clearly
user-kprobes get to run first.  The system needs to know whether user
space has also set a breakpoint at the same spot, so a subsequent
ptrace signal can be propagated to the debugger.  Some peculiar
applications may put breakpoints into themselves even without a
debugger present, expecting to catch SIGTRAP.  Ideally, user kprobes
should work with these too.

- FChE

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-02-09 13:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-03 17:43 user kprobes vs debuggers Stone, Joshua I
2006-02-03 18:39 ` Vara Prasad
  -- strict thread matches above, loose matches on Subject: below --
2006-02-03 20:29 Stone, Joshua I
2006-02-03 21:08 ` James Dickens
2006-02-03 22:00 ` Vara Prasad
2006-02-02 19:22 Frank Ch. Eigler
2006-02-03  6:37 ` Vara Prasad
2006-02-03  8:04   ` Mathieu Lacage
2006-02-03 16:12     ` Vara Prasad
2006-02-06  9:58 ` Ananth N Mavinakayanahalli
2006-02-09 13:59   ` Richard J Moore

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).