[squeak-dev] The Inbox: Tools-ct.991.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Thu Oct 1 12:04:06 UTC 2020


Hi Christoph,

that's funny. You already did that with Tools-ct.957. :-) I will move both 956 and 957 to treated.

Best,
Marcel
Am 30.09.2020 19:46:56 schrieb commits at source.squeak.org <commits at source.squeak.org>:
Christoph Thiede uploaded a new version of Tools to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.991.mcz

==================== Summary ====================

Name: Tools-ct.991
Author: ct
Time: 30 September 2020, 7:46:39.949807 pm
UUID: 4d2f75ef-336d-cc4c-aa0d-dd4f7ff99fc7
Ancestors: Tools-mt.990

Fixes a bug in DebuggerMethodMap's rangeForPC lookup

Steps to reproduce:

c := Object newSubclass.
c compile: 'foo: foo
foo = #foo ifTrue: [^ true].
^ (foo ifNil: [^ false]) = #bar'.
c new foo: #bar.
"Debug it. Step into #foo:, step over #=.
Before this commit, the selection was '^ true'"

The error was that #findNearbyBinaryIndex: uses to return the lower possible index if there is no exact match. For debugging, we cannot need this behavior, because we want to select the next operation to be executed.

Furthermore, this commit refactors some duplication with DebuggerMethodMapForFullBlockCompiledMethod. Please review!

Uploaded again due to totally broken ancestry. Replaces Tools-ct.956, which can be moved into the treated inbox.

=============== Diff against Tools-mt.990 ===============

Item was changed:
----- Method: DebuggerMethodMap>>rangeForPC:in:contextIsActiveContext: (in category 'source mapping') -----
rangeForPC: contextsConcretePC in: method contextIsActiveContext: contextIsActiveContext
+ "Answer the indices in the source code for the supplied pc. If the context is the active context (is at the hot end of the stack) then its pc is the current pc. But if the context isn't, because it is suspended sending a message, then its current pc is the previous pc."
- "Answer the indices in the source code for the supplied pc.
- If the context is the actve context (is at the hot end of the stack)
- then its pc is the current pc. But if the context isn't, because it is
- suspended sending a message, then its current pc is the previous pc."

+ | pc i end sortedMap |
- | pc i end |
pc := method abstractPCForConcretePC: (contextIsActiveContext
+ ifTrue: [contextsConcretePC]
+ ifFalse: [(method pcPreviousTo: contextsConcretePC)
+ ifNil: [contextsConcretePC]]).
+ (self abstractSourceMapForMethod: method)
+ at: pc
+ ifPresent: [:range | ^ range].
+ sortedMap := self sortedSourceMapForMethod: method.
+ sortedMap ifEmpty: [^ 1 to: 0].
+ i := sortedMap
+ findBinaryIndex: [:assoc | pc - assoc key]
+ ifNone: [:lower :upper | upper].
+ i
+ i > sortedMap size ifTrue: [
+ end := sortedMap inject: 0 into: [:prev :this |
+ prev max: this value last].
+ ^ end + 1 to: end].
+ ^ (sortedMap at: i) value!
- ifTrue: [contextsConcretePC]
- ifFalse: [(method pcPreviousTo: contextsConcretePC)
- ifNotNil: [:prevpc| prevpc]
- ifNil: [contextsConcretePC]]).
- (self abstractSourceMap includesKey: pc) ifTrue:
- [^self abstractSourceMap at: pc].
- sortedSourceMap ifNil:
- [sortedSourceMap := self abstractSourceMap associations
- replace: [ :each | each copy ];
- sort].
- sortedSourceMap isEmpty ifTrue: [^1 to: 0].
- i := sortedSourceMap findNearbyBinaryIndex: [:assoc| pc - assoc key].
- i
- i > sortedSourceMap size ifTrue:
- [end := sortedSourceMap inject: 0 into:
- [:prev :this | prev max: this value last].
- ^end+1 to: end].
- ^(sortedSourceMap at: i) value
-
- "| method source scanner map |
- method := DebuggerMethodMap compiledMethodAt: #rangeForPC:in:contextIsActiveContext:.
- source := method getSourceFromFile asString.
- scanner := InstructionStream on: method.
- map := method debuggerMap.
- Array streamContents:
- [:ranges|
- [scanner atEnd] whileFalse:
- [| range |
- range := map rangeForPC: scanner pc in: method contextIsActiveContext: true.
- ((map abstractSourceMap includesKey: scanner abstractPC)
- and: [range first ~= 0]) ifTrue:
- [ranges nextPut: (source copyFrom: range first to: range last)].
- scanner interpretNextInstructionFor: InstructionClient new]]"!

