Skip to content

Commit

Permalink
taking a fresh approach to build stack frames ... TDRawStackFrame pro…
Browse files Browse the repository at this point in the history
…vides basic access the stack frame contents with very little interpretation ... there is enough protocol present so that a TDRawStackFrame can be used in a TDDebugger. but I've got no client element support ... this class may migrate to the base image. TDTopazContext emulates the frame information displayed in topaz
  • Loading branch information
dalehenrich committed Dec 30, 2016
1 parent f4b6e80 commit 181236f
Show file tree
Hide file tree
Showing 67 changed files with 419 additions and 38 deletions.
Expand Up @@ -3,4 +3,6 @@ execBlockComplexScopedTemps
| a b |
a := 1.
b := 2.
^ [ a halt ]
^ [ | c |
c := 3.
[ a halt ] value ]
@@ -1,3 +1,3 @@
private
stackClass
^ TDStackNew
^ TDNewStack
Expand Up @@ -3,9 +3,9 @@
"shouldInheritSelectors" : "dkh 12/29/2016 17:27" },
"instance" : {
"createFrames" : "dkh 12/29/2016 10:16",
"execBlockComplexScopedTemps" : "dkh 12/29/2016 18:04",
"stackClass" : "dkh 12/29/2016 09:13",
"testExecBlockComplexScopedTempsBaseNodeMap" : "dkh 12/29/2016 18:06",
"execBlockComplexScopedTemps" : "dkh 12/29/2016 18:20",
"stackClass" : "dkh 12/30/2016 04:19",
"testExecBlockComplexScopedTempsBaseNodeMap" : "dkh 12/30/2016 05:49",
"testExecBlockComplexTempsBaseNodeMap" : "dkh 12/29/2016 18:01",
"testExecBlockSimpleBaseNodeMap" : "dkh 12/29/2016 17:44",
"testExecBlockSimpleWithTempsBaseNodeMap" : "dkh 12/29/2016 17:54" } }
Expand Up @@ -22,7 +22,7 @@
"stackFrameClass" : "dkh 12/29/2016 13:47",
"testExecBlockComplexSelfBaseNodeMap" : "dkh 12/29/2016 09:20",
"testExecBlockComplexTempsBaseNodeMap" : "dkh 12/29/2016 09:20",
"testExecBlockSimpleBaseNodeMap" : "dkh 12/29/2016 17:15",
"testExecBlockSimpleBaseNodeMap" : "dkh 12/29/2016 17:45",
"testExecBlockSimpleWithTempsBaseNodeMap" : "dkh 12/29/2016 09:20",
"testFactoryBlockComplexSelfBaseNodeMap" : "dkh 11/23/2016 12:23",
"testFactoryBlockSimpleBaseNodeMap" : "dkh 11/23/2016 12:22",
Expand Down

Large diffs are not rendered by default.

@@ -0,0 +1,4 @@
accessing
argAndTempNames
^ argAndTempNames
ifNil: [ argAndTempNames := (self frameContents at: 9) collect: [ :each | each asString ] ]
@@ -0,0 +1,3 @@
accessing
argAndTempNamesAt: index
^ self frameContents at: 10 + index
@@ -0,0 +1,5 @@
accessing
argOrTempNamed: aString
^ self
argOrTempNamed: aString
ifAbsent: [ self error: 'no arg or temp named: ' , aString printString ]
@@ -0,0 +1,7 @@
accessing
argOrTempNamed: aString ifAbsent: absentBlock
| index |
index := self argAndTempNames indexOf: aString.
index == 0
ifTrue: [ ^ absentBlock value ].
^ self argAndTempNamesAt: index
@@ -0,0 +1,11 @@
querying
findFrameSuchThat: testBlock
"Search self and my sender chain for first one that satisfies testBlock. Return nil if none satisfy"

| frame |
frame := self.
[ frame isNil ] whileFalse: [ self frameContents ~~ nil
ifTrue: [ (testBlock value: frame)
ifTrue: [ ^ frame ] ].
frame := frame next ].
^ nil
@@ -0,0 +1,34 @@
accessing
frameContents
"Private. Returns an Array describing the specified level in the receiver.
aLevel == 1 is top of stack. If aLevel is less than 1 or greater than
stackDepth, returns nil.
The result Array contains:
offset item
----- -----
1 gsMethod (a GsNMethod)
2 ipOffset (absolute instruction offset in portable code
negative means a stack breakpoint is present)
3 frameOffset (always nil , not compatible with Gs64 v2.x)
4 varContext
5 saveProtectedMode (always nil in v3.0)
6 markerOrException (always nil in v3.0)
7 homeMethod if gsMethod is for a block, otherwise nil .
8 self (possibly nil in a ComplexBlock)
9 argAndTempNames (an Array of Symbols or Strings)
10 receiver
11... arguments and temp values, if any"

"Notes to GemStone implementors:
If result of this method is changed, you must change tpaux.c in the
topaz C sources, other methods in this class, and the code for primitive 195.
Note that if execution stops at a breakpoint at the entry to a method,
the method temporaries may not be allocated yet and so some or all of
the method temporaries may be missing from the result."

frameContents
ifNil: [ frameContents := self process _frameContentsAt: self frameIndex ].
^ frameContents
@@ -0,0 +1,4 @@
accessing
frameIndex: anInteger
frameIndex := anInteger.
self argAndTempNames
@@ -0,0 +1,3 @@
accessing
frameIndex
^ frameIndex
@@ -0,0 +1,3 @@
accessing
frameSelf
^ self frameContents at: 8
@@ -0,0 +1,3 @@
accessing
gsMethod
^ self frameContents at: 1
@@ -0,0 +1,3 @@
accessing
homeMethod
^ (self frameContents at: 7) ifNil: [ self gsMethod homeMethod ]
@@ -0,0 +1,4 @@
accessing
inClass
self gsMethod ifNil: [ ^ nil ].
^ self homeMethod ifNotNil: [ :hm | hm inClass ]
@@ -0,0 +1,3 @@
accessing
ipOffset
^ self frameContents at: 2
@@ -0,0 +1,4 @@
testing
isMethodForBlock
self gsMethod ifNil: [ ^ false ].
^ self gsMethod isMethodForBlock
@@ -0,0 +1,3 @@
accessing
next: aFrame
next := aFrame
@@ -0,0 +1,3 @@
accessing
next
^ next
@@ -0,0 +1,3 @@
accessing
previous: aFrame
previous := aFrame
@@ -0,0 +1,3 @@
accessing
previous
^ previous
@@ -0,0 +1,25 @@
printing
printOn: aStream
| theSelf |
self frameContents ifNil: [ ^ aStream nextPutAll: '..bad frame...' ].
self isMethodForBlock
ifTrue: [ aStream nextPutAll: '[] in ' ].
self inClass == nil
ifTrue: [ aStream nextPutAll: 'Executed Code'.
^ self ].
theSelf := self theSelf.
theSelf class ~= self inClass
ifTrue: [ aStream
nextPutAll: theSelf class name asString;
nextPutAll: '(' , self inClass name asString , ')' ]
ifFalse: [ aStream nextPutAll: self inClass name asString ].
aStream nextPutAll: '>>'.
aStream nextPutAll: self selector.
(self process respondsTo: #'_localStepPointStringAt:')
ifTrue: [ aStream
nextPutAll:
' ' , (self process perform: #'_localStepPointStringAt:' with: self frameIndex) ]
ifFalse: [ (self process respondsTo: #'_stepPointStringAt:')
ifTrue: [ aStream
nextPutAll:
' ' , (self process perform: #'_stepPointStringAt:' with: self frameIndex) ] ]
@@ -0,0 +1,3 @@
accessing
process
^ self stack process
@@ -0,0 +1,3 @@
accessing
receiver
^ self frameContents at: 10
@@ -0,0 +1,4 @@
accessing
selector
self gsMethod ifNil: [ ^ #'' ].
^ self homeMethod selector
@@ -0,0 +1,3 @@
accessing
stack: aTDStack
stack := aTDStack
@@ -0,0 +1,3 @@
accessing
stack
^ stack
@@ -0,0 +1,3 @@
accessing
theSelf
^ self frameSelf ifNil: [ self argOrTempNamed: 'self' ifAbsent: [ ] ]
@@ -0,0 +1,3 @@
accessing
varContext
^ self frameContents at: 4
@@ -0,0 +1,30 @@
{
"class" : {
},
"instance" : {
"argAndTempNames" : "dkh 12/30/2016 04:12",
"argAndTempNamesAt:" : "dkh 12/30/2016 04:05",
"argOrTempNamed:" : "dkh 12/30/2016 04:06",
"argOrTempNamed:ifAbsent:" : "dkh 12/30/2016 04:06",
"findFrameSuchThat:" : "dkh 12/30/2016 04:48",
"frameContents" : "dkh 12/30/2016 04:17",
"frameIndex" : "dkh 12/30/2016 04:07",
"frameIndex:" : "dkh 12/30/2016 04:48",
"frameSelf" : "dkh 12/30/2016 04:15",
"gsMethod" : "dkh 12/30/2016 04:16",
"homeMethod" : "dkh 12/30/2016 04:36",
"inClass" : "dkh 12/30/2016 04:33",
"ipOffset" : "dkh 12/30/2016 04:14",
"isMethodForBlock" : "dkh 12/30/2016 04:22",
"next" : "dkh 12/30/2016 04:22",
"next:" : "dkh 12/30/2016 04:22",
"previous" : "dkh 12/30/2016 04:23",
"previous:" : "dkh 12/30/2016 04:23",
"printOn:" : "dkh 12/30/2016 04:32",
"process" : "dkh 12/30/2016 04:26",
"receiver" : "dkh 12/30/2016 04:16",
"selector" : "dkh 12/30/2016 04:34",
"stack" : "dkh 12/30/2016 04:26",
"stack:" : "dkh 12/30/2016 04:45",
"theSelf" : "dkh 12/30/2016 04:31",
"varContext" : "dkh 12/30/2016 04:15" } }
@@ -0,0 +1,19 @@
{
"category" : "Topez-Server-3x-DebugTools",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"stack",
"argAndTempNames",
"frameIndex",
"frameContents",
"next",
"previous" ],
"name" : "TDRawStackFrame",
"pools" : [
],
"super" : "Object",
"type" : "normal" }
@@ -0,0 +1 @@
display the same frame context fields as topaz
@@ -0,0 +1,18 @@
initialization
initialize
"builder:
#view - normal view (i.e., collection of associations for Dictionary)
#inspect - raw object/implementation view
editor:
#edit - text code editor (falls back to #navigate)
#navigate - structural access via navigator
CUSTOM - custom names for specialized window access"

TDTopezServer
registerEditorClass: TDStackFrameContentsClientListElementBuilder
for: self
aspect: #'contents';
registerEditorClass: TDStackFrameMethodElementBuilder
for: self
aspect: #'source'
@@ -0,0 +1,5 @@
synthetic fields
blockSelf
(self receiver isKindOf: ExecBlock)
ifTrue: [ ^ self receiver selfValue ].
^ nil
@@ -0,0 +1,11 @@
private
calculateSelectionRange
| method stepPoint begin end |
method := self gsMethod.
stepPoint := method
_stepPointForIp: self ipOffset
level: self frameIndex
useNext: self process _nativeStack.
begin := method _sourceOffsetsAt: stepPoint.
end := self calculateSourceRangeEnd: begin in: method sourceString.
^ begin to: end
@@ -0,0 +1,58 @@
private
calculateSourceRangeEnd: start in: string
| scan i char characterStack beginners enders |
i := start.
(string at: i) = $^
ifTrue: [ ^ string size - 1 ].
(char := string at: i) isCompilerSpecial
ifTrue: [
^ (i < string size and: [ (char := string at: i + 1) isCompilerSpecial ])
ifTrue: [ i + 1 ]
ifFalse: [ i ] ].
scan := true.
[ scan ]
whileTrue: [
[ i <= string size and: [ (string at: i) isSeparator ] ] whileTrue: [ i := i + 1 ].
[ i <= string size and: [ (char := string at: i) isAlphaNumeric or: [ char = $_ ] ] ]
whileTrue: [ i := i + 1 ].
char = $:
ifFalse: [ ^ i - 1 ].
scan := start == 1.
scan
ifTrue: [ i := i + 1 ] ].
characterStack := OrderedCollection new.
beginners := String
with: $'
with: $"
with: $(
with: $[.
enders := String with: $) with: $].
[
i := i + 1.
i < string size ]
whileTrue: [
char := string at: i.
characterStack isEmpty
ifTrue: [
(char = $. or: [ char = $; ])
ifTrue: [ ^ i - 1 ].
(beginners includes: char)
ifTrue: [ characterStack addLast: char ]
ifFalse: [
(enders includes: char)
ifTrue: [ ^ i - 1 ] ] ]
ifFalse: [
(characterStack last = $' or: [ characterStack last = $" ])
ifTrue: [
char = characterStack last
ifTrue: [ characterStack removeLast ] ]
ifFalse: [
(beginners includes: char)
ifTrue: [ characterStack addLast: char ]
ifFalse: [
(characterStack last = $( and: [ char = $) ])
ifTrue: [ characterStack removeLast ]
ifFalse: [
(characterStack last = $[ and: [ char = $] ])
ifTrue: [ characterStack removeLast ] ] ] ] ] ].
^ i - 1

0 comments on commit 181236f

Please sign in to comment.