home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 303.lha / AssemTools / Include / debug.i < prev    next >
Text File  |  1980-12-03  |  4KB  |  157 lines

  1. ;
  2. ; ### Library for debugging programs by JM  v1.21 ###
  3. ;
  4. ; - Created 890312 by JM -
  5. ;
  6. ; To fully utilize the macros in this file you also need program
  7. ; called DeBug by the Supervisor Software.
  8. ;
  9. ; Edited:
  10. ; - 890701 by JM -> v1.1    - .bug macro and data structure added.
  11. ; - 890701 by JM -> v1.11    - structure edited.
  12. ; - 890702 by JM -> v1.20    - .bug regs now acceps a string as the second
  13. ;                    parameter.
  14. ; - 890702 by JM -> v1.21    - .bug stra added.
  15. ;
  16. ;
  17. ;
  18. ;  .flash    flashes the screen in different colors.
  19. ;  .bug        currently only dumps the registers to a special screen
  20. ;        and watches the memory allocations made by one task.
  21. ;        syntax:
  22. ;         .bug regs[,s]    causes the registers to be updated on
  23. ;                the screen.  If a string is used as the
  24. ;                second parameter the string will be printed
  25. ;                on screen.
  26. ;         .bug memb    activates the memory watch for this task.
  27. ;                No other task can use this function before
  28. ;                the current task releases it using .bug meme
  29. ;         .bug meme    stops the memory watch for this task.  If
  30. ;                the alerts were not disabled will inform
  31. ;                if any memory blocks were allocated but not
  32. ;                released between .bug memb and .bug meme.
  33. ;         .bug stra,adr    prints a string starting at adr.
  34. ;
  35. ;  The corresponding debugging utility program is called DeBug.  Usage:
  36. ;  DeBug i    installes the routines and a global message port.
  37. ;  DeBug r    removes all routines and the message port.
  38. ;  DeBug c    clears the memory allocation data buffer.
  39. ;  DeBug l    lists the current allocations on the default output.
  40. ;  DeBug    prints a message telling if DeBug is currently installed.
  41. ;
  42. ;  The flag bits are supported by the DeBug program but not currently
  43. ;  by the command line parser.
  44. ;  With the flags you can disable:
  45. ;  - watching of memory allocated and freed by ROM routines.
  46. ;  - alerts from unreleased memory.
  47. ;  - alerts if a block of memory is released with a wrong size.
  48. ;
  49. ;
  50.  
  51.  
  52. .flash        macro    *color
  53.         movem.l    d0/d1,-(sp)
  54.         ifc    'red','\1'
  55.         move.w    #$f00,d0
  56.         endc
  57.         ifc    'green','\1'
  58.         move.w    #$f0,d0
  59.         endc
  60.         ifc    'blue','\1'
  61.         move.w    #$f,d0
  62.         endc
  63.         ifc    'yellow','\1'
  64.         move.w    #$ff0,d0
  65.         endc
  66.         ifc    'white','\1'
  67.         move.w    #$fff,d0
  68.         endc
  69.         ifc    'purple','\1'
  70.         move.w    #$f0f,d0
  71.         endc
  72.         ifc    'cyan','\1'
  73.         move.w    #$0ff,d0
  74.         endc
  75.         ifc    'black','\1'
  76.         move.w    #$0,d0
  77.         endc
  78.         moveq.l    #-1,d1
  79. \@.flash    move.w    d0,$dff180
  80.         move.w    d0,$dff180
  81.         move.w    d0,$dff180
  82.         dbf    d1,\@.flash
  83.         movem.l    (sp)+,d0/d1
  84.         endm
  85.  
  86.  
  87.  
  88.       STRUCTURE MYP,MP_SIZE
  89.     APTR    MyP_CODE        prg code buffer
  90.     APTR    MyP_OBUF        output buffer for Text()
  91.     APTR    MyP_ABUF        output buffer for alerts
  92.     STRUCT    MyP_MYNAME,16        port name
  93.     APTR    MyP_SCREEN        screen*
  94.     APTR    MyP_RPORT        rport*
  95.     APTR    MyP_VPORT        vport*
  96.     APTR    MyP_GFX            gfxbase
  97.     APTR    MyP_INTUITION        intuitionbase
  98.     APTR    MyP_OLDALLOC        AllocMem() in Exec
  99.     APTR    MyP_OLDFREE        FreeMem() in Exec
  100.     APTR    MyP_MEMTASK        task using memwatch
  101.     APTR    MyP_DUMPTASK        task using dumpreg()
  102.     APTR    MyP_ALERTTASK        task using Malert()
  103.     APTR    MyP_MEMBUF        buffer for allocation data
  104.     ULONG    MyP_CHIP        allocated CHIP RAM
  105.     ULONG    MyP_FAST        allocated FAST RAM
  106.     ULONG    MyP_PIECES        # of blocks allocated
  107.     ULONG    MyP_FLAGS        flags
  108.     APTR    MyP_regs        pointer to dumpreg()
  109.     APTR    MyP_memb        pointer to membeg()
  110.     APTR    MyP_meme        pointer to memend()
  111.     APTR    MyP_stra        pointer to prtstr()
  112.     LABEL    MYSIZE
  113.  
  114.  
  115. DEBUGPORTNAME    macro
  116.         dc.b    'BuggerBoyPort',0    EVEN LENTGH!!
  117.         endm
  118.  
  119.  
  120. .bug        macro    *regs | memb | meme | stra[,string]
  121. \@.bug1        movem.l    a0-a7/d0-d7,-(sp)
  122.         lea.l    \@.bug1(pc),a4        get pc
  123.         movea.l    $4,a6
  124.         jsr    _LVOGetCC(a6)        get cc
  125.         move.l    d0,d7
  126.         lea.l    .debug_port(pc),a1
  127.         jsr    _LVOFindPort(a6)
  128.         tst.l    d0
  129.         beq.s    \@.bug2
  130.         move.l    d0,a1
  131.         move.l    MyP_\1(a1),a1
  132.         ifnc    '\1','stra'
  133.         ifnc    '\2',''
  134.         lea.l    \@.bugs(pc),a0
  135.         endc
  136.         endc
  137.         ifc    '\1','stra'
  138.         move.l    \2,a0
  139.         endc
  140.         jsr    (a1)
  141.         ifnd    .debug_port
  142.         bra.s    \@.bug2
  143. .debug_port    DEBUGPORTNAME
  144.         endc
  145.         ifnc    '\1','stra'
  146.         ifnc    '\2',''
  147.         bra.s    \@.bug2
  148. \@.bugs        dc.b    \2
  149.         dc.b    0
  150.         cnop    0,4
  151.         endc
  152.         endc
  153. \@.bug2        move    d7,CCR
  154.         movem.l    (sp)+,a0-a7/d0-d7
  155.         endm
  156.  
  157.