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
53cac58e
Commit
53cac58e
authored
Oct 11, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix processing of last instruction in 'try' block
parent
adc32ed3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
7 deletions
+86
-7
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+2
-1
SSATransform.java
...rc/main/java/jadx/core/dex/visitors/ssa/SSATransform.java
+31
-5
TestNestedLoops3.java
...t/java/jadx/tests/integration/loops/TestNestedLoops3.java
+0
-1
TestTryCatch6.java
...t/java/jadx/tests/integration/trycatch/TestTryCatch6.java
+53
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
53cac58e
...
...
@@ -356,7 +356,8 @@ public class RegionMaker {
if
(
loopExit
==
exit
)
{
// try/catch at loop end
BlockNode
source
=
exitEdge
.
getSource
();
if
(
source
.
contains
(
AType
.
CATCH_BLOCK
))
{
if
(
source
.
contains
(
AType
.
CATCH_BLOCK
)
&&
source
.
getSuccessors
().
size
()
==
2
)
{
BlockNode
other
=
BlockUtils
.
selectOther
(
loopExit
,
source
.
getSuccessors
());
if
(
other
!=
null
&&
other
.
contains
(
AType
.
EXC_HANDLER
))
{
insertBlock
=
source
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ssa/SSATransform.java
View file @
53cac58e
package
jadx
.
core
.
dex
.
visitors
.
ssa
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.attributes.AType
;
import
jadx.core.dex.attributes.nodes.PhiListAttr
;
import
jadx.core.dex.instructions.InsnType
;
...
...
@@ -40,7 +41,11 @@ public class SSATransform extends AbstractVisitor {
placePhi
(
mth
,
i
,
la
);
}
renameVariables
(
mth
);
removeUselessPhi
(
mth
);
fixLastTryCatchAssign
(
mth
);
if
(
removeUselessPhi
(
mth
))
{
renameVariables
(
mth
);
}
}
private
static
void
placePhi
(
MethodNode
mth
,
int
regNum
,
LiveVarAnalysis
la
)
{
...
...
@@ -147,7 +152,27 @@ public class SSATransform extends AbstractVisitor {
System
.
arraycopy
(
inputVars
,
0
,
vars
,
0
,
vars
.
length
);
}
private
static
void
removeUselessPhi
(
MethodNode
mth
)
{
private
static
void
fixLastTryCatchAssign
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
PhiListAttr
phiList
=
block
.
get
(
AType
.
PHI_LIST
);
if
(
phiList
==
null
||
!
block
.
contains
(
AType
.
EXC_HANDLER
))
{
continue
;
}
for
(
PhiInsn
phi
:
phiList
.
getList
())
{
for
(
int
i
=
0
;
i
<
phi
.
getArgsCount
();
i
++)
{
RegisterArg
arg
=
phi
.
getArg
(
i
);
InsnNode
parentInsn
=
arg
.
getAssignInsn
();
if
(
parentInsn
!=
null
&&
parentInsn
.
getResult
()
!=
null
&&
parentInsn
.
contains
(
AFlag
.
TRY_LEAVE
))
{
phi
.
removeArg
(
arg
);
}
}
}
}
}
private
static
boolean
removeUselessPhi
(
MethodNode
mth
)
{
List
<
PhiInsn
>
insnToRemove
=
new
ArrayList
<
PhiInsn
>();
for
(
SSAVar
var
:
mth
.
getSVars
())
{
// phi result not used
...
...
@@ -167,7 +192,7 @@ public class SSATransform extends AbstractVisitor {
removePhiWithSameArgs
(
phi
,
insnToRemove
);
}
}
removePhiList
(
mth
,
insnToRemove
);
re
turn
re
movePhiList
(
mth
,
insnToRemove
);
}
private
static
void
removePhiWithSameArgs
(
PhiInsn
phi
,
List
<
PhiInsn
>
insnToRemove
)
{
...
...
@@ -194,9 +219,9 @@ public class SSATransform extends AbstractVisitor {
}
}
private
static
void
removePhiList
(
MethodNode
mth
,
List
<
PhiInsn
>
insnToRemove
)
{
private
static
boolean
removePhiList
(
MethodNode
mth
,
List
<
PhiInsn
>
insnToRemove
)
{
if
(
insnToRemove
.
isEmpty
())
{
return
;
return
false
;
}
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
PhiListAttr
phiList
=
block
.
get
(
AType
.
PHI_LIST
);
...
...
@@ -217,5 +242,6 @@ public class SSATransform extends AbstractVisitor {
}
}
insnToRemove
.
clear
();
return
true
;
}
}
jadx-core/src/test/java/jadx/tests/integration/loops/TestNestedLoops3.java
View file @
53cac58e
...
...
@@ -62,7 +62,6 @@ public class TestNestedLoops3 extends IntegrationTest {
@Test
public
void
test
()
{
setOutputCFG
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatch6.java
0 → 100644
View file @
53cac58e
package
jadx
.
tests
.
integration
.
trycatch
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
java.io.IOException
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestTryCatch6
extends
IntegrationTest
{
public
static
class
TestCls
{
private
static
boolean
test
(
Object
obj
)
{
boolean
res
=
false
;
while
(
true
)
{
try
{
res
=
exc
(
obj
);
return
res
;
}
catch
(
IOException
e
)
{
res
=
true
;
}
catch
(
Throwable
e
)
{
if
(
obj
==
null
)
{
obj
=
new
Object
();
}
}
}
}
private
static
boolean
exc
(
Object
obj
)
throws
IOException
{
if
(
obj
==
null
)
{
throw
new
IOException
();
}
return
true
;
}
public
void
check
()
{
assertTrue
(
test
(
new
Object
()));
}
}
@Test
public
void
test
()
{
noDebugInfo
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"try {"
));
}
}
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