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
9305829a
Commit
9305829a
authored
Jul 12, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display full storages changes
parent
14e1dc2e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
22 deletions
+103
-22
BasicPanel.js
src/BasicPanel.js
+14
-3
StoragePanel.js
src/StoragePanel.js
+5
-2
TxBrowser.js
src/TxBrowser.js
+1
-1
VmDebugger.js
src/VmDebugger.js
+35
-1
ui.js
src/helpers/ui.js
+3
-1
traceAnalyser.js
src/trace/traceAnalyser.js
+16
-5
traceCache.js
src/trace/traceCache.js
+9
-7
traceManager.js
src/trace/traceManager.js
+20
-2
No files found.
src/BasicPanel.js
View file @
9305829a
...
...
@@ -3,9 +3,12 @@ var style = require('./styles/basicStyles')
var
yo
=
require
(
'yo-yo'
)
var
ui
=
require
(
'./helpers/ui'
)
function
BasicPanel
(
_name
)
{
function
BasicPanel
(
_name
,
_id
,
_width
,
_height
)
{
this
.
data
this
.
name
=
_name
this
.
id
=
_id
this
.
width
=
_width
this
.
height
=
_height
this
.
view
}
...
...
@@ -13,12 +16,20 @@ BasicPanel.prototype.update = function () {
yo
.
update
(
this
.
view
,
this
.
render
())
}
BasicPanel
.
prototype
.
hide
=
function
()
{
document
.
getElementById
(
this
.
id
+
'container'
).
style
.
display
=
'none'
}
BasicPanel
.
prototype
.
show
=
function
()
{
document
.
getElementById
(
this
.
id
+
'container'
).
style
.
display
=
'block'
}
BasicPanel
.
prototype
.
render
=
function
()
{
var
view
=
yo
`<div
style=
${
ui
.
formatCss
(
style
.
panel
.
container
)}
>
var
view
=
yo
`<div
id='
${
this
.
id
}
container' style=
${
ui
.
formatCss
({
'width'
:
this
.
width
},
style
.
panel
.
container
)}
>
<div style=
${
ui
.
formatCss
(
style
.
panel
.
title
)}
>
${
this
.
name
}
</div>
<div style=
${
ui
.
formatCss
(
style
.
panel
.
tableContainer
)}
>
<div style=
${
ui
.
formatCss
({
'height'
:
this
.
height
},
style
.
panel
.
tableContainer
)}
>
<pre style=
${
ui
.
formatCss
(
style
.
panel
.
table
,
style
.
font
)}
id='basicpanel' >
${
this
.
data
}
</pre>
</div>
</div>`
...
...
src/StoragePanel.js
View file @
9305829a
...
...
@@ -2,11 +2,13 @@
var
BasicPanel
=
require
(
'./BasicPanel'
)
var
yo
=
require
(
'yo-yo'
)
function
StoragePanel
(
_parent
,
_traceManager
)
{
function
StoragePanel
(
_parent
,
_traceManager
,
_address
)
{
this
.
parent
=
_parent
this
.
traceManager
=
_traceManager
this
.
basicPanel
=
new
BasicPanel
(
'Storage Changes'
)
this
.
address
=
_address
this
.
init
()
this
.
disabled
=
false
}
StoragePanel
.
prototype
.
render
=
function
()
{
...
...
@@ -16,6 +18,7 @@ StoragePanel.prototype.render = function () {
StoragePanel
.
prototype
.
init
=
function
()
{
var
self
=
this
this
.
parent
.
register
(
'indexChanged'
,
this
,
function
(
index
)
{
if
(
self
.
disabled
)
return
if
(
index
<
0
)
return
if
(
self
.
parent
.
currentStepIndex
!==
index
)
return
...
...
@@ -27,7 +30,7 @@ StoragePanel.prototype.init = function () {
self
.
basicPanel
.
data
=
self
.
formatStorage
(
storage
)
}
self
.
basicPanel
.
update
()
})
}
,
self
.
address
)
})
}
...
...
src/TxBrowser.js
View file @
9305829a
...
...
@@ -31,7 +31,7 @@ TxBrowser.prototype.setDefaultValues = function () {
this
.
to
=
' - '
this
.
hash
=
' - '
this
.
blockNumber
=
null
this
.
txNumber
=
'0x
cda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff
'
this
.
txNumber
=
'0x
20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51
'
this
.
connectInfo
=
''
this
.
updateWeb3Url
(
this
.
web3
.
currentProvider
.
host
)
}
...
...
src/VmDebugger.js
View file @
9305829a
...
...
@@ -6,6 +6,8 @@ var MemoryPanel = require('./MemoryPanel')
var
CallstackPanel
=
require
(
'./CallstackPanel'
)
var
StackPanel
=
require
(
'./StackPanel'
)
var
StoragePanel
=
require
(
'./StoragePanel'
)
var
BasicPanel
=
require
(
'./BasicPanel'
)
var
FullStoragesChangesPanel
=
require
(
'./FullStoragesChanges'
)
var
yo
=
require
(
'yo-yo'
)
var
ui
=
require
(
'./helpers/ui'
)
...
...
@@ -16,6 +18,28 @@ function VmDebugger (_parent, _traceManager, _web3) {
this
.
memoryPanel
=
new
MemoryPanel
(
_parent
,
_traceManager
)
this
.
calldataPanel
=
new
CalldataPanel
(
_parent
,
_traceManager
)
this
.
callstackPanel
=
new
CallstackPanel
(
_parent
,
_traceManager
)
/* Return values - */
this
.
returnValuesPanel
=
new
BasicPanel
(
'Return Values'
,
'returnvalues'
,
'auto'
,
'100px'
)
_parent
.
register
(
'indexChanged'
,
this
.
returnValuesPanel
,
function
(
index
)
{
var
self
=
this
_traceManager
.
getReturnValue
(
index
,
function
(
error
,
returnValue
)
{
if
(
error
)
{
console
.
log
(
error
)
self
.
data
=
''
}
else
if
(
_parent
.
currentStepIndex
===
index
)
{
self
.
data
=
returnValue
}
self
.
update
()
if
(
!
returnValue
)
{
self
.
hide
()
}
})
})
/* Return values - */
this
.
fullStoragesChangesPanel
=
new
FullStoragesChangesPanel
(
_parent
,
_traceManager
)
this
.
view
var
self
=
this
_parent
.
register
(
'newTraceLoaded'
,
this
,
function
()
{
...
...
@@ -30,7 +54,7 @@ VmDebugger.prototype.render = function () {
var
view
=
yo
`<div id='vmdebugger' style='display:none'>
<div style=
${
ui
.
formatCss
(
style
.
container
)}
>
<table>
<tbody>
<tbody>
<tr>
<td>
${
this
.
asmCode
.
render
()}
...
...
@@ -55,6 +79,16 @@ VmDebugger.prototype.render = function () {
${
this
.
callstackPanel
.
render
()}
</td>
</tr>
<tr>
<td colspan='2'>
${
this
.
returnValuesPanel
.
render
()}
</td>
</tr>
<tr>
<td colspan='2'>
${
this
.
fullStoragesChangesPanel
.
render
()}
</td>
</tr>
</tbody>
</table>
</div>
...
...
src/helpers/ui.js
View file @
9305829a
...
...
@@ -37,7 +37,9 @@ module.exports = {
var
ret
=
''
for
(
var
arg
in
arguments
)
{
for
(
var
k
in
arguments
[
arg
])
{
ret
+=
k
+
':'
+
arguments
[
arg
][
k
]
+
';'
if
(
arguments
[
arg
][
k
]
&&
ret
.
indexOf
(
k
)
===
-
1
)
{
ret
+=
k
+
':'
+
arguments
[
arg
][
k
]
+
';'
}
}
}
return
ret
...
...
src/trace/traceAnalyser.js
View file @
9305829a
...
...
@@ -29,10 +29,20 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
this
.
buildMemory
(
k
,
step
)
context
=
this
.
buildDepth
(
k
,
step
,
tx
,
callStack
,
context
)
context
=
this
.
buildStorage
(
k
,
step
,
context
)
this
.
buildReturnValues
(
k
,
step
)
}
callback
(
null
,
true
)
}
TraceAnalyser
.
prototype
.
buildReturnValues
=
function
(
index
,
step
)
{
if
(
traceHelper
.
isReturnInstruction
(
step
))
{
var
offset
=
2
*
parseInt
(
step
.
stack
[
step
.
stack
.
length
-
1
])
var
size
=
2
*
parseInt
(
step
.
stack
[
step
.
stack
.
length
-
2
])
var
memory
=
this
.
trace
[
this
.
traceCache
.
memoryChanges
[
this
.
traceCache
.
memoryChanges
.
length
-
1
]].
memory
this
.
traceCache
.
pushReturnValue
(
index
,
'0x'
+
memory
.
join
(
''
).
substr
(
offset
,
size
))
}
}
TraceAnalyser
.
prototype
.
buildCalldata
=
function
(
index
,
step
,
tx
,
newContext
)
{
var
calldata
=
''
if
(
index
===
0
)
{
...
...
@@ -85,20 +95,21 @@ TraceAnalyser.prototype.buildStorage = function (index, step, context) {
TraceAnalyser
.
prototype
.
buildDepth
=
function
(
index
,
step
,
tx
,
callStack
,
context
)
{
if
(
traceHelper
.
isCallInstruction
(
step
)
&&
!
traceHelper
.
isCallToPrecompiledContract
(
index
,
this
.
trace
))
{
var
newAddress
if
(
traceHelper
.
isCreateInstruction
(
step
))
{
var
contractToken
=
traceHelper
.
contractCreationToken
(
index
)
callStack
.
push
(
contractToken
)
newAddress
=
traceHelper
.
contractCreationToken
(
index
)
callStack
.
push
(
newAddress
)
var
lastMemoryChange
=
this
.
traceCache
.
memoryChanges
[
this
.
traceCache
.
memoryChanges
.
length
-
1
]
this
.
traceCache
.
pushContractCreationFromMemory
(
index
,
contractToken
,
this
.
trace
,
lastMemoryChange
)
this
.
traceCache
.
pushContractCreationFromMemory
(
index
,
newAddress
,
this
.
trace
,
lastMemoryChange
)
}
else
{
var
newAddress
=
traceHelper
.
resolveCalledAddress
(
index
,
this
.
trace
)
newAddress
=
traceHelper
.
resolveCalledAddress
(
index
,
this
.
trace
)
if
(
newAddress
)
{
callStack
.
push
(
newAddress
)
}
else
{
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
)
this
.
traceCache
.
pushCallChanges
(
step
,
index
+
1
,
newAddress
)
this
.
traceCache
.
pushCallStack
(
index
+
1
,
{
callStack
:
callStack
.
slice
(
0
)
})
...
...
src/trace/traceCache.js
View file @
9305829a
...
...
@@ -6,12 +6,13 @@ function TraceCache () {
TraceCache
.
prototype
.
init
=
function
()
{
// ...Changes contains index in the vmtrace of the corresponding changes
this
.
returnValues
=
{}
this
.
callChanges
=
[]
this
.
returnChanges
=
[]
this
.
calls
=
{}
this
.
callsData
=
{}
this
.
contractCreation
=
{}
this
.
steps
=
{}
this
.
addresses
=
[]
this
.
callDataChanges
=
[]
this
.
memoryChanges
=
[]
...
...
@@ -33,13 +34,18 @@ TraceCache.prototype.pushMemoryChanges = function (value) {
this
.
memoryChanges
.
push
(
value
)
}
TraceCache
.
prototype
.
pushCallChanges
=
function
(
step
,
value
)
{
TraceCache
.
prototype
.
pushCallChanges
=
function
(
step
,
value
,
address
)
{
this
.
callChanges
.
push
(
value
)
this
.
calls
[
value
]
=
{
op
:
step
.
op
op
:
step
.
op
,
address
:
address
}
}
TraceCache
.
prototype
.
pushReturnValue
=
function
(
step
,
value
)
{
this
.
returnValues
[
step
]
=
value
}
TraceCache
.
prototype
.
pushContractCreationFromMemory
=
function
(
index
,
token
,
trace
,
lastMemoryChange
)
{
var
memory
=
trace
[
lastMemoryChange
].
memory
var
stack
=
trace
[
index
].
stack
...
...
@@ -52,10 +58,6 @@ TraceCache.prototype.pushContractCreation = function (token, code) {
this
.
contractCreation
[
token
]
=
code
}
TraceCache
.
prototype
.
pushReturnChanges
=
function
(
value
)
{
this
.
returnChanges
.
push
(
value
)
}
TraceCache
.
prototype
.
pushCallStack
=
function
(
index
,
callStack
)
{
this
.
callStack
[
index
]
=
callStack
}
...
...
src/trace/traceManager.js
View file @
9305829a
...
...
@@ -73,14 +73,16 @@ TraceManager.prototype.getLength = function (callback) {
}
}
TraceManager
.
prototype
.
getStorageAt
=
function
(
stepIndex
,
tx
,
callback
)
{
TraceManager
.
prototype
.
getStorageAt
=
function
(
stepIndex
,
tx
,
callback
,
address
)
{
var
check
=
this
.
checkRequestedStep
(
stepIndex
)
if
(
check
)
{
return
callback
(
check
,
null
)
}
var
stoChange
=
traceHelper
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
storageChanges
)
if
(
stoChange
===
undefined
)
return
callback
(
'no storage found'
,
null
)
var
address
=
this
.
traceCache
.
sstore
[
stoChange
].
address
if
(
!
address
)
{
address
=
this
.
traceCache
.
sstore
[
stoChange
].
address
}
var
storage
=
{}
storage
=
this
.
traceCache
.
rebuildStorage
(
address
,
storage
,
stepIndex
)
callback
(
null
,
storage
)
...
...
@@ -104,6 +106,14 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback) {
*/
}
TraceManager
.
prototype
.
getAddresses
=
function
(
callback
)
{
var
addresses
=
{}
for
(
var
k
in
this
.
traceCache
.
calls
)
{
addresses
[
this
.
traceCache
.
calls
[
k
].
address
]
=
''
}
callback
(
null
,
addresses
)
}
TraceManager
.
prototype
.
getCallDataAt
=
function
(
stepIndex
,
callback
)
{
var
check
=
this
.
checkRequestedStep
(
stepIndex
)
if
(
check
)
{
...
...
@@ -203,6 +213,14 @@ TraceManager.prototype.getCurrentPC = function (stepIndex, callback) {
callback
(
null
,
this
.
trace
[
stepIndex
].
pc
)
}
TraceManager
.
prototype
.
getReturnValue
=
function
(
stepIndex
,
callback
)
{
var
check
=
this
.
checkRequestedStep
(
stepIndex
)
if
(
check
)
{
return
callback
(
check
,
null
)
}
callback
(
null
,
this
.
traceCache
.
returnValues
[
stepIndex
])
}
TraceManager
.
prototype
.
getCurrentStep
=
function
(
stepIndex
,
callback
)
{
var
check
=
this
.
checkRequestedStep
(
stepIndex
)
if
(
check
)
{
...
...
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