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
c0e9da3b
Unverified
Commit
c0e9da3b
authored
Feb 01, 2021
by
yann300
Committed by
GitHub
Feb 01, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #820 from ethereum/yann300-patch-28
Fix getting parentScope while debugging
parents
b4675032
b39f707f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
3 deletions
+49
-3
internalCallTree.ts
libs/remix-debug/src/solidity-decoder/internalCallTree.ts
+1
-2
sourceLocationTracker.ts
libs/remix-debug/src/source/sourceLocationTracker.ts
+20
-1
sourceLocationTracker.ts
libs/remix-debug/test/sourceLocationTracker.ts
+28
-0
No files found.
libs/remix-debug/src/solidity-decoder/internalCallTree.ts
View file @
c0e9da3b
...
...
@@ -108,8 +108,7 @@ export class InternalCallTree {
}
parentScope
(
scopeId
)
{
const
matched
=
scopeId
.
match
(
/
(
.
\d
|
\d)
$/
)
return
scopeId
.
replace
(
matched
[
1
],
''
)
return
scopeId
.
replace
(
/
(
.
\d
|
\d)
$/
,
''
)
}
findScopeId
(
vmtraceIndex
)
{
...
...
libs/remix-debug/src/source/sourceLocationTracker.ts
View file @
c0e9da3b
...
...
@@ -60,6 +60,19 @@ export class SourceLocationTracker {
}
/**
* Returns the total amount of sources from a specific @arg address and @arg contracts
*
* @param {String} address - contract address from which has generated sources
* @param {Object} contracts - AST of compiled contracts
*/
getTotalAmountOfSources
(
address
,
contracts
)
{
let
sourcesLength
=
Object
.
keys
(
contracts
).
length
const
generatedSources
=
this
.
getGeneratedSourcesFromAddress
(
address
)
if
(
generatedSources
)
sourcesLength
=
sourcesLength
+
Object
.
keys
(
generatedSources
).
length
return
sourcesLength
}
/**
* Return a valid source location associated with the given @arg vmTraceIndex
*
* @param {String} address - contract address from which the source location is retrieved
...
...
@@ -67,8 +80,14 @@ export class SourceLocationTracker {
* @param {Object} contractDetails - AST of compiled contracts
*/
async
getValidSourceLocationFromVMTraceIndex
(
address
,
vmtraceStepIndex
,
contracts
)
{
const
amountOfSources
=
this
.
getTotalAmountOfSources
(
address
,
contracts
)
let
map
:
Record
<
string
,
number
>
=
{
file
:
-
1
}
while
(
vmtraceStepIndex
>=
0
&&
map
.
file
===
-
1
)
{
/*
(map.file === -1) this indicates that it isn't associated with a known source code
(map.file > amountOfSources - 1) this indicates the current file index exceed the total number of files.
this happens when generated sources should not be considered.
*/
while
(
vmtraceStepIndex
>=
0
&&
(
map
.
file
===
-
1
||
map
.
file
>
amountOfSources
-
1
))
{
map
=
await
this
.
getSourceLocationFromVMTraceIndex
(
address
,
vmtraceStepIndex
,
contracts
)
vmtraceStepIndex
=
vmtraceStepIndex
-
1
}
...
...
libs/remix-debug/test/sourceLocationTracker.ts
View file @
c0e9da3b
...
...
@@ -54,9 +54,37 @@ tape('SourceLocationTracker', function (t) {
traceManager
.
resolveTrace
(
tx
).
then
(
async
()
=>
{
try
{
// with debugWithGeneratedSources: false
const
sourceLocationTracker
=
new
SourceLocationTracker
(
codeManager
,
{
debugWithGeneratedSources
:
false
})
let
map
=
await
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
0
,
output
.
contracts
)
console
.
log
(
map
)
st
.
equal
(
map
[
'file'
],
0
)
st
.
equal
(
map
[
'start'
],
35
)
map
=
await
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
45
,
output
.
contracts
)
st
.
equal
(
map
[
'file'
],
1
)
// 1 refers to the generated source (pragma experimental ABIEncoderV2)
map
=
await
sourceLocationTracker
.
getValidSourceLocationFromVMTraceIndex
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
45
,
output
.
contracts
)
st
.
equal
(
map
[
'file'
],
0
)
// 1 refers to the generated source (pragma experimental ABIEncoderV2)
st
.
equal
(
map
[
'start'
],
303
)
st
.
equal
(
map
[
'length'
],
448
)
map
=
await
sourceLocationTracker
.
getValidSourceLocationFromVMTraceIndex
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
36
,
output
.
contracts
)
st
.
equal
(
map
[
'file'
],
0
)
// 0 refers to the initial solidity code. see source below (ABIEncoderV2)
st
.
equal
(
map
[
'start'
],
303
)
st
.
equal
(
map
[
'length'
],
448
)
}
catch
(
e
)
{
console
.
log
(
e
)
}
try
{
// with debugWithGeneratedSources: true
const
sourceLocationTracker
=
new
SourceLocationTracker
(
codeManager
,
{
debugWithGeneratedSources
:
true
})
let
map
=
await
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
0
,
output
.
contracts
)
console
.
log
(
map
)
st
.
equal
(
map
[
'file'
],
0
)
...
...
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