home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnusmalltalk / debugger.st < prev    next >
Text File  |  1992-02-15  |  3KB  |  86 lines

  1. "======================================================================
  2. |
  3. |   Experimental Debugger
  4. |
  5.  ======================================================================"
  6.  
  7.  
  8. "======================================================================
  9. |
  10. | Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  11. | Written by Steve Byrne.
  12. |
  13. | This file is part of GNU Smalltalk.
  14. |
  15. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  16. | under the terms of the GNU General Public License as published by the Free
  17. | Software Foundation; either version 1, or (at your option) any later version.
  18. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  19. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  21. | details.
  22. | You should have received a copy of the GNU General Public License along with
  23. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  24. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  25. |
  26.  ======================================================================"
  27.  
  28.  
  29. "
  30. |     Change Log
  31. | ============================================================================
  32. | Author       Date       Change 
  33. | sbyrne     25 Dec 89      created.
  34. |
  35. "
  36.  
  37. Object subclass: #Debugger
  38.        instanceVariableNames: ''
  39.        classVariableNames: 'Breakpoints'
  40.        poolDictionaries: ''
  41.        category: 'Method debugging'
  42. !
  43.  
  44. Debugger comment:
  45. 'I provide a simple breakpoint facility for GNU Smalltalk.  In the future,
  46. I may be expanded to perform inspection, and other useful functions.
  47. One idea would be to have an instance of a debugger created for each method
  48. that has breakpoints, or somehow have the debugger run from a separate
  49. processes that has a higher priority.'!
  50.  
  51. !Debugger class methodsFor: 'breakpoint management'!
  52.  
  53. recordOldByte: byte atIndex: anIndex forMethod: aMethod
  54.     "I preserve the original byte code from a compiled method, for restoration
  55.     after the breakpoint is removed.  My implementation does not notice if
  56.     the compiled method is shared; so a breakpoint in a compiled method will 
  57.     cause a break in whichever classes share this method.  This does not occur
  58.     at all in practice, so it's probably not an issue."
  59.     | breakpointDict |
  60.     byte == self debugByte
  61.     ifTrue: [ ^self ].
  62.     breakpointDict _ Breakpoints at: aMethod
  63.                  ifAbsent: [ Dictionary new ].
  64.     breakpointDict at: anIndex put: byte
  65. !
  66.  
  67. origByteAt: anIndex forMethod: aMethod
  68.     "I return the original byte code at the given index for the given method.
  69.     If there is no breakpoint for that method at that index, I return nil."
  70.     breakpointDict _ Breakpoints at: aMethod
  71.                  ifAbsent: [ ^nil ].
  72.     ^breakpointDict at: anIndex
  73.             ifAbsent: [ ^nil ]
  74. !!
  75.  
  76.  
  77.  
  78. !Debugger class methodsFor: 'private'!
  79.  
  80. debugByte
  81.     "Answer the byte code that the debugger uses for breakpoints"
  82.     ^127
  83. !!
  84.