-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Line Numbers to Dex Dump #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I left a couple of comments. A few more things:
- There are now 2 empty lines between methods in the output instead of just 1. I remember I had to do something to deal with this in the original implementation as well.
- There seems to be a bug with naming classes. For instance I got this in a dump:
class IntOffset..ExternalSyntheticBackport0
(note the two dots) - Could you add a menu to turn debug line numbers on/off? It would make it more obvious to users what those numbers are, but more importantly it would make copy/pasting out of the tool easier when line numbers are disabled.
- Your change breaks another feature: when clicking on a line with a jump (goto/if/etc.) in the DEX output, the tool will draw a line to show where the jump will go. If the target line has a debug line number in the output, the feature stops working (prob. because the regex I use assumes whitespace at the beginning; one of the reasons why I wanted to change the parsers to output a list of class/methods/instructions)
build.gradle.kts
Outdated
implementation("org.jetbrains.compose.components:components-splitpane-desktop:${extra["compose.version"] as String}") | ||
implementation("com.fifesoft:rsyntaxtextarea:${extra["rsyntaxtextarea.version"] as String}") | ||
implementation("com.fifesoft:rstaui:${extra["rstaui.version"] as String}") | ||
implementation("net.java.dev.jna:jna:${extra["jna.version"] as String}") | ||
implementation("androidx.collection:collection:${extra["collections.version"] as String}") | ||
implementation("org.jetbrains.androidx.lifecycle:lifecycle-runtime:${extra["lifecycle.version"] as String}") | ||
runtimeOnly("org.jetbrains.skiko:skiko-awt-runtime-linux-x64:${extra["skiko.version"] as String}") | ||
runtimeOnly("org.jetbrains.skiko:skiko-awt-runtime-macos-arm64:${extra["skiko.version"] as String}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks on macOS, the native library can't be found if it's not implementation()
:/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
private val PositionRegex = Regex("^\\s*0x(?<address>[0-9a-f]+) line=(?<line>\\d+)$") | ||
|
||
private const val CLASS_START = "Class #" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been following the SnakeCase
style for constants here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
} | ||
return classes | ||
.filter { it.methods.isNotEmpty() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can combine those two filters in a single one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
val code = buildString { | ||
instructions.forEach { | ||
val lineNumber = positions[it.address] | ||
val prefix = when (lineNumber != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an if/else here instead of when/true/false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, though as an aside, I really like using when-true-false in these cases because is more readable. At least IMO.
0d0343f
to
7d0370d
Compare
Thanks for the updates! One last issue, there are still 2 empty lines between methods in the dump instead of 1. |
2c556be
to
4f9ec31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
I rewrote the DexDump parsing into a dedicated class.
I changed the implementation to be (IMO) less brittle and more readable.