Ghidra Decompiler Analysis Engine
|
A class for sorting comments into and within basic blocks. More...
#include <comment.hh>
Public Types | |
enum | { header_basic = 0, header_unplaced = 1 } |
Public Member Functions | |
void | setupFunctionList (uint4 tp, const Funcdata *fd, const CommentDatabase &db, bool displayUnplaced) |
Collect and sort comments specific to the given function. More... | |
void | setupBlockList (const FlowBlock *bl) |
Prepare to walk comments from a single basic block. More... | |
void | setupOpList (const PcodeOp *op) |
Establish a p-code landmark within the current set of comments. More... | |
void | setupHeader (uint4 headerType) |
Prepare to walk comments in the header. More... | |
A class for sorting comments into and within basic blocks.
The decompiler endeavors to display comments within the flow of the source code statements it generates. Comments should be placed at or near the statement that encompasses the address of the original instruction to which the comment is attached. This is complicated by the fact that instructions may get removed and transformed during decompilation and even whole basic blocks may get removed.
This class sorts comments into the basic block that contains it. As statements are emitted, comments can get picked up, in the correct order, even if there is no longer a specific p-code operation at the comment's address. The decompiler maintains information about basic blocks that have been entirely removed, in which case, the user can elect to not display the corresponding comments.
This class also acts as state for walking comments within a specific basic block or within the header.
anonymous enum |
Enumerator | |
---|---|
header_basic | Basic header comments. |
header_unplaced | Comment that can't be placed in code flow. |
void CommentSorter::setupBlockList | ( | const FlowBlock * | bl | ) |
Prepare to walk comments from a single basic block.
Find iterators that bound everything in the basic block
bl | is the basic block |
void CommentSorter::setupFunctionList | ( | uint4 | tp, |
const Funcdata * | fd, | ||
const CommentDatabase & | db, | ||
bool | displayUnplaced | ||
) |
Collect and sort comments specific to the given function.
Only keep comments matching one of a specific set of properties
tp | is the set of properties (may be zero) |
fd | is the given function |
db | is the container of comments to collect from |
displayUnplaced | is true if unplaced comments should be displayed in the header |
void CommentSorter::setupHeader | ( | uint4 | headerType | ) |
Prepare to walk comments in the header.
Header comments are grouped together. Set up iterators.
headerType | selects either header_basic or header_unplaced comments |
void CommentSorter::setupOpList | ( | const PcodeOp * | op | ) |
Establish a p-code landmark within the current set of comments.
This will generally get called with the root p-code op of a statement being emitted by the decompiler. This establishes a key value within the basic block, so it is known where to stop emitting comments within the block for emitting the statement.
op | is the p-code representing the root of a statement |