Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
An implementation of CommentDatabase backed by a Ghidra client. More...
#include <comment_ghidra.hh>
Public Member Functions | |
CommentDatabaseGhidra (ArchitectureGhidra *g) | |
Constructor. | |
virtual void | clear (void) |
Clear all comments from this container. | |
virtual void | clearType (const Address &fad, uint4 tp) |
Clear all comments matching (one of) the indicated types. | |
virtual void | addComment (uint4 tp, const Address &fad, const Address &ad, const string &txt) |
virtual bool | addCommentNoDuplicate (uint4 tp, const Address &fad, const Address &ad, const string &txt) |
Add a new comment to the container, making sure there is no duplicate. | |
virtual void | deleteComment (Comment *com) |
Remove the given Comment object from the container. | |
virtual CommentSet::const_iterator | beginComment (const Address &fad) const |
Get an iterator to the beginning of comments for a single function. | |
virtual CommentSet::const_iterator | endComment (const Address &fad) const |
Get an iterator to the ending of comments for a single function. | |
virtual void | encode (Encoder &encoder) const |
Encode all comments in the container to a stream. | |
virtual void | decode (Decoder &decoder) |
Decode all comments from a <commentdb> element. | |
![]() | |
CommentDatabase (void) | |
Constructor. | |
virtual | ~CommentDatabase (void) |
Destructor. | |
Private Member Functions | |
void | fillCache (const Address &fad) const |
Fetch comments for the given function. | |
Private Attributes | |
ArchitectureGhidra * | ghidra |
The Architecture and connection to the Ghidra client. | |
CommentDatabaseInternal | cache |
A cache of Comment objects received from the Ghidra client. | |
bool | cachefilled |
Set to true if comments for the current function have been fetched. | |
An implementation of CommentDatabase backed by a Ghidra client.
Comment information about particular functions is obtained by querying a Ghidra client. All comments for a single function are queried at once, and results are cached in this object. The cache needs to be cleared between functions using the clear() method.
|
virtual |
For the Ghidra implementation of CommentDatabase, addComment() is currently only called by the warning routines which generates the warning and warningheader comment types. Neither of these types is intended to be a permanent comment in the database, so we only add the comment to the cache
Implements ghidra::CommentDatabase.
References ghidra::CommentDatabaseInternal::addComment(), and cache.
|
virtual |
Add a new comment to the container, making sure there is no duplicate.
If there is already a comment at the same address with the same body, no new comment is added.
tp | is a set of properties to associate with the new comment (may be zero) |
fad | is the address of the function to which the comment belongs |
ad | is the address to which the comment is attached |
txt | is the body of the comment |
Implements ghidra::CommentDatabase.
References ghidra::CommentDatabaseInternal::addCommentNoDuplicate(), and cache.
|
virtual |
Get an iterator to the beginning of comments for a single function.
fad | is the address of the function |
Implements ghidra::CommentDatabase.
References ghidra::CommentDatabaseInternal::beginComment(), cache, and fillCache().
|
inlinevirtual |
Clear all comments from this container.
Implements ghidra::CommentDatabase.
References cache, cachefilled, and ghidra::CommentDatabaseInternal::clear().
|
inlinevirtual |
Clear all comments matching (one of) the indicated types.
Clearing is restricted to comments belonging to a specific function and matching at least one of the given properties
fad | is the address of the owning function |
tp | is a set of one or more properties |
Implements ghidra::CommentDatabase.
References cache, and ghidra::CommentDatabaseInternal::clearType().
|
inlinevirtual |
Decode all comments from a <commentdb> element.
decoder | is the stream decoder |
Implements ghidra::CommentDatabase.
|
inlinevirtual |
Remove the given Comment object from the container.
com | is the given Comment |
Implements ghidra::CommentDatabase.
|
inlinevirtual |
Encode all comments in the container to a stream.
Writes a <commentdb> element, with <comment> children for each Comment object.
encoder | is the stream encoder |
Implements ghidra::CommentDatabase.
|
virtual |
Get an iterator to the ending of comments for a single function.
fad | is the address of the function |
Implements ghidra::CommentDatabase.
References cache, and ghidra::CommentDatabaseInternal::endComment().
|
private |
Fetch comments for the given function.
Fetch all comments for the function in one chunk. Deserialize them and store the Comment objects in the cache
fad | is the address of the given function |
References ghidra::CommentDatabaseInternal::beginComment(), cache, cachefilled, ghidra::CommentDatabaseInternal::decode(), ghidra::CommentDatabaseInternal::endComment(), ghidra::ArchitectureGhidra::getComments(), ghidra::PrintLanguage::getHeaderComment(), ghidra::PrintLanguage::getInstructionComment(), ghidra, and ghidra::Architecture::print.
Referenced by beginComment().