Subject: Re: proc(4): updating for LWP
To: Matt Thomas <matt@3am-software.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 03/28/2003 09:16:09
On Thu, 27 Mar 2003, Matt Thomas wrote:

> The NetSD proc(4) (AKA procfs) is fairly old and don't understand LWP at
> all.  ttrace(2) from HP-UX might be a better interface for GDB but proc(4)
> can be useful because you don't need a program to glance at things.  It
> also seems (to me) that it'd be easier to adapter to LWPs (and get GDB
> support) than implmenting ttrace(2) from stratch.
>
> I'd to propose that the NetBSD proc(4) be extended to allow for  debugging
> of LWP's.  Rather than invent something unique to NetBSD, NetBSD should
> adopt the Solaris 2.9 proc(4) interface (for more information, see
> http://docs.sun.com/db/doc/816-0219/6m6njqbb6?a=view ).  Here's a listing
> of my ksh process from a Solaris 8 system:

Sounds good.

> total 1877

[snip]

> lwp/1:
> total 2
>        3425 -r--------   1 mthomas         0 Mar 27 14:23 gwindows
>        3420 --w-------   1 mthomas         0 Mar 27 14:23 lwpctl
>        3422 -r--r--r--   1 mthomas       104 Mar 27 14:23 lwpsinfo
>        3421 -r--------   1 mthomas       896 Mar 27 14:23 lwpstatus
>        3423 -r--r--r--   1 mthomas       256 Mar 27 14:23 lwpusage
>        3424 -r--------   1 mthomas       248 Mar 27 14:23 xregs
>
> object:
> total 2541
>      467970 -r-xr-xr-x   3 root       200936 Jan  5  2000 a.out
>      214663 -r-xr-xr-x   1 root        17096 Jan  5  2000 ufs.136.0.214663
>      280812 -r-xr-xr-x   1 bin         25564 Nov 23  1999 ufs.136.0.280812
>       71601 -r-xr-xr-x   1 root       195104 Nov  9  2000 ufs.136.0.71601
>       71704 -r-xr-xr-x   1 root      1129948 Nov 23  2000 ufs.136.0.71704
>       71717 -r-xr-xr-x   1 root         4624 Nov  9  2000 ufs.136.0.71717
>       71737 -r-xr-xr-x   1 root        24968 Jan  5  2000 ufs.136.0.71737
>       71740 -r-xr-xr-x   1 root       888508 Jun  8  2000 ufs.136.0.71740
>       71760 -r-xr-xr-x   1 root        70260 Jan  5  2000 ufs.136.0.71760
>
> Some of the significant changes are the fd, object, and lwp subdirectories.
> The fd subdir contain file entries for each open fd of the process; exactly
> the same a /dev/fd put per-process.  The object subdir contain file entries
> so that the objects that have mmap'ed pages can be easily opened by the
> debugger to get symbol tables, etc.  The lwp subdir contains one subdir for
> each lightweight process in the process.
>
> Note that the register contents are in the lwp/1/lwpstatus file, not in the
> top-level process directory file regs.
>
> I can either make native proc(4) look like the above or make it optional
> (similar to the existing -o linux option to mount_procfs).  Any comments
> or suggestions?

Make it look like the above. Well, I'm not sure about the object part (I'm
indifferent), but everything else sounds like a win.

Take care,

Bill