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

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

-+-+-+-+-+-+-+-+ START OF PART 5 -+-+-+-+-+-+-+-+
Xcode_start:
X;`09jsb`09g`5Eini$brk
X`09bsbb`09allocate_p1image_r4`09`09;`20allocate`20paged`20image`20block
X`09blbc`09r0,`201$`09`09`09`09;`20quit`20with`20error
X;
X;`20At`20this`20point
X;`20`20`20`20R1:`20Size`20of`20memory`20allocated
X;`20`20`20`20R2:`20Address`20of`20allocated`20memory
X;
X`09pushl`09r5`09`09`09`09;`20save`20ACB
X`09movl`09acb_l_acb(r5),`20r1`09`09;`20get`20chained`20ACB
X`09clrl`09acb_l_acb(r5)`09`09`09;`20say`20its`20no`20longer`20chained
X`09movl`09acb$l_pid(r5),`20acb$l_pid(r1)`09;`20set`20our`20pid
X`09movl`09r1,`20r5`09`09`09`09;`20copy`20to`20proper`20register
X`09movab`09pib_r_code(r2),`20acb$l_ast(r5)`09;`20set`20address`20of`20code
X`09movl`09r2,`20acb$l_astprm(r5)`09`09;`20set`20param`20as`20block`20address
X`09assume`09psl$c_kernel`20eq`200`09`09;`20Can`20we`20use`20clear`20for`20spee
Vd
X`09clrb`09acb$b_rmod(r5)`09`09`09;`20set`20mode`20to`20kernel
X`09movl`09#pri$_ticom,`20r2`09`09`09;`20set`20large`20priority`20inc
X`09jsb`09g`5Esch$qast`09`09`09;`20queue`20the`20AST`20to`20us
X`09popl`09r5`09`09`09`09;`20get`20back`20ACB`20addres
X1$:`09movl`09r0,`20acb_l_status(r5)`09`09;`20save`20final`20status
X`09movl`09acb_l_acb(r5),`20r0`09`09;`20get`20chained`20ACB
X`09beql`092$`09`09`09`09;`20nothing`20to`20drop
X`09jsb`09g`5Eexe$deanonpaged`09`09;`20drop`20chained`20ACB
X2$:`09movb`09#psl$c_kernel!acb$m_kast,`20-
X`09`09acb$b_rmod(r5)`09`09`09;`20set`20AST`20mode`20to`20kernel
X`09movl`09acb_l_rpid(r5),`20acb$l_pid(r5)`09;`20set`20return`20PID
X`09movab`09w`5Epost_results,`20acb$l_kast(r5)`09;`20Set`20address`20of`20routi
Vne
X`09movl`09#pri$_ticom,`20r2`09`09`09;`20set`20large`20priority`20inc
X`09jmp`09g`5Esch$qast`09`09`09;`20queue`20the`20AST`09
X;
X;`20Allocates`20a`20chunk`20of`20memory`20in`20the`20remote`20processes`20P1
V`20space.
X;
Xallocate_p1image_r4:
X`09movzwl`09#pib_k_length+pcode_length,`20r1`09;`20Set`20size`20of`20paged`20c
Vode
X`09jsb`09g`5Eexe$alop1imag`09`09`09;`20allocate`20the`20memory
X`09blbc`09r0,`2099$
X;
X;`20At`20this`20point
X;`20`20`20`20R1:`20Size`20of`20memory`20allocated
X;`20`20`20`20R2:`20Address`20of`20allocated`20memory
X;
X`09pushr`09#`5Em<r2,r5>`09`09`09;`20save`20ACB`20and`20paged`20mem
X`09movl`09acb_l_epid(r5),`20pib_l_epid(r2)`09;`20save`20external`20pid
X`09movc3`09#acb_k_devlen+1,`20acb_t_terminal(r5),`20-
X`09`09pib_t_terminal(r2)`09`09;`20move`20terminal`20buffer
X`09movl`09(sp),`20r2`09`09`09;`20get`20back`20address
X`09movc3`09#pcode_length,`20w`5Epcode_start,`20-
X`09`09pib_r_code(r2)`09`09`09;`20copy`20code`20to`20paged`20buffer
X`09popr`09#`5Em<r2,r5>`09`09`09;`20restore`20ACB`20and`20paged`20buffer
X`09movl`09#ss$_normal,`20r0`09`09`09
X99$:`09rsb
X
X;
X;`20Here`20we`20are`20back`20in`20the`20context`20of`20the`20original`20proces
Vs.`20We`20have`20to`20write`20the
X;`20status`20in`20the`20iosb`20and`20set`20the`20event`20flag.
X;
Xpost_results:
X;`09jsb`09g`5Eini$brk
X`09movl`09g`5Ectl$gl_phd,`20r0`09`09;`20get`20address`20of`20process`20header
V
X`09cmpl`09phd$l_imgcnt(r0),`20-
X`09`09acb_l_imgcnt(r5)`09`09;`20compare`20image`20count
X`09bneq`092$`09`09`09`09;`20Image`20has`20terminated!
X`09movl`09acb_l_acmode(r5),`20r0`09`09;`20get`20original`20mode
X`09movl`09acb_l_iosb(r5),`20r1`09`09;`20get`20address`20of`20iosb
X`09probew`09r0,`20#8,`20(r1)`09`09`09;`20write`20the`20iosb?
X`09beql`091$`09`09`09`09;`20nope
X`09movl`09acb_l_status(r5),`20(r1)`09`09;`20set`20iosb`20status
X1$:`09movl`09acb_l_efn(r5),`20r3`09`09;`20get`20event`20flag
X`09movl`09acb_l_rpid(r5),`20r1`09`09;`20set`20our`20pid
X`09jsb`09g`5Esch$postef`09`09`09;`20set`20the`20event`20flag
X2$:`09movl`09r5,`20r0`09`09`09`09;`20copy`20ACB`20address
X`09jmp`09g`5Eexe$deanonpaged`09`09;`20deallocate`20memory
X;
X`09.entry`09pcode_start`20`5Em<r2,r3,r4,r5>
X;
X;`20We`20are`20called`20here`20in`20kernel`20mode.`20the`20AST`20parameter`20i
Vs`20the`20address`20of`20the
X;`20paged`20block.
X;
Xpibadr`20=`204
X;`09jsb`09g`5Eini$brk
X`09movl`094(ap),`20r5`09`09`09;`20get`20address`20of`20block
X`09bsbw`09create_logicals_r4`09`09;`20create`20all`20logical`20names
X`09blbc`09r0,`2099$
X`09$dclast_s`20-
X`09`09astadr`20=`20w`5Euser_routine,`20-`09;`20Declare`20user`20mode`20AST
X`09`09astprm`20=`20r5,`20-`09`09`09;`20`20to`20signal`20ss$_debug
X`09`09acmode`20=`20#psl$c_user`09`09;`20`20in`20user`20mode
X`09blbc`09r0,`2099$
X`09assume`09pib_k_lockname`20eq`204`09`09;`20can`20we`20use`20movl`20for`20pre
Vfix
X`09movl`09b`5Elock,`20pib_t_lockname(r5)`09;`20set`20lock`20prefix
X`09assume`09<pib_t_lockname+pib_k_lockname>`20eq`20-
X`09`09pib_l_epid`09`09`09;`20Can`20we`20not`20move`20the`20pid?
X`09pushab`09pib_t_lockname(r5)`09`09;`20push`20address
X`09pushl`09#lock_length+4`09`09`09;`20save`20length
X`09movl`09sp,`20r2`09`09`09`09;`20get`20address`20of`20descriptor
X`09$enq_s`09efn`20`20`20`20=`20s`5E#exe$c_sysefn,`20-`20
X`09`09lkmode`20=`20#lck$k_exmode,`20-`09;`20Take`20out`20resignal`20lock
X`09`09lksb`20`20`20=`20pib_q_lksb(r5),`20-`09;`20LKSB`20in`20pib
X`09`09flags`20`20=`20#<lck$m_system!lck$m_noquota!lck$m_syncsts>,`20-
X`09`09resnam`20=`20(r2),`20-`09`09;`20Use`20this`20resource`20name
X`09`09astprm`20=`20r5,`20-`09`09`09;`20Pass`20pib`20as`20parameter
X`09`09blkast`20=`20w`5Eresignal,`20-`09`09;`20call`20resignal`20when`20blocked
V
X`09`09acmode`20=`20psl$c_user`09`09;`20allow`20user`20mode`20queues
X99$:`09ret
X;
Xtab:`09.ascii`09/LNM$JOB/
Xtab_len`20=`20.-tab
X;
Xdbgin:`09.ascii`09/DBG$INPUT/
Xdbgin_len`20=`20.-dbgin
X;
Xdbgout:`09.ascii`09/DBG$OUTPUT/
Xdbgout_len`20=`20.-dbgout
X;
X;dbgproc:.ascii`09/DBG$PROCESS/
X;dbgproc_len`20=`20.-dbgproc
X;
X;dbgnone:.ascii`09/NONE/
X;dbgnone_len`20=`20.-dbgnone
X;
Xsystab:`09.ascii`09/LNM$SYSTEM/
Xsystab_len`20=`20.-systab
X;
Xlog:`09.ascii`09/DDB_/
Xlog_length`20=`20.-log
X`09assume`09log_length`20eq`204`09`09`09;`20move`20easily?
Xlock:`09.ascii`09/DDB_/`09`09`09`09;`20Prefix`20for`20lock`20name
Xlock_length`20=`20.-lock
X`09assume`09lock_length`20eq`20pib_k_lockname`09;`20Is`20code`20above`20correc
Vt
X;
Xuacmode:.byte`09psl$c_user
X;
X;`20Creates`20the`20logical`20names:`20DBG$INPUT,`20DBG$OUTPUT,`20DDB_<PID>,
V`20DBG$PROCESS.
X;`20Inputs:
X;`20`20`20`20R5:`20Address`20of`20pib
X;`20Outputs:
X;`20`20`20`20R0:`20Status
X;`20Trashes:
X;`20`20`20`20R1,R2,R3,R4
X;
Xcreate_logicals_r4:
X`09pushab`09tab`09`09`09`09;`20push`20string`20address
X`09pushl`09#tab_len`09`09`09;`20set`20length
X`09movl`09sp,`20r2`09`09`09`09;`20address`20of`20table`20name
X`09pushab`09dbgin`09`09`09`09;`20push`20string`20address
X`09pushl`09#dbgin_len
X`09movl`09sp,`20r3`09`09`09`09;`20save`20descriptor`20address
X`09clrq`09-(sp)`09`09`09`09;`20no`20retlen`20and`20end`20of`20list
X`09pushab`09pib_t_terminal+1(r5)`09`09;`20set`20buffer`20address
X`09movw`09#lnm$_string,`20-(sp)`09`09;`20we`20are`20setting`20this`20value
X`09movzbw`09pib_t_terminal(r5),`20-(sp)`09;`20set`20size`20of`20input
X`09movl`09sp,`20r4`09`09`09`09;`20point`20to`20item`20list
X`09$crelnm_s`20-
X`09`09tabnam`20=`20(r2),`20-`09`09;`20Create`20DBG$INPUT
X`09`09lognam`20=`20(r3),`20-
X`09`09acmode`20=`20uacmode,`20-`09`09;`20In`20user`20mode
X`09`09itmlst`20=`20(r4)
X`09blbc`09r0,`2099$
X`09movzbl`09#dbgout_len,`20(r3)`09`09;`20Patch`20up`20item`20list
X`09movab`09dbgout,`204(r3)
X`09$crelnm_s`20-
X`09`09tabnam`20=`20(r2),`20-`09`09;`20Create`20DBG$OUTPUT
X`09`09lognam`20=`20(r3),`20-
X`09`09acmode`20=`20uacmode,`20-`09`09;`20In`20user`20mode
X`09`09itmlst`20=`20(r4)
X`09blbc`09r0,`2099$
X;`09movzbl`09#dbgproc_len,`20(r3)`09`09;`20Patch`20up`20item`20list
X;`09movab`09dbgproc,`204(r3)
X;`09movzbw`09#dbgnone_len,`20(r4)`09`09;`20Set`20size`20of`20none`20string
X;`09movab`09dbgnone,`204(r4)`09`09`09;`20Set`20address`20of`20string
X;`09$crelnm_s`20-
X;`09`09tabnam`20=`20(r2),`20-`09`09;`20Create`20DBG$PROCESS
X;`09`09lognam`20=`20(r3),`20-
X;`09`09acmode`20=`20uacmode,`20-`09`09;`20In`20user`20mode
X;`09`09itmlst`20=`20(r4)
X;`09blbc`09r0,`2099$`09`09`09`09;`20Quit`20if`20error
X`09movzbl`09#systab_len,`20(r2)`09`09;`20set`20up`20table`20name`20size
X`09movab`09systab,`204(r2)`09`09`09;`20set`20up`20address`20of`20table
X`09assume`09pib_k_lockname`20eq`204`09`09;`20can`20we`20use`20movl`20for`20pre
Vfix
X`09movl`09log,`20pib_t_lockname(r5)`09`09;`20set`20logical`20prefix
X`09assume`09<pib_t_lockname+pib_k_lockname>`20eq`20-
X`09`09pib_l_epid`09`09`09;`20Can`20we`20not`20move`20the`20pid?
X`09movzbl`09#log_length+4,`20(r3)`09`09;`20save`20length
X`09movab`09pib_t_lockname(r5),`204(r3)`09;`20move`20address`20of`20string
X`09$crelnm_s`20-
X`09`09tabnam`20=`20(r2),`20-`09`09;`20Create`20DBG$OUTPUT
X`09`09lognam`20=`20(r3),`20-
X`09`09acmode`20=`20uacmode,`20-`09`09;`20In`20user`20mode
X`09`09itmlst`20=`20(r4)
X99$:`09movab`098(r2),`20sp`09`09`09;`20drop`20reserved`20stack`20space
X`09rsb
X;
X`09.entry`09resignal`20`5Em<r5>
Xpibadr`20=`204
X;`09jsb`09g`5Eini$brk
X`09movl`09pibadr(ap),`20r5`09`09`09;`20Get`20pib`20address
X`09$enqw_s`09efn`20`20`20`20=`20s`5E#exe$c_sysefn,`20-
X`09`09lkmode`20=`20#lck$k_nlmode,`20-`09;`20Convert`20to`20null`20mode
X`09`09lksb`20`20`20=`20pib_q_lksb(r5),`20-`09;`20LKSB`20in`20pib
X`09`09flags`20`20=`20#<lck$m_syncsts!lck$m_convert>
X`09blbc`09r0,`2099$`09`09`09`09;`20quit`20on`20error
X`09movzwl`09pib_q_lksb(r5),`20r0`09`09;`20get`20other`20status
X`09blbc`09r0,`2099$`09`09`09`09;`20quit`20on`20error
X`09$enq_s`09efn`20`20`20`20=`20s`5E#exe$c_sysefn,`20-`20`09;`20use`20system`20
Vefn
X`09`09lkmode`20=`20#lck$k_exmode,`20-`09;`20Convert`20back`20to`20ex`20mode
X`09`09lksb`20`20`20=`20pib_q_lksb(r5),`20-`09;`20LKSB`20in`20pib
X`09`09flags`20`20=`20#<lck$m_syncsts!lck$m_convert>,`20-
X`09`09astprm`20=`20r5,`20-`09`09`09;`20Pass`20pib`20as`20parameter
X`09`09blkast`20=`20b`5Eresignal`09`09;`20call`20resignal`20when`20blocked
X`09blbc`09r0,`2099$`09`09`09`09;`20quit`20on`20error
X`09$dclast_s`20-
X`09`09astadr`20=`20b`5Euser_routine,`20-`09;`20Declare`20user`20mode`20AST
X`09`09astprm`20=`20r5,`20-`09`09`09;`20`20to`20signal`20ss$_debug
X`09`09acmode`20=`20#psl$c_user`09`09;`20change`20to`20user`20mode
X99$:`09ret
X;
X`09.entry`09user_routine`20`5Em<>
X;
Xpibadr`20=`204
Xsavr0`20`20=`20pibadr`20+`204
Xsavr1`20`20=`20savr0`20`20+`204
Xsavpc`20`20=`20savr1`20`20+`204
Xsavpsl`20=`20savpc`20`20+`204
X;
X;`09jsb`09g`5Eini$brk
X`09movab`09b`5Eastret,`20sf$l_save_pc(fp)`09;`20Set`20new`20return`20for`20ast
V
X`09ret
Xastret:
X`09chmk`09#0`09`09`09`09;`20Allow`20ASTs`20again
X`09addl2`09#8,`20sp`09`09`09`09;`20Drop`20ASTPRM`20and`20arg`20count
X`09movq`09(sp)+,`20r0`09`09`09;`20Get`20back`20r0`20and`20r1
X`09pushl`09#ss$_debug`09`09`09;`20signal`20debug
X`09pushl`09#3`09`09`09`09;`20set`20number`20of`20arguments
X`09pushl`09#1`09`09`09`09;`20Say`20this`20is`20from`20lib$signal
X`09movq`09r0,`20-(sp)`09`09`09;`20save`20r0,r1
X`09mnegl`09#3,`20-(sp)`09`09`09;`20say`20start`20at`20primary`20frame
X`09pushl`09fp`09`09`09`09;`20save`20initial`20FP
X`09pushl`09#4`09`09`09`09;`20set`20mechargs`20count
X`09pushl`09sp`09`09`09`09;`20point`20to`20mechanism`20args
X`09pushal`0928(sp)`09`09`09`09;`20poit`20to`20signal`20args
X`09pushl`09#2`09`09`09`09;`20two`20arguments
X`09jmp`09g`5Eexe$srchandler`09`09;`20search`20for`20a`20handler
Xpcode_end:
Xpcode_length`20=`20pcode_end`20-`20pcode_start
X;
Xcode_end:
Xcode_length`20=`20code_end`20-`20code_start
X;
X;`09
X`09.end
$ call unpack DDB_PRIV.MAR;112 825295970 "" 43 6 10 
$!
$ create 'f'
Xall`20:`20ddb.exe,`20test.exe
X`20`20`20!
X
Xddb.exe`20:`20ddb_main.obj,`20ddb_msg.obj,`20ddb_cld.obj,`20ddb_priv.obj
X`20`20`20link/notrace/exe=ddb.exe`20ddb_main.obj,`20ddb_msg.obj,`20ddb_cld.obj
V,`20-
X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20
V`20`20ddb_priv.obj
X
Xtest.exe`20:`20test.obj
X`20`20`20link/debug`20test.obj
X
Xtest.obj`20:`20test.for
X`20`20`20fortran/debug/nooptim/check=all`20test.for
$ call unpack DESCRIP.MMS;3 457798745 "" 1 7 10 
$!
$ create 'f'
X$`20exe`20=`20f$environment("PROCEDURE")
X$`20exe`20=`20f$parse("ddb.exe;",exe)
X$`20exe`20=`20f$search(exe)
X$`20exe`20=`20exe`20-`20f$parse(exe,,,"version")
X$`20ddb`20:==`20$'exe'
X$`20if`20.not.`20f$getdvi("_VTA0:","EXISTS")
X$`20then
X$`20`20`20`20mcr`20sysgen`20connect`20vta0:/noadapter/driver=ttdriver
X$`20endif
$ call unpack SETUP.COM;3 1980918505 "" 1 8 10 
$!
$ create 'f'
X$`20if`20f$mode`20()`20.eqs.`20"OTHER"
X$`20then
X$`20`20`20`20run/nodebug`20test.exe
X$`20else
X$`20`20`20`20run/deta/prio=0/input='f$env("procedure")'/output=test.log/proc="
VTEST"`20-
X`20`20`20`20`20`20`20`20sys$system:loginout.exe
X$`20endif
$ call unpack TEST.COM;6 275123249 "" 1 9 10 
$!
$ create 'f'
X`20`20`20`20`20`20program`20test
Xc
Xc`20Just`20in`20case`20you`20don't`20know`20FORTRAN`20(what`20planet`20you`20f
Vrom?)`20this`20code`20is`20an
Xc`20infinite`20loop.
Xc
X`20`20`20`20`20`20implicit`20none
X`20`20`20`20`20`20integer`20*`204`20i
Xc
X`20`20`20`20`20`20i`20=`200
X`20`20`20`20`20`20do`20while`20(.true.)
X`20`20`20`20`20`20`20`20`20i`20=`20i`20+`201
X`20`20`20`20`20`20enddo
X`20`20`20`20`20`20end
$ call unpack TEST.FOR;1 321332281 "" 1 10 10 
$ v=f$verify(v)
$ exit
--
Neill Clift  neill@macro.demon.co.uk
