On Solaris, all debuggers attach to a process through proc(4).  In
particular, the debugger opens the 'ctl' file (typically O_EXCL).  From
there, the debugger can notify the process to stop (PCSTOP and friends)
and then wait for an 'event of interest' (PCSTOP or PCWSTOP).  The
debugger can control which signals, system call entry/exit, and
faults should generate such events.

The details on how this all works is documented in the proc(4) manpage,
although the best source of information is the source itself.  You may
want to check out the following pages:

http://www.opensolaris.org/os/community/mdb/architecture
http://www.opensolaris.org/os/community/observability/process/libproc
http://www.opensolaris.org/os/community/observability/process/procfs

Which point to the associated source code.  We're working on improving
the community pages and associated documentation in this area.

- Eric

On Fri, Jul 08, 2005 at 03:06:25PM -0500, Tao Chen wrote:
> Although none of these two commands is part of OpenSolaris, it's more of a 
> question for general debugger tool I guess.
> 
> On AIX, dbx command (comes with the base OS) uses SIGTRAP signal to attach 
> to a running process.
> Looking at the gdb AIX specific source (./gdb/aix-thread.c), it appears to 
> use SIGTRAP also:
> 
> /* Search through the list of all kernel threads for the thread
> that has stopped on a SIGTRAP signal, and return its TID.
> Return 0 if none found. */
> 
> One issue we found is that when we dbx or gdb attach to the a process with 
> one of its threads waiting on select() call,
> the select() will be interrupted and returns -1 with errno set to EINTR.
> I don't (yet) think this is an unexpected behaviour in itself, since EINTR 
> is a legitimate errno when select() is interrupted by a signal.
> 
> However this happens only on AIX and the reason (I think) might be that 
> dbx/gdb on other *nix doesn't use signal.
> 
> How does the debuggers attach to running process in Solaris? 
> Through some interface of procfs? (which seems to be the case in gdb source 
> : ./gdb/sol-thread.c ).
> Maybe I can find more information in mdb doc/source?
> 
> Thanks,
> Tao

> _______________________________________________
> observability-discuss mailing list
> observability-discuss at opensolaris.org

--
Eric Schrock, Solaris Kernel Development.

Reply via email to