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
826855f3
Commit
826855f3
authored
Jul 17, 2020
by
Iuri Matias
Committed by
aniket-engg
Aug 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refacto getMemoryAt
parent
3866faa9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
78 deletions
+90
-78
Ethdebugger.js
libs/remix-debug/src/Ethdebugger.js
+9
-1
VmDebugger.js
libs/remix-debug/src/debugger/VmDebugger.js
+6
-6
solidityLocals.js
libs/remix-debug/src/debugger/solidityLocals.js
+8
-1
internalCallTree.js
libs/remix-debug/src/solidity-decoder/internalCallTree.js
+23
-25
solidityProxy.js
libs/remix-debug/src/solidity-decoder/solidityProxy.js
+17
-21
helper.js
libs/remix-debug/test/decoder/localsTests/helper.js
+8
-1
traceManager.js
libs/remix-lib/src/trace/traceManager.js
+6
-8
traceManager.js
libs/remix-lib/test/traceManager.js
+13
-15
No files found.
libs/remix-debug/src/Ethdebugger.js
View file @
826855f3
...
...
@@ -98,7 +98,15 @@ Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback)
callback
(
error
)
}
},
this
.
traceManager
.
getMemoryAt
,
function
getMemoryAt
(
stepIndex
,
callback
)
{
try
{
const
result
=
self
.
traceManager
.
getMemoryAt
(
stepIndex
)
callback
(
null
,
result
)
}
catch
(
error
)
{
callback
(
error
)
}
},
function
getCurrentCalledAddressAt
(
stepIndex
,
next
)
{
try
{
const
address
=
self
.
traceManager
.
getCurrentCalledAddressAt
(
stepIndex
)
...
...
libs/remix-debug/src/debugger/VmDebugger.js
View file @
826855f3
...
...
@@ -69,14 +69,14 @@ class VmDebuggerLogic {
}
})
this
.
_traceManager
.
getMemoryAt
(
index
,
(
error
,
memory
)
=>
{
if
(
error
)
{
// console.log(error)
this
.
event
.
trigger
(
'traceManagerMemoryUpdate'
,
[{}])
}
else
if
(
this
.
stepManager
.
currentStepIndex
===
index
)
{
try
{
const
memory
=
this
.
_traceManager
.
getMemoryAt
(
index
)
if
(
this
.
stepManager
.
currentStepIndex
===
index
)
{
this
.
event
.
trigger
(
'traceManagerMemoryUpdate'
,
[
ui
.
formatMemory
(
memory
,
16
)])
}
})
}
catch
(
error
)
{
this
.
event
.
trigger
(
'traceManagerMemoryUpdate'
,
[{}])
}
try
{
const
callstack
=
this
.
_traceManager
.
getCallStackAt
(
index
)
...
...
libs/remix-debug/src/debugger/solidityLocals.js
View file @
826855f3
...
...
@@ -41,7 +41,14 @@ class DebuggerSolidityLocals {
callback
(
error
)
}
},
this
.
traceManager
.
getMemoryAt
,
function
getMemoryAt
(
stepIndex
,
callback
)
{
try
{
const
result
=
self
.
traceManager
.
getMemoryAt
(
stepIndex
)
callback
(
null
,
result
)
}
catch
(
error
)
{
callback
(
error
)
}
},
function
getCurrentCalledAddressAt
(
stepIndex
,
next
)
{
try
{
const
address
=
this
.
traceManager
.
getCurrentCalledAddressAt
(
stepIndex
)
...
...
libs/remix-debug/src/solidity-decoder/internalCallTree.js
View file @
826855f3
...
...
@@ -228,8 +228,8 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
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.
tree
.
solidityProxy
.
contractNameAt
(
step
,
(
error
,
contractName
)
=>
{
// cached
if
(
!
error
&&
variableDeclaration
.
attributes
.
name
!==
''
)
{
tree
.
solidityProxy
.
contractNameAt
(
step
).
then
((
contractName
)
=>
{
if
(
variableDeclaration
.
attributes
.
name
!==
''
)
{
var
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
var
location
=
typesUtil
.
extractLocationFromAstVariable
(
variableDeclaration
)
location
=
location
===
'default'
?
'storage'
:
location
...
...
@@ -242,7 +242,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
}
}
})
}
catch
(
error
)
{
}
catch
(
_
error
)
{
}
}
// we check here if we are at the beginning inside a new function.
...
...
@@ -254,32 +254,30 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
// 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
)
{
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
}
tree
.
solidityProxy
.
contractNameAt
(
step
).
then
((
contractName
)
=>
{
// cached
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
)
}
}
catch
(
error
)
{
// 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
)
{
}
})
...
...
libs/remix-debug/src/solidity-decoder/solidityProxy.js
View file @
826855f3
...
...
@@ -39,26 +39,25 @@ class SolidityProxy {
* @param {Int} vmTraceIndex - index in the vm trave where to resolve the executed contract name
* @param {Function} cb - callback returns (error, contractName)
*/
contractNameAt
(
vmTraceIndex
,
cb
)
{
try
{
const
address
=
this
.
traceManager
.
getCurrentCalledAddressAt
(
vmTraceIndex
)
if
(
this
.
cache
.
contractNameByAddress
[
address
])
{
cb
(
null
,
this
.
cache
.
contractNameByAddress
[
address
])
}
else
{
contractNameAt
(
vmTraceIndex
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
const
address
=
this
.
traceManager
.
getCurrentCalledAddressAt
(
vmTraceIndex
)
if
(
this
.
cache
.
contractNameByAddress
[
address
])
{
return
resolve
(
this
.
cache
.
contractNameByAddress
[
address
])
}
this
.
codeManager
.
getCode
(
address
,
(
error
,
code
)
=>
{
if
(
error
)
{
cb
(
error
)
}
else
{
const
contractName
=
contractNameFromCode
(
this
.
contracts
,
code
.
bytecode
,
address
)
this
.
cache
.
contractNameByAddress
[
address
]
=
contractName
cb
(
null
,
contractName
)
return
reject
(
error
)
}
const
contractName
=
contractNameFromCode
(
this
.
contracts
,
code
.
bytecode
,
address
)
this
.
cache
.
contractNameByAddress
[
address
]
=
contractName
resolve
(
contractName
)
})
}
catch
(
error
)
{
reject
(
error
)
}
}
catch
(
error
)
{
cb
(
error
)
}
})
}
/**
...
...
@@ -98,12 +97,9 @@ class SolidityProxy {
*/
extractStateVariablesAt
(
vmtraceIndex
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
contractNameAt
(
vmtraceIndex
,
(
error
,
contractName
)
=>
{
if
(
error
)
{
return
reject
(
error
)
}
return
resolve
(
this
.
extractStateVariables
(
contractName
))
})
this
.
contractNameAt
(
vmtraceIndex
).
then
((
contractName
)
=>
{
resolve
(
this
.
extractStateVariables
(
contractName
))
}).
catch
(
reject
)
})
}
...
...
libs/remix-debug/test/decoder/localsTests/helper.js
View file @
826855f3
...
...
@@ -15,7 +15,14 @@ function decodeLocal (st, index, traceManager, callTree, verifier) {
callback
(
error
)
}
},
traceManager
.
getMemoryAt
],
function
getMemoryAt
(
stepIndex
,
callback
)
{
try
{
const
result
=
traceManager
.
getMemoryAt
(
stepIndex
)
callback
(
null
,
result
)
}
catch
(
error
)
{
callback
(
error
)
}
}],
index
,
function
(
error
,
result
)
{
if
(
!
error
)
{
...
...
libs/remix-lib/src/trace/traceManager.js
View file @
826855f3
...
...
@@ -170,15 +170,13 @@ TraceManager.prototype.getContractCreationCode = function (token, callback) {
}
}
TraceManager
.
prototype
.
getMemoryAt
=
function
(
stepIndex
,
callback
)
{
try
{
this
.
checkRequestedStep
(
stepIndex
)
}
catch
(
check
)
{
return
callback
(
check
,
null
)
}
TraceManager
.
prototype
.
getMemoryAt
=
function
(
stepIndex
)
{
this
.
checkRequestedStep
(
stepIndex
)
const
lastChanges
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
memoryChanges
)
if
(
lastChanges
===
null
)
return
callback
(
'no memory found'
,
null
)
callback
(
null
,
this
.
trace
[
lastChanges
].
memory
)
if
(
lastChanges
===
null
)
{
throw
new
Error
(
'no memory found'
)
}
return
this
.
trace
[
lastChanges
].
memory
}
TraceManager
.
prototype
.
getCurrentPC
=
function
(
stepIndex
,
callback
)
{
...
...
libs/remix-lib/test/traceManager.js
View file @
826855f3
...
...
@@ -186,24 +186,22 @@ tape('TraceManager', function (t) {
t
.
test
(
'TraceManager.getMemoryAt'
,
function
(
st
)
{
st
.
plan
(
3
)
traceManager
.
getMemoryAt
(
0
,
function
(
error
,
result
)
{
try
{
const
result
=
traceManager
.
getMemoryAt
(
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
.
getMemoryAt
(
34
,
function
(
error
,
result
)
{
try
{
const
result
=
traceManager
.
getMemoryAt
(
34
)
console
.
log
(
result
)
if
(
error
)
{
st
.
fail
(
error
)
}
else
{
st
.
ok
(
result
.
length
===
3
)
st
.
ok
(
result
[
2
]
===
'0000000000000000000000000000000000000000000000000000000000000060'
)
}
})
st
.
ok
(
result
.
length
===
3
)
st
.
ok
(
result
[
2
]
===
'0000000000000000000000000000000000000000000000000000000000000060'
)
}
catch
(
error
)
{
st
.
fail
(
error
)
}
})
t
.
test
(
'TraceManager.getCurrentPC'
,
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