home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 19 / AACD19.BIN / AACD / Programming / YAEC / testsrc / edbug.e < prev    next >
Encoding:
Text File  |  2001-02-23  |  2.1 KB  |  85 lines

  1. MODULE 'exec/ports'
  2. MODULE 'exec/nodes'
  3. MODULE 'dos/dos'
  4.  
  5. MODULE 'sendrexx'
  6.  
  7. -> VERY smple debugger for executables created by yaec.
  8. -> DBUG switch must be on!
  9. -> uses GoldEd to show lines in sources.
  10. -> there is no sendrexx module for yaec yet, so this have to
  11. -> be compiled with Wouters EC for now.
  12.  
  13. OBJECT msg OF mn
  14.    debugtask
  15.    sourcename
  16.    line
  17. ENDOBJECT
  18.  
  19. RAISE "PORT" IF CreateMsgPort() = NIL,
  20.       "LIB" IF OpenLibrary() = NIL
  21.  
  22. PROC main() HANDLE
  23.    DEF mp:PTR TO mp
  24.    DEF wsigs
  25.    DEF mpsig
  26.    DEF rsigs
  27.    DEF msg:PTR TO msg
  28.    DEF exit=FALSE
  29.    DEF instr[50]:STRING
  30.    DEF port
  31.    DEF toline=NIL
  32.  
  33.    rexxsysbase := OpenLibrary('rexxsyslib.library', 36)
  34.  
  35.    /* yaec executables fetches this port at startup */
  36.    mp := CreateMsgPort()
  37.    mp.ln.name := 'edbug'
  38.    mp.ln.pri := 0
  39.    AddPort(mp)
  40.  
  41.    mpsig := Shl(1, mp.sigbit)
  42.    wsigs := mpsig OR SIGBREAKF_CTRL_C
  43.  
  44.    port := FindPort('GOLDED.1')
  45.    StringF(instr, 'ged \s.eeh', arg)
  46.    SystemTagList(instr, NIL)
  47.    IF port = NIL THEN Delay(200)
  48.    SystemTagList('RUN t:exe', NIL)
  49.  
  50.    REPEAT
  51.       rsigs := Wait(wsigs) -> wait for debugged task(s) to give us control
  52.       IF rsigs AND mpsig
  53.          msg := GetMsg(mp)
  54.          IF msg
  55.             IF msg.sourcename THEN PrintF('source : \s, ', msg.sourcename)
  56.             PrintF('line : \d\n', msg.line)
  57.             StringF(instr, '''PC LINE \d HIGHLIGHT''', msg.line)
  58.             ->rx_SendMsg('GOLDED.1', '''LOCK CURRENT RELEASE=4''', NIL)
  59.             rx_SendMsg('GOLDED.1', instr, NIL)
  60.             ->rx_SendMsg('GOLDED.1', '''UNLOCK''', NIL)
  61.             IF msg.line >= (toline-1) THEN toline := NIL
  62.             IF toline = NIL
  63.                ReadStr(stdout, instr)
  64.                toline := Val(instr)
  65.             ENDIF
  66.             /* let debugged task continiue execution */
  67.             Signal(msg.debugtask, SIGBREAKF_CTRL_F)
  68.          ENDIF
  69.       ENDIF
  70.       IF rsigs AND SIGBREAKF_CTRL_C THEN exit := TRUE
  71.    UNTIL exit
  72.  
  73. EXCEPT DO
  74.  
  75.    IF exception THEN PrintF('error!!\n')
  76.  
  77.    IF rexxsysbase THEN CloseLibrary(rexxsysbase)
  78.  
  79.    IF mp THEN RemPort(mp)
  80.  
  81.    IF mp THEN DeleteMsgPort(mp)
  82.  
  83. ENDPROC
  84.  
  85.