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
cb599405
Commit
cb599405
authored
Dec 05, 2016
by
yann300
Committed by
GitHub
Dec 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #153 from ethereum/fixgoforwardaction
Fix go forward action
parents
25d02e28
c2dd1aa8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
103 deletions
+46
-103
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
vmdebugger.js
test-browser/vmdebugger.js
+10
-4
traceManager.js
test/traceManager.js
+2
-16
No files found.
src/trace/traceAnalyser.js
View file @
cb599405
...
...
@@ -15,11 +15,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
)
}
...
...
@@ -109,10 +105,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
...
...
@@ -120,10 +113,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 @
cb599405
...
...
@@ -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 @
cb599405
...
...
@@ -128,7 +128,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
)
{
...
...
@@ -172,7 +172,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
)
...
...
@@ -267,14 +267,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 @
cb599405
'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-browser/vmdebugger.js
View file @
cb599405
...
...
@@ -128,10 +128,16 @@ function stepping (browser) {
.
click
(
'#intoforward'
)
.
click
(
'#intoforward'
)
.
click
(
'#overforward'
)
.
assertCurrentSelectedItem
(
'058 RETURN'
)
.
click
(
'#intoforward'
)
.
assertCurrentSelectedItem
(
'007 MLOAD'
)
.
click
(
'#overback'
)
.
assertCurrentSelectedItem
(
'181 CREATE'
)
.
click
(
'#overback'
)
.
click
(
'#overback'
)
.
click
(
'#overback'
)
.
click
(
'#overback'
)
.
click
(
'#overforward'
)
.
assertCurrentSelectedItem
(
'182 PUSH1 01'
)
.
click
(
'#overforward'
)
.
assertCurrentSelectedItem
(
'184 PUSH1 00'
)
return
browser
}
...
...
@@ -162,8 +168,8 @@ function stepdetail (browser) {
.
assertStepDetail
(
'6'
,
'6'
,
''
,
'3'
,
'84476'
,
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
)
.
click
(
'#nextcall'
)
.
assertStepDetail
(
'63'
,
'63'
,
''
,
'32000'
,
'79283'
,
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
)
.
click
(
'#intoforward'
)
.
click
(
'#overforward'
)
.
click
(
'#intoback'
)
.
assertStepDetail
(
'108'
,
'44'
,
''
,
'0'
,
'27145'
,
'(ContractCreation-Step63)'
)
.
click
(
'#intoforward'
)
.
assertStepDetail
(
'109'
,
'64'
,
''
,
'3'
,
'25145'
,
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
)
...
...
test/traceManager.js
View file @
cb599405
...
...
@@ -275,28 +275,14 @@ tape('TraceManager', function (t) {
t
.
test
(
'TraceManager.findStepOverBack'
,
function
(
st
)
{
var
result
=
traceManager
.
findStepOverBack
(
116
)
console
.
log
(
result
)
st
.
ok
(
result
===
-
1
)
st
.
ok
(
result
===
115
)
st
.
end
()
})
t
.
test
(
'TraceManager.findStepOverForward'
,
function
(
st
)
{
var
result
=
traceManager
.
findStepOverForward
(
66
)
console
.
log
(
result
)
st
.
ok
(
result
===
108
)
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
.
ok
(
result
===
67
)
st
.
end
()
})
...
...
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