decompiler  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
ghidra::Comment Class Reference

A comment attached to a specific function and code address. More...

#include <comment.hh>

Public Types

enum  comment_type {
  user1 = 1, user2 = 2, user3 = 4, header = 8,
  warning = 16, warningheader = 32
}
 Possible properties associated with a comment. More...
 

Public Member Functions

 Comment (uint4 tp, const Address &fad, const Address &ad, int4 uq, const string &txt)
 Constructor. More...
 
 Comment (void)
 Constructor for use with decode.
 
void setEmitted (bool val) const
 Mark that this comment has been emitted.
 
bool isEmitted (void) const
 Return true if this comment is already emitted.
 
uint4 getType (void) const
 Get the properties associated with the comment.
 
const AddressgetFuncAddr (void) const
 Get the address of the function containing the comment.
 
const AddressgetAddr (void) const
 Get the address to which the instruction is attached.
 
int4 getUniq (void) const
 Get the sub-sorting index.
 
const string & getText (void) const
 Get the body of the comment.
 
void encode (Encoder &encoder) const
 Encode the comment to a stream. More...
 
void decode (Decoder &decoder)
 Restore the comment from XML. More...
 

Static Public Member Functions

static uint4 encodeCommentType (const string &name)
 Convert name string to comment property. More...
 
static string decodeCommentType (uint4 val)
 Convert comment property to string. More...
 

Private Attributes

uint4 type
 The properties associated with the comment.
 
int4 uniq
 Sub-identifier for uniqueness.
 
Address funcaddr
 Address of the function containing the comment.
 
Address addr
 Address associated with the comment.
 
string text
 The body of the comment.
 
bool emitted
 true if this comment has already been emitted
 

Friends

class CommentDatabaseInternal
 

Detailed Description

A comment attached to a specific function and code address.

Things contains the actual character data of the comment. It is fundamentally attached to a specific function and to the address of an instruction (within the function's body). Comments can be categorized as a header (or not) depending on whether it should be displayed as part of the general description of the function or not. Other properties can be assigned to a comment, to allow the user to specify the subset of all comments they want to display.

Member Enumeration Documentation

◆ comment_type

Possible properties associated with a comment.

Enumerator
user1 

The first user defined property.

user2 

The second user defined property.

user3 

The third user defined property.

header 

The comment should be displayed in the function header.

warning 

The comment is auto-generated to alert the user.

warningheader 

The comment is auto-generated and should be in the header.

Constructor & Destructor Documentation

◆ Comment()

ghidra::Comment::Comment ( uint4  tp,
const Address fad,
const Address ad,
int4  uq,
const string &  txt 
)

Constructor.

Parameters
tpis the set of properties to associate with the comment (or 0 for no properties)
fadis the Address of the function containing the comment
adis the Address of the instruction associated with the comment
uqis used internally to sub-sort comments at the same address
txtis the body of the comment

Member Function Documentation

◆ decode()

void ghidra::Comment::decode ( Decoder decoder)

Restore the comment from XML.

Parse a <comment> element from the given stream decoder

Parameters
decoderis the given stream decoder

References addr, ghidra::Decoder::closeElement(), ghidra::Address::decode(), emitted, encodeCommentType(), funcaddr, ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), ghidra::Decoder::readString(), text, and type.

Referenced by ghidra::CommentDatabaseInternal::decode(), getText(), and ghidra::CommentDatabase::~CommentDatabase().

◆ decodeCommentType()

string ghidra::Comment::decodeCommentType ( uint4  val)
static

Convert comment property to string.

Parameters
valis a single comment property
Returns
the string representation of the property

References header, user1, user2, user3, warning, and warningheader.

Referenced by encode(), and getText().

◆ encode()

void ghidra::Comment::encode ( Encoder encoder) const

Encode the comment to a stream.

The single comment is encoded as a <comment> element.

Parameters
encoderis the stream encoder

References addr, ghidra::Encoder::closeElement(), decodeCommentType(), ghidra::AddrSpace::encodeAttributes(), funcaddr, ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::Encoder::openElement(), text, type, and ghidra::Encoder::writeString().

Referenced by getText(), and ghidra::CommentDatabase::~CommentDatabase().

◆ encodeCommentType()

uint4 ghidra::Comment::encodeCommentType ( const string &  name)
static

Convert name string to comment property.

Parameters
nameis a string representation of a single comment property
Returns
the enumerated property type

References header, user1, user2, user3, warning, and warningheader.

Referenced by ghidra::OptionCommentHeader::apply(), ghidra::OptionCommentInstruction::apply(), decode(), and getText().


The documentation for this class was generated from the following files: