Breakpoint.st
author Stefan Vogel <sv@exept.de>
Mon, 12 Dec 2016 16:38:47 +0100
changeset 4080 08869106d07e
parent 4000 d9956ca67abf
child 4082 7d87a1910e3d
permissions -rw-r--r--
#BUGFIX by stefan class: Parser comment/format in: #checkSelector:for:inClass: changed: #selectorCheck:for:positions: avoid symbol creation better message if method selector is totally unknown

"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libcomp' }"

"{ NameSpace: Smalltalk }"

Object subclass:#Breakpoint
	instanceVariableNames:'position description line isReached method'
	classVariableNames:''
	poolDictionaries:''
	category:'System-Compiler-Debugging'
!

!Breakpoint class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    statement breakpoint support.
    Instances of me are placed into a (bytecode-) compiled method's
    literal array and are sent messages dynamically when a statement
    with a breakpoint is about to be executed.
"    
! !

!Breakpoint class methodsFor:'instance creation'!

new
    "return an initialized instance"

    ^ self basicNew initialize.
! !

!Breakpoint class methodsFor:'queries'!

breakpointDescriptionClass
    "redefinable in subclasses"
    
    ^ BreakpointDescription
! !

!Breakpoint class methodsFor:'utilities'!

disableAllBreakpoints
    MethodWithBreakpoints allBreakpointedMethods do:[:m |
        m disableAllBreakpoints
    ]

    "Created: / 03-02-2014 / 10:35:55 / cg"
! !

!Breakpoint methodsFor:'accessing'!

description
    ^ description
!

description:aBreakpointDescription
    description := aBreakpointDescription.
!

isReached
    ^ isReached
!

isReached:aBoolean
    isReached := aBoolean.
!

line
    "the lineNr"
    
    ^ line
!

line:lineArg
    self assert:lineArg >= 0.
    line := lineArg.
!

method:something
    method := something.
!

position
    ^ position
!

position:anInteger
    position := anInteger.

    "Modified (format): / 02-08-2012 / 09:26:03 / cg"
!

position:positionArg line:lineArg
    position := positionArg.
    line := lineArg.
    self assert:lineArg >= 0.

    "Created: / 02-08-2012 / 09:26:27 / cg"
! !

!Breakpoint methodsFor:'initialization'!

initialize
    "Invoked when a new instance is created."

    "/ please change as required (and remove this comment)
    "/ method := nil.
    "/ position := nil.
    description := self class breakpointDescriptionClass new.
    "/ line := nil.

    "/ super initialize.   -- commented since inherited method does nothing

    "Modified: / 21-08-2014 / 09:35:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Breakpoint methodsFor:'printing & storing'!

printBreakpointNrInDebuggerOn:aStream
    "to be redefined for concrete debuggers"
!

printOn:aStream
    "append a printed representation of the receiver to the argument, aStream"

    aStream nextPutAll: 'BPNT '.
    self printBreakpointNrInDebuggerOn:aStream.
    aStream nextPutAll: ' at'.
    position notNil ifTrue:[
        aStream
            nextPutAll: ' source position:';
            nextPutAll: position printString.
    ].
    line notNil ifTrue:[
        aStream
            nextPutAll: ' line:';
            nextPutAll: line printString.
    ].
    (position isNil and:[line isNil]) ifTrue:[
        aStream nextPutAll: ' ???'
    ]

    "Modified: / 24-04-2013 / 20:42:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Breakpoint methodsFor:'support'!

beInvisible
    "make this breakpoint hidden (in gutter)"

    description beInvisible
!

beTracepoint
    "make this breakpoint a tracepoint"

    description beTracepoint

    "Created: / 27-01-2012 / 13:56:11 / cg"
!

break
    "invoked by the breakPoint's code (see BreakPointNode)"

    <resource: #skipInDebuggersWalkBack>

    |sender mthd where|

    description isEnabled ifFalse:[^ self].
    sender := thisContext sender.
    (description shouldBreakIn: sender) ifTrue:[
        mthd := method.
        mthd notNil ifTrue:[
            mthd mclass isNil ifTrue:[
                mthd := sender method.
            ].
        ].
        mthd notNil ifTrue:[
            where := mthd whoString
        ] ifFalse:[
            where := '?'
        ].
        BreakPointInterrupt
            raiseRequestWith: self
            errorString:('Breakpoint encountered at line %1 in %2' 
                                bindWith:self line with:where)
            "/ in:sender.
    ].
    (description shouldTraceIn: sender) ifTrue:[
        Transcript 
            show:Timestamp now;
            showCR:(' Trace %1 [%2]' bindWith:sender methodPrintString with:self line)
    ].

    "Created: / 15-06-2011 / 12:48:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-07-2011 / 18:17:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 27-01-2012 / 14:10:22 / cg"
!

disable
    "disable this breakpoint"

    "/ if there is currently an ignore on this breakpoint in the debugger, remove it
    DebugView stopIgnoringHaltsFor:method atLineNr:line.
    description disable
!

toggle
    "toggle this breakpoint"

    "/ if there is currently an ignore on this breakpoint in the debugger, remove it
    DebugView stopIgnoringHaltsFor:method atLineNr:line.
    description toggle

    "Created: / 17-06-2011 / 13:40:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-07-2011 / 18:18:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 27-01-2012 / 10:41:03 / cg"
!

toggleTracing
    "toggle this breakpoint"

    description toggleTracing

    "Created: / 27-01-2012 / 13:56:05 / cg"
! !

!Breakpoint methodsFor:'testing'!

isEnabled

    "Bad coding here, state should be full object"

    ^description isEnabled

    "Created: / 28-06-2011 / 08:27:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isTracepoint
    ^description isTracepoint
!

isVisible
    ^description isVisible
! !

!Breakpoint class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
!

version_SVN
    ^ '$ Id $'
! !