fix(script): use script log for show stages exceptions (#1912)

This commit is contained in:
Skylot
2023-06-15 21:12:01 +01:00
parent 6f4451364b
commit 26fb7f33fb
3 changed files with 17 additions and 3 deletions
@@ -23,4 +23,12 @@ class Debug(private val jadx: JadxScriptInstance) {
fun printPasses() {
jadx.internalDecompiler.root.passes.forEach { jadx.log.info { it.name } }
}
fun catchExceptions(label: String = "", code: () -> Unit) {
try {
code.invoke()
} catch (e: Throwable) {
jadx.log.error(e) { "Exception in '$label'" }
}
}
}
@@ -16,7 +16,9 @@ class Stages(private val jadx: JadxScriptInstance) {
) {
override fun visit(mth: MethodNode) {
mth.instructions?.let {
block.invoke(mth, it)
jadx.debug.catchExceptions("Method instructions visit") {
block.invoke(mth, it)
}
}
}
})
@@ -37,7 +39,9 @@ class Stages(private val jadx: JadxScriptInstance) {
) {
override fun visit(mth: MethodNode) {
mth.basicBlocks?.let {
block.invoke(mth, it)
jadx.debug.catchExceptions("Method blocks visit") {
block.invoke(mth, it)
}
}
}
})
@@ -51,7 +55,9 @@ class Stages(private val jadx: JadxScriptInstance) {
) {
override fun visit(mth: MethodNode) {
mth.region?.let {
block.invoke(mth, it)
jadx.debug.catchExceptions("Method region visit") {
block.invoke(mth, it)
}
}
}
})