NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
50.94k stars 5.81k forks source link

About improving the readability of decompiled code #6489

Open 01ChenQing opened 4 months ago

01ChenQing commented 4 months ago

Is your feature request related to a problem? Please describe. I'm always frustrated when use ghidra to view an if statement with a long expression

Ghidra: image

IDA: image

Describe the solution you'd like Consider formatting the decompiled code to increase its readability

Varriount commented 4 months ago

@ryanmkurtz @caheckman Since Ghidra's internal documentation is a bit sparse on the subject, is there any way for an internal plugin to reformat the C code emitted by the decompiler? If so, then perhaps an existing formatting tool can be leveraged for this feature.

01ChenQing commented 4 months ago

@ryanmkurtz @caheckman Since Ghidra's internal documentation is a bit sparse on the subject, is there any way for an internal plugin to reformat the C code emitted by the decompiler? If so, then perhaps an existing formatting tool can be leveraged for this feature.

I reconsidered this problem. Implementing this Feature by introducing a code formatting tool like ClangFormat may solve the problem now, but the code formatting tool has limited understanding of program semantics. Although it can adjust the code format, it cannot Improve code readability in other aspects, such as reducing the number of statement nesting levels(#6014), etc.