Skip to content

Commit

Permalink
- implement pcRange for context in terms of #sourceNodeExecuted
Browse files Browse the repository at this point in the history
- remove all not needed code

fixes pharo-project#4735
  • Loading branch information
MarcusDenker committed Sep 26, 2019
1 parent 77230ed commit 59c4cf5
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 99 deletions.
8 changes: 1 addition & 7 deletions src/Debugger-Model/DebugSession.class.st
Expand Up @@ -226,12 +226,6 @@ DebugSession >> isInterruptedContextDoesNotUnderstand [
^ self interruptedContext selector == #doesNotUnderstand:
]

{ #category : #context }
DebugSession >> isLatestContext: aContext [

^ interruptedProcess suspendedContext == aContext
]

{ #category : #testing }
DebugSession >> isTestMethod: aCompiledMethod of: aTestCase [

Expand Down Expand Up @@ -270,7 +264,7 @@ DebugSession >> pcRangeForContext: aContext [

(aContext isNil or: [ aContext isDead ])
ifTrue: [ ^ 1 to: 0 ].
^ aContext pcRangeContextIsActive: (self isLatestContext: aContext)
^ aContext pcRange
]

{ #category : #'debugging actions' }
Expand Down
36 changes: 0 additions & 36 deletions src/Debugger-Tests/IsLatestContextTest.class.st

This file was deleted.

6 changes: 0 additions & 6 deletions src/Debugging-Core/CompiledCode.extension.st
Expand Up @@ -102,12 +102,6 @@ CompiledCode >> pcPreviousTo: pc [
^prevPc
]

{ #category : #'*Debugging-Core' }
CompiledCode >> rangeForPC: aPC [
"return which code to hightlight in the debugger"
^(self methodNode sourceNodeForPC: aPC) debugHighlightRange
]

{ #category : #'*Debugging-Core' }
CompiledCode >> symbolicBytecodes [
"Answer Collection that contains of all the byte codes in a method as an instance of SymbolicInstruction"
Expand Down
15 changes: 2 additions & 13 deletions src/Debugging-Core/Context.extension.st
Expand Up @@ -56,20 +56,9 @@ Context >> namedTempAt: index put: aValue [
]

{ #category : #'*Debugging-Core' }
Context >> pcRangeContextIsActive: contextIsActive [
Context >> pcRange [
"return the debug highlight for aPC"
| thePC |

"make sure we have some usable value (can happen for contexts in the ProcessBrowser"
thePC := pc ifNil: [self method endPC].

"When on the top of the stack the pc is pointing to right instruction, but deeper in the stack
the pc was already advanced one bytecode, so we need to go back this one bytecode, which
can consist of multiple bytes. But on IR, we record the *last* bytecode offset as the offset of
the IR instruction, which means we can just go back one"
thePC := contextIsActive ifTrue: [thePC] ifFalse: [thePC - 1].

^self method rangeForPC: thePC
^self sourceNodeExecuted debugHighlightRange
]

{ #category : #'*Debugging-Core' }
Expand Down
22 changes: 0 additions & 22 deletions src/OpalCompiler-Core/DebuggerMethodMapOpal.class.st
Expand Up @@ -45,28 +45,6 @@ DebuggerMethodMapOpal >> namedTempAt: index put: aValue in: aContext [
^self tempNamed: (aContext tempNames at: index) in: aContext put: aValue
]

{ #category : #public }
DebuggerMethodMapOpal >> rangeForPC: aPC [
"return the debug highlight for aPC"

^self rangeForPC: aPC contextIsActiveContext: false

]

{ #category : #public }
DebuggerMethodMapOpal >> rangeForPC: aPC contextIsActiveContext: contextIsActive [
"return the debug highlight for aPC"
| pc |

"When on the top of the stack the pc is pointing to right instruction, but deeper in the stack
the pc was already advanced one bytecode, so we need to go back this one bytecode, which
can consist of multiple bytes. But on IR, we record the *last* bytecode offset as the offset of the
IR instruction, which means we can just go back one"

pc := contextIsActive ifTrue: [aPC] ifFalse: [aPC - 1].
^(methodNode sourceNodeForPC: pc) debugHighlightRange
]

{ #category : #public }
DebuggerMethodMapOpal >> tempNamed: name in: aContext [
"Answer the value of the temp with name in aContext"
Expand Down
14 changes: 0 additions & 14 deletions src/OpalCompiler-Tests/MethodMapTest.class.st
Expand Up @@ -188,20 +188,6 @@ MethodMapTest >> testPrimitiveMethodSourceNodeAtInitialPC [

self assert: actual equals: method ast

]

{ #category : #'testing - source mapping' }
MethodMapTest >> testSimpleSourceMapping [
| method range highlight |

method := Object>>('ha', 'lt') asSymbol.

range := method rangeForPC: (Smalltalk vm for32bit: 23 for64bit: 43).
highlight := method sourceCode copyFrom: range first to: range last.
self assert: highlight equals: 'now'.



]

{ #category : #'testing - temp access' }
Expand Down
2 changes: 1 addition & 1 deletion src/Tool-ProcessBrowser/ProcessBrowser.class.st
Expand Up @@ -809,7 +809,7 @@ ProcessBrowser >> pcRange [
the selected context's program counter value."
(selectedContext isNil or: [methodText isEmptyOrNil])
ifTrue: [^ 1 to: 0].
^selectedContext pcRangeContextIsActive: (stackListIndex = 1)
^selectedContext pcRange
]

{ #category : #'process list' }
Expand Down

0 comments on commit 59c4cf5

Please sign in to comment.