1 * ***********************************************************
  2 * *                                                         *
  3 * * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  4 * *                                                         *
  5 * * Copyright (c) 1972 by Massachusetts Institute of        *
  6 * * Technology and Honeywell Information Systems, Inc.      *
  7 * *                                                         *
  8 * ***********************************************************
  9 
 10           ttl       module to handle breakpoints in control tables
 11           ttls
 12           lbl       ,breakpoint_man
 13           editp     on
 14           pmc       on
 15           detail    off
 16           pcc       off
 17           rem
 18           rem
 19           tib
 20           comreg
 21           pmc       off
 22           ttls
 23 bkpt      null
 24           symdef    bkpt
 25           start     bkpt
 26           rem
 27           symdef    brkptr    handles requests from diaman
 28           symdef    brkhit    handles breaks ops for interpreter
 29           symdef    brktab    address of break table pointer
 30           rem
 31           symref    istbrk
 32           symref    gettib
 33           symref    setptw
 34           rem
 35 sm.cd     equ       4         location of cmd data in sub-mbx
 36           rem
 37 brline    equ       sm.cd+0   line number
 38 braddr    equ       sm.cd+1   addr of break
 39 bractc    equ       sm.cd+2   action code
 40 brflag    equ       sm.cd+3   flags
 41           rem
 42 *         values for action codes
 43           rem
 44 actset    equ       1         set break
 45 actrst    equ       2         reset break
 46 actstr    equ       3         restart line from breakpoint
 47           rem
 48           rem
 49 *         format of break table
 50           rem
 51 nbreak    equ       10        max number of breaks
 52           rem
 53 btbadr    equ       0         addr of break
 54 btblin    equ       1         line number
 55 btborg    equ       2         origional op_block code
 56 btbflg    equ       3         flags
 57 btblen    equ       4         length of entry in table
 58           rem
 59 *         btbflg values
 60           rem
 61 trcoff    bool      400000    stop tracing when break is hit
 62           eject
 63 *         define address and length of break table
 64 *         ring-4 multics software finds the following 3 words thru
 65 *         .crbrk and pretends to understand their meaning
 66           rem
 67 brktab    ind       brtab
 68           vfd       18/nbreak
 69 ercode    oct       0         error code from last bkpt request.
 70           rem                 after performing a bkpt operation, ring-4
 71           rem                 multics software will read this word
 72           rem                 to check for errors.
 73           rem
 74 *         values for ercode
 75           rem
 76 *         1 = bad address
 77 *         2 = bad line
 78 *         3 = no entry in table
 79 *         4 = line not at break
 80 *         5 = no room in table
 81 *         6 = no opblock at address
 82 *         7 = invalid request
 83           rem
 84           rem
 85 ************************************************************************
 86 *
 87 *         modified 79 july 27 by art beattie to call setptw after
 88 *           call to gettib.
 89 *
 90 ************************************************************************
 91           eject
 92 *         subroutine to handle request from dia_man.
 93 *         entered with sub-mbx addr in x3
 94           rem
 95 brkptr    subr      brq,(x1,x2,x3)
 96           rem
 97 *         check address supplied in args
 98           rem
 99           ila       1         error code, in case bad
100           ldq       braddr,3  pick up value
101           tmi       brqerr-*
102           cmpq      a.a004-*,*          =.crmem
103           tpl       brqerr-*  toobig
104           rem
105 *         check that line number, if given, is ok
106           rem
107           stz       tibadr-*  0 will mean no line
108           lda       brline,3  get line from mbx
109           tmi       brqgo-*   none
110           tsy       a.a005-*,*          =gettib, get real tib address
111           tsy       a.a007-*,*          (setptw) virtualize tib address
112           sta       tibadr-*
113           szn       tibadr-*  was an addr returned?
114           tnz       brqgo-*   yes
115           ila       2         bad line number
116           tra       brqerr-*
117           rem
118 *         check action code to see what kind of request this is
119           rem
120 brqgo     stz       ercode-*
121           lda       bractc,3  get code
122           icmpa     actset
123           tze       set-*     to set a break
124           icmpa     actrst
125           tze       reset-*   to reset a break
126           icmpa     actstr
127           tze       start-*   to restart after a break
128 brqinv    ila       7         error, invalid request
129           rem
130 brqerr    sta       ercode-*  come here to store error
131 brqret    return    brkptr
132           eject
133 *         set a breakpoint
134           rem
135 set       lda       braddr,3* get current opblock
136           ana       l.a001-*  =777000
137           cmpa      l.a001-*  does it look like valid opblock?
138           tze       set1-*    yes
139           ila       6         error code, no opblock
140           tra       brqerr-*
141 set1      ldx1      a.a001-*  =brtab, address of break table
142           lda       braddr,3  pickup break addr
143 set5      cmpa      btbadr,1  entry for this address?
144           tze       set4-*    yes, just update it
145           iacx1     btblen
146           cmpx1     a.a002-*  =brttbe, end of table?
147           tnz       set5-*    no
148           rem
149           ldx1      a.a001-*  scan table again for free entry
150 set3      szn       btbadr,1  look for free empty
151           tze       set2-*    found one
152           iacx1     btblen    next entry
153           cmpx1     a.a002-*  end of table?
154           tnz       set3-*    no
155           ila       5         error, no room
156           tra       brqerr-*  no room for entry, give up
157           rem
158 set2      ldx2      braddr,3  address to set break
159           stx2      btbadr,1  save in break table
160           lda       0,2       get orig opblock
161           sta       btborg,1  save in table
162           lda       bkop-*    get a breakpoint opblock
163           sta       0,2       break is set
164 set4      lda       brline,3  line number
165           sta       btblin,1
166           lda       brflag,3  copy flags
167           sta       btbflg,1
168           tra       brqret-*  done
169           eject
170           rem
171 *         reset a break
172           rem
173 reset     ldx2      braddr,3  address of break toreset
174           tze       reset3-*  bad
175           ldx1      a.a001-*  =brtab, start of table
176 reset2    cmpx2     btbadr,1  find entry for this break
177           tze       reset1-*  got it
178           iacx1     btblen
179           cmpx1     a.a002-*  =brttbe, end of table
180           tnz       reset2-*
181 reset3    ila       3         error, no entry
182           tra       brqerr-*  cant find entry, give up
183 reset1    lda       btborg,1  get origional opblock
184           sta       0,2       replace it
185           stz       btbadr,1  free table entry
186           tra       brqret-*  done
187           eject
188 *         restart a line at a breakpoint
189           rem
190 start     szn       tibadr-*  line specified?
191           tze       brqinv-*  no, done
192           ldx1      tibadr-*  addr of tib
193           lda       t.flg3,1  third word of flags
194           cana      l.a002-*  =tfbkpt see if at break
195           tnz       start5-*  is is
196           ila       4         error, not at break
197           tra       brqerr-*
198 start5    ldx2      braddr,3  get starting address specified
199           tze       start7-*  none given, use t.cur
200           lda       0,2       be sure opblock at start address
201           ana       l.a001-*  =777000
202           cmpa      l.a001-*
203           tze       start6-*  good opblock
204           ila       6         error, no opblock
205           tra       brqerr-*
206 start6    stx2      t.cur,1   starting address becomes t.cur
207           ila       0         no new opblock for intp
208           tra       start2-*
209 start7    ldx2      t.cur,1   addr of current opblock
210           lda       0,2       pick it up
211           cmpa      bkop-*    is it a break?
212           tze       start1-*  yes, intpreter will want something else
213           ila       0         not a break, interpeter can use real op
214           tra       start2-*
215 start1    ldx1      a.a001-*  =brtab, must scan to find real op
216 start4    cmpx2     btbadr,1  found entry?
217           tze       start3-*  yes
218           iacx1     btblen
219           cmpx1     a.a002-*  end of tab?
220           tnz       start4-*
221           lda       nullop-*  give intpreter a nullop to exec
222           tra       start2-*
223 start3    lda       btborg,1  give interpreter the origional op
224 start2    sta       saveop-*  saveop for intp
225           lda       brflag,3  get flags
226           cana      l.a004-*  asked to start tracing?
227           tze       2         no
228           stz       a.a006-*,*          =.crtsw
229           ldx1      tibadr-*  interpreter needs tib addr
230           lda       saveop-*  op for intp
231           tsy       a.a003-*,*          =istbrk, restart after break
232           tra       brqret-*  done
233 saveop    bss       1
234           eject
235 *         subroutine called by the intpreterer when a break point op
236 *         is found. entered with tib in x1, current op pointer in x2.
237 *         an in line return indicates that the break should not be
238 *         taken; the a will contain the opblock to execute instead.
239 *         a skip return will mean take the break.
240           rem
241 brkhit    subr      hit,(x3)
242           rem
243           ldx3      a.a001-*  =brtab, start of break table
244 hit2      cmpx2     btbadr,3  entry for current opblock?
245           tze       hit1-*    yes, found it
246           iacx3     btblen
247           cmpx3     a.a002-*  end of table
248           tnz       hit2-*
249           tra       hit3-*    no entry in table, so must take break
250 hit1      szn       btblin,3  is break for special line?
251           tmi       hit4-*    no, take break
252           lda       t.line,1  check to see if this is the line
253           cmpa      btblin,3
254           tze       hit4-*    it is, take break
255           lda       btborg,3  no break, return origional opblock
256           tra       hitret-*
257 hit4      lda       btbflg,3  get flag word
258           cana      l.a003-*  =trcoff, should we stop tracing?
259           tze       hit3-*    no
260           ila       1
261           sta       a.a006-*,*          =.crtsw
262 hit3      aos       brkhit-*  skip means take break
263 hitret    return    brkhit
264           eject
265           rem
266           rem
267 a.a001    ind       brtab     address of break table
268 a.a002    ind       brtabe    address of end of table
269 a.a003    ind       istbrk    control table rtn to restart break
270 a.a004    ind       .crmem
271 a.a005    ind       gettib
272 a.a006    ind       .crtsw
273 a.a007    ind       setptw
274           rem
275 l.a001    vfd       o18/777000
276 l.a002    vfd       o18/tfbkpt
277 l.a003    vfd       o18/trcoff
278 l.a004    vfd       o18/400000
279           rem
280 tibadr    bss       1
281           rem
282 bkop      bkptop              a breakpoint opblock
283 nullop    nullop              a no-operation opblock
284           rem
285 brtab     null                the break table
286           bss       btblen*nbreak
287 brtabe    null
288           rem
289           end