use of jadx.core.dex.nodes.IRegion in project jadx by skylot.
the class DebugUtils method printRegion.
private static void printRegion(MethodNode mth, IRegion region, String indent, boolean printInsns) {
LOG.debug("{}{}", indent, region);
indent += "| ";
for (IContainer container : region.getSubBlocks()) {
if (container instanceof IRegion) {
printRegion(mth, (IRegion) container, indent, printInsns);
} else {
LOG.debug("{}{} {}", indent, container, container.getAttributesString());
if (printInsns && container instanceof IBlock) {
IBlock block = (IBlock) container;
printInsns(mth, indent, block);
}
}
}
}
use of jadx.core.dex.nodes.IRegion in project jadx by skylot.
the class RegionUtils method isBlocksInSameRegion.
/**
* Check if two blocks in same region on same level
* TODO: Add 'region' annotation to all blocks to speed up checks
*/
public static boolean isBlocksInSameRegion(MethodNode mth, BlockNode firstBlock, BlockNode secondBlock) {
Region region = mth.getRegion();
if (region == null) {
return false;
}
IContainer firstContainer = getBlockContainer(region, firstBlock);
if (firstContainer instanceof IRegion) {
if (firstContainer instanceof IBranchRegion) {
return false;
}
List<IContainer> subBlocks = ((IRegion) firstContainer).getSubBlocks();
return subBlocks.contains(secondBlock);
}
return false;
}
use of jadx.core.dex.nodes.IRegion in project jadx by skylot.
the class RegionUtils method hasExitEdge.
public static boolean hasExitEdge(IContainer container) {
if (container instanceof IBlock) {
return BlockUtils.containsExitInsn((IBlock) container);
}
if (container instanceof IBranchRegion) {
// all branches must have exit edge
for (IContainer br : ((IBranchRegion) container).getBranches()) {
if (br == null || !hasExitEdge(br)) {
return false;
}
}
return true;
}
if (container instanceof IRegion) {
IRegion region = (IRegion) container;
List<IContainer> blocks = region.getSubBlocks();
return !blocks.isEmpty() && hasExitEdge(blocks.get(blocks.size() - 1));
}
throw new JadxRuntimeException(unknownContainerType(container));
}
use of jadx.core.dex.nodes.IRegion in project jadx by skylot.
the class DebugUtils method printRegion.
private static void printRegion(MethodNode mth, IRegion region, ICodeWriter cw, String indent, boolean printInsns) {
printWithAttributes(cw, indent, region.toString(), region);
indent += "| ";
printRegionSpecificInfo(cw, indent, mth, region, printInsns);
for (IContainer container : region.getSubBlocks()) {
if (container instanceof IRegion) {
printRegion(mth, (IRegion) container, cw, indent, printInsns);
} else {
printWithAttributes(cw, indent, container.toString(), container);
if (printInsns && container instanceof IBlock) {
IBlock block = (IBlock) container;
printInsns(mth, cw, indent, block);
}
}
}
}
use of jadx.core.dex.nodes.IRegion in project jadx by skylot.
the class DebugUtils method printRegionsWithBlock.
public static void printRegionsWithBlock(MethodNode mth, BlockNode block) {
Set<IRegion> regions = new LinkedHashSet<>();
DepthRegionTraversal.traverse(mth, new TracedRegionVisitor() {
@Override
public void processBlockTraced(MethodNode mth, IBlock container, IRegion currentRegion) {
if (block.equals(container)) {
regions.add(currentRegion);
}
}
});
LOG.debug(" Found block: {} in regions: {}", block, regions);
}
Aggregations