Subject: Re: proc(4): updating for LWP
To: Matt Thomas <matt@3am-software.com>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 03/27/2003 21:59:46
>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.

that might be true, but it would move in the direction of solaris and
linux where, if a certain pseudo-filesystem isn't mounted, lots of
stuff just doesn't work.

>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:
>
>total 1877
>       3396 -rw-------   1 mthomas   1900544 Mar 27 14:23 as
>       3407 -r--------   1 mthomas       152 Mar 27 14:23 auxv
>       3405 -r--------   1 mthomas        32 Mar 27 14:23 cred
>       3397 --w-------   1 mthomas         0 Mar 27 14:23 ctl
>       3412 lr-x------   1 mthomas         0 Mar 27 14:23 cwd ->
>       3414 dr-x------   2 mthomas      2064 Mar 27 14:23 fd
>       3401 -r--r--r--   1 mthomas       120 Mar 27 14:23 lpsinfo
>       3399 -r--------   1 mthomas       912 Mar 27 14:23 lstatus
>       3409 -r--r--r--   1 mthomas       536 Mar 27 14:23 lusage
>       3418 dr-xr-xr-x   3 mthomas        48 Mar 27 14:23 lwp
>       3402 -r--------   1 mthomas      2016 Mar 27 14:23 map
>       3416 dr-x------   2 mthomas       544 Mar 27 14:23 object
>       3410 -r--------   1 mthomas      2376 Mar 27 14:23 pagedata
>       3400 -r--r--r--   1 mthomas       336 Mar 27 14:23 psinfo
>       3403 -r--------   1 mthomas      2016 Mar 27 14:23 rmap
>       3413 lr-x------   1 mthomas         0 Mar 27 14:23 root ->
>       3406 -r--------   1 mthomas      1440 Mar 27 14:23 sigact
>       3398 -r--------   1 mthomas      1232 Mar 27 14:23 status
>       3408 -r--r--r--   1 mthomas       256 Mar 27 14:23 usage
>       3411 -r--------   1 mthomas         0 Mar 27 14:23 watch
>       3404 -r--------   1 mthomas      3192 Mar 27 14:23 xmap
>...
>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

mmm...information for free.  :)

>The fd subdir contain file entries for each open fd of the process; exactly
>Some of the significant changes are the fd, object, and lwp subdirectories.
>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.

well...christos actually implemented /proc/nnn/fd already, and the
object subdirectory just looks like...what is that?  ah.  it's the
shared objects it has mapped in, but no indication of which one where.
hmm...filesystem type, major and minor of the file system device, and
the inode.  interesting...

that a.out file is nice, too, considering that it's really elf.  :)

actually...this is one area where netbsd is (already) more like
solaris than it is like linux.  our /proc/nnn/fd entries "map" back to
the real "thing".  linux has symlinks that point to the "thing".

>Note that the register contents are in the lwp/1/lwpstatus file, not in the
>top-level process directory file regs.

well...that makes sense, considering that the "process" is
"deprecated".  :)

>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?

currently, the linux option makes more stuff pop up, but doesn't
change stuff around or make other things disappear.  this would
be...different.  proc2?

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."