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
21acaa8d
Commit
21acaa8d
authored
Feb 04, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: resolve mix up in SKIP and DONT_GENERATE flags
parent
c705f8cb
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
37 additions
and
37 deletions
+37
-37
RegionGen.java
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
+1
-1
AFlag.java
jadx-core/src/main/java/jadx/core/dex/attributes/AFlag.java
+3
-4
TryCatchBlock.java
...e/src/main/java/jadx/core/dex/trycatch/TryCatchBlock.java
+1
-1
CodeShrinker.java
...re/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
+1
-1
BlockFinallyExtract.java
...dx/core/dex/visitors/blocksmaker/BlockFinallyExtract.java
+6
-6
CheckRegions.java
...ain/java/jadx/core/dex/visitors/regions/CheckRegions.java
+3
-2
IfMakerHelper.java
...in/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
+3
-3
LoopRegionVisitor.java
...ava/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
+6
-6
ProcessVariables.java
...java/jadx/core/dex/visitors/regions/ProcessVariables.java
+1
-1
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+8
-8
RegionMakerVisitor.java
...va/jadx/core/dex/visitors/regions/RegionMakerVisitor.java
+1
-1
SSATransform.java
...rc/main/java/jadx/core/dex/visitors/ssa/SSATransform.java
+1
-1
BlockUtils.java
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
+2
-2
No files found.
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
View file @
21acaa8d
...
...
@@ -98,7 +98,7 @@ public class RegionGen extends InsnGen {
private
void
makeSimpleBlock
(
IBlock
block
,
CodeWriter
code
)
throws
CodegenException
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
if
(!
insn
.
contains
(
AFlag
.
SKIP
))
{
if
(!
insn
.
contains
(
AFlag
.
DONT_GENERATE
))
{
makeInsn
(
insn
,
code
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/AFlag.java
View file @
21acaa8d
...
...
@@ -16,11 +16,10 @@ public enum AFlag {
DECLARE_VAR
,
DONT_WRAP
,
DONT_SHRINK
,
DONT_INLINE
,
DONT_GENERATE
,
SKIP
,
REMOVE
,
DONT_GENERATE
,
// process as usual, but don't output to generated code
REMOVE
,
// can be completely removed
ADDED_TO_REGION
,
SKIP_FIRST_ARG
,
SKIP_ARG
,
// skip argument in invoke call
...
...
jadx-core/src/main/java/jadx/core/dex/trycatch/TryCatchBlock.java
View file @
21acaa8d
...
...
@@ -70,7 +70,7 @@ public class TryCatchBlock {
for
(
BlockNode
block
:
handler
.
getBlocks
())
{
// skip synthetic loop exit blocks
BlockUtils
.
skipPredSyntheticPaths
(
block
);
block
.
add
(
AFlag
.
SKIP
);
block
.
add
(
AFlag
.
REMOVE
);
ExcHandlerAttr
excHandlerAttr
=
block
.
get
(
AType
.
EXC_HANDLER
);
if
(
excHandlerAttr
!=
null
&&
excHandlerAttr
.
getHandler
().
equals
(
handler
))
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
View file @
21acaa8d
...
...
@@ -31,7 +31,7 @@ public class CodeShrinker extends AbstractVisitor {
}
public
static
void
shrinkMethod
(
MethodNode
mth
)
{
if
(
mth
.
isNoCode
()
||
mth
.
contains
(
AFlag
.
DONT_SHRINK
)
)
{
if
(
mth
.
isNoCode
())
{
return
;
}
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockFinallyExtract.java
View file @
21acaa8d
...
...
@@ -236,7 +236,7 @@ public class BlockFinallyExtract extends AbstractVisitor {
}
if
(!
replaced
)
{
insnsList
.
remove
(
insnsList
.
size
()
-
1
);
handlerBlock
.
add
(
AFlag
.
SKIP
);
handlerBlock
.
add
(
AFlag
.
REMOVE
);
}
}
...
...
@@ -650,18 +650,18 @@ public class BlockFinallyExtract extends AbstractVisitor {
int
size
=
insns
.
size
();
for
(
int
i
=
splitIndex
;
i
<
size
;
i
++)
{
InsnNode
insnNode
=
insns
.
get
(
i
);
insnNode
.
add
(
AFlag
.
SKIP
);
insnNode
.
add
(
AFlag
.
DONT_GENERATE
);
newBlock
.
getInstructions
().
add
(
insnNode
);
}
Iterator
<
InsnNode
>
it
=
insns
.
iterator
();
while
(
it
.
hasNext
())
{
InsnNode
insnNode
=
it
.
next
();
if
(
insnNode
.
contains
(
AFlag
.
SKIP
))
{
if
(
insnNode
.
contains
(
AFlag
.
DONT_GENERATE
))
{
it
.
remove
();
}
}
for
(
InsnNode
insnNode
:
newBlock
.
getInstructions
())
{
insnNode
.
remove
(
AFlag
.
SKIP
);
insnNode
.
remove
(
AFlag
.
DONT_GENERATE
);
}
return
newBlock
;
}
...
...
@@ -680,13 +680,13 @@ public class BlockFinallyExtract extends AbstractVisitor {
block
.
getPredecessors
().
clear
();
block
.
getSuccessors
().
clear
();
block
.
add
(
AFlag
.
REMOVE
);
block
.
remove
(
AFlag
.
SKIP
);
block
.
remove
(
AFlag
.
DONT_GENERATE
);
CatchAttr
catchAttr
=
block
.
get
(
AType
.
CATCH_BLOCK
);
if
(
catchAttr
!=
null
)
{
catchAttr
.
getTryBlock
().
removeBlock
(
mth
,
block
);
for
(
BlockNode
skipBlock
:
mth
.
getBasicBlocks
())
{
if
(
skipBlock
.
contains
(
AFlag
.
SKIP
))
{
if
(
skipBlock
.
contains
(
AFlag
.
REMOVE
))
{
markForRemove
(
mth
,
skipBlock
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/CheckRegions.java
View file @
21acaa8d
...
...
@@ -47,7 +47,7 @@ public class CheckRegions extends AbstractVisitor {
}
if
(
LOG
.
isDebugEnabled
()
&&
!
block
.
contains
(
AFlag
.
RETURN
)
&&
!
block
.
contains
(
AFlag
.
SKIP
)
&&
!
block
.
contains
(
AFlag
.
REMOVE
)
&&
!
block
.
contains
(
AFlag
.
SYNTHETIC
)
&&
!
block
.
getInstructions
().
isEmpty
())
{
LOG
.
debug
(
"Duplicated block: {} - {}"
,
mth
,
block
);
...
...
@@ -58,7 +58,8 @@ public class CheckRegions extends AbstractVisitor {
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
if
(!
blocksInRegions
.
contains
(
block
)
&&
!
block
.
getInstructions
().
isEmpty
()
&&
!
block
.
contains
(
AFlag
.
SKIP
))
{
&&
!
block
.
contains
(
AFlag
.
ADDED_TO_REGION
)
&&
!
block
.
contains
(
AFlag
.
REMOVE
))
{
String
blockCode
=
getBlockInsnStr
(
mth
,
block
);
mth
.
addWarn
(
"Missing block: "
+
block
+
", code skipped:"
+
CodeWriter
.
NL
+
blockCode
);
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
View file @
21acaa8d
...
...
@@ -291,13 +291,13 @@ public class IfMakerHelper {
if
(
info
.
getMergedBlocks
().
size
()
>
1
)
{
for
(
BlockNode
block
:
info
.
getMergedBlocks
())
{
if
(
block
!=
info
.
getIfBlock
())
{
block
.
add
(
AFlag
.
SKIP
);
block
.
add
(
AFlag
.
ADDED_TO_REGION
);
}
}
}
if
(!
info
.
getSkipBlocks
().
isEmpty
())
{
for
(
BlockNode
block
:
info
.
getSkipBlocks
())
{
block
.
add
(
AFlag
.
SKIP
);
block
.
add
(
AFlag
.
ADDED_TO_REGION
);
}
info
.
getSkipBlocks
().
clear
();
}
...
...
@@ -325,7 +325,7 @@ public class IfMakerHelper {
}
private
static
BlockNode
getNextIfNode
(
BlockNode
block
)
{
if
(
block
==
null
||
block
.
contains
(
AType
.
LOOP
)
||
block
.
contains
(
AFlag
.
SKIP
))
{
if
(
block
==
null
||
block
.
contains
(
AType
.
LOOP
)
||
block
.
contains
(
AFlag
.
ADDED_TO_REGION
))
{
return
null
;
}
List
<
InsnNode
>
insns
=
block
.
getInstructions
();
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
View file @
21acaa8d
...
...
@@ -114,8 +114,8 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
}
// all checks passed
initInsn
.
add
(
AFlag
.
SKIP
);
incrInsn
.
add
(
AFlag
.
SKIP
);
initInsn
.
add
(
AFlag
.
DONT_GENERATE
);
incrInsn
.
add
(
AFlag
.
DONT_GENERATE
);
LoopType
arrForEach
=
checkArrayForEach
(
mth
,
initInsn
,
incrInsn
,
condition
);
if
(
arrForEach
!=
null
)
{
loopRegion
.
setType
(
arrForEach
);
...
...
@@ -188,8 +188,8 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
}
// array for each loop confirmed
len
.
add
(
AFlag
.
SKIP
);
arrGetInsn
.
add
(
AFlag
.
SKIP
);
len
.
add
(
AFlag
.
DONT_GENERATE
);
arrGetInsn
.
add
(
AFlag
.
DONT_GENERATE
);
InstructionRemover
.
unbindInsn
(
mth
,
len
);
// inline array variable
...
...
@@ -265,9 +265,9 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
toSkip
.
add
(
nextCall
);
}
assignInsn
.
add
(
AFlag
.
SKIP
);
assignInsn
.
add
(
AFlag
.
DONT_GENERATE
);
for
(
InsnNode
insnNode
:
toSkip
)
{
insnNode
.
add
(
AFlag
.
SKIP
);
insnNode
.
add
(
AFlag
.
DONT_GENERATE
);
}
loopRegion
.
setType
(
new
ForEachLoop
(
iterVar
,
iterableArg
));
return
true
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessVariables.java
View file @
21acaa8d
...
...
@@ -122,7 +122,7 @@ public class ProcessVariables extends AbstractVisitor {
int
len
=
container
.
getInstructions
().
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
InsnNode
insn
=
container
.
getInstructions
().
get
(
i
);
if
(
insn
.
contains
(
AFlag
.
SKIP
))
{
if
(
insn
.
contains
(
AFlag
.
DONT_GENERATE
))
{
continue
;
}
args
.
clear
();
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
21acaa8d
...
...
@@ -203,13 +203,13 @@ public class RegionMaker {
BlockNode
thenBlock
=
condInfo
.
getThenBlock
();
out
=
thenBlock
==
loopStart
?
condInfo
.
getElseBlock
()
:
thenBlock
;
loopStart
.
remove
(
AType
.
LOOP
);
loop
.
getEnd
().
add
(
AFlag
.
SKIP
);
loop
.
getEnd
().
add
(
AFlag
.
ADDED_TO_REGION
);
stack
.
addExit
(
loop
.
getEnd
());
processedBlocks
.
clear
(
loopStart
.
getId
());
Region
body
=
makeRegion
(
loopStart
,
stack
);
loopRegion
.
setBody
(
body
);
loopStart
.
addAttr
(
AType
.
LOOP
,
loop
);
loop
.
getEnd
().
remove
(
AFlag
.
SKIP
);
loop
.
getEnd
().
remove
(
AFlag
.
ADDED_TO_REGION
);
}
else
{
out
=
condInfo
.
getElseBlock
();
if
(
outerRegion
!=
null
...
...
@@ -229,7 +229,7 @@ public class RegionMaker {
blocks
.
remove
(
conditionBlock
);
for
(
BlockNode
block
:
blocks
)
{
if
(
block
.
getInstructions
().
isEmpty
()
&&
!
block
.
contains
(
AFlag
.
SKIP
)
&&
!
block
.
contains
(
AFlag
.
ADDED_TO_REGION
)
&&
!
RegionUtils
.
isRegionContainsBlock
(
body
,
block
))
{
body
.
add
(
block
);
}
...
...
@@ -489,7 +489,7 @@ public class RegionMaker {
return
false
;
}
BlockNode
codePred
=
preds
.
get
(
0
);
if
(
codePred
.
contains
(
AFlag
.
SKIP
))
{
if
(
codePred
.
contains
(
AFlag
.
ADDED_TO_REGION
))
{
return
false
;
}
if
(
loopEnd
.
isDominator
(
codePred
)
...
...
@@ -530,9 +530,9 @@ public class RegionMaker {
for
(
InsnNode
exitInsn
:
synchRegion
.
getExitInsns
())
{
BlockNode
insnBlock
=
BlockUtils
.
getBlockByInsn
(
mth
,
exitInsn
);
if
(
insnBlock
!=
null
)
{
insnBlock
.
add
(
AFlag
.
SKIP
);
insnBlock
.
add
(
AFlag
.
DONT_GENERATE
);
}
exitInsn
.
add
(
AFlag
.
SKIP
);
exitInsn
.
add
(
AFlag
.
DONT_GENERATE
);
InstructionRemover
.
unbindInsn
(
mth
,
exitInsn
);
}
...
...
@@ -615,7 +615,7 @@ public class RegionMaker {
}
private
BlockNode
processIf
(
IRegion
currentRegion
,
BlockNode
block
,
IfNode
ifnode
,
RegionStack
stack
)
{
if
(
block
.
contains
(
AFlag
.
SKIP
))
{
if
(
block
.
contains
(
AFlag
.
ADDED_TO_REGION
))
{
// block already included in other 'if' region
return
ifnode
.
getThenBlock
();
}
...
...
@@ -681,7 +681,7 @@ public class RegionMaker {
private
void
addEdgeInsn
(
IfInfo
ifInfo
,
Region
region
,
EdgeInsnAttr
edgeInsnAttr
)
{
BlockNode
start
=
edgeInsnAttr
.
getStart
();
if
(
start
.
contains
(
AFlag
.
SKIP
))
{
if
(
start
.
contains
(
AFlag
.
ADDED_TO_REGION
))
{
return
;
}
boolean
fromThisIf
=
false
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMakerVisitor.java
View file @
21acaa8d
...
...
@@ -126,7 +126,7 @@ public class RegionMakerVisitor extends AbstractVisitor {
BlockNode
bn
=
(
BlockNode
)
block
;
for
(
BlockNode
s
:
bn
.
getCleanSuccessors
())
{
if
(!
blocks
.
contains
(
s
)
&&
!
bn
.
contains
(
AFlag
.
SKIP
)
&&
!
bn
.
contains
(
AFlag
.
ADDED_TO_REGION
)
&&
!
s
.
contains
(
AFlag
.
FALL_THROUGH
))
{
addBreak
(
mth
,
c
,
bn
);
break
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ssa/SSATransform.java
View file @
21acaa8d
...
...
@@ -429,7 +429,7 @@ public class SSATransform extends AbstractVisitor {
if
(
resArg
.
getRegNum
()
!=
arg
.
getRegNum
()
&&
!
resArg
.
getSVar
().
isUsedInPhi
())
{
markThisArgs
(
resArg
);
parentInsn
.
add
(
AFlag
.
SKIP
);
parentInsn
.
add
(
AFlag
.
DONT_GENERATE
);
}
}
}
...
...
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
View file @
21acaa8d
...
...
@@ -74,7 +74,7 @@ public class BlockUtils {
}
public
static
boolean
isBlockMustBeCleared
(
BlockNode
b
)
{
if
(
b
.
contains
(
AType
.
EXC_HANDLER
)
||
b
.
contains
(
AFlag
.
SKIP
))
{
if
(
b
.
contains
(
AType
.
EXC_HANDLER
)
||
b
.
contains
(
AFlag
.
REMOVE
))
{
return
true
;
}
if
(
b
.
contains
(
AFlag
.
SYNTHETIC
))
{
...
...
@@ -495,7 +495,7 @@ public class BlockUtils {
if
(
pred
.
contains
(
AFlag
.
SYNTHETIC
)
&&
!
pred
.
contains
(
AType
.
SPLITTER_BLOCK
)
&&
pred
.
getInstructions
().
isEmpty
())
{
pred
.
add
(
AFlag
.
SKIP
);
pred
.
add
(
AFlag
.
DONT_GENERATE
);
skipPredSyntheticPaths
(
pred
);
}
}
...
...
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