Plan 9 from Bell Labs’s /usr/web/sources/contrib/rminnich/trace/9.probe/pc/README

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.



sp9sss proudly presents ronprobes for plan9

pc/ronprobes contains userland bits which
can be used to test the stuff without killing
your kernel, and to print the offset defines
of struct Probe for use in probe.s (it knows
many many fields of it)

extract somewhere, bind -bc over your
/sys/src/9/pc and /sys/src/9/port or
which ever is your favourite way of doing
it. try to compile, figure out what went wrong,
compile, retry, compile, retry, install and
boot new kernel, and then...

theory of operation: replace function start with
jmp to magic handler, magic handler calls a
hook, puts back the original function start, 
mangles the stack to force magic exit handler
to be called when the probed function returns,
and the magic exit handler again calls a hook
and puts back the magic function start replacement.

mp safe: i don't even want to think about it.
up safe: probably not.

usage: too difficult. but you get an adventure instead

term% bind -a '#+' /dev
term% cat /dev/probectl
probehits 0
term% nm $home/src/9/pc/9pcf | grep allocb
f01b25df t _allocb
f01b2682 T allocb
f01667b2 t gc82543allocb
f01b2713 T iallocb
term% term% echo probe 0xf01b2682 new > /dev/probectl
term% cat /dev/probectl
probe 0xf01b2682 off
probehits 0
term% cat /dev/probe &
term% echo probe 0xf01b2682 on > /dev/probectl
term% 0xf01b2682 1536
0xf01b2682 1536
0xf01b2682 1280
0xf01b2682 1280
0xf01b2682 1536
0xf01b2682 1280
0xf01b2682 1280
0xf01b2682 1280
0xf01b2682 1536
0xf01b2682 1280
0xf01b2682 1280
....

meanwhile on another window:

term% bind -a '#+' /dev
term% cat /dev/probectl
probe 0xf01b2682 on
probehits 151784
term% cat /dev/probectl
probe 0xf01b2682 on
probehits 163663
term% cat /dev/probectl
probe 0xf01b2682 on
probehits 321111
term% echo probe 0xf01b2682 off > /dev/probectl

at this point, the crazy scrolling should
immediatelly stop on the other window.

that's it. enabling/disabling the probe is not safe
for now. we probably could have that by use of
cmpxchg8. on SMP the problem is "slightly" difficult
if cmpxchg8 doesn't cut it. anyway, the window
of opportunity is small, so, for now,  have fun with
your new probes.


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].