In my quest to understand the Frida magic regarding re-implementing methods, I am having trouble running JDB in parallel with Frida on a simple Java application.
The Frida script is as follows, only adding logs when passing through the method Main.a
:
Java.perform(() => {
Java.use("Main").a.overload("java.lang.String").implementation = function(s) {
console.log('hooked!');
this.a(s);
};
})
This alone works perfectly. However, when I try to attach JDB to the simple Java program, JDB hangs, whereas when the main program is not instrumented with Frida, I can attach JDB easily and it works flawlessly.
Do you know what migth cause this behavior ? Any workaround ?
NB : answering the above interrogations will help me towards understanding the Frida magic regarding re-implementing Java methods, but if you know precisely how Frida does that do not hesitate to reach out.
As far as I know :
- Frida compiles my javascript code into C
- it injects it in frida-agent.so
- it replaces the function pointer of the original method with a pointer towards the native code in frida-agent.so ?? This is the part I do not understand. I assume it works like this (opposed to adding a call to a subroutine in frida-agent.so at the first line of
Main.a
) because I inspected the bytecode ofMain.a
before and after reimplementation, and it stays exactly the same. - When I call
this.a
in the new implementation, it calls back to the original location ofMain.a
I do not understand why that would break the debugging interface.