Item was added:
+ ----- Method: DebuggerMethodMap>>sortedSourceMap (in category 'private') -----
+ sortedSourceMap
+
+ ^ sortedSourceMap ifNil: [
+ sortedSourceMap := self abstractSourceMap associations
+ replace: [:each | each copy];
+ sort]!

Item was added:
+ ----- Method: DebuggerMethodMap>>sortedSourceMapForMethod: (in category 'source mapping') -----
+ sortedSourceMapForMethod: aCompiledMethod
+
+ ^ self sortedSourceMap!

Item was changed:
----- Method: DebuggerMethodMapForFullBlockCompiledMethods>>abstractSourceMap (in category 'source mapping') -----
abstractSourceMap
+
+ ^ self shouldNotImplement!
- self shouldNotImplement!

Item was removed:
- ----- Method: DebuggerMethodMapForFullBlockCompiledMethods>>rangeForPC:in:contextIsActiveContext: (in category 'source mapping') -----
- rangeForPC: contextsConcretePC in: method contextIsActiveContext: contextIsActiveContext
- "Answer the indices in the source code for the supplied pc.
- If the context is the actve context (is at the hot end of the stack)
- then its pc is the current pc. But if the context isn't, because it is
- suspended sending a message, then its current pc is the previous pc."
-
- | pc i end mapForMethod sortedMap |
- pc := method abstractPCForConcretePC: (contextIsActiveContext
- ifTrue: [contextsConcretePC]
- ifFalse: [(method pcPreviousTo: contextsConcretePC)
- ifNotNil: [:prevpc| prevpc]
- ifNil: [contextsConcretePC]]).
- ((mapForMethod := self abstractSourceMapForMethod: method) includesKey: pc) ifTrue:
- [^mapForMethod at: pc].
- sortedSourceMap ifNil:
- [sortedSourceMap := IdentityDictionary new].
- sortedMap := sortedSourceMap
- at: method
- ifAbsentPut: [mapForMethod associations
- replace: [ :each | each copy ];
- sort].
- sortedMap isEmpty ifTrue: [^1 to: 0].
- i := sortedMap findNearbyBinaryIndex: [:assoc| pc - assoc key].
- i
- i > sortedMap size ifTrue:
- [end := sortedMap inject: 0 into:
- [:prev :this | prev max: this value last].
- ^end+1 to: end].
- ^(sortedMap at: i) value
-
- "| method source scanner map |
- method := DebuggerMethodMapForFullBlockCompiledMethods compiledMethodAt: #rangeForPC:in:contextIsActiveContext:.
- source := method getSourceFromFile asString.
- scanner := InstructionStream on: method.
- map := method debuggerMap.
- Array streamContents:
- [:ranges|
- [scanner atEnd] whileFalse:
- [| range |
- range := map rangeForPC: scanner pc in: method contextIsActiveContext: true.
- ((map abstractSourceMap includesKey: scanner abstractPC)
- and: [range first ~= 0]) ifTrue:
- [ranges nextPut: (source copyFrom: range first to: range last)].
- scanner interpretNextInstructionFor: InstructionClient new]]"!

Item was added:
+ ----- Method: DebuggerMethodMapForFullBlockCompiledMethods>>sortedSourceMap (in category 'source mapping') -----
+ sortedSourceMap
+
+ ^ self shouldNotImplement!

Item was added:
+ ----- Method: DebuggerMethodMapForFullBlockCompiledMethods>>sortedSourceMapForMethod: (in category 'source mapping') -----
+ sortedSourceMapForMethod: method
+
+ sortedSourceMap ifNil: [
+ sortedSourceMap := IdentityDictionary new].
+ ^ sortedSourceMap
+ at: method
+ ifAbsentPut: [(self abstractSourceMapForMethod: method) associations
+ replace: [ :each | each copy ];
+ sort]!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201001/121810bc/attachment.html>


More information about the Squeak-dev mailing list