On Wed, Dec 12, 2007 at 01:47:53AM +0800, ???? TaoJie wrote:
> Dear Mike:
> 
> I'm trying to learn the code flow.
> Thanks :)
> 
> 
> Kind Regards,
> TJ

Here's a summary of the key points and then I'll use some
of the code locations on x64 to illustrate:

You have a breakpoint trap instruction.  Your trap table has
an entry for that.  On x64 we jump from there to a bit of
assembly code brktrap() in uts/intel/ia32/ml/exception.s.

If the trap is in user mode, then we start the breakpoint processing.
As part of DTrace we first check if this breakpoint is associated
with DTrace activity:

dtrace_trap() in uts/i86pc/ml/locore.s
dtrace_user_probe() in uts/i86pc/os/dtrace_subr.c

and if not then we proceed to trap() which is the C-based
master routine that does trap processing.

So then we go to trap() in uts/i86pc/os/trap.c with T_BPTFLT + T_USER as
the parameter, and this converts a breakpoint exception from the hardware
into a SIGTRAP with fault code FLTBPT for purposes of /proc.  The debugger
typically has marked this fault of interest, and so trap() will end up
calling stop_on_fault() to stop the process before returning to userland.
This is just a trivial wrapper around stop(), which is, well, quite a gem :)

stop() is then the main engine of making a process stop and dealing
with things like stopping all the LWPs and bringing them into the kernel,
and notifying waiters in /proc, like your debugger which is then waiting
for the process to stop on an event of interest.

-Mike

-- 
Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to