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

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

-+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+
X`09pushl`09r0`09`09`09;`20Real`20error
X`09pushaq`09idstr`09`09`09;`20Process`20name
X`09pushl`09#1`09`09`09;`201`20argument
X`09pushal`09g`5Eddb__prcpid`09`09;`20Signal`20error`20in`20process`20id
X`09calls`09#4,`20g`5Elib$signal`09;`20Signal`20error`20for`20process
X`09rsb
X;
X`09.entry`09get_input`20`5Em<>`09`09;`20Input`20routine`20for`20CLI$DCL_PARSE
V
Xline`20`20`20=`204`09`09`09`09;`20put`20input`20here
Xprompt`20=`208`09`09`09`09;`20use`20this`20prompt
Xlength`20=`2012`09`09`09`09;`20put`20length`20of`20input`20here
X`09pushal`09frcpmt`09`09`09;`20used`20to`20force`20prompting`20after`20first
X`09pushl`09length(ap)`09`09;`20put`20length`20here
X`09assume`09<line+4>`20eq`20prompt`09;`20can`20we`20copy`20both`20in`20one
X`09movq`09line(ap),`20-(sp)`09`09;`20copy`20line`20and`20prompt
X`09calls`09#4,`20g`5Elib$get_foreign`09;`20get`20command`20line
X`09ret
X;
X`09.entry`09got_output`20`5Em<r2,r3,r4,r5>
X`09assume`09flags_v_finished`20eq`200
X`09blbs`09flags,`2099$
X`09movzwl`09rbuf,`20r0
X`09blbc`09r0,`20sig
X`09bsbb`09log_output_r5
X`09blbc`09r0,`20sig
X`09movzwl`09rbuf+2,`20r0
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=`20rbuf+4,`20-
X`09`09p2`20`20`20=`20r0
X`09blbc`09r0,`20sig
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
X`09blbc`09r0,`20sig
X99$:`09ret
X;
Xsig:`09brw`09sig1
X;
Xlog_output_r5:
X`09movab`09flush_lines_r5,`20r4`09`09;`20Try`20flushing`20lines`20first
X1$:`09bbc`09#flags_v_logging,`20flags,`2098$`09;`20logging`20to`20be`20done?
X`09movq`09logbuf,`20r0`09`09`09;`20Get`20descriptor
X`09movzwl`09r0,`20r0`09`09`09`09;`20get`20real`20length
X`09addl2`09r0,`20r1`09`09`09`09;`20get`20address`20of`20end
X`09subl3`09r0,`20#logbuf_len,`20r0`09`09;`20get`20remaining
X`09movzwl`09rbuf+2,`20r2`09`09`09;`20get`20length`20of`20new`20data
X`09cmpl`09r0,`20r2`09`09`09`09;`20test`20for`20space
X`09bgtru`092$`09`09`09`09;`20enough`20space?
X`09jsb`09(r4)`09`09`09`09;`20flush`20the`20buffer
X`09movab`09flush_buffer_r5,`20r4`09`09;`20flush`20everything`20if`20need`20be
V
X`09blbc`09r0,`2099$`09`09`09`09;`20quit`20with`20error
X`09brb`091$`09`09`09`09;`20try`20again
X2$:`09addw2`09r2,`20logbuf`09`09`09;`20set`20new`20length
X`09movc3`09r2,`20rbuf+4,`20(r1)`09`09;`20copy`20in`20new`20data
X98$:`09movl`09#ss$_normal,`20r0
X99$:`09rsb
X;
Xflush_lines_r5:
X`09bbc`09#flags_v_logging,`20flags,`2098$`09;`20logging`20to`20be`20done?
X`09bsbw`09compress_deletes_r5`09`09;`20Trim`20out`20any`20deletes
X`09movq`09logbuf,`20r2`09`09`09;`20Get`20descriptor
X`09movzwl`09r2,`20r2`09`09`09`09;`20get`20real`20length
X1$:`09movl`09r3,`20lograb+rab$l_rbf`09`09;`20set`20buffer`20start
X`09locc`09#CR,`20r2,`20(r3)`09`09`09;`20Any`20line`20breaks?
X`09beql`094$
X`09cmpb`091(r1),`20#LF`09`09`09;`20line`20feed`20after?
X`09bneq`092$
X`09incl`09r1`09`09`09`09;`20skip`20LF
X2$:`09subw3`09r0,`20r2,`20lograb+rab$w_rsz`09;`20length`20upto`20CR
X`09subl3`09r3,`20r1,`20r0
X`09subl2`09r0,`20r2
X`09addl3`09#1,`20r1,`20r3
X`09movab`09g`5Eddb__logputerr,`20lograb+fab$l_ctx
X`09$put`09rab`20=`20lograb,`20-
X`09`09err`20=`20file_err
X`09blbs`09r0,`203$
X`09bicl`09#flags_m_logging,`20flags`09`09;`20file`20error`20turn`20off`20loggi
Vng
X`09brb`0998$
X3$:`09decl`09r2
X`09bgtr`091$
X4$:`09movw`09r2,`20logbuf
X`09movc3`09r2,`20(r3),`20logbuf_b
X98$:`09movl`09#ss$_normal,`20r0
X99$:`09rsb
X;
Xflush_buffer_r5:
X`09bbc`09#flags_v_logging,`20flags,`2098$`09;`20logging`20to`20be`20done?
X`09bsbw`09flush_lines_r5`09`09`09;`20flush`20any`20lines`20first
X`09blbc`09r0,`2099$`09`09`09`09;`20quit`20on`20error
X`09movq`09logbuf,`20r2`09`09`09;`20Get`20descriptor
X`09movw`09r2,`20lograb+rab$w_rsz`09`09;`20length`20left
X`09movl`09r3,`20lograb+rab$l_rbf`09`09;`20set`20buffer`20address
X`09movab`09g`5Eddb__logputerr,`20lograb+fab$l_ctx
X`09$put`09rab`20=`20lograb,`20-`09`09`09;`20put`20to`20output
X`09`09err`20=`20file_err
X`09blbs`09r0,`201$
X`09bicl`09#flags_m_logging,`20flags`09`09;`20file`20error`20turn`20off`20loggi
Vng
X1$:`09clrw`09logbuf`09`09`09`09;`20say`20no`20more`20output
X98$:`09movl`09#ss$_normal,`20r0
X99$:`09rsb
X;
Xcompress_deletes_r5:
X1$:`09subw3`09#1,`20logbuf,`20`20`20r2`09`09;`20Get`20descriptor`20length-1
X`09bleq`0999$`09`09`09`09;`20only`20one`20byte
X`09addl3`09#1,`20logbuf+4,`20r3`09`09;`20get`20address`20of`20second`20byte
X`09matchc`09#delstr_len,`20delstr,`20r2,`20(r3)`09;`20look`20for`20delstr`09
X`09bneq`0999$`09`09`09`09;`20all`20done
X`09movc3`09r2,`20(r3),`20-delstr_len-1(r3)`09;`20scrunch`20it`20out
X`09subw2`09#delstr_len+1,`20logbuf
X`09brb`091$
X99$:`09rsb
X;
Xsig2:`09brw`09sig1
X;
X`09.entry`09got_input`20`5Em<r2>
X`09assume`09flags_v_finished`20eq`200
X`09blbs`09flags,`2099$
X`09movzwl`09ttiosb,`20r0
X`09blbc`09r0,`20sig2
X`09bsbw`09read_typahd_r2
X`09blbs`09r0,`202$
X1$:`09cmpw`09r0,`20#ss$_timeout
X`09bneq`09sig1
X2$:`09tstl`09r2
X`09beql`0999$
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=`20r2
X`09blbc`09r0,`20sig1
X`09movzwl`09wbuf,`20r0
X`09blbc`09r0,`20sig1
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,`20sig1
X99$:`09ret
X;
Xsig1:`09cmpw`09r0,`20#ss$_cancel
X`09beql`0999$
X`09cmpw`09r0,`20#ss$_abort
X`09beql`0999$
X`09pushl`09r0
X`09calls`09#1,`20g`5Elib$signal
X99$:`09ret
X;
X;`20reads`20in`20the`20typeahead`20buffer`20into`20the`20rest`20of`20the`20IO
V`20line.
X;
Xread_typahd_r2:
X`09clrl`09r2
X`09addw3`09ttiosb+2,`20ttiosb+6,`20r2
X`09subw3`09r2,`20#wbuf_len-4,`20r1
X`09movab`09wbuf+4`5Br2`5D,`20r0
X`09$qiow_s`09chan`20`20`20=`20ttchan,`20-
X`09`09func`20`20`20=`20#io$_readvblk!io$m_noecho!io$m_timed,`20-
X`09`09iosb`20`20`20=`20iosb,`20-
X`09`09p1`20`20`20`20`20=`20(r0),`20-
X`09`09p2`20`20`20`20`20=`20r1
X`09blbc`09r0,`2099$
X`09addw2`09iosb+2,`20r2
X`09addw2`09iosb+6,`20r2
X`09locc`09#quit_char,`20r2,`20wbuf+4
X`09beql`091$
X`09subl2`09r0,`20r2
X`09$dclast_s`20-
X`09`09astadr`20=`20got_outband
X`09blbc`09r0,`2099$
X1$:`09movzwl`09iosb,`20r0
X99$:`09rsb
X;
X;`20Reset`20terminal`20characteristics`20before`20exiting.
X;
X`09.entry`09rundown`20`5Em<>
Xstatus`20=`204
X`09bsbw`09flush_buffer_r5`09`09`09`09;`20flush`20any`20output
X`09bsbb`09cancel_io_r1`09`09`09`09;`20cancel`20all`20io
X`09$qiow_s`20-`09`09`09`09`09;`20reset`20terminal`20chars
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=`20devchar,`20-
X`09`09p2`20`20`20=`20#devchar_len
X`09ret
X;
Xcancel_io_r1:
X`09$cancel_s`20-
X`09`09chan`20=`20ttchan`09`09`09`09;`20cancel`20terminal`20IO
X`09$cancel_s`20-
X`09`09chan`20=`20ftchan`09`09`09`09;`20cancel`20FT`20IO
X`09ptd$cancel_s`20-
X`09`09chan`20=`20ftchan`09`09`09`09;`20Cancel`20PTD`20reads
X`09rsb
X;
X`09.entry`09got_outband`20`5Em<>
X`09bsbb`09cancel_io_r1`09`09`09`09;`20cancel`20all`20io
X`09bisl2`09#flags_m_finished,`20flags`09`09;`20Say`20all`20is`20finished
X`09$wake_s`09`09`09`09`09`09;`20Wake`20main`20thread
X`09ret
X;
X`09.entry`09file_err`20`5Em<r2>
X;
Xrmsblock`20=`204
Xsavedr0`20`20=`20rmsblock`20+`204
Xsavedr1`20`20=`20savedr0`20+`204
Xsavedpc`20`20=`20savedr1`20+`204
Xsavedpsl`20=`20savedpc`20+`204
X;
X`09assume`09fab$l_sts`20eq`20rab$l_sts
X`09assume`09fab$l_stv`20eq`20rab$l_stv
X`09assume`09fab$l_ctx`20eq`20rab$l_ctx
X`09assume`09fab$b_bid`20eq`20rab$b_bid
X;
X`09movl`09rmsblock(ap),`20r0
X`09pushl`09fab$l_stv(r0)`09`09`09;`20Save`20other`20status`20value
X`09pushl`09fab$l_sts(r0)`09`09`09;`20Save`20status`20value
X;
X;`20Assume`20this`20is`20a`20RAB`20and`20if`20so`20move`20to`20the`20FAB
X;
X`09movl`09r0,`20r1`09`09`09`09;`20Assume`20this`20is`20the`20fab
X`09cmpb`09rab$b_bid(r0),`20#rab$c_bid`09;`20this`20a`20rab?
X`09bneq`091$`09`09`09`09;`20Its`20a`20FAB`20so`20no`20need`20to`20switch
X`09movl`09rab$l_fab(r0),`20r1`09`09;`20Get`20address`20of`20the`20fab
X1$:`09movl`09fab$l_nam(r1),`20r2`09`09;`20Skip`20to`20NAM`20block
X;
X;`20Try`20and`20use`20resultant`20name`20first`20then`20expanded`20then`20fina
Vly`20fab`20inputs.
X;
X`09pushl`09nam$l_rsa(r2)`09`09`09;`20Save`20address`20of`20string
X`09movzbl`09nam$b_rsl(r2),`20-(sp)`09`09;`20Set`20length`20of`20string
X`09bneq`092$`09`09`09`09;`20We`20got`20one`20so`20continue
X`09movl`09nam$l_esa(r2),`204(sp)`09`09;`20Save`20address`20of`20other`20string
V
X`09movzbl`09nam$b_esl(r2),`20(sp)`09`09;`20Save`20new`20length`20of`20string
X`09bneq`092$`09`09`09`09;`20We`20got`20one`20so`20continue
X`09movl`09fab$l_fna(r1),`204(sp)`09`09;`20Save`20address`20of`20other`20string
V
X`09movzbl`09fab$b_fns(r1),`20(sp)`09`09;`20Save`20new`20length`20of`20string
X2$:`09pushl`09#2`09`09`09`09;`20Two`20arguments`20for`20error
X`09pushl`09fab$l_ctx(r0)`09`09`09;`20Save`20primary`20error
X`09calls`09#6,`20g`5Elib$signal`09`09;`20Signal`20the`20error
X`09ret
X;
X`09.end`09ddb
$ call unpack DDB_MAIN.MAR;120 1901637136 "" 38 4 10 
$!
$ create 'f'
X.facility/prefix=ddb__`09ddb,`20104
X.severity`09fatal
Xlogopenerr`09<error`20opening`20file`20!AF>/FAO=2
Xlogconnerr`09<error`20connecting`20to`20file`20!AF>/FAO=2
Xlogputerr`09<error`20during`20$PUT`20for`20file`20!AF>/FAO=2
Xprcnam`09`09<error`20obtaining`20PID`20of`20process`20!AS>/FAO=1
Xprcpid`09`09<error`20converting`20process`20PID`20!AS>/FAO=1
Xvtcon`09`09<error`20connecting`20to`20virtual`20terminal`20!AS.`20Check`20your
V`20UIC>/FAO=1
Xastdis`09`09<ASTs`20are`20disabled`20for`20the`20specified`20process>/FAO=0
Xastact`09`09<the`20specified`20process`20has`20an`20AST`20thread`20active>/FAO
V=0
X.end
$ call unpack DDB_MSG.MSG;6 722942423 "" 1 5 10 
$!
$ create 'f'
X`09.title`09ddb_priv`20privileged`20code`20to`20debug`20detached`20process
X;
X;`20Copyright`20(C)`201994`20Neill`20Clift`20(neill@macro.demon.co.uk).
X;
X;`20This`20program`20comes`20without`20any`20warranty.`20The`20author`20does
V`20not`20accept`20any
X;`20responsibility`20for`20any`20damage`20caused`20by`20the`20use`20of`20this
V`20program.`20This
X;`20program`20is`20not`20in`20the`20public`20domain`20but`20may`20be`20copied
V`20freely`20so`20long`20as`20this
X;`20copyright`20notice`20remains.
X;
X;`20Please`20send`20any`20modifications`20to`20the`20author.
X;
X;`20The`20aim`20of`20this`20code`20is`20to`20run`20up`20the`20debugger`20in`20
Va`20detached`20process`20with
X;`20dbg$input`20etc`20pointing`20to`20a`20pseudo-terminal`20created`20especial
Vy`20for`20the`20debug
X;`20purpose.
X;
X`09.disable`20global
X`09.link`09/sys$system:sys.stb//selective_search
X`09.library`20/sys$library:lib.mlb/
X;
X;`20Error`20messages
X;
X`09.external`20ddb__astact,`20-`09;`20AST`20thread`20active
X`09`09ddb__astdis`09`09;`20ASTs`20are`20disabled
X;
X;`20External`20data`20cells
X;
X
X`09.external`20ctl$gl_pcb,`20-`09`09;`20Process`20control`20block`20address
X`09`09ctl$gl_phd`09`09;`20P1`20window`20to`20Process`20Header
X;
X;`20External`20routines
X;
X`09.external`20sch$clrefr,`20-`09`09;`20Clear`20event`20flag`20rsb`20return
X`09`09sch$iolockw,`20-`09`09;`20lock`20IO`20database`20for`20write`20access
X`09`09sch$iounlock,`20-`09`09;`20unlock`20IO`20database
X`09`09sch$postef,`20-`09`09;`20Set`20event`20flag
X`09`09sch$qast`09`09;`20Queue`20an`20AST`20to`20another`20process
X;
X`09.external`20exe$allocbuf,`20-`09;`20Allocate`20nonpaged`20pool
X`09`09exe$alop1imag,`20-`09;`20allocate`20image`20temporary`20memory
X`09`09exe$deanonpaged,`20-`09;`20Deallocate`20nonpaged`20pool
X`09`09exe$epid_to_ipid,`20-`09;`20Convert`20external`20to`20internal`20PID
X`09`09exe$srchandler,`20-`09;`20Search`20for`20condition`20handler
X`09`09exe$ipid_to_pcb`09`09;`20Convert`20internal`20PID`20to`20PCB
X;
X`09.external`20ioc$clone_ucb,`20-`09;`20Make`20copy`20of`20device`20UCB
X`09`09ioc$cvt_devnam,`20-`09;`20Convert`20UCB`20to`20device`20name
X`09`09ioc$searchdev`09`09;`20search`20for`20device`20in`20IO`20database
X;
X`09.external`20ini$brk`09`09;`20Bring`20up`20xdelta
X;
X`09.external`20exe$c_sysefn`09`09;`20System`20event`20flag`20number
X;
X;`20Include`20structure`20definitions
X;
X`09$acbdef`09`09;`20AST`20Control`20block`20offsets
X`09$dcdef`09`09;`20Device`20Class`20and`20type`20definitions
X`09$devdef`09`09;`20Device`20flags`20definitions
X`09$dyndef`09`09;`20Dynamic`20memory`20structure`20types
X`09$ipldef`09`09;`20Interupt`20priority`20levels
X`09$lckdef`09`09;`20Lock`20manager`20flags
X`09$lnmdef`09`09;`20Logical`20name`20services`20definitions
X`09$orbdef`09`09;`20Object`20Rights`20Block`20offsets
X`09$pcbdef`09`09;`20Process`20control`20block`20offsets
X`09$phddef`09`09;`20process`20header`20offsets
X`09$prdef`09`09;`20Internal`20processor`20registers
X`09$pridef`09`09;`20Priority`20increment`20classes
X`09$psldef`09`09;`20Process`20status`20longword
X`09$sfdef`09`09;`20Stack`20frame`20definitions
X`09$ssdef`09`09;`20System`20service`20completion`20codes
X`09$statedef`09;`20Scheduling`20state`20definitions
X`09$ttyucbdef`09;`20Terminal`20extension`20to`20UCB`20offsets
X`09$ucbdef`09`09;`20Unit`20Control`20Block`20offsets
X;
X;`20Define`20ACB`20+`20extension`20to`20carry`20our`20data`20and`20code`20to
V`20another`20process.
X;
X`09$defini`09acb
X.`20=`20acb$k_length
X`09$def`09acb_l_iosb`09.blkq`091`09`09;`20User`20IOSB`20address
X`09$def`09acb_l_efn`09.blkl`091`09`09;`20User`20event`20flag`20no.
X`09$def`09acb_l_acmode`09.blkl`091`09`09;`20Callers`20access`20mode
X`09$def`09acb_l_epid`09.blkl`091`09`09;`20External`20dest`20PID
X`09$def`09acb_l_rpid`09.blkl`091`09`09;`20PID`20to`20return`20to
X`09$def`09acb_l_status`09.blkl`091`09`09;`20Return`20status
X`09$def`09acb_l_imgcnt`09.blkl`091`09`09;`20Image`20count
X`09$def`09acb_l_acb`09.blkl`091`09`09;`20another`20ACB`20chained
X`09$equ`09acb_k_devlen`0910`09`09`09;`20Length`20of`20device
X`09$def`09acb_t_terminal`09.blkb`09acb_k_devlen+1`09;`20Input/Output`20termina
Vl
X`09$equ`09acb_r_code`09.`09`09`09;`20Code`20to`20execute
X`09$equ`09acb_k_length`09.`09`09`09;`20length`20of`20ACB
X`09$defend`09acb
X;
X;`20Define`20Paged`20Image`20Block`20to`20carry`20paged`20kernel`20and`20user
V`20code`20+`20data`20in`20the
X;`20remote`20image.`20This`20block`20is`20not`20deallocated`20but`20left`20for
V`20the`20life`20of`20the
X;`20image.
X;
X;
X`09$defini`09pib
X`09$equ`09pib_k_lockname`094`09`09`09;`20prefix`20size
X`09$def`09pib_l_length`09.blkl`091`09`09;`20length`20of`20block
+-+-+-+-+-+-+-+-  END  OF PART 3 +-+-+-+-+-+-+-+-
--
Neill Clift  neill@macro.demon.co.uk
