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
af1be323
Unverified
Commit
af1be323
authored
Apr 22, 2020
by
yann300
Committed by
GitHub
Apr 22, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1456 from ethereum/improveFetchingCompilationResult
Improve fetching compilation result
parents
8c6da69a
d7b71e52
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
26 deletions
+38
-26
Ethdebugger.js
remix-debug/src/Ethdebugger.js
+5
-7
index.js
remix-debug/src/cmdline/index.js
+4
-4
debugger.js
remix-debug/src/debugger/debugger.js
+13
-15
util.js
remix-lib/src/util.js
+16
-0
util.js
remix-lib/test/util.js
+0
-0
No files found.
remix-debug/src/Ethdebugger.js
View file @
af1be323
...
...
@@ -29,9 +29,7 @@ const EventManager = remixLib.EventManager
* @param {Map} opts - { function compilationResult } //
*/
function
Ethdebugger
(
opts
)
{
this
.
opts
=
opts
||
{}
if
(
!
this
.
opts
.
compilationResult
)
this
.
opts
.
compilationResult
=
()
=>
{
return
null
}
this
.
compilationResult
=
opts
.
compilationResult
||
function
(
contractAddress
)
{
return
null
}
this
.
web3
=
opts
.
web3
this
.
event
=
new
EventManager
()
...
...
@@ -60,8 +58,8 @@ Ethdebugger.prototype.resolveStep = function (index) {
}
Ethdebugger
.
prototype
.
setCompilationResult
=
function
(
compilationResult
)
{
if
(
compilationResult
&&
compilationResult
.
sources
&&
compilationResult
.
contracts
)
{
this
.
solidityProxy
.
reset
(
compilationResult
)
if
(
compilationResult
&&
compilationResult
.
data
)
{
this
.
solidityProxy
.
reset
(
compilationResult
.
data
)
}
else
{
this
.
solidityProxy
.
reset
({})
}
...
...
@@ -173,10 +171,10 @@ Ethdebugger.prototype.debug = function (tx) {
if
(
!
tx
.
to
)
{
tx
.
to
=
traceHelper
.
contractCreationToken
(
'0'
)
}
this
.
setCompilationResult
(
this
.
opts
.
compilationResult
())
this
.
tx
=
tx
this
.
traceManager
.
resolveTrace
(
tx
,
(
error
,
result
)
=>
{
this
.
traceManager
.
resolveTrace
(
tx
,
async
(
error
,
result
)
=>
{
if
(
result
)
{
this
.
setCompilationResult
(
await
this
.
compilationResult
(
tx
.
to
))
this
.
event
.
trigger
(
'newTraceLoaded'
,
[
this
.
traceManager
.
trace
])
if
(
this
.
breakpointManager
&&
this
.
breakpointManager
.
hasBreakpoint
())
{
this
.
breakpointManager
.
jumpNextBreakpoint
(
false
)
...
...
remix-debug/src/cmdline/index.js
View file @
af1be323
...
...
@@ -28,7 +28,7 @@ class CmdLine {
loadCompilationResult
(
compilationResult
)
{
this
.
compilation
=
{}
this
.
compilation
.
lastC
ompilationResult
=
compilationResult
this
.
compilation
.
c
ompilationResult
=
compilationResult
}
initDebugger
(
cb
)
{
...
...
@@ -36,7 +36,7 @@ class CmdLine {
this
.
debugger
=
new
Debugger
({
web3
:
this
.
contextManager
.
getWeb3
(),
compil
er
:
this
.
compilation
compil
ationResult
:
()
=>
{
return
this
.
compilation
.
compilationResult
}
})
this
.
contextManager
.
event
.
register
(
'providerChanged'
,
()
=>
{
...
...
@@ -54,7 +54,7 @@ class CmdLine {
if
(
!
lineColumnPos
||
!
lineColumnPos
.
start
)
return
[]
const
content
=
this
.
compilation
.
lastC
ompilationResult
.
source
.
sources
[
this
.
filename
].
content
.
split
(
'
\
n'
)
const
content
=
this
.
compilation
.
c
ompilationResult
.
source
.
sources
[
this
.
filename
].
content
.
split
(
'
\
n'
)
const
source
=
[]
...
...
@@ -85,7 +85,7 @@ class CmdLine {
const
lineColumnPos
=
this
.
lineColumnPos
if
(
!
lineColumnPos
)
return
''
const
currentLineNumber
=
lineColumnPos
.
start
.
line
const
content
=
this
.
compilation
.
lastC
ompilationResult
.
source
.
sources
[
this
.
filename
].
content
.
split
(
'
\
n'
)
const
content
=
this
.
compilation
.
c
ompilationResult
.
source
.
sources
[
this
.
filename
].
content
.
split
(
'
\
n'
)
return
content
[
currentLineNumber
]
}
...
...
remix-debug/src/debugger/debugger.js
View file @
af1be323
...
...
@@ -12,21 +12,19 @@ function Debugger (options) {
this
.
event
=
new
EventManager
()
this
.
offsetToLineColumnConverter
=
options
.
offsetToLineColumnConverter
||
(
new
OffsetToColumnConverter
())
this
.
compiler
=
options
.
compiler
/*
Returns a compilation result for a given address or the last one available if none are found
*/
this
.
compilationResult
=
options
.
compilationResult
||
function
(
contractAddress
)
{
return
null
}
this
.
debugger
=
new
Ethdebugger
({
web3
:
options
.
web3
,
compilationResult
:
()
=>
{
var
compilationResult
=
this
.
compiler
.
lastCompilationResult
if
(
compilationResult
)
{
return
compilationResult
.
data
}
return
null
}
compilationResult
:
this
.
compilationResult
})
this
.
breakPointManager
=
new
remixLib
.
code
.
BreakpointManager
(
this
.
debugger
,
(
sourceLocation
)
=>
{
return
this
.
offsetToLineColumnConverter
.
offsetToLineColumn
(
sourceLocation
,
sourceLocation
.
file
,
this
.
compiler
.
lastCompilationResult
.
source
.
sources
,
this
.
compiler
.
lastCompilationResult
.
data
.
sources
)
this
.
breakPointManager
=
new
remixLib
.
code
.
BreakpointManager
(
this
.
debugger
,
async
(
sourceLocation
)
=>
{
const
compilationResult
=
await
this
.
compilationResult
()
return
this
.
offsetToLineColumnConverter
.
offsetToLineColumn
(
sourceLocation
,
sourceLocation
.
file
,
compilationResult
.
source
.
sources
,
compilationResult
.
data
.
sources
)
},
(
step
)
=>
{
this
.
event
.
trigger
(
'breakpointStep'
,
[
step
])
})
...
...
@@ -48,12 +46,12 @@ function Debugger (options) {
Debugger
.
prototype
.
registerAndHighlightCodeItem
=
function
(
index
)
{
// register selected code item, highlight the corresponding source location
if
(
!
this
.
compiler
.
lastCompilationResult
)
return
this
.
debugger
.
traceManager
.
getCurrentCalledAddressAt
(
index
,
(
error
,
address
)
=>
{
this
.
debugger
.
traceManager
.
getCurrentCalledAddressAt
(
index
,
async
(
error
,
address
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
this
.
debugger
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
address
,
index
,
this
.
compiler
.
lastCompilationResult
.
data
.
contracts
,
(
error
,
rawLocation
)
=>
{
if
(
!
error
&&
this
.
compiler
.
lastCompilationResult
&&
this
.
compiler
.
lastCompilationResult
.
data
)
{
var
lineColumnPos
=
this
.
offsetToLineColumnConverter
.
offsetToLineColumn
(
rawLocation
,
rawLocation
.
file
,
this
.
compiler
.
lastCompilationResult
.
source
.
sources
,
this
.
compiler
.
lastCompilationResult
.
data
.
sources
)
const
compilationResultForAddress
=
await
this
.
compilationResult
(
address
)
this
.
debugger
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
address
,
index
,
compilationResultForAddress
.
data
.
contracts
,
(
error
,
rawLocation
)
=>
{
if
(
!
error
&&
compilationResultForAddress
&&
compilationResultForAddress
.
data
)
{
var
lineColumnPos
=
this
.
offsetToLineColumnConverter
.
offsetToLineColumn
(
rawLocation
,
rawLocation
.
file
,
compilationResultForAddress
.
source
.
sources
,
compilationResultForAddress
.
data
.
sources
)
this
.
event
.
trigger
(
'newSourceLocation'
,
[
lineColumnPos
,
rawLocation
])
}
else
{
this
.
event
.
trigger
(
'newSourceLocation'
,
[
null
])
...
...
remix-lib/src/util.js
View file @
af1be323
...
...
@@ -193,6 +193,19 @@ module.exports = {
return
/a265627a7a72305820
([
0-9a-f
]{64})
64736f6c6343
([
0-9a-f
]{6})
0032$/
},
/**
* return a regex which extract the cbor encoded metadata : {"ipfs": <IPFS hash>, "solc": <compiler version>} from the bytecode.
* ref https://solidity.readthedocs.io/en/v0.6.6/metadata.html?highlight=ipfs#encoding-of-the-metadata-hash-in-the-bytecode
* @return {RegEx}
*/
cborEncodedValueExtraction
:
function
()
{
return
/64697066735822
([
0-9a-f
]{68})
64736f6c6343
([
0-9a-f
]{6})
0033$/
},
extractcborMetadata
:
function
(
value
)
{
return
value
.
replace
(
this
.
cborEncodedValueExtraction
(),
''
)
},
extractSwarmHash
:
function
(
value
)
{
value
=
value
.
replace
(
this
.
swarmHashExtraction
(),
''
)
value
=
value
.
replace
(
this
.
swarmHashExtractionPOC31
(),
''
)
...
...
@@ -224,7 +237,10 @@ module.exports = {
code1
=
replaceLibReference
(
code1
,
pos
)
}
code1
=
this
.
extractSwarmHash
(
code1
)
code1
=
this
.
extractcborMetadata
(
code1
)
code2
=
this
.
extractSwarmHash
(
code2
)
code2
=
this
.
extractcborMetadata
(
code2
)
if
(
code1
&&
code2
&&
code1
.
indexOf
(
code2
)
===
0
)
{
return
true
}
...
...
remix-lib/test/util.js
View file @
af1be323
This diff is collapsed.
Click to expand it.
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