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
How to Debug an Android Emulator with Ghidra in Windows #6386
Comments
For the GDB connection, this looks related to #6107. In theory, that issue was resolved in 11.0.2, which you're already using, but it still could be similar. What helped me most there was capturing the application log file. I'd like to start with the case where "It gets stuck at the connection phase without any error output." Please also capture the comms between Ghidra and GDB/MI. That can be accomplished by passing the As for JDWP, this connector has probably suffered too much bitrot at this point. We're not likely to fix it ourselves, though we are open to PRs. Most likely, if we pursue JDWP again, it will be to port it to our new "Trace RMI" system. |
When I deleted and recreated the project, gdb worked. However, after the gdb connection, the thread list appears empty and debugging cannot be done. It seems that there is a mismatch between gdb and gdbserver. I am getting an architecture mismatch warning even though the Android emulator and Windows are of the same architecture(x64). Can someone who debugs Android emulator suggest the most stable and error-free solution? GDB.log:
|
@alpgul Thanks for the log. There are a few items of interest, but I think it all comes down to a mismatch is OS/ABI. The first item of interest:
You should probably try using the multiarch build of gdb. The rest I think are symptoms of this mismatch, but I exhibit them here to demonstrate that Ghidra is displaying what GDB tells it:
It seems GDB was not able to get any initial break in the application. The target is created and exited before Ghidra has a chance to interrogate GDB about the target. The "thread-group-exited" event is the application terminating.
Here gdb and gdbserver do not agree in how to exchange registers. I suspect this is due to OS/ABI, but I'm not sure. During negotation of the connection, the gdbserver may send a small XML snippet describing the target. This description also includes the order and types/sizes of registers, which is important for decoding the long hex string GDB is complaining about above. GDB rejected that description because it doesn't understand the GNU/Linux ABI in that description. That's my guess, anyway.
This is just further demonstrating why the Threads list is empty. The target application has exited by now, because GDB did not get an initial break. When Ghidra asks for the threads list, it is indeed empty. My recommendation is to try gdb-multiarch. Get it working from just a plain terminal, without Ghidra, to verify all the other pieces are working correctly. Then, once that's working, try again from Ghidra. |
Error Messages:
C://msys64//mingw64//bin//gdb.exe
The following error occurred while trying to debug in Ghidra:
ghidra.dbg.error.DebuggerModelTerminatingException: Error while starting GDB: Pty implementation does not support null sessions. Try C:\msys64\mingw64\bin\gdb.exe -i mi2.
C://msys64//mingw64//bin//gdb.exe -i mi2
It gets stuck at the connection phase without any error output.
GDB over SSH
The following error occurred while attempting to debug in Ghidra:
ghidra.dbg.error.DebuggerModelTerminatingException: Error while starting GDB: SSH connection error
.ssh/config:
JDWP Execution
Connectors and virtual machine sections appear blank, and there is no error output.
System Information:
Windows Version: 10
Ghidra Version: 11.0.2
JVM Version: Oracle Corporation 22
gdb Version: 14.2
gdbserver (GDB) Version: 7.11
SSH: OpenSSH via Termux
Debugging an Application on a Targeted Android Emulator
Description:
I want to report the issues I encountered while debugging an application on an Android emulator using Ghidra. When using Ghidra, I encountered the following errors:
The first error occurred when Ghidra tried to start GDB. The error message states, "Pty application does not support empty sessions." To resolve the issue, I was advised to try the command "C://msys64//mingw64//bin//gdb.exe -i mi2" but it did not solve the problem.
The second error is related to getting stuck during the connection phase when using the "C://msys64//mingw64//bin//gdb.exe -i mi2" command. There is no error output available.
The third error occurred when attempting to use GDB over SSH. When I run ssh via cmd ("ssh root@localhost -p 8022 -i C:/Users/Demo/.ssh/id_ed25519"), the connection is successful. However, I couldn't establish a successful connection using the "ssh config" due to the Android emulator not having "passwd" installed. I defined the config file as "C://Users//Demo//.ssh//config."
JDWP Execution: After running the command "adb forward tcp:11111 jdwp:1234" via ADB, I can establish a JDWP connection in Ghidra. However, I cannot perform the debugging process because the connectors and virtual machine sections appear blank, and I don't receive any error output. When I tested JDWP via cmd("jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=11111"), it worked correctly.
The text was updated successfully, but these errors were encountered: