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
72a50eae
Commit
72a50eae
authored
Aug 11, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix missing blocks in loop region
parent
fa37b90c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
3 deletions
+72
-3
LoopRegion.java
...-core/src/main/java/jadx/core/dex/regions/LoopRegion.java
+1
-1
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+16
-2
TestLoopInTry2.java
.../test/java/jadx/tests/internal/others/TestLoopInTry2.java
+55
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/regions/LoopRegion.java
View file @
72a50eae
...
...
@@ -138,6 +138,6 @@ public final class LoopRegion extends AbstractRegion {
@Override
public
String
toString
()
{
return
"LOOP
"
;
return
"LOOP
: "
+
baseString
()
;
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
72a50eae
...
...
@@ -213,7 +213,21 @@ public class RegionMaker {
}
stack
.
addExit
(
out
);
BlockNode
loopBody
=
condInfo
.
getThenBlock
();
loopRegion
.
setBody
(
makeRegion
(
loopBody
,
stack
));
Region
body
=
makeRegion
(
loopBody
,
stack
);
// add blocks from loop start to first condition block
BlockNode
conditionBlock
=
condInfo
.
getIfBlock
();
if
(
loopStart
!=
conditionBlock
)
{
Set
<
BlockNode
>
blocks
=
BlockUtils
.
getAllPathsBlocks
(
loopStart
,
conditionBlock
);
blocks
.
remove
(
conditionBlock
);
for
(
BlockNode
block
:
blocks
)
{
if
(
block
.
getInstructions
().
isEmpty
()
&&
!
block
.
contains
(
AFlag
.
SKIP
)
&&
!
RegionUtils
.
isRegionContainsBlock
(
body
,
block
))
{
body
.
add
(
block
);
}
}
}
loopRegion
.
setBody
(
body
);
}
stack
.
pop
();
return
out
;
...
...
@@ -569,7 +583,7 @@ public class RegionMaker {
Set
<
BlockNode
>
exits
=
new
HashSet
<
BlockNode
>();
for
(
BlockNode
splitter
:
splitters
)
{
for
(
BlockNode
handler
:
blocks
)
{
List
<
BlockNode
>
s
=
splitter
.
get
Clean
Successors
();
List
<
BlockNode
>
s
=
splitter
.
getSuccessors
();
if
(
s
.
isEmpty
())
{
LOG
.
debug
(
ErrorsCounter
.
formatErrorMsg
(
mth
,
"No successors for splitter: "
+
splitter
));
continue
;
...
...
jadx-core/src/test/java/jadx/tests/internal/others/TestLoopInTry2.java
0 → 100644
View file @
72a50eae
package
jadx
.
tests
.
internal
.
others
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.DexNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.utils.exceptions.DecodeException
;
import
java.io.EOFException
;
import
org.junit.Test
;
import
com.android.dex.Code
;
import
com.android.dx.io.instructions.DecodedInstruction
;
import
com.android.dx.io.instructions.ShortArrayCodeInput
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestLoopInTry2
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
MethodNode
method
;
private
DexNode
dex
;
private
DecodedInstruction
[]
insnArr
;
public
void
test
(
Code
mthCode
)
throws
DecodeException
{
short
[]
encodedInstructions
=
mthCode
.
getInstructions
();
int
size
=
encodedInstructions
.
length
;
DecodedInstruction
[]
decoded
=
new
DecodedInstruction
[
size
];
ShortArrayCodeInput
in
=
new
ShortArrayCodeInput
(
encodedInstructions
);
try
{
while
(
in
.
hasMore
())
{
decoded
[
in
.
cursor
()]
=
DecodedInstruction
.
decode
(
in
);
}
}
catch
(
EOFException
e
)
{
throw
new
DecodeException
(
method
,
""
,
e
);
}
insnArr
=
decoded
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
"try {"
));
assertThat
(
code
,
containsOne
(
"while (in.hasMore()) {"
));
assertThat
(
code
,
containsOne
(
"decoded[in.cursor()] = DecodedInstruction.decode(in);"
));
assertThat
(
code
,
containsOne
(
"} catch (EOFException e) {"
));
assertThat
(
code
,
containsOne
(
"throw new DecodeException"
));
}
}
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