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
Debugging the native (C++) decompiler? #720
Comments
You can activate the debug dump actions from the pull down menu at the top of the decompiler. They dump .xml files that describe all the input to the decompiler. Very useful for submitting a bug report as all the information necessary to re-produce the issue is included. |
I’m interested in the compile time flag. I want to use it for debugging the decompiler and/or my new processor definitions. I want to find out why the decompiler erroneously optimizes / deletes certain p-code instructions, until it believes that some code is unreachable (which is incorrect). Sent with GitHawk |
I think the compile time flag is actually used to compile C++ code to I tried e.g. |
@mh- ony way to debug the decompiler is using the integrated "dump debug info to xml" from Ghidra and then load the XML file into a command-line instance of the decompiler, like this:
Then you can easily modify the decompiler source / compiler flags and re-decompile the same function, or even attach a debugger like GDB to the decompiler directly. |
Hi @bennofs , thanks a lot for your hint! Since I didn't find any detailed instructions for the command line decompiler, I'll post my results here, hopefully this will help others...
(
Now I can indeed debug the decompiler using gdb, or add
The built-in commands can be found in ifacedecomp.cc If there are public instructions available for this, I would be most interested :) |
For anyone curious this works on windows using wsl without a problem. You just need to do |
Can someone share here what did they need to modify in the MakeFile? im trying to run it in windows (using wsl of course) and its not working... |
I believe it originally worked out of the box. I attempted to recompile it from a out of data branch that built the last time I used it and ended up with:
I can take a further look later this week if nobody else happens to do so. |
I'm having a couple of errors concerning bison command - did you need to manually install that or something? |
Do you have it installed in windows? If not you shouldn't have to install it. Then again it may depend on which subsystem you're using. You could always just install it via apt |
I solve the issue with a dirty hack: patch. |
My working environment is Windows 7 64. |
So I successfully built the decomp_dbg but when I run the "restore" command, giving it the xml file I generated (using the "Debug Function Decompilation" button in the Decompiler"), the following error pops up: "Execution error: XML error parsing SLEIGH file: Unable to open xml document". Thanks in advance. P.S. needless to say I copied the xml file to the same directory of the decomp_dbg file. |
Same issue as @meromwolff ghidra 9.2 Edit: I figured it out with some GDB work. In a fresh git checkout of Ghidra, the SLEIGH spec files (.slaspec) are not compiled into the required .sla files. The loading will fail in
|
@grant-h |
What steps do you recommend to activate the debugging code that's already in the C++ decompiler and apparently could write a debug log to a file (#define "CPUI_DEBUG")?
There's e.g. DecompileDebug.java and DebugDecompilerAction.java, but what's the best way to activate these?
The text was updated successfully, but these errors were encountered: