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
39efcc85
Commit
39efcc85
authored
Apr 20, 2020
by
yann300
Committed by
Iuri Matias
May 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function stack trace
parent
29c4f59c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
10 deletions
+42
-10
package.json
package.json
+1
-1
VmDebugger.js
remix-debug/src/debugger/VmDebugger.js
+2
-0
internalCallTree.js
remix-debug/src/solidity-decoder/internalCallTree.js
+39
-9
No files found.
package.json
View file @
39efcc85
...
...
@@ -7,7 +7,7 @@
"scripts"
:
{
"diff"
:
"lerna diff"
,
"updated"
:
"lerna updated"
,
"bootstrap"
:
"
npm run build-ts-packages; lerna bootstrap
"
,
"bootstrap"
:
"
lerna bootstrap; npm run build-ts-packages
"
,
"build-ts-packages"
:
"lerna run --scope 'remix-analyzer' --scope 'remix-astwalker' --scope 'remix-solidity' --scope 'remix-tests' --scope 'remix-url-resolver' build"
,
"publish"
:
"npm run build-ts-packages; lerna publish"
,
"release"
:
"lerna bootstrap; lerna publish;"
,
...
...
remix-debug/src/debugger/VmDebugger.js
View file @
39efcc85
...
...
@@ -58,6 +58,8 @@ class VmDebuggerLogic {
this
.
event
.
trigger
(
'indexUpdate'
,
[
index
])
this
.
event
.
trigger
(
'functionsStackUpdate'
,
[
this
.
_callTree
.
retrieveFunctionsStack
(
index
)])
this
.
_traceManager
.
getCallDataAt
(
index
,
(
error
,
calldata
)
=>
{
if
(
error
)
{
// console.log(error)
...
...
remix-debug/src/solidity-decoder/internalCallTree.js
View file @
39efcc85
...
...
@@ -66,6 +66,7 @@ class InternalCallTree {
*/
this
.
sourceLocationTracker
.
clearCache
()
this
.
functionCallStack
=
[]
this
.
functionDefinitionsByScope
=
{}
this
.
scopeStarts
=
{}
this
.
variableDeclarationByFile
=
{}
this
.
functionDefinitionByFile
=
{}
...
...
@@ -79,21 +80,43 @@ class InternalCallTree {
* @param {Int} vmtraceIndex - index on the vm trace
*/
findScope
(
vmtraceIndex
)
{
const
scopes
=
Object
.
keys
(
this
.
scopeStarts
)
if
(
!
scopes
.
length
)
{
return
null
}
let
scopeId
=
util
.
findLowerBoundValue
(
vmtraceIndex
,
scopes
)
scopeId
=
this
.
scopeStarts
[
scopeId
]
let
scopeId
=
this
.
findScopeId
(
vmtraceIndex
)
if
(
!
scopeId
)
return
null
let
scope
=
this
.
scopes
[
scopeId
]
while
(
scope
.
lastStep
&&
scope
.
lastStep
<
vmtraceIndex
&&
scope
.
firstStep
>
0
)
{
const
matched
=
scopeId
.
match
(
/
(
.
\d
|
\d)
$/
)
scopeId
=
scopeId
.
replace
(
matched
[
1
],
''
)
scopeId
=
this
.
parentScope
(
scopeId
)
scope
=
this
.
scopes
[
scopeId
]
}
return
scope
}
parentScope
(
scopeId
)
{
const
matched
=
scopeId
.
match
(
/
(
.
\d
|
\d)
$/
)
return
scopeId
.
replace
(
matched
[
1
],
''
)
}
findScopeId
(
vmtraceIndex
)
{
const
scopes
=
Object
.
keys
(
this
.
scopeStarts
)
if
(
!
scopes
.
length
)
return
null
const
scopeStart
=
util
.
findLowerBoundValue
(
vmtraceIndex
,
scopes
)
return
this
.
scopeStarts
[
scopeStart
]
}
retrieveFunctionsStack
(
vmtraceIndex
)
{
let
scope
=
this
.
findScope
(
vmtraceIndex
)
if
(
!
scope
)
return
[]
let
scopeId
=
this
.
scopeStarts
[
scope
.
firstStep
]
let
functions
=
[]
if
(
!
scopeId
)
return
functions
while
(
true
)
{
functions
.
push
(
this
.
functionDefinitionsByScope
[
scopeId
])
let
parent
=
this
.
parentScope
(
scopeId
)
if
(
!
parent
)
break
else
scopeId
=
parent
}
return
functions
}
extractSourceLocation
(
step
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
traceManager
.
getCurrentCalledAddressAt
(
step
,
(
error
,
address
)
=>
{
...
...
@@ -220,6 +243,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
const
functionDefinition
=
resolveFunctionDefinition
(
tree
,
step
,
previousSourceLocation
)
if
(
functionDefinition
&&
(
newLocation
&&
traceHelper
.
isJumpDestInstruction
(
tree
.
traceManager
.
trace
[
step
-
1
])
||
functionDefinition
.
attributes
.
isConstructor
))
{
tree
.
functionCallStack
.
push
(
step
)
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
...
...
@@ -240,7 +264,9 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
}
}
// input params
if
(
inputs
)
addParams
(
inputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
inputs
.
children
.
length
,
-
1
)
if
(
inputs
)
{
functionDefinitionAndInputs
.
inputs
.
push
(
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
)
}
...
...
@@ -248,6 +274,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
})
}
})
tree
.
functionDefinitionsByScope
[
scopeId
]
=
functionDefinitionAndInputs
}
}
...
...
@@ -304,6 +331,7 @@ function extractFunctionDefinitions (ast, astWalker) {
}
function
addParams
(
parameterList
,
tree
,
scopeId
,
states
,
contractName
,
sourceLocation
,
stackLength
,
stackPosition
,
dir
)
{
let
params
=
[]
for
(
let
inputParam
in
parameterList
.
children
)
{
const
param
=
parameterList
.
children
[
inputParam
]
const
stackDepth
=
stackLength
+
(
dir
*
stackPosition
)
...
...
@@ -317,9 +345,11 @@ function addParams (parameterList, tree, scopeId, states, contractName, sourceLo
stackDepth
:
stackDepth
,
sourceLocation
:
sourceLocation
}
params
.
push
(
attributesName
)
}
stackPosition
+=
dir
}
return
params
}
module
.
exports
=
InternalCallTree
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