Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
08ea61f4
Commit
08ea61f4
authored
Dec 31, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: don't traverse exception handlers twice (includes in TryCatchRegion)
parent
1d5368f5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
32 deletions
+22
-32
CheckRegions.java
...ain/java/jadx/core/dex/visitors/regions/CheckRegions.java
+2
-2
CleanRegions.java
...ain/java/jadx/core/dex/visitors/regions/CleanRegions.java
+1
-1
DepthRegionTraversal.java
.../jadx/core/dex/visitors/regions/DepthRegionTraversal.java
+3
-15
IfRegionVisitor.java
.../java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
+13
-11
LoopRegionVisitor.java
...ava/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
+1
-1
ProcessTryCatchRegions.java
...adx/core/dex/visitors/regions/ProcessTryCatchRegions.java
+1
-1
ProcessVariables.java
...java/jadx/core/dex/visitors/regions/ProcessVariables.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/CheckRegions.java
View file @
08ea61f4
...
...
@@ -67,7 +67,7 @@ public class CheckRegions extends AbstractVisitor {
}
// check loop conditions
DepthRegionTraversal
.
traverse
All
(
mth
,
new
AbstractRegionVisitor
()
{
DepthRegionTraversal
.
traverse
(
mth
,
new
AbstractRegionVisitor
()
{
@Override
public
void
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
if
(
region
instanceof
LoopRegion
)
{
...
...
@@ -82,7 +82,7 @@ public class CheckRegions extends AbstractVisitor {
private
static
void
printRegionsWithBlock
(
MethodNode
mth
,
final
BlockNode
block
)
{
final
Set
<
IRegion
>
regions
=
new
LinkedHashSet
<
IRegion
>();
DepthRegionTraversal
.
traverse
All
(
mth
,
new
TracedRegionVisitor
()
{
DepthRegionTraversal
.
traverse
(
mth
,
new
TracedRegionVisitor
()
{
@Override
public
void
processBlockTraced
(
MethodNode
mth
,
IBlock
container
,
IRegion
currentRegion
)
{
if
(
block
.
equals
(
container
))
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/CleanRegions.java
View file @
08ea61f4
...
...
@@ -44,6 +44,6 @@ public class CleanRegions {
}
}
};
DepthRegionTraversal
.
traverse
All
(
mth
,
removeEmptyBlocks
);
DepthRegionTraversal
.
traverse
(
mth
,
removeEmptyBlocks
);
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/regions/DepthRegionTraversal.java
View file @
08ea61f4
...
...
@@ -18,18 +18,18 @@ public class DepthRegionTraversal {
traverseInternal
(
mth
,
visitor
,
mth
.
getRegion
());
}
public
static
void
traverse
All
(
MethodNode
mth
,
IRegionVisitor
visitor
)
{
public
static
void
traverse
IncludingExcHandlers
(
MethodNode
mth
,
IRegionVisitor
visitor
)
{
traverseInternal
(
mth
,
visitor
,
mth
.
getRegion
());
for
(
ExceptionHandler
h
:
mth
.
getExceptionHandlers
())
{
traverseInternal
(
mth
,
visitor
,
h
.
getHandlerRegion
());
}
}
public
static
void
traverse
All
Iterative
(
MethodNode
mth
,
IRegionIterativeVisitor
visitor
)
{
public
static
void
traverseIterative
(
MethodNode
mth
,
IRegionIterativeVisitor
visitor
)
{
boolean
repeat
;
int
k
=
0
;
do
{
repeat
=
traverse
AllIterativeInternal
(
mth
,
visitor
);
repeat
=
traverse
IterativeInternal
(
mth
,
visitor
,
mth
.
getRegion
()
);
if
(
k
++
>
ITERATIVE_LIMIT
)
{
throw
new
JadxOverflowException
(
"Iterative traversal limit reached, method: "
+
mth
);
}
...
...
@@ -49,18 +49,6 @@ public class DepthRegionTraversal {
}
}
private
static
boolean
traverseAllIterativeInternal
(
MethodNode
mth
,
IRegionIterativeVisitor
visitor
)
{
if
(
traverseIterativeInternal
(
mth
,
visitor
,
mth
.
getRegion
()))
{
return
true
;
}
for
(
ExceptionHandler
h
:
mth
.
getExceptionHandlers
())
{
if
(
traverseIterativeInternal
(
mth
,
visitor
,
h
.
getHandlerRegion
()))
{
return
true
;
}
}
return
false
;
}
private
static
boolean
traverseIterativeInternal
(
MethodNode
mth
,
IRegionIterativeVisitor
visitor
,
IContainer
container
)
{
if
(
container
instanceof
IRegion
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
View file @
08ea61f4
...
...
@@ -19,20 +19,22 @@ import static jadx.core.utils.RegionUtils.insnsCount;
public
class
IfRegionVisitor
extends
AbstractVisitor
implements
IRegionVisitor
,
IRegionIterativeVisitor
{
private
static
final
TernaryVisitor
TERNARY_VISITOR
=
new
TernaryVisitor
();
@Override
public
void
visit
(
MethodNode
mth
)
{
// collapse ternary operators
DepthRegionTraversal
.
traverse
AllIterative
(
mth
,
new
IRegionIterativeVisitor
()
{
@Override
public
boolean
visitRegion
(
MethodNode
mth
,
IRegion
region
)
{
if
(
region
instanceof
IfRegion
)
{
return
TernaryMod
.
makeTernaryInsn
(
mth
,
(
IfRegion
)
region
);
}
return
false
;
}
});
DepthRegionTraversal
.
traverseAll
(
mth
,
this
);
DepthRegionTraversal
.
traverseAllIterative
(
mth
,
this
);
DepthRegionTraversal
.
traverse
Iterative
(
mth
,
TERNARY_VISITOR
);
DepthRegionTraversal
.
traverse
(
mth
,
this
);
DepthRegionTraversal
.
traverseIterative
(
mth
,
this
);
}
private
static
class
TernaryVisitor
implements
IRegionIterativeVisitor
{
@Override
public
boolean
visitRegion
(
MethodNode
mth
,
IRegion
region
)
{
return
region
instanceof
IfRegion
&&
TernaryMod
.
makeTernaryInsn
(
mth
,
(
IfRegion
)
region
);
}
}
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
View file @
08ea61f4
...
...
@@ -43,7 +43,7 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
@Override
public
void
visit
(
MethodNode
mth
)
{
DepthRegionTraversal
.
traverse
All
(
mth
,
this
);
DepthRegionTraversal
.
traverse
(
mth
,
this
);
}
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessTryCatchRegions.java
View file @
08ea61f4
...
...
@@ -44,7 +44,7 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
int
k
=
0
;
while
(!
tryBlocksMap
.
isEmpty
())
{
DepthRegionTraversal
.
traverse
All
(
mth
,
new
AbstractRegionVisitor
()
{
DepthRegionTraversal
.
traverse
IncludingExcHandlers
(
mth
,
new
AbstractRegionVisitor
()
{
@Override
public
void
leaveRegion
(
MethodNode
mth
,
IRegion
region
)
{
checkAndWrap
(
mth
,
tryBlocksMap
,
region
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessVariables.java
View file @
08ea61f4
...
...
@@ -186,7 +186,7 @@ public class ProcessVariables extends AbstractVisitor {
// collect all variables usage
IRegionVisitor
collect
=
new
CollectUsageRegionVisitor
(
usageMap
);
DepthRegionTraversal
.
traverse
All
(
mth
,
collect
);
DepthRegionTraversal
.
traverse
(
mth
,
collect
);
// reduce assigns map
List
<
RegisterArg
>
mthArgs
=
mth
.
getArguments
(
true
);
...
...
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