i was having some trouble with a user program that was setting
Proc.debugmem. for various reasons it was easier to hack the
kernel than hack the program in question. so i thought i'd
just get into the kernel and set Proc.debugmem = 0.
obviously, this doesn't work out-of-the-box, so i modified the
kernel a bit to allow writes. (relax, it's normally compiled out ☺)
and it was easy enough to write a bit of acid
p = (Proc)procalloc.ht[mypid % 128]
while(p != 0 && p.pid != mypid) do p = p.pidhash
but how to set p.privatemem=0? a first cut was to take
p\X + y
where y was determined by grepping around in the kernel acid
file. but this really is ugly, and hard to hand off to somebody else
as a "solution". since -> is something wierd and . is taken, i used
the syntax
x·y ≡ x\X + y
where y is the same value as before, e.g. offsetof(Proc, privatemem)
so now i can say
*(p·privatemem) = 0
before jeering too much, consider that this also allows one to set
aggr members in user programs. if you've got another solution that
looks better, doesn't require a rune, etc. i'd be happy to hear it.
so perhaps i'll define the "acid prize". 5 euros to the first person
to post a convincingly improved approach to the list.
- erik