From:	SMTP%"neill@macro.demon.co.uk"  5-JAN-1994 19:46:07.90
To:	EVERHART
CC:	
Subj:	DDB.2-OF-5  Detached debugger

Date: Wed, 05 Jan 1994 23:27:06 +0000
From: Neill Clift <neill@macro.demon.co.uk>
To: EVERHART@arisia.gce.com
Message-ID: <009781AA.D8BB8360.5389@macro.demon.co.uk>
Subject: DDB.2-OF-5  Detached debugger

-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X`09`09rfm`20=`20var,`20-
X`09`09shr`20=`20get
X;
Xlograb:`09$rab`09fab`20=`20logfab,`20-
X`09`09rac`20=`20seq,`20-
X`09`09rop`20=`20wbh
X;
Xlognam:`09$nam`09esa`20=`20ess_b,`20-
X`09`09ess`20=`20ess_len,`20-
X`09`09rsa`20=`20rss_b,`20-
X`09`09rss`20=`20ess_len
X;
Xiosb:`09.quad`090`09`09`09`09;`20IOSB`20for`20sys$getjpiw
Xttiosb:
X`09.quad`090`09`09`09`09;`20IOSB`20for`20async`20calls`20(TT:)
Xlksb:`09.quad`090`09`09`09`09;`20LKSB`20for`20resignal`20lock
Xfrcpmt:`09.long`090`09`09`09`09;`20Force`20prompting`20flag
Xpid:`09.long`090`09`09`09`09;`20PID`20of`20process`20to`20debug
Xflags:`09.long`090`09`09`09`09;`20Flags.`20Lowest`20bit`20=`20exit
Xflags_v_finished`20=`200`09`09`09`09;`20All`20finished
Xflags_v_logging`20`20=`201`09`09`09`09;`20logging`20turned`20on
Xflags_m_finished`20=`201@flags_v_finished`09`09;`20All`20done?
Xflags_m_logging`20`20=`201@flags_v_logging`09`09;`20logging`20turned`20on?
Xfinal_status:
X`09.long`090`09`09`09`09;`20final`20status
X;
X;`20Create`20exit`20handler`20block
X;
Xexit_block:
X`09.long`090`09`09`09`09;`20Forward`20link
X`09.address`20rundown`09`09`09;`20Address`20of`20rundown`20routine
X`09.long`091`09`09`09`09;`20One`20argument
X`09.address`20final_status`09`09`09;`20Address`20of`20final`20status
X;
X;`20build`20descriptor`20for`20/identification`20qualifier
X;
Xidstr_len`20=`2030
Xidstr:`09.word`09idstr_len,`200
X`09.address`20idstr_buf
Xidstr_buf:
X`09.blkb`09idstr_len
X;
X;`20Build`20descriptor`20for`20the`20process`20name
X;
Xprcnam_len`20=`2030
Xprcnam:`09.word`09prcnam_len,`200
X`09.address`20prcnam_buf
Xprcnam_buf:
X`09.blkb`09prcnam_len
X;
X;`20Build`20descriptor`20for`20VT`20device`20name
X;
Xvtnam_len`20=`2010
Xvtnam:`09.word`09vtnam_len,`200
X`09.address`20vtnam_buf
Xvtnam_buf:
X`09.blkb`09vtnam_len
X
X;
Xftchan:`09.word`090`09`09`09`09;`20Channel`20to`20FTAnnn`20(control)
Xftchan1:.word`090`09`09`09`09;`20Channel`20to`20FTAnnn`20(Normal)
Xttchan:`09.word`090`09`09`09`09;`20Channel`20to`20SYS$COMMAND
X;
Xdevchar_len`20=`2020`09`09`09`09;`20Device`20characteristics`20TT:
Xdevchar:.blkb`09devchar_len
X;
Xndevchar_len`20=`2020`09`09`09`09;`20Modified`20device`20chars
Xndevchar:.blkb`09devchar_len
X;
X;`20Build`20descriptor`20to`20hold`20device`20name`20of`20FTAnnnn:`20device
X;
Xdevnam_len`20=`2010
Xdevnam:`09.word`09devnam_len,`200
X`09.address`20-
X`09`09devnam_buf
Xdevnam_buf:
X`09.blkb`09devnam_len
X;
Xlogfile_len`20=`20nam$c_maxrss
Xlogfile:
X`09.word`09logfile_len,`200
X`09.address`20logfile_b
Xlogfile_b:
X`09.blkb`09logfile_len
X;
Xlogbuf_len`20=`202048
Xlogbuf:`09.word`090,`200
X`09.address`20logbuf_b
Xlogbuf_b:
X`09.blkb`09logbuf_len
X;
X;`20Define`20NAM`20block`20name`20buffers`20to`20improve`20errors
X;
Xess_len`20=`20nam$c_maxrss
Xess_b:`09.blkb`09ess_len
Xrss_len`20=`20nam$c_maxrss
Xrss_b:`09.blkb`09rss_len
X;
X`09.align`09page
Xbuf_start:
Xrbuf:`09.blkb`09500
Xrbuf_len`20=`20.-rbuf
Xwbuf:`09.blkb`09500
Xwbuf_len`20=`20.-wbuf
Xbuf_end:
X;
X`09.psect`09ddb_rdata`20nowrt`20rd`20noexe`20shr
X;
Xinadr:`09.address`20buf_start,`20buf_end-1
X;
Xitmlst:`09.word`09devnam_len,`20dvi$_devnam
X`09.address`20devnam_buf,`20devnam
X`09.long`090
X;
X;`20Item`20list`20to`20translate`20DDB_<pid>`20logical.`20This`20contains`20th
Ve`20virtual`20terminal
X;`20name.
X;
Xtrnlst:`09.word`09vtnam_len,`20lnm$_string
X`09.address`20vtnam_buf,`20vtnam
X`09.long`090
X;
Xquit_char`20=`20`5EA/`5C/-`5EA/@/`09`09`09`09;`20Quit`20character`20is`20`5E
V`5C
XBS`20=`20`5EA/H/-`5EA/@/
XLF`20=`20`5EA/J/-`5EA/@/
XCR`20=`20`5EA/M/-`5EA/@/
X;
Xlog:`09.ascii`09/DDB_/`09`09`09`09;`20Prefix`20for`20logical`20name
Xlog_length`20=`20.-log
Xlock:`09.ascii`09/DDB_/`09`09`09`09;`20Prefix`20for`20lock`20name
Xlock_length`20=`20.-lock
Xdelstr:`09.ascii`09<BS>/`20/<BS>`09`09`09;`20Delete`20one`20char`20string
Xdelstr_len`20=`20.-delstr
X;
X;`20To`20start`20the`20ball`20rolling`20we`20prime`20CLI$DCL_PARSE`20with`20ju
Vst`20the`20verb
X;
Xverb:`09.ascid`09/DDB/
X;
Xidentification:
X`09.ascid`09/IDENTIFICATION/
Xprocess_name:
X`09.ascid`09/PROCESS_NAME/
Xlog_qual:
X`09.ascid`09/LOG/
X;
Xinput:`09.ascid`09/SYS$COMMAND:/
Xlnm$system:
X`09.ascid`09/LNM$SYSTEM/
Xtrmmsg:`09.ascii`09/Use`20`5E`5C`20to`20terminate`20session/
Xtrmmsg_len`20=`20.-trmmsg
X;
X;!!!`09.psect`09ddb_code`20nowrt`20rd`20exe`20pic`20shr
X`09.psect`09ddb_code`20wrt`20rd`20exe`20pic`20shr
X;
X`09.entry`09ddb`20`5Em<r2,r3,r4,r5>
X`09bsbw`09parse_commands_r1`09`09;`20Parse`20command`20line
X`09blbc`09r0,`2099$`09`09`09`09;`20quit`20on`20error
X`09bsbw`09open_logfile_r1`09`09`09;`20get`20and`20open`20logfile
X`09blbc`09r0,`2099$`09`09`09`09;`20quit`20on`20error
X`09bsbb`09redirect_io_r3`09`09`09;`20copy`20input`20and`20output
X99$:`09ret
X;
X;`20Sets`20up`20IO`20redirection`20so`20it`20looks`20like`20the`20user`20is`20
Vtyping`20directly`20to`20the
X;`20debugged`20process.
X;`20Inputs:
X;`20Outputs:
X;`20`20`20`20R0:`20Status
X;`20Trashes:
X;`20`20`20`20R1,R2
X;
Xredirect_io_r3:
X`09bsbw`09assign_chans
X`09blbc`09r0,`2099$
X`09bsbb`09signal_proc_r3
X`09blbc`09r0,`2099$
X`09bsbb`09message
X`09blbc`09r0,`2099$
X`09bsbw`09start_r1
X`09blbc`09r0,`2099$
X1$:`09$hiber_s
X`09assume`09flags_v_finished`20eq`200
X`09blbc`09flags,`201$
X99$:`09rsb
X;
X;`20Outputs`20a`20message`20to`20the`20terminal.
X;
Xmessage:
X`09$qiow_s`09chan`20=`20ttchan,`20-
X`09`09func`20=`20#io$_writevblk,`20-
X`09`09iosb`20=`20iosb,`20-
X`09`09p1`20`20`20=`20trmmsg,`20-
X`09`09p2`20`20`20=`20#trmmsg_len
X`09blbc`09r0,`2099$
X`09movzwl`09iosb,`20r0
X99$:`09rsb
X`09
X;
X;`20Causes`20the`20debug`20signal`20to`20be`20generated`20in`20the`20remote`20
Vprocess
X;
Xsignal_proc_r3:
X`09bsbw`09get_vtnam_r2
X`09blbs`09r0,`20reconnect`09`09`09;`20reconnect`20device
X`09pushaq`09devnam`09`09`09`09;`20bring`20it`20up`20on`20this`20device
X`09pushaq`09iosb
X`09pushal`09pid
X`09clrl`09-(sp)
X`09calls`09#4,`20g`5Eddb_privw`09`09`09;`20Boot`20debug`20up`20initialy
X`09blbc`09r0,`2099$
X`09movl`09#20,`20r3`09`09`09`09;`20do`20this`20upto`20twenty`20times
X1$:`09bsbw`09get_vtnam_r2`09`09`09;`20try`20again
X`09blbc`09r0,`202$
X`09bsbw`09get_vtrefc_r1
X`09blbc`09r0,`2099$
X`09tstl`09r1
X`09bneq`09reconnect1`09`09`09;`20Thats`20it`20so`20grab`20it
X2$:`09pushaf`09i`5E#`5Ef1.0
X`09calls`09#1,`20g`5Elib$wait`09`09`09;`20wait`20for`20a`20second
X`09sobgtr`09r3,`201$`09`09`09`09;`20try`20again
X99$:`09rsb
X;
X`09.enable`09lsb
Xreconnect:
X;
X;`20Reconnect`20processing`20is`20strange!`20A`20connect`20request`20is`20not
V`20completed`20until`20all
X;`20channels`20are`20deassigned`20on`20the`20device`20and`20the`20reference`20
Vcount`20drops`20to`20zero.
X;`20FTAnnnn:`20devices`20have`20a`20reference`20count`20of`20zero`20when`20we
V`20do`20the`20connect`20and`20so
X;`20a`20channel`20is`20never`20deassigned`20to`20make`20the`20connect.`20to`20
Vget`20round`20this`20we`20must
X;`20assign`20a`20channel`20that`20we`20can`20deassign`20just`20to`20force`20la
Vst`20channel`20processing!
X;`20Its`20wacky`20but`20it`20does`20make`20sense!
X;
X`09$cmkrnl_s`20-
X`09`09routin`20=`20take_lock`09`09;`20take`20out`20kernel`20lock
X`09blbc`09r0,`2099$
Xreconnect1:
X`09$assign_s`20-
X`09`09chan`20`20`20=`20ftchan1,`20-`09`09;`20assign`20another`20channel
X`09`09devnam`20=`20devnam`09`09`09;`20to`20FTAnnnn:`20device
X`09blbc`09r0,`2099$
X`09$qiow_s`20-`09`09`09`09;`20connect`20to`20virtual
X`09`09chan`20=`20ftchan1,`20-
X`09`09iosb`20=`20iosb,`20-
X`09`09func`20=`20#io$_setmode!io$m_tt_connect,`20-
X`09`09p1`20`20`20=`20vtnam`09`09`09;`20VTAnnn
X`09blbc`09r0,`20100$
X`09movzwl`09iosb,`20r0`09`09`09;`20check`20other`20status
X`09blbc`09r0,`20100$
X`09$dassgn_s`20-`09`09`09`09;`20Drop`20last`20channel
X`09`09chan`20=`20ftchan1
X99$:`09rsb
X100$:`09pushl`09r0
X`09pushaq`09vtnam
X`09pushl`09#1
X`09pushal`09g`5Eddb__vtcon
X`09calls`09#4,`20g`5Elib$signal`09`09;`20signal`20connect`20error
X`09rsb
X`09.disable`20lsb
X;
Xget_vtrefc_r1:
X`09clrl`09-(sp)`09`09`09`09;`20put`20ref`20count`20here
X`09clrq`09-(sp)`09`09`09`09;`20end`20of`20list`20and`20no`20length
X`09pushal`098(sp)`09`09`09`09;`20put`20refc`20in`20hole
X`09pushl`09#dvi$_refcnt@16+4
X`09movl`09sp,`20r0
X`09$getdviw_s`20-
X`09`09devnam`20=`20vtnam,`20-
X`09`09iosb`20`20`20=`20iosb,`20-
X`09`09itmlst`20=`20(r0)
X`09addl2`09#4*4,`20sp
X`09popl`09r1
X`09blbc`09r0,`2099$
X`09movl`09iosb,`20r0
X99$:`09rsb
X;
Xget_vtnam_r2:
X`09assume`09log_length`20eq`204`09`09`09;`20move`20with`20fast`20instruction
X`09pushl`09pid`09`09`09`09;`20push`20pid
X`09pushl`09log`09`09`09`09;`20Add`20prefix
X`09pushl`09sp`09`09`09`09;`20push`20address
X`09pushl`09#log_length+4`09`09`09;`20save`20size
X`09movl`09sp,`20r2`09`09`09`09;`20point`20to`20lognam
X`09$trnlnm_s`20-
X`09`09tabnam`20=`20lnm$system,`20-`09`09;`20its`20in`20system`20table
X`09`09lognam`20=`20(r2),`20-`09`09;`20translate`20DDB`20logical
X`09`09itmlst`20=`20trnlst
X`09addl2`09#16,`20sp`09`09`09`09;`20drop`20stack`20allocation
X`09rsb
X;
X;`20Opens`20up`20the`20logging`20file`20if`20specified
X;
Xopen_logfile_r1:
X`09pushaq`09log_qual
X`09calls`09#1,`20g`5Ecli$present
X`09blbc`09r0,`2098$
X`09pushaw`09logfile
X`09pushaq`09logfile
X`09pushaq`09log_qual
X`09calls`09#3,`20g`5Ecli$get_value
X`09blbc`09r0,`2099$
X`09movab`09logfab,`20r0
X`09movab`09logfile_b,`20fab$l_fna(r0)
X`09movb`09logfile,`20`20`20fab$b_fns(r0)
X`09movab`09g`5Eddb__logopenerr,`20fab$l_ctx(r0)
X`09$create`09fab`20=`20logfab,`20-
X`09`09err`20=`20file_err
X`09blbc`09r0,`2099$
X`09movab`09g`5Eddb__logconnerr,`20lograb+rab$l_ctx
X`09$connect`20rab`20=`20lograb,`20-
X`09`09err`20=`20file_err
X`09blbc`09r0,`2099$
X`09bisl`09#flags_m_logging,`20flags
X98$:`09movl`09#ss$_normal,`20r0
X99$:`09rsb
X;
X`09.entry`09take_lock`20`5Em<>
X`09assume`09lock_length`20eq`204`09`09;`20move`20with`20fast`20instruction
X`09pushl`09pid`09`09`09`09;`20push`20pid
X`09pushl`09lock`09`09`09`09;`20Add`20prefix
X`09pushl`09sp`09`09`09`09;`20push`20address
X`09pushl`09#lock_length+4`09`09`09;`20save`20size
X`09movl`09sp,`20r0`09`09`09`09;`20point`20to`20lognam
X`09$enqw_s`09lkmode`20=`20#lck$k_exmode,`20-`09;`20Take`20out`20resignal`20loc
Vk
X`09`09lksb`20`20`20=`20lksb,`20-
X`09`09flags`20`20=`20#lck$m_system,`20-`09;`20use`20system`20lock
X`09`09resnam`20=`20(r0),`20-`09`09;`20Use`20this`20resource`20name
X`09`09acmode`20=`20#psl$c_kernel
X`09blbc`09r0,`2099$
X`09movzwl`09lksb,`20r0`09`09`09;`20get`20other`20status
X`09blbc`09r0,`2099$
X`09$deq_s`09lkid`20=`20lksb+4`09`09`09;`20drop`20lock
X99$:`09ret
X
X;
X;`20Starts`20reads`20on`20both`20the`20terminal`20and`20pseudo`20device
X;`20Inputs:
X;`20Outputs:
X;`20`20`20`20R0:`20Status
X;`20Trashes:
X;`20`20`20`20R1
X;
Xstart_r1:
X`09movb`09#`5EA/X/-`5EA/@/,`20wbuf+4
X`09ptd$write_s`20-
X`09`09chan`20`20`20`20`20`20`20=`20ftchan,`20-
X`09`09wrtbuf`20`20`20`20`20=`20wbuf,`20-
X`09`09wrtbuf_len`20=`20#1
X`09blbc`09r0,`2099$
X`09$qio_s`09chan`20`20`20=`20ttchan,`20-
X`09`09func`20`20`20=`20#io$_readvblk!io$m_noecho!io$m_nofiltr,`20-
X`09`09iosb`20`20`20=`20ttiosb,`20-
X`09`09astadr`20=`20got_input,`20-
X`09`09p1`20`20`20`20`20=`20wbuf+4,`20-
X`09`09p2`20`20`20`20`20=`20#1
X`09blbc`09r0,`2099$
X`09ptd$read_s`20-
X`09`09chan`20`20`20`20`20`20`20`20=`20ftchan,`20-
X`09`09astadr`20`20`20`20`20`20=`20got_output,`20-
X`09`09readbuf`20`20`20`20`20=`20rbuf,`20-
X`09`09readbuf_len`20=`20#rbuf_len-4
X99$:`09rsb
X;
Xassign_chans:
X`09bsbb`09do_term
X`09blbc`09r0,`2099$
X`09bicl2`09#tt$m_passall,`20`20`20`20`20ndevchar+4`09`09;`20Turn`20off`20passa
Vll
X`09bicl2`09#tt2$m_secure,`20`20`20`20`20ndevchar+8`09`09;`20No`20secure`20serv
Ver
X`09bisl2`09#tt2$m_disconnect,`20ndevchar+8`09`09;`20Turn`20on`20disconnect
X`09ptd$create_s`20-
X`09`09chan`20`20`20`20`20=`20ftchan,`20-
X`09`09inadr`20`20`20`20=`20inadr,`20-
X`09`09charbuff`20=`20ndevchar,`20-
X`09`09buflen`20`20`20=`20#ndevchar_len
X`09blbc`09r0,`2099$
X`09$getdviw_s`20-
X`09`09chan`20`20`20=`20ftchan,`20-
X`09`09iosb`20`20`20=`20iosb,`20-
X`09`09itmlst`20=`20itmlst
X`09blbc`09r0,`2099$
X`09movl`09iosb,`20r0
X99$:`09rsb
X;
Xdo_term:
X`09$assign_s`20-
X`09`09chan`20`20`20=`20ttchan,`20-
X`09`09devnam`20=`20input
X`09blbc`09r0,`2099$
X`09$qiow_s`20-
X`09`09chan`20=`20ttchan,`20-
X`09`09iosb`20=`20iosb,`20-
X`09`09func`20=`20#io$_sensemode,`20-
X`09`09p1`20`20`20=`20devchar,`20-
X`09`09p2`20`20`20=`20#devchar_len
X`09blbc`09r0,`2099$
X`09movzwl`09iosb,`20r0
X`09blbc`09r0,`2099$
X`09$dclexh_s`20-
X`09`09desblk`20=`20exit_block`09`09`09;`20declare`20exit`20handler
X`09blbc`09r0,`2099$
X`09bsbb`09set_term_chars_r5`09`09`09;`20set`20terminal`20chars
X99$:`09rsb
X;
Xset_term_chars_r5:
X`09assume`09devchar_len`20eq`20ndevchar_len`09`09;`20Both`20blocks`20the`20sam
Ve?
X`09movc3`09#devchar_len,`20devchar,`20ndevchar`09`09;`20Make`20copy`20of`20cha
Vrs
X`09bisl2`09#tt$m_passall,`20ndevchar+4`09`09;`20Set`20passall`20mode
X`09$qiow_s`20-
X`09`09chan`20=`20ttchan,`20-
X`09`09iosb`20=`20iosb,`20-
X`09`09func`20=`20#io$_setmode,`20-
X`09`09p1`20`20`20=`20ndevchar,`20-
X`09`09p2`20`20`20=`20#ndevchar_len
X`09blbc`09r0,`2099$
X`09movzwl`09iosb,`20r0
X99$:`09rsb
X;
X;
X;`20Gets`20the`20command`20line`20and`20parses`20it`20with`20cli$dcl_parse
X;`20Inputs:
X;`20Outputs:
X;`20`20`20`20R0:`20status
X;`20Trashes:
X;`20`20`20`20R1
X;
Xparse_commands_r1:
X`09pushaw`09get_input`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20;`20Input`20
Vand
X`09pushaw`09get_input`09`09;`20`20`20`20continuation`20routines
X`09pushab`09ddb_clitable`09`09;`20command`20table`20address
X`09pushaq`09verb`09`09`09;`20start`20of`20command
X`09calls`09#4,`20g`5Ecli$dcl_parse`09;`20parse`20command
X`09bisl2`09#sts$m_inhib_msg,`20r0`09;`20Dont`20signal`20errors
X`09blbc`09r0,`2099$`09`09`09;`20quit`20with`20error
X`09pushaq`09identification`09`09;`20this`20qualifier`20there?
X`09calls`09#1,`20g`5Ecli$present`09;`20/IDENT`20there?
X`09blbs`09r0,`201$`09`09`09;`20if`20no`20get`20process`20name
X`09pushaw`09prcnam`09`09`09;`20put`20length`20here
X`09pushaq`09prcnam`09`09`09;`20put`20it`20here
X`09pushaq`09process_name`09`09;`20get`20process`20name
X`09calls`09#3,`20g`5Ecli$get_value`09;`20get`20process`20name
X`09blbc`09r0,`2099$`09`09`09;`20quit`20on`20error
X`09$getjpiw_s`20-
X`09`09prcnam`20=`20prcnam,`20-`09;`20use`20process`20name
X`09`09pidadr`20=`20pid,`20-`09`09;`20put`20PID`20here
X`09`09iosb`20`20`20=`20iosb,`20-`09;`20use`20iosb
X`09`09itmlst`20=`20#0`09`09;`20empty`20item`20list
X`09blbc`09r0,`2098$`09`09`09;`20quit`20on`20error
X`09movl`09iosb,`20r0`09`09;`20get`20other`20status
X98$:`09blbs`09r0,`2099$`09`09`09;`20all`20is`20ok
X`09pushl`09r0`09`09`09;`20Real`20error
X`09pushaq`09prcnam`09`09`09;`20Process`20name
X`09pushl`09#1`09`09`09;`201`20argument
X`09pushal`09g`5Eddb__prcnam`09`09;`20Signal`20error`20in`20process`20name
X`09calls`09#4,`20g`5Elib$signal`09;`20Signal`20error`20for`20process
X99$:`09rsb
X;
X;`20Use`20specified`20process`20id
X;
X1$:`09pushaw`09idstr`09`09`09;`20put`20length`20here
X`09pushaq`09idstr`09`09`09;`20put`20PID`20string`20here
X`09pushaq`09identification`09`09;`20get`20/ID`20value
X`09calls`09#3,`20g`5Ecli$get_value`09;`20get`20the`20value
X`09blbc`09r0,`2099$`09`09`09;`20quit`20on`20error
X`09pushal`09pid`09`09`09;`20put`20result`20here
X`09pushaq`09idstr`09`09`09;`20convert`20/id`20value
X`09calls`09#2,`20g`5Eots$cvt_tz_l`09;`20convert`20to`20binary
X`09blbs`09r0,`2099$
+-+-+-+-+-+-+-+-  END  OF PART 2 +-+-+-+-+-+-+-+-
--
Neill Clift  neill@macro.demon.co.uk
