#!/bin/rc
# rdb - remote kernel debugging
rfork en
fn usage {
echo >[1=2] usage: rdb '['acid options']' system '['text']'
exit usage
}
opts=()
while(~ $1 -*){
switch($1){
case -l -m
if(~ $#* 1)
usage
opts=($opts $1 $2)
shift
case -q
opts=($opts $1)
case -*
usage
}
shift
}
if(~ $#* 0)
usage
if(! ~ $#* 1)
text=$2
if not{
ether=`{ndb/query -m sys $1 ether}
if(~ $ether ''){
echo >[1=2] rdb: unknown ether for $1
exit noether
}
if(! test -e /cfg/pxe/$ether){
echo >[1=2] rdb: unknown pxe file for $1
exit nopxe
}
text=`{grep 'bootfile=' /cfg/pxe/$ether |awk -F! '{print $NF}' |sed 's/\.gz$//'}
}
if(! test -f $text){
echo >[1=2] rdb: file not found: $text
exit notext
}
textbase=`{basename -d $text}
if(test -f $textbase/mkfile)
@{cd $textbase && mk acid}>/dev/null >[2=1]
if(test -f $textbase/acid)
opts=($opts -l $textbase/acid)
opts=($opts -l kernel)
if(~ `{file $text} *386*)
opts=($opts -l mach)
if(test -e /srv/rdbfs.$1)
mount -b /srv/rdbfs.$1 /proc
if not{
if(! test -e /mnt/consoles/$1){
server=`{ndb/query sys $1 console}
if(~ $server ''){
echo >[1=2] rdb: unknown console server for $1
exit noconsole
}
switch($sysname){
case $server
mount /srv/consoles /mnt/consoles
case *
import $server /mnt/consoles
}
}
rdbfs -s rdbfs.$1 /mnt/consoles/$1
}
acid -k $opts -r $text
|