Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
8c6b6d10
Commit
8c6b6d10
authored
Nov 29, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix step over, step into action
parent
70c6fc4b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
97 deletions
+34
-97
traceAnalyser.js
src/trace/traceAnalyser.js
+3
-13
traceCache.js
src/trace/traceCache.js
+13
-9
traceManager.js
src/trace/traceManager.js
+2
-10
traceStepManager.js
src/trace/traceStepManager.js
+16
-51
traceManager.js
test/traceManager.js
+0
-14
No files found.
src/trace/traceAnalyser.js
View file @
8c6b6d10
...
...
@@ -16,11 +16,7 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
lastCallIndex
:
0
}
var
callStack
=
[
tx
.
to
]
this
.
traceCache
.
pushCallChanges
(
0
,
0
,
callStack
[
0
])
this
.
traceCache
.
pushCallStack
(
0
,
{
callStack
:
callStack
.
slice
(
0
)
})
this
.
traceCache
.
pushCall
(
trace
[
0
],
0
,
callStack
[
0
],
callStack
.
slice
(
0
))
if
(
traceHelper
.
isContractCreation
(
tx
.
to
))
{
this
.
traceCache
.
pushContractCreation
(
tx
.
to
,
tx
.
input
)
}
...
...
@@ -110,10 +106,7 @@ TraceAnalyser.prototype.buildDepth = function (index, step, tx, callStack, conte
console
.
log
(
'unable to build depth changes. '
+
index
+
' does not match with a CALL. depth changes will be corrupted'
)
}
}
this
.
traceCache
.
pushCallChanges
(
step
,
index
+
1
,
newAddress
)
this
.
traceCache
.
pushCallStack
(
index
+
1
,
{
callStack
:
callStack
.
slice
(
0
)
})
this
.
traceCache
.
pushCall
(
step
,
index
+
1
,
newAddress
,
callStack
.
slice
(
0
))
this
.
buildCalldata
(
index
,
step
,
tx
,
true
)
this
.
traceCache
.
pushSteps
(
index
,
context
.
currentCallIndex
)
context
.
lastCallIndex
=
context
.
currentCallIndex
...
...
@@ -121,10 +114,7 @@ TraceAnalyser.prototype.buildDepth = function (index, step, tx, callStack, conte
}
else
if
(
traceHelper
.
isReturnInstruction
(
step
)
||
traceHelper
.
isStopInstruction
(
step
))
{
if
(
index
+
1
<
this
.
trace
.
length
)
{
callStack
.
pop
()
this
.
traceCache
.
pushCallChanges
(
step
,
index
+
1
)
this
.
traceCache
.
pushCallStack
(
index
+
1
,
{
callStack
:
callStack
.
slice
(
0
)
})
this
.
traceCache
.
pushCall
(
step
,
index
+
1
,
null
,
callStack
.
slice
(
0
))
this
.
buildCalldata
(
index
,
step
,
tx
,
false
)
this
.
traceCache
.
pushSteps
(
index
,
context
.
currentCallIndex
)
context
.
currentCallIndex
=
context
.
lastCallIndex
+
1
...
...
src/trace/traceCache.js
View file @
8c6b6d10
...
...
@@ -9,6 +9,7 @@ TraceCache.prototype.init = function () {
this
.
returnValues
=
{}
this
.
callChanges
=
[]
this
.
calls
=
{}
this
.
callsRef
=
[
0
]
// track of calls during the vm trace analysis
this
.
callsData
=
{}
this
.
contractCreation
=
{}
this
.
steps
=
{}
...
...
@@ -18,7 +19,6 @@ TraceCache.prototype.init = function () {
this
.
memoryChanges
=
[]
this
.
storageChanges
=
[]
this
.
sstore
=
{}
// all sstore occurence in the trace
this
.
callStack
=
{}
// contains all callStack by vmtrace index (we need to rebuild it, callstack is not included in the vmtrace)
}
TraceCache
.
prototype
.
pushSteps
=
function
(
index
,
currentCallIndex
)
{
...
...
@@ -34,11 +34,19 @@ TraceCache.prototype.pushMemoryChanges = function (value) {
this
.
memoryChanges
.
push
(
value
)
}
TraceCache
.
prototype
.
pushCall
Changes
=
function
(
step
,
value
,
address
)
{
this
.
callChanges
.
push
(
value
)
this
.
calls
[
value
]
=
{
TraceCache
.
prototype
.
pushCall
=
function
(
step
,
index
,
address
,
callStack
)
{
this
.
callChanges
.
push
(
index
)
this
.
calls
[
index
]
=
{
op
:
step
.
op
,
address
:
address
address
:
address
,
callStack
:
callStack
}
if
(
step
.
op
===
'RETURN'
||
step
.
op
===
'STOP'
)
{
var
call
=
this
.
callsRef
.
pop
()
this
.
calls
[
index
].
call
=
call
this
.
calls
[
call
].
return
=
index
}
else
{
this
.
callsRef
.
push
(
index
)
}
}
...
...
@@ -58,10 +66,6 @@ TraceCache.prototype.pushContractCreation = function (token, code) {
this
.
contractCreation
[
token
]
=
code
}
TraceCache
.
prototype
.
pushCallStack
=
function
(
index
,
callStack
)
{
this
.
callStack
[
index
]
=
callStack
}
TraceCache
.
prototype
.
pushStoreChanges
=
function
(
index
,
address
,
key
,
value
)
{
this
.
sstore
[
index
]
=
{
'address'
:
address
,
...
...
src/trace/traceManager.js
View file @
8c6b6d10
...
...
@@ -135,7 +135,7 @@ TraceManager.prototype.getCallStackAt = function (stepIndex, callback) {
}
var
callStackChange
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
callChanges
)
if
(
callStackChange
===
null
)
return
callback
(
'no callstack found'
,
null
)
callback
(
null
,
this
.
traceCache
.
call
Stack
[
callStackChange
].
callStack
)
callback
(
null
,
this
.
traceCache
.
call
s
[
callStackChange
].
callStack
)
}
TraceManager
.
prototype
.
getStackAt
=
function
(
stepIndex
,
callback
)
{
...
...
@@ -179,7 +179,7 @@ TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex, callback
if
(
addressIndex
===
0
)
{
callback
(
null
,
self
.
tx
.
to
)
}
else
{
var
callStack
=
self
.
traceCache
.
call
Stack
[
addressIndex
].
callStack
var
callStack
=
self
.
traceCache
.
call
s
[
addressIndex
].
callStack
var
calledAddress
=
callStack
[
callStack
.
length
-
1
]
if
(
calledAddress
)
{
callback
(
null
,
calledAddress
)
...
...
@@ -274,14 +274,6 @@ TraceManager.prototype.findStepOverForward = function (currentStep) {
return
this
.
traceStepManager
.
findStepOverForward
(
currentStep
)
}
TraceManager
.
prototype
.
findStepOutBack
=
function
(
currentStep
)
{
return
this
.
traceStepManager
.
findStepOutBack
(
currentStep
)
}
TraceManager
.
prototype
.
findStepOutForward
=
function
(
currentStep
)
{
return
this
.
traceStepManager
.
findStepOutForward
(
currentStep
)
}
TraceManager
.
prototype
.
findNextCall
=
function
(
currentStep
)
{
return
this
.
traceStepManager
.
findNextCall
(
currentStep
)
}
...
...
src/trace/traceStepManager.js
View file @
8c6b6d10
'use strict'
var
traceHelper
=
require
(
'../helpers/traceHelper'
)
var
util
=
require
(
'../helpers/util'
)
function
TraceStepManager
(
_traceAnalyser
)
{
this
.
traceAnalyser
=
_traceAnalyser
...
...
@@ -16,66 +17,30 @@ TraceStepManager.prototype.isReturnInstruction = function (index) {
}
TraceStepManager
.
prototype
.
findStepOverBack
=
function
(
currentStep
)
{
if
(
currentStep
===
0
)
return
0
return
this
.
findStepOutBack
(
currentStep
)
}
TraceStepManager
.
prototype
.
findStepOverForward
=
function
(
currentStep
)
{
if
(
currentStep
===
this
.
traceAnalyser
.
trace
.
length
-
1
)
return
currentStep
return
this
.
findStepOutForward
(
currentStep
)
}
TraceStepManager
.
prototype
.
findStepOutBack
=
function
(
currentStep
)
{
if
(
!
this
.
traceAnalyser
.
trace
)
{
return
currentStep
if
(
this
.
isReturnInstruction
(
currentStep
-
1
))
{
return
this
.
traceAnalyser
.
traceCache
.
calls
[
currentStep
].
call
-
1
}
else
{
return
currentStep
>
0
?
currentStep
-
1
:
0
}
var
i
=
currentStep
-
1
var
depth
=
0
while
(
--
i
>=
0
)
{
if
(
this
.
isCallInstruction
(
i
))
{
if
(
depth
===
0
)
{
break
}
else
{
depth
--
}
}
else
if
(
this
.
isReturnInstruction
(
i
))
{
depth
++
}
}
return
i
}
TraceStepManager
.
prototype
.
findStepOutForward
=
function
(
currentStep
)
{
if
(
!
this
.
traceAnalyser
.
trace
)
{
return
currentStep
}
var
i
=
currentStep
var
depth
=
0
while
(
++
i
<
this
.
traceAnalyser
.
trace
.
length
)
{
if
(
this
.
isReturnInstruction
(
i
))
{
if
(
depth
===
0
)
{
break
}
else
{
depth
--
}
}
else
if
(
this
.
isCallInstruction
(
i
))
{
depth
++
}
TraceStepManager
.
prototype
.
findStepOverForward
=
function
(
currentStep
)
{
if
(
this
.
isCallInstruction
(
currentStep
))
{
return
this
.
traceAnalyser
.
traceCache
.
calls
[
currentStep
+
1
].
return
}
else
{
return
this
.
traceAnalyser
.
trace
.
length
>=
currentStep
+
1
?
currentStep
+
1
:
currentStep
}
return
i
}
TraceStepManager
.
prototype
.
findNextCall
=
function
(
currentStep
)
{
if
(
!
this
.
traceAnalyser
.
trace
)
{
var
callChanges
=
this
.
traceAnalyser
.
traceCache
.
callChanges
var
stepIndex
=
util
.
findLowerBound
(
currentStep
,
callChanges
)
var
callchange
=
callChanges
[
stepIndex
+
1
]
if
(
callchange
&&
this
.
isCallInstruction
(
callchange
-
1
))
{
return
callchange
-
1
}
else
{
return
currentStep
}
var
i
=
currentStep
while
(
++
i
<
this
.
traceAnalyser
.
trace
.
length
)
{
if
(
this
.
isCallInstruction
(
i
))
{
return
i
}
}
return
currentStep
}
module
.
exports
=
TraceStepManager
test/traceManager.js
View file @
8c6b6d10
...
...
@@ -286,20 +286,6 @@ tape('TraceManager', function (t) {
st
.
end
()
})
t
.
test
(
'TraceManager.findStepOutBack'
,
function
(
st
)
{
var
result
=
traceManager
.
findStepOutBack
(
70
)
console
.
log
(
result
)
st
.
ok
(
result
===
63
)
st
.
end
()
})
t
.
test
(
'TraceManager.findStepOutForward'
,
function
(
st
)
{
var
result
=
traceManager
.
findStepOutForward
(
15
)
console
.
log
(
result
)
st
.
ok
(
result
===
142
)
st
.
end
()
})
t
.
test
(
'TraceManager.findNextCall'
,
function
(
st
)
{
var
result
=
traceManager
.
findNextCall
(
10
)
console
.
log
(
result
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment