jadx icon indicating copy to clipboard operation
jadx copied to clipboard

[feature] Smali debugger: enhanced breakpoints (scripting)

Open Bleuzen opened this issue 2 years ago • 0 comments

Describe your idea: Currently, breakpoints are very bare-bones in jadx and can only suspend the app if hit.

However it would be really useful to be able to:

  • (1) Only suspend on breakpoint if a condition is met
  • (2) Not suspend on breakpoint but only log a value
  • (3) Automatically modify a variable every time the breakpoint is hit without suspending the application

As inspiration: IntelliJ IDEA / Android Studio already support this in some way. When you right click on a breakpoint this comes up: image

You can toggle if it should suspend on that breakpoint, set conditions for the suspend, output logs on hit. There is also an "Evaluate and log" which can even be used to set variables every time the breakpoint is hit. This makes live so much easier!


How exactly (and if at all) this could be implemented in jadx can still be discussed. I'm not sure if I like that box from IntelliJ IDEA / Android Studio.

Here is one possibility I see:

Breakpoints could be entirely scriptable with some basic scripting language. On right click on a breakpoint, bring up a textbox. There one could put in code which will get executed when the breakpoint is hit.

By default (right after user created a new breakpoint) this code would be:

suspend()

This would mimic the current behaviour. But one can change it. For example if user wants to not suspend on that breakpoint, but only log a value, the code of the breakpoint could be modified to:

# suspend()  # commented out, we don't want to hold execution here
print(p1)  # print variable "p1" to the debugger log

or if one wants to modify the the "p1" variable (boolean), breakpoints script could look like this:

setValue(p1, 0)  # set "p1" always to false when breakpoint is hit

or if user wants to suspend on breakpoint only if "p1" is true:

if p1 == 1:
    suspend()

Maybe an existing scripting language could be used to not have to invent a new one. Saw that many use lua, but not sure if it would fit here, never used it myself.


I'm not sure yet if having a scripting language for breakpoints is overkill. At least it would be the most flexible I guess :D But can also understand if this is out of scope for jadx. What do you think?

Bleuzen avatar Apr 01 '22 00:04 Bleuzen