Breakpoints in a ix86 32 bit indirect threaded Forth 
Author Message
 Breakpoints in a ix86 32 bit indirect threaded Forth

I have a Forth system that I've coded myself, and currently the next
pseudo instruction is

%define IP esi
%define W  ebx
%define ONECELL 4

next:   mov W, [IP]
        add IP, ONECELL
        jmp [W]

I was trying to figure out how to implement breakpoints, without slowing
down the Forth-code interpreter too much. I came up with this.

next:   mov W, [IP]
        js .breakpoint
        add IP ONECELL
        jmp [W]
.breakpoint
        ; Push something similar to a catch frame here
        ; and call a breakpoint handler. It can return to
        ; this suspended word through this `suspension' frame.

Now setting a breakpoint in a thread is as simple as negating the xt in
the thread.

I'm wondering, however, what ANS rules this breaks.
If something fetches the xt at one of these breakpoints, it will receive
the negative xt. I do *not* want to have to change all the words in the
system to accept both positive and negative xt's. I'm hoping there is a
more elegant solution.

Here is my solution: this modification can be completely transparent to
an application if it sticks to these two words to whenever accessing an
xt directly from a thread.



Since the method in which xt's are stored in threads is implementation
defined, I think these words should have been in the ANS standard
anyway.

This all boils down to two questions:
1. Does this break-point implementation break any ANS rules?
2. Since I'm reinventing the wheel here, how have breakpoints in a Forth
system been handled in the past?

Thanks for your help,
Shaun Jackman



Sun, 10 Jun 2001 03:00:00 GMT  
 Breakpoints in a ix86 32 bit indirect threaded Forth
There was one minor mistake in what I posted:
Quote:
> next:   mov W, [IP]
>         js .breakpoint
>         add IP ONECELL
>         jmp [W]

Since mov doesn't update the flags, I'm testing garbage here!

This would have to be:

next:   mov W, [IP]
        or W, W
        js .breakpoint
        add IP, ONECELL
        jmp [W]

Sorry for the confusion,
Shaun Jackman



Mon, 11 Jun 2001 03:00:00 GMT  
 Breakpoints in a ix86 32 bit indirect threaded Forth
There is another way to implement breakpoints without modifying next. Put
the xt of the breakpoint handler at the place where you want to break.

Here is an extract from Win32Forth's de{*filter*}:

2VARIABLE IP  \ ip & contents of current breakpoint

\ Patch in the breakpoint word at the current debug ip.

: PATCH  ( xt -- )


To set the breakpoint
: SET-BREAK  ( ip -- )
   IP !  ['] TRACE PATCH ;

This has the advantage that it can work when next is inlined rather that
jumped to.

Andrew



Mon, 11 Jun 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Direct Threaded 32 bit Forth

2. Division 32-Bit/32-Bit with 16-Bit Register

3. 32 bit standard forth, forth assembler, unreadability

4. Building 32 bit DLL from 32 bit EXE

5. 32 Bit ASM from 32 Bit Windows COBOL

6. 32 Bit ASM from 32 Bit Windows COBOL

7. Calling 32-bit FORTRAN dlls from 32-bit VB

8. top 32 bits of 64-bit product of two 32-bit integers

9. 32-bit ST/V outruns 32-bit ST80 on Intel

10. 32-bit PMode threading using Int 8...

11. A small 32 bit Forth metacompile

12. 32 BIT FORTH FOR P/C WITH SOUND

 

 
Powered by phpBB® Forum Software