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
3866faa9
Commit
3866faa9
authored
Jul 17, 2020
by
Iuri Matias
Committed by
aniket-engg
Aug 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor getStackAt
parent
f788b8d2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
77 deletions
+98
-77
Ethdebugger.js
libs/remix-debug/src/Ethdebugger.js
+8
-1
VmDebugger.js
libs/remix-debug/src/debugger/VmDebugger.js
+6
-6
solidityLocals.js
libs/remix-debug/src/debugger/solidityLocals.js
+9
-1
internalCallTree.js
libs/remix-debug/src/solidity-decoder/internalCallTree.js
+38
-36
debugger.js
libs/remix-debug/test/debugger.js
+11
-7
helper.js
libs/remix-debug/test/decoder/localsTests/helper.js
+8
-1
traceManager.js
libs/remix-lib/src/trace/traceManager.js
+5
-10
traceManager.js
libs/remix-lib/test/traceManager.js
+13
-15
No files found.
libs/remix-debug/src/Ethdebugger.js
View file @
3866faa9
...
...
@@ -90,7 +90,14 @@ Ethdebugger.prototype.extractLocalsAt = function (step, callback) {
Ethdebugger
.
prototype
.
decodeLocalsAt
=
function
(
step
,
sourceLocation
,
callback
)
{
const
self
=
this
this
.
traceManager
.
waterfall
([
this
.
traceManager
.
getStackAt
,
function
getStackAt
(
stepIndex
,
callback
)
{
try
{
const
result
=
self
.
traceManager
.
getStackAt
(
stepIndex
)
callback
(
null
,
result
)
}
catch
(
error
)
{
callback
(
error
)
}
},
this
.
traceManager
.
getMemoryAt
,
function
getCurrentCalledAddressAt
(
stepIndex
,
next
)
{
try
{
...
...
libs/remix-debug/src/debugger/VmDebugger.js
View file @
3866faa9
...
...
@@ -87,14 +87,14 @@ class VmDebuggerLogic {
this
.
event
.
trigger
(
'traceManagerCallStackUpdate'
,
[{}])
}
this
.
_traceManager
.
getStackAt
(
index
,
(
error
,
callstack
)
=>
{
if
(
error
)
{
// console.log(error)
this
.
event
.
trigger
(
'traceManagerStackUpdate'
,
[{}])
}
else
if
(
this
.
stepManager
.
currentStepIndex
===
index
)
{
try
{
const
callstack
=
this
.
_traceManager
.
getStackAt
(
index
)
if
(
this
.
stepManager
.
currentStepIndex
===
index
)
{
this
.
event
.
trigger
(
'traceManagerStackUpdate'
,
[
callstack
])
}
})
}
catch
(
error
)
{
this
.
event
.
trigger
(
'traceManagerStackUpdate'
,
[{}])
}
try
{
const
address
=
this
.
_traceManager
.
getCurrentCalledAddressAt
(
index
)
...
...
libs/remix-debug/src/debugger/solidityLocals.js
View file @
3866faa9
...
...
@@ -30,9 +30,17 @@ class DebuggerSolidityLocals {
}
decode
(
sourceLocation
)
{
const
self
=
this
this
.
event
.
trigger
(
'solidityLocalsMessage'
,
[
''
])
this
.
traceManager
.
waterfall
([
this
.
traceManager
.
getStackAt
,
function
getStackAt
(
stepIndex
,
callback
)
{
try
{
const
result
=
self
.
traceManager
.
getStackAt
(
stepIndex
)
callback
(
null
,
result
)
}
catch
(
error
)
{
callback
(
error
)
}
},
this
.
traceManager
.
getMemoryAt
,
function
getCurrentCalledAddressAt
(
stepIndex
,
next
)
{
try
{
...
...
libs/remix-debug/src/solidity-decoder/internalCallTree.js
View file @
3866faa9
...
...
@@ -224,26 +224,26 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
// we check if the current vm trace step target a new ast node of type VariableDeclaration
// that way we know that there is a new local variable from here.
if
(
variableDeclaration
&&
!
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
attributes
.
name
])
{
tree
.
traceManager
.
getStackAt
(
step
,
(
error
,
stack
)
=>
{
try
{
const
stack
=
tree
.
traceManager
.
getStackAt
(
step
)
// the stack length at this point is where the value of the new local variable will be stored.
// so, either this is the direct value, or the offset in memory. That depends on the type.
if
(
!
error
)
{
tree
.
solidityProxy
.
contractNameAt
(
step
,
(
error
,
contractName
)
=>
{
// cached
if
(
!
error
&&
variableDeclaration
.
attributes
.
name
!==
''
)
{
var
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
var
location
=
typesUtil
.
extractLocationFromAstVariable
(
variableDeclaration
)
location
=
location
===
'default'
?
'storage'
:
location
tree
.
solidityProxy
.
contractNameAt
(
step
,
(
error
,
contractName
)
=>
{
// cached
if
(
!
error
&&
variableDeclaration
.
attributes
.
name
!==
''
)
{
var
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
var
location
=
typesUtil
.
extractLocationFromAstVariable
(
variableDeclaration
)
location
=
location
===
'default'
?
'storage'
:
location
// we push the new local variable in our tree
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
attributes
.
name
]
=
{
name
:
variableDeclaration
.
attributes
.
name
,
type
:
decodeInfo
.
parseType
(
variableDeclaration
.
attributes
.
type
,
states
,
contractName
,
location
),
stackDepth
:
stack
.
length
,
sourceLocation
:
sourceLocation
}
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
attributes
.
name
]
=
{
name
:
variableDeclaration
.
attributes
.
name
,
type
:
decodeInfo
.
parseType
(
variableDeclaration
.
attributes
.
type
,
states
,
contractName
,
location
),
stackDepth
:
stack
.
length
,
sourceLocation
:
sourceLocation
}
})
}
})
}
})
}
catch
(
error
)
{
}
}
// we check here if we are at the beginning inside a new function.
// if that is the case, we have to add to locals tree the inputs and output params
...
...
@@ -253,34 +253,36 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
const
functionDefinitionAndInputs
=
{
functionDefinition
,
inputs
:
[]}
// means: the previous location was a function definition && JUMPDEST
// => we are at the beginning of the function and input/output are setup
tree
.
solidityProxy
.
contractNameAt
(
step
,
(
error
,
contractName
)
=>
{
// cached
if
(
!
error
)
{
tree
.
traceManager
.
getStackAt
(
step
,
(
error
,
stack
)
=>
{
if
(
!
error
)
{
var
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
if
(
functionDefinition
.
children
&&
functionDefinition
.
children
.
length
)
{
let
inputs
let
outputs
for
(
const
element
of
functionDefinition
.
children
)
{
if
(
element
.
name
===
'ParameterList'
)
{
if
(
!
inputs
)
inputs
=
element
else
{
outputs
=
element
break
}
try
{
const
stack
=
tree
.
traceManager
.
getStackAt
(
step
)
var
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
if
(
functionDefinition
.
children
&&
functionDefinition
.
children
.
length
)
{
let
inputs
let
outputs
for
(
const
element
of
functionDefinition
.
children
)
{
if
(
element
.
name
===
'ParameterList'
)
{
if
(
!
inputs
)
inputs
=
element
else
{
outputs
=
element
break
}
}
// input params
if
(
inputs
)
{
functionDefinitionAndInputs
.
inputs
=
addParams
(
inputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
inputs
.
children
.
length
,
-
1
)
}
// output params
if
(
outputs
)
addParams
(
outputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
0
,
1
)
}
// input params
if
(
inputs
)
{
functionDefinitionAndInputs
.
inputs
=
addParams
(
inputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
inputs
.
children
.
length
,
-
1
)
}
// output params
if
(
outputs
)
addParams
(
outputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
0
,
1
)
}
})
}
catch
(
error
)
{
}
}
})
tree
.
functionDefinitionsByScope
[
scopeId
]
=
functionDefinitionAndInputs
}
}
...
...
libs/remix-debug/test/debugger.js
View file @
3866faa9
...
...
@@ -193,23 +193,27 @@ function testDebugging (debugManager) {
// stack
tape
(
'traceManager.getStackAt 4'
,
(
t
)
=>
{
t
.
plan
(
1
)
debugManager
.
traceManager
.
getStackAt
(
4
,
(
error
,
callstack
)
=>
{
if
(
error
)
return
t
.
end
(
error
)
t
.
equal
(
JSON
.
stringify
(
callstack
),
JSON
.
stringify
([
'0x0000000000000000000000000000000000000000000000000000000000000000'
]))
})
try
{
const
callstack
=
debugManager
.
traceManager
.
getStackAt
(
4
)
t
.
equal
(
JSON
.
stringify
(
callstack
),
JSON
.
stringify
([
'0x0000000000000000000000000000000000000000000000000000000000000000'
]))
}
catch
(
error
)
{
return
t
.
end
(
error
)
}
})
tape
(
'traceManager.getStackAt 41'
,
(
t
)
=>
{
t
.
plan
(
1
)
debugManager
.
traceManager
.
getStackAt
(
41
,
(
error
,
callstack
)
=>
{
if
(
error
)
return
t
.
end
(
error
)
try
{
const
callstack
=
debugManager
.
traceManager
.
getStackAt
(
41
)
t
.
equal
(
JSON
.
stringify
(
callstack
),
JSON
.
stringify
([
'0x0000000000000000000000000000000000000000000000000000000000000080'
,
'0x0000000000000000000000000000000000000000000000000000000000000020'
,
'0x0000000000000000000000000000000000000000000000000000000000000080'
,
'0x00000000000000000000000000000000000000000000000000000000000000e0'
,
'0x00000000000000000000000000000000000000000000000000000000000000e0'
]))
})
}
catch
(
error
)
{
return
t
.
end
(
error
)
}
})
// storage
...
...
libs/remix-debug/test/decoder/localsTests/helper.js
View file @
3866faa9
...
...
@@ -7,7 +7,14 @@ var localDecoder = require('../../../src/solidity-decoder/localDecoder')
function
decodeLocal
(
st
,
index
,
traceManager
,
callTree
,
verifier
)
{
try
{
traceManager
.
waterfall
([
traceManager
.
getStackAt
,
function
getStackAt
(
stepIndex
,
callback
)
{
try
{
const
result
=
traceManager
.
getStackAt
(
stepIndex
)
callback
(
null
,
result
)
}
catch
(
error
)
{
callback
(
error
)
}
},
traceManager
.
getMemoryAt
],
index
,
function
(
error
,
result
)
{
...
...
libs/remix-lib/src/trace/traceManager.js
View file @
3866faa9
...
...
@@ -124,19 +124,14 @@ TraceManager.prototype.getCallStackAt = function (stepIndex) {
return
call
.
callStack
}
TraceManager
.
prototype
.
getStackAt
=
function
(
stepIndex
,
callback
)
{
try
{
this
.
checkRequestedStep
(
stepIndex
)
}
catch
(
check
)
{
return
callback
(
check
,
null
)
}
let
stack
TraceManager
.
prototype
.
getStackAt
=
function
(
stepIndex
)
{
this
.
checkRequestedStep
(
stepIndex
)
if
(
this
.
trace
[
stepIndex
]
&&
this
.
trace
[
stepIndex
].
stack
)
{
// there's always a stack
stack
=
this
.
trace
[
stepIndex
].
stack
.
slice
(
0
)
let
stack
=
this
.
trace
[
stepIndex
].
stack
.
slice
(
0
)
stack
.
reverse
()
callback
(
null
,
stack
)
return
stack
}
else
{
callback
(
'no stack found'
,
null
)
throw
new
Error
(
'no stack found'
)
}
}
...
...
libs/remix-lib/test/traceManager.js
View file @
3866faa9
...
...
@@ -96,24 +96,22 @@ tape('TraceManager', function (t) {
t
.
test
(
'TraceManager.getStackAt'
,
function
(
st
)
{
st
.
plan
(
3
)
traceManager
.
getStackAt
(
0
,
function
(
error
,
result
)
{
try
{
const
result
=
traceManager
.
getStackAt
(
0
)
console
.
log
(
result
)
if
(
error
)
{
st
.
fail
(
error
)
}
else
{
st
.
ok
(
result
.
length
===
0
)
}
})
st
.
ok
(
result
.
length
===
0
)
}
catch
(
error
)
{
st
.
fail
(
error
)
}
traceManager
.
getStackAt
(
28
,
function
(
error
,
result
)
{
try
{
const
result
=
traceManager
.
getStackAt
(
28
)
console
.
log
(
result
)
if
(
error
)
{
st
.
fail
(
error
)
}
else
{
st
.
ok
(
result
.
length
===
4
)
st
.
ok
(
result
[
3
]
===
'0x60fe47b1'
)
}
})
st
.
ok
(
result
.
length
===
4
)
st
.
ok
(
result
[
3
]
===
'0x60fe47b1'
)
}
catch
(
error
)
{
st
.
fail
(
error
)
}
})
t
.
test
(
'TraceManager.getLastCallChangeSince'
,
function
(
st
)
{
...
...
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