home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
pd6.lzh
/
LIB
/
TILE
/
debugger.f83
< prev
next >
Wrap
Text File
|
1989-12-21
|
5KB
|
144 lines
\
\ FORTH DEBUGGER DEFINITIONS
\
\ Copyright (c) 1989 by Mikael R.K. Patel
\
\ Computer Aided Design Laboratory (CADLAB)
\ Department of Computer and Information Science
\ Linkoping University
\ S-581 83 LINKOPING
\ SWEDEN
\
\ Email: mip@ida.liu.se
\
\ Started on: 30 June 1988
\
\ Last updated on: 29 November 1989
\
\ Dependencies:
\ (forth) forth, compiler, structures, blocks
\
\ Description:
\ Basic debugging function built on a general advice function
\ management. Allows black-box tracing, break points and
\ colon definitions call profiling.
\
\ Copying:
\ This program is free software; you can redistribute it and\or modify
\ it under the terms of the GNU General Public License as published by
\ the Free Software Foundation; either version 1, or (at your option)
\ any later version.
\
\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\ GNU General Public License for more details.
\
\ You should have received a copy of the GNU General Public License
\ along with this program; see the file COPYING. If not, write to
\ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
.( Loading Debugger definitions...) cr
#include structures.f83
#include forth.f83
#include blocks.f83
vocabulary debugger
compiler blocks structures forth debugger definitions
struct.type ADVICE ( -- )
ptr +block private ( Pointer to code definition)
ptr +entry private ( Pointer to entry structure)
ptr +advice private ( Pointer to advice function)
long +profile private ( Call counter for profiling)
struct.end
: [advice] ( advice -- )
dup +advice @ execute ; private ( Access and execute the advice)
: [colon] ( advice -- )
1 over +profile +! ( Increment profile counter)
+block @ call ; private ( Call the code definition)
: [trace] ( advice -- )
." --> " dup >r +entry @ .name .s cr ( Print function entry)
r@ [colon] ( Call the code definition)
." <-- " r> +entry @ .name .s cr ( Print function exit)
; private
: [break] ( advice -- )
>r ( Save pointer to advice block)
begin
.s ." Break at: " ( Print stack status and break)
r@ +entry @ .name cr ( Print name of entry)
[compile] ascii ( Scan a command)
case
ascii a ( Abort command)
of abort endof
ascii c ( Call command)
of r> [colon] exit endof
ascii e ( Execute command)
of r@ [colon] endof
ascii p ( Profile command)
of r@ +profile @ . cr endof
ascii r ( Return command)
of r> drop exit endof
." a(bort), c(ontinue), e(xecute), p(rofile) or r(eturn)" cr
endcase
again ; private
: tail-recurse ( -- )
compile (branch) ( Compile a branch to the beginning)
last >body +block @ <resolve ( And resolve the address)
; compilation immediate
: ?advice ( entry -- flag)
+code @ ['] [advice] >body = ; ( Check for advice handler)
: advice ( action -- )
' dup ?advice not ( Access entry and check coding)
abort" advice: not an adviced definition" ( Abort if wrong code type)
>body ( Access advice block)
0 over +profile ! ( Initiate the profile counter)
+advice ! ; ( Define a new advice action)
: colon ( -- )
['] [colon] advice ; ( Use colon as the advice action)
: trace ( -- )
['] [trace] advice ; ( Use trace as the advice action)
: break ( -- )
['] [break] advice ; ( Use break as the advice action)
: .r ( n w -- )
>r <# #s #> r> over - spaces type ; ( Formated printing of numbers)
: .profile ( -- )
last ( Print profile for all definitions)
5 spaces ." Calls" ( Print a profile header with calls and)
1 spaces ." Function" cr ( last the name of the function)
begin
dup ?advice ( Check for adviced function)
if dup >body +profile @ ( Access profile information)
10 .r space ( Print in a nice format)
dup .name cr ( Print name)
then
+link @ ?dup nil = ( Print information about all functions)
until ; ( in the current search path)
: : ( -- )
: ( Use the old colon definition)
new ADVICE ( Create an advice block)
dup last +parameter ! ( Store the advice block into the last)
['] [advice] >body last +code ! ( Make the last entry use the advice)
last over +entry ! ( Save pointer to the entry)
['] [colon] over +advice ! ( Colon is the initiate advice action)
0 over +profile ! ( Initiate the profile counter)
here swap +block ! ; ( Setup pointer to block definition)
forth only