Subject: Re: proc(4): updating for LWP
To: Bill Studenmund <wrstuden@netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 03/28/2003 12:44:17
>> >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.
>
>So? What's wrong with mounting file systems? It's not like we're talking
>about ones that really get in the way; nothing else sits on either /kern
>or /proc. And file systems provide a much cleaner name space to get at a
>lot of things.

i know that some people are opposed to /proc (and /kern).  personally,
i like them, but if we're going to have to depend on them being
around, doesn't it have to stop being an "option" in kernel config
files?

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

yeah.  modulo the "htf do you cons up struct stat info for a kqueue
file descriptor?" problem...  :)

>> >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?
>
>What would disappear/move, other than the register stuff that now doesn't
>make sense?

% uname -sr
NetBSD 1.6Q
% ls -al /proc/$$
total 2396
dr-xr-xr-x  2 andrew  staff     512 Mar 28 12:40 ./
dr-xr-xr-x  1 root    wheel     512 Mar 28 12:40 ../
-r--r--r--  1 andrew  staff       0 Mar 28 12:40 cmdline
--w-------  1 andrew  staff       0 Mar 28 12:40 ctl
dr-xr-xr-x  2 andrew  staff     512 Mar 28 12:40 fd/
-r-xr-xr-x  1 root    wheel  289492 Sep 18  2002 file*
-rw-------  1 andrew  staff     108 Mar 28 12:40 fpregs
-r--r--r--  1 andrew  staff       0 Mar 28 12:40 map
-r--r--r--  1 andrew  staff       0 Mar 28 12:40 maps
-rw-------  1 andrew  staff  921600 Mar 28 12:40 mem
--w-------  1 andrew  staff       0 Mar 28 12:40 note
--w-------  1 andrew  staff       0 Mar 28 12:40 notepg
-rw-------  1 andrew  staff      64 Mar 28 12:40 regs
-r--r--r--  1 andrew  staff       0 Mar 28 12:40 status
-rw-------  1 andrew  staff     512 Mar 28 12:40 xmmregs

% uname -sr
SunOS 5.8
% ls -al /proc/$$
total 4687
dr-x--x--x   5 andrew   staff        736 Mar 28 12:40 ./
dr-xr-xr-x  23 root     root       25536 Mar 28 12:41 ../
-rw-------   1 andrew   staff    2351104 Mar 28 12:40 as
-r--------   1 andrew   staff        152 Mar 28 12:40 auxv
-r--------   1 andrew   staff         32 Mar 28 12:40 cred
--w-------   1 andrew   staff          0 Mar 28 12:40 ctl
lr-x------   1 andrew   staff          0 Mar 28 12:40 cwd -> /
dr-x------   2 andrew   staff        528 Mar 28 12:40 fd/
-r--r--r--   1 andrew   staff        120 Mar 28 12:40 lpsinfo
-r--------   1 andrew   staff        912 Mar 28 12:40 lstatus
-r--r--r--   1 andrew   staff        536 Mar 28 12:40 lusage
dr-xr-xr-x   3 andrew   staff         48 Mar 28 12:40 lwp/
-r--------   1 andrew   staff       2208 Mar 28 12:40 map
dr-x------   2 andrew   staff        544 Mar 28 12:40 object/
-r--------   1 andrew   staff       2896 Mar 28 12:40 pagedata
-r--r--r--   1 andrew   staff        336 Mar 28 12:40 psinfo
-r--------   1 andrew   staff       2208 Mar 28 12:40 rmap
lr-x------   1 andrew   staff          0 Mar 28 12:40 root -> /
-r--------   1 andrew   staff       1440 Mar 28 12:40 sigact
-r--------   1 andrew   staff       1232 Mar 28 12:40 status
-r--r--r--   1 andrew   staff        256 Mar 28 12:40 usage
-r--------   1 andrew   staff          0 Mar 28 12:40 watch
-r--------   1 andrew   staff       3496 Mar 28 12:40 xmap

the "cmdline" file is gone, the "map" file is totally different (the
solaris one is binary data), the "maps" file is gone, the "mem" file
is gone, the "note" and "notepg" files are gone, and so on.

i'm not claiming to know what to do with all those files on either
system, but it does look rather different.

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