tap: various improvements
dont use sed pipeline for indention, cache process arguments, get process list once at start.
This commit is contained in:
parent
00daf47137
commit
1f02aabc6b
1 changed files with 26 additions and 17 deletions
43
rc/bin/tap
43
rc/bin/tap
|
@ -1,7 +1,12 @@
|
||||||
#!/bin/rc
|
#!/bin/rc
|
||||||
rfork e
|
rfork e
|
||||||
|
|
||||||
v=()
|
if(~ $#* 0){
|
||||||
|
echo 'Usage: ' $0 '[ pid ... ]' >[1=2]
|
||||||
|
exit usage
|
||||||
|
}
|
||||||
|
|
||||||
|
f=/proc/*/fd
|
||||||
|
|
||||||
fn otherqid {
|
fn otherqid {
|
||||||
x=`{echo $1 | sed 's/[12]$//'}
|
x=`{echo $1 | sed 's/[12]$//'}
|
||||||
|
@ -15,9 +20,10 @@ fn otherqid {
|
||||||
|
|
||||||
fn traceqid {
|
fn traceqid {
|
||||||
while(! ~ $#* 0){
|
while(! ~ $#* 0){
|
||||||
echo '['$2']' $3 $1
|
echo $t '['$2']' $3 $1
|
||||||
tracepid `{grep -n `{otherqid $1} /proc/*/fd | sed 's!^/proc/([^/]+)/.*!\1!g'} \
|
t=(' ' $t)
|
||||||
| sed 's/^/ /g'
|
tracepid `{grep -n `{otherqid $1} $f >[2]/dev/null | sed 's!^/proc/([^/]+)/.*!\1!g'}
|
||||||
|
t=$t(2-)
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
|
@ -26,22 +32,25 @@ fn traceqid {
|
||||||
|
|
||||||
fn tracepid {
|
fn tracepid {
|
||||||
while(! ~ $#* 0){
|
while(! ~ $#* 0){
|
||||||
echo $1 `{cat /proc/$1/args >[2]/dev/null}
|
a=ap$1
|
||||||
switch($1){
|
v=av$1
|
||||||
case $v
|
if(~ $$v $1){
|
||||||
echo ' ...'
|
echo $t $1 $$a ' ...'
|
||||||
case *
|
}
|
||||||
v=($1 $v)
|
if not {
|
||||||
traceqid `{awk '/\|/{q=substr($5,2);print q" "$1" "$10}' /proc/$1/fd} \
|
$v=$1
|
||||||
| sed 's/^/ /g'
|
$a=`{cat /proc/$1/args >[2]/dev/null}
|
||||||
|
if(~ $$a ''){
|
||||||
|
s=`{cat /proc/$1/status >[2]/dev/null}
|
||||||
|
$a=$s(1)
|
||||||
|
}
|
||||||
|
echo $t $1 $$a
|
||||||
|
t=(' ' $t)
|
||||||
|
traceqid `{awk '/\|/{q=substr($5,2);print q" "$1" "$10}' /proc/$1/fd >[2]/dev/null}
|
||||||
|
t=$t(2-)
|
||||||
}
|
}
|
||||||
shift
|
shift
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(~ $#* 0){
|
|
||||||
echo 'Usage: ' $0 '[ pid ... ]' >[1=2]
|
|
||||||
exit usage
|
|
||||||
}
|
|
||||||
|
|
||||||
tracepid $*
|
tracepid $*
|
||||||
|
|
Loading…
Reference in a new issue