ROSE 0.11.145.147
|
Unparses binary AST into text.
This class operates on part of an AST corresponding to a binary file (executable, library, etc) and generates output. It is intended to be highly customizable and has been used to generate both assembly listings and Graphviz files.
To generate an assembly listing, use the unparse() method, like this:
The unparser can organize the output either by address (like traditional assembly listings) or by the organization found in the AST (by interpretation, then function, then basic block). The AST organization is often more useful and is therefore the default. Some of the callbacks mentioned below apply only to one organizational style or the other.
Instead of passing a SgProject node to the unparse() method, one may also pass lower-level nodes, such as SgAsmInterpretation, SgAsmFunction, SgAsmBlock, or even a single SgAsmInstruction. The unparser operates finding the list of top-level, unparsable nodes (see find_unparsable_nodes()) reachable from the specified node and then unparsing each one. For each node, an appropriate unparse_TYPE() is called, where TYPE is "insn", "basicblock", "staticdata", "datablock", "function", or "interpretation". Each of these unparse functions invokes three lists of callbacks:
The callback lists are initialized to contain the following functor types. Some callbacks are no-ops for certain organizations of the output, and these are noted.
Additional functors are defined within the AsmUnparser class but are not installed into the callback lists by default. They're only provided because they might be useful to end users.
Sometimes ROSE mistakenly assumes that certain parts of the address space are static data. This can happen, for example, when code is unreachable. One common place this happens is when a call is made to a function that never returns, but the compiler thought it might return. It's often useful to be able to disassemble these static data areas and present them as instructions (in addition to the usual data presentation). Originally, this had to be done by hand using a derived AsmUnparser class and registering a static data unparser that did the disassembly, but now the AsmUnparser class defines a staticDataDisassembler callback (of type StaticDataDisassembler) for this purpose. In order to disassemble static data, one needs to provide the staticDataDisassembler with a disassembler. One way to do that is to use the default disassembler for the interpretation that's being unparsed. One could also use the same disassembler that was originally used to disassemble the entire specimen. In either case, setting the disassembler's recursion properties is probably wise since static data is often meaningless as instructions.
The output will look something like this:
0x0804828f: 00 ff 35 a0 95 04 08 ff |..5.....| 0x08048297: 25 a4 95 04 08 00 00 00 |%.......| 0x0804829f: 00 |. | 17 bytes untyped data beginning at 0x0804828f 0x0804828f: 00 ff |.. | (data) add bh, bh 0x08048291: 35 a0 95 04 08 |5.... | (data) xor eax, 0x080495a0 0x08048296: ff 25 a4 95 04 08 |.%.... | (data) jmp DWORD PTR ds:[0x080495a4] 0x0804829c: 00 00 |.. | (data) add BYTE PTR ds:[eax], al 0x0804829e: 00 00 |.. | (data) add BYTE PTR ds:[eax], al
This example shows how one can replace a register name with something else. Let's say that MIPS32 Release 1 instructions are being unparsed and you'd rather see "lr" (for "link register") rather than "r31" or "ra". This can be accomplished by creating a new register dictionary, adding the definition for "lr", and using that dictionary for unparsing:
This next example shows how to escape entire instructions for HTML output, and surround each instruction with an HTML table row. We could have just as easily combined all three parts into a single functor, but doing it this way makes the example a bit more interesting.
Definition at line 257 of file AsmUnparser.h.
#include <backend/asmUnparser/AsmUnparser.h>
Classes | |
class | BasicBlockBody |
Functor to emit the instructions that belong to a basic block. More... | |
class | BasicBlockCleanup |
Functor to clean up after basic block. More... | |
class | BasicBlockLineTermination |
Functor to emit a blank line after every basic block. More... | |
class | BasicBlockNoopUpdater |
Functor to update unparser's is_noop array. More... | |
class | BasicBlockNoopWarning |
Functor to emit a warning if the block contains any no-effect sequences. More... | |
class | BasicBlockOutgoingStackDelta |
Functor to emit basic block outgoing stack delta. More... | |
class | BasicBlockPredecessors |
Functor to emit control flow predecessor addresses. More... | |
class | BasicBlockReasons |
Functor to emit reasons this block is part of a function. More... | |
class | BasicBlockSuccessors |
Functor to emit block successor list. More... | |
struct | CallbackLists |
class | DataBlockBody |
Functor to emit each data statement of the block. More... | |
class | DataBlockLineTermination |
Functor to emit a blank line after every data block. More... | |
class | DataBlockTitle |
Functor to print some information at the beginning of a data block. More... | |
class | FunctionAttributes |
Functor to emit function attributes. More... | |
class | FunctionBody |
Functor to unparse the function body. More... | |
class | FunctionComment |
Functor to print function comments followed by a linefeed if necessary. More... | |
class | FunctionEntryAddress |
Functor to emit function entry address. More... | |
class | FunctionLineTermination |
Functor to emit function line termination. More... | |
class | FunctionName |
Functor to emit function name. More... | |
class | FunctionPredecessors |
Functor to print caller addresses. More... | |
class | FunctionReasons |
Functor to emit function reasons. More... | |
class | FunctionSeparator |
Functor to emit function separator. More... | |
class | FunctionSuccessors |
Functor to print callee addresses. More... | |
class | InsnAddress |
Functor to emit instruction address. More... | |
class | InsnBlockEntry |
Functor to emit info about the first instruction of a block. More... | |
class | InsnBlockSeparation |
Functor to emit basic block separation in output organized by address. More... | |
class | InsnBody |
Functor to emit the entire instruction. More... | |
class | InsnComment |
Functor to emit instruction comment, if any. More... | |
class | InsnFuncEntry |
Functor to emit function information at entry points. More... | |
class | InsnLineTermination |
Functor to emit instruction line termination. More... | |
class | InsnNoEffect |
Functor to emit a note about instructions that have no effect. More... | |
class | InsnRawBytes |
Functor to emit instruction bytes. More... | |
class | InsnSkipBackBegin |
Functor to print skip/back information when an instruction is entered. More... | |
class | InsnSkipBackEnd |
Update instruction end address for skip/back reporting. More... | |
class | InsnStackDelta |
Functor to emit the numeric stack delta at each instruction. More... | |
class | InterpBody |
Functor to emit the functions in an interpretation. More... | |
class | InterpName |
Functor to emit interpretation name. More... | |
struct | LinePrefix |
Details for line prefixes. More... | |
struct | SkipBack |
Details for skip/back reporting. More... | |
class | StaticDataBlockEntry |
Functor to emit info about the first data node of a block. More... | |
class | StaticDataBlockSeparation |
Functor to emit data block separation in output organized by address. More... | |
class | StaticDataComment |
Functor to emit optional static data comment. More... | |
class | StaticDataDetails |
Functor to emit details about static data. More... | |
class | StaticDataDisassembler |
Disassembles static data as if it were code. More... | |
class | StaticDataLineTermination |
Functor to emit a blank line after every data block. More... | |
class | StaticDataRawBytes |
Functor to emit the bytes of the data block. More... | |
class | StaticDataSkipBackBegin |
Functor to print skip/back information when a static data block is entered. More... | |
class | StaticDataSkipBackEnd |
Update static data end address for skip/back reporting. More... | |
class | UnparserCallback |
Public Types | |
enum | Organization { ORGANIZED_BY_AST , ORGANIZED_BY_ADDRESS } |
typedef Rose::BinaryAnalysis::ControlFlow::Graph | CFG |
Control Flow Graph type. | |
typedef boost::graph_traits< CFG >::vertex_descriptor | CFG_Vertex |
typedef std::map< SgAsmBlock *, CFG_Vertex > | CFG_BlockMap |
typedef Rose::BinaryAnalysis::FunctionCall::Graph | CG |
typedef boost::graph_traits< CG >::vertex_descriptor | CG_Vertex |
typedef std::map< SgAsmFunction *, CG_Vertex > | CG_FunctionMap |
typedef std::map< uint64_t, std::string > | LabelMap |
Maps integers to labels. | |
Public Member Functions | |
AsmUnparser () | |
Constructor that intializes the "unparser" callback lists with some useful functors. | |
virtual bool | is_unparsable_node (SgNode *node) |
Determines if a node can be unparsed. | |
virtual SgNode * | find_unparsable_node (SgNode *ast) |
Finds first unparsable node. | |
virtual std::vector< SgNode * > | find_unparsable_nodes (SgNode *ast) |
Finds top unparsable nodes. | |
virtual size_t | unparse (std::ostream &, SgNode *ast) |
Unparse part of the AST. | |
std::string | to_string (SgNode *ast) |
Unparse part of the AST into a string. | |
virtual bool | unparse_one_node (std::ostream &, SgNode *) |
Unparse a single node if possible. | |
void | add_function_labels (SgNode *ast) |
Adds function labels to the label map. | |
void | add_control_flow_graph (const Rose::BinaryAnalysis::ControlFlow::Graph &cfg) |
Associates a control flow graph with this unparser. | |
virtual Organization | get_organization () const |
Get/set how output is organized. | |
virtual void | set_organization (Organization organization) |
Get/set how output is organized. | |
virtual RegisterDictionaryPtr | get_registers () const |
Register dictionaries. | |
virtual void | set_registers (const RegisterDictionaryPtr ®isters) |
Register dictionaries. | |
virtual bool | unparse_insn (bool enabled, std::ostream &, SgAsmInstruction *, size_t position_in_block=(size_t) -1) |
Unparse an object. | |
virtual bool | unparse_basicblock (bool enabled, std::ostream &, SgAsmBlock *) |
Unparse an object. | |
virtual bool | unparse_staticdata (bool enabled, std::ostream &, SgAsmStaticData *, size_t position_in_block=(size_t) -1) |
Unparse an object. | |
virtual bool | unparse_datablock (bool enabled, std::ostream &, SgAsmBlock *) |
Unparse an object. | |
virtual bool | unparse_function (bool enabled, std::ostream &, SgAsmFunction *) |
Unparse an object. | |
virtual bool | unparse_interpretation (bool enabled, std::ostream &, SgAsmInterpretation *) |
Unparse an object. | |
void | set_skipback_reporting (bool b=true) |
Controls printing of skip/back messages during linear output. | |
void | clear_skipback_reporting () |
Controls printing of skip/back messages during linear output. | |
bool | get_skipback_reporting () const |
Controls printing of skip/back messages during linear output. | |
void | reset_skipback () |
Controls printing of skip/back messages during linear output. | |
void | start_of_object (rose_addr_t, std::ostream &) |
Controls printing of skip/back messages during linear output. | |
void | end_of_object (rose_addr_t) |
Controls printing of skip/back messages during linear output. | |
virtual void | set_prefix_format (const std::string &format) |
Controls printing of line prefixes. | |
virtual const std::string & | get_prefix_format () const |
Controls printing of line prefixes. | |
virtual void | set_prefix_address (rose_addr_t va) |
Controls printing of line prefixes. | |
virtual rose_addr_t | get_prefix_address () const |
Controls printing of line prefixes. | |
virtual std::string | line_prefix () const |
Controls printing of line prefixes. | |
virtual std::string | blank_prefix () const |
Controls printing of line prefixes. | |
Static Public Member Functions | |
static void | initDiagnostics () |
Initialize diagnostic messages subsystem. | |
Static Public Attributes | |
static Sawyer::Message::Facility | mlog |
Diagnostic messages. | |
Protected Member Functions | |
virtual void | init () |
Initializes the callback lists. | |
Protected Attributes | |
CallbackLists | insn_callbacks |
Callbacks for instruction unparsing. | |
CallbackLists | basicblock_callbacks |
Callbacks for basic block unparsing. | |
CallbackLists | staticdata_callbacks |
Callbacks for static data unparsing. | |
CallbackLists | datablock_callbacks |
Callbacks for data block unparsing. | |
CallbackLists | function_callbacks |
Callbacks for function unparsing. | |
CallbackLists | interp_callbacks |
Callbacks for interpretation unparsing. | |
LabelMap | labels |
This map is consulted whenever a constant is encountered. | |
Organization | organization |
How output will be organized. | |
RegisterDictionaryPtr | user_registers |
Dictionaries used to convert register descriptors to register names. | |
RegisterDictionaryPtr | interp_registers |
CFG | cfg |
Control flow graph. | |
CFG_BlockMap | cfg_blockmap |
A mapping from SgAsmBlock to control flow graph vertex. | |
CG | cg |
Function call graph. | |
CG_FunctionMap | cg_functionmap |
A mapping from SgAsmFunction to call graph vertex. | |
struct Rose::BinaryAnalysis::AsmUnparser::SkipBack | skipback |
struct Rose::BinaryAnalysis::AsmUnparser::LinePrefix | lineprefix |
Control Flow Graph type.
The unparser supports the standard binary control flow graph data type. This could be templatized, but we're planning to move to a non-template graph type in the near future [RPM 2012-04-18].
Definition at line 273 of file AsmUnparser.h.
typedef boost::graph_traits<CFG>::vertex_descriptor Rose::BinaryAnalysis::AsmUnparser::CFG_Vertex |
Definition at line 274 of file AsmUnparser.h.
typedef std::map<SgAsmBlock*, CFG_Vertex> Rose::BinaryAnalysis::AsmUnparser::CFG_BlockMap |
Definition at line 275 of file AsmUnparser.h.
typedef Rose::BinaryAnalysis::FunctionCall::Graph Rose::BinaryAnalysis::AsmUnparser::CG |
Definition at line 276 of file AsmUnparser.h.
typedef boost::graph_traits<CG>::vertex_descriptor Rose::BinaryAnalysis::AsmUnparser::CG_Vertex |
Definition at line 277 of file AsmUnparser.h.
typedef std::map<SgAsmFunction*, CG_Vertex> Rose::BinaryAnalysis::AsmUnparser::CG_FunctionMap |
Definition at line 278 of file AsmUnparser.h.
typedef std::map<uint64_t, std::string> Rose::BinaryAnalysis::AsmUnparser::LabelMap |
Maps integers to labels.
Definition at line 902 of file AsmUnparser.h.
Enumerator | |
---|---|
ORGANIZED_BY_AST | Output follows the AST organization. In other words, the instructions and data for a block appear consecutively, the blocks of a function appear consecutively, and the functions of an interpretation appear consecutively. This is the default format since it provides the most information about the organization of the binary file. |
ORGANIZED_BY_ADDRESS | Output of instructions and data are organized by address. Specifically, in the case of overlapping instructions and/or data, the starting address is used to sort the output. This organization is typical of more traditional disassemblers. |
Definition at line 259 of file AsmUnparser.h.
|
inlinevirtual |
Get/set how output is organized.
The unparse() method organizes output by one of the methods described for the Organization enum.
Definition at line 817 of file AsmUnparser.h.
|
inlinevirtual |
Get/set how output is organized.
The unparse() method organizes output by one of the methods described for the Organization enum.
Definition at line 818 of file AsmUnparser.h.
|
virtual |
Determines if a node can be unparsed.
The AsmUnparser only handles certain node types, namely those that correspond to binary functions, blocks, and instructions. This method should return true if the specified node is one that can be parsed. See also, find_unparsable_node().
Finds first unparsable node.
Traverses the specified AST to find a node that can be unparsed, and returns it. The traversal is a depth-first traversal with pre-order visiting. The traversal terminates as soon as a node is found. Returns false if no suitable node can be found.
|
virtual |
Finds top unparsable nodes.
Traverses the specified AST to find nodes that can be unparsed, and returns a vector of such nodes. Once a node is discovered, the subtree rooted at that node is not searched.
|
virtual |
Register dictionaries.
A register dictionary is used to convert register descriptors stored within instructions (via RegisterDescriptor) into names. The unparser keeps two register dictionaries: the user-specified register dictionary, and a dictionary obtained from a SgAsmInterpretation. The user-specified dictionary is used in preference to the SgAsmInterpretation dictionary when both are specified. The SgAsmInterpretation dictionary is set (internally) whenever an SgAsmInterpretation node is encountered during unparsing, and reset after the entire node is unparsed. The user-specified dictionary is set via the set_registers() method. The get_registers() returns either the user-specified or SgAsmInterpretation dictionary.
|
virtual |
Register dictionaries.
A register dictionary is used to convert register descriptors stored within instructions (via RegisterDescriptor) into names. The unparser keeps two register dictionaries: the user-specified register dictionary, and a dictionary obtained from a SgAsmInterpretation. The user-specified dictionary is used in preference to the SgAsmInterpretation dictionary when both are specified. The SgAsmInterpretation dictionary is set (internally) whenever an SgAsmInterpretation node is encountered during unparsing, and reset after the entire node is unparsed. The user-specified dictionary is set via the set_registers() method. The get_registers() returns either the user-specified or SgAsmInterpretation dictionary.
|
virtual |
Unparse part of the AST.
This is the primary method for this class. It traverses the specified ast
and prints some kind of assembly language output to the specified output stream. The specifics of what is produced depend on how the AsmUnparser is configured.
The return value is the number of unparsable nodes encountered and has various meanings depending on the output organization. For output organized by AST it is the number of "top-level unparsable nodes", the number of nodes, R, such that is_unparsable_node(R) is true, and there exists no node C such that C is a proper ancestor of R and contained in the specified AST. For output organized by address, it is the number of instructions and data objects unparsed. In any case, a return value of zero means that nothing was unparsed and no output was produced.
std::string Rose::BinaryAnalysis::AsmUnparser::to_string | ( | SgNode * | ast | ) |
|
virtual |
|
virtual |
Unparse an object.
These are called by unparse_one_node(), but might also be called by callbacks.
|
virtual |
Unparse an object.
These are called by unparse_one_node(), but might also be called by callbacks.
|
virtual |
Unparse an object.
These are called by unparse_one_node(), but might also be called by callbacks.
|
virtual |
Unparse an object.
These are called by unparse_one_node(), but might also be called by callbacks.
|
virtual |
Unparse an object.
These are called by unparse_one_node(), but might also be called by callbacks.
|
virtual |
Unparse an object.
These are called by unparse_one_node(), but might also be called by callbacks.
void Rose::BinaryAnalysis::AsmUnparser::add_function_labels | ( | SgNode * | ast | ) |
Adds function labels to the label map.
This method traverses the specified AST looking for function symbols, and adds their address and name to the label map for the unparser. The map is used by some callbacks to convert numeric values to more human friendly labels. If integer values are relative to other AST nodes, then one doesn't need to populate the LabelMap (see documentation for the AsmUnparser::labels data member.
void Rose::BinaryAnalysis::AsmUnparser::add_control_flow_graph | ( | const Rose::BinaryAnalysis::ControlFlow::Graph & | cfg | ) |
Associates a control flow graph with this unparser.
If a control flow graph is present then certain output callbacks will be able to use that information. For instance, the basicBlockPredecessors will emit a list of all the predecessors of a block. Passing an empty graph will remove control flow information.
|
inline |
Controls printing of skip/back messages during linear output.
Each callback that prints an object that occupies address space should call start_of_object() and end_of_object() before and after printing the object. If output is organized in the linear fashion and the start of an object does not coincide with the end of the previous object, and if skip/back reporting is enabled, then a message about skipping ahead or backward is inserted into the unparse output at that point.
Definition at line 921 of file AsmUnparser.h.
|
inline |
Controls printing of skip/back messages during linear output.
Each callback that prints an object that occupies address space should call start_of_object() and end_of_object() before and after printing the object. If output is organized in the linear fashion and the start of an object does not coincide with the end of the previous object, and if skip/back reporting is enabled, then a message about skipping ahead or backward is inserted into the unparse output at that point.
Definition at line 922 of file AsmUnparser.h.
|
inline |
Controls printing of skip/back messages during linear output.
Each callback that prints an object that occupies address space should call start_of_object() and end_of_object() before and after printing the object. If output is organized in the linear fashion and the start of an object does not coincide with the end of the previous object, and if skip/back reporting is enabled, then a message about skipping ahead or backward is inserted into the unparse output at that point.
Definition at line 923 of file AsmUnparser.h.
|
inline |
Controls printing of skip/back messages during linear output.
Each callback that prints an object that occupies address space should call start_of_object() and end_of_object() before and after printing the object. If output is organized in the linear fashion and the start of an object does not coincide with the end of the previous object, and if skip/back reporting is enabled, then a message about skipping ahead or backward is inserted into the unparse output at that point.
Definition at line 924 of file AsmUnparser.h.
void Rose::BinaryAnalysis::AsmUnparser::start_of_object | ( | rose_addr_t | , |
std::ostream & | |||
) |
Controls printing of skip/back messages during linear output.
Each callback that prints an object that occupies address space should call start_of_object() and end_of_object() before and after printing the object. If output is organized in the linear fashion and the start of an object does not coincide with the end of the previous object, and if skip/back reporting is enabled, then a message about skipping ahead or backward is inserted into the unparse output at that point.
void Rose::BinaryAnalysis::AsmUnparser::end_of_object | ( | rose_addr_t | ) |
Controls printing of skip/back messages during linear output.
Each callback that prints an object that occupies address space should call start_of_object() and end_of_object() before and after printing the object. If output is organized in the linear fashion and the start of an object does not coincide with the end of the previous object, and if skip/back reporting is enabled, then a message about skipping ahead or backward is inserted into the unparse output at that point.
|
inlinevirtual |
Controls printing of line prefixes.
Lines have an optional prefix area that tends to be the same regardless of the kind of object being printed. For instance, the default is for most lines to contain an address of some sort. Sometimes we want the prefix area to be the same size for all lines but have some lines with a blank prefix; and sometimes we want to omit the prefix and its indentation altogether.
The prefix format (set_prefix_format() and get_prefix_format()) is a printf-style format string with an optional format specifier for an unsigned 64-bit integer address. The address is set by the unparser when an unparsable object is encountered, but can be overridden by on of that object's callbacks (set_prefix_address() and get_prefix_address()). A prefix string is returned by by line_prefix() or blank_prefix() using the current format string and address (a blank prefix first calls line_prefix() and then changes all characters to ASCII SPC).
Definition at line 943 of file AsmUnparser.h.
|
inlinevirtual |
Controls printing of line prefixes.
Lines have an optional prefix area that tends to be the same regardless of the kind of object being printed. For instance, the default is for most lines to contain an address of some sort. Sometimes we want the prefix area to be the same size for all lines but have some lines with a blank prefix; and sometimes we want to omit the prefix and its indentation altogether.
The prefix format (set_prefix_format() and get_prefix_format()) is a printf-style format string with an optional format specifier for an unsigned 64-bit integer address. The address is set by the unparser when an unparsable object is encountered, but can be overridden by on of that object's callbacks (set_prefix_address() and get_prefix_address()). A prefix string is returned by by line_prefix() or blank_prefix() using the current format string and address (a blank prefix first calls line_prefix() and then changes all characters to ASCII SPC).
Definition at line 944 of file AsmUnparser.h.
|
inlinevirtual |
Controls printing of line prefixes.
Lines have an optional prefix area that tends to be the same regardless of the kind of object being printed. For instance, the default is for most lines to contain an address of some sort. Sometimes we want the prefix area to be the same size for all lines but have some lines with a blank prefix; and sometimes we want to omit the prefix and its indentation altogether.
The prefix format (set_prefix_format() and get_prefix_format()) is a printf-style format string with an optional format specifier for an unsigned 64-bit integer address. The address is set by the unparser when an unparsable object is encountered, but can be overridden by on of that object's callbacks (set_prefix_address() and get_prefix_address()). A prefix string is returned by by line_prefix() or blank_prefix() using the current format string and address (a blank prefix first calls line_prefix() and then changes all characters to ASCII SPC).
Definition at line 945 of file AsmUnparser.h.
|
inlinevirtual |
Controls printing of line prefixes.
Lines have an optional prefix area that tends to be the same regardless of the kind of object being printed. For instance, the default is for most lines to contain an address of some sort. Sometimes we want the prefix area to be the same size for all lines but have some lines with a blank prefix; and sometimes we want to omit the prefix and its indentation altogether.
The prefix format (set_prefix_format() and get_prefix_format()) is a printf-style format string with an optional format specifier for an unsigned 64-bit integer address. The address is set by the unparser when an unparsable object is encountered, but can be overridden by on of that object's callbacks (set_prefix_address() and get_prefix_address()). A prefix string is returned by by line_prefix() or blank_prefix() using the current format string and address (a blank prefix first calls line_prefix() and then changes all characters to ASCII SPC).
Definition at line 946 of file AsmUnparser.h.
|
virtual |
Controls printing of line prefixes.
Lines have an optional prefix area that tends to be the same regardless of the kind of object being printed. For instance, the default is for most lines to contain an address of some sort. Sometimes we want the prefix area to be the same size for all lines but have some lines with a blank prefix; and sometimes we want to omit the prefix and its indentation altogether.
The prefix format (set_prefix_format() and get_prefix_format()) is a printf-style format string with an optional format specifier for an unsigned 64-bit integer address. The address is set by the unparser when an unparsable object is encountered, but can be overridden by on of that object's callbacks (set_prefix_address() and get_prefix_address()). A prefix string is returned by by line_prefix() or blank_prefix() using the current format string and address (a blank prefix first calls line_prefix() and then changes all characters to ASCII SPC).
|
inlinevirtual |
Controls printing of line prefixes.
Lines have an optional prefix area that tends to be the same regardless of the kind of object being printed. For instance, the default is for most lines to contain an address of some sort. Sometimes we want the prefix area to be the same size for all lines but have some lines with a blank prefix; and sometimes we want to omit the prefix and its indentation altogether.
The prefix format (set_prefix_format() and get_prefix_format()) is a printf-style format string with an optional format specifier for an unsigned 64-bit integer address. The address is set by the unparser when an unparsable object is encountered, but can be overridden by on of that object's callbacks (set_prefix_address() and get_prefix_address()). A prefix string is returned by by line_prefix() or blank_prefix() using the current format string and address (a blank prefix first calls line_prefix() and then changes all characters to ASCII SPC).
Definition at line 948 of file AsmUnparser.h.
|
protectedvirtual |
Initializes the callback lists.
This is invoked by the default constructor.
InsnSkipBackBegin Rose::BinaryAnalysis::AsmUnparser::insnSkipBackBegin |
Definition at line 753 of file AsmUnparser.h.
InsnBlockSeparation Rose::BinaryAnalysis::AsmUnparser::insnBlockSeparation |
Definition at line 754 of file AsmUnparser.h.
InsnFuncEntry Rose::BinaryAnalysis::AsmUnparser::insnFuncEntry |
Definition at line 755 of file AsmUnparser.h.
InsnAddress Rose::BinaryAnalysis::AsmUnparser::insnAddress |
Definition at line 756 of file AsmUnparser.h.
InsnRawBytes Rose::BinaryAnalysis::AsmUnparser::insnRawBytes |
Definition at line 757 of file AsmUnparser.h.
InsnBlockEntry Rose::BinaryAnalysis::AsmUnparser::insnBlockEntry |
Definition at line 758 of file AsmUnparser.h.
InsnStackDelta Rose::BinaryAnalysis::AsmUnparser::insnStackDelta |
Definition at line 759 of file AsmUnparser.h.
InsnBody Rose::BinaryAnalysis::AsmUnparser::insnBody |
Definition at line 760 of file AsmUnparser.h.
InsnNoEffect Rose::BinaryAnalysis::AsmUnparser::insnNoEffect |
Definition at line 761 of file AsmUnparser.h.
InsnComment Rose::BinaryAnalysis::AsmUnparser::insnComment |
Definition at line 762 of file AsmUnparser.h.
InsnLineTermination Rose::BinaryAnalysis::AsmUnparser::insnLineTermination |
Definition at line 763 of file AsmUnparser.h.
InsnSkipBackEnd Rose::BinaryAnalysis::AsmUnparser::insnSkipBackEnd |
Definition at line 764 of file AsmUnparser.h.
BasicBlockReasons Rose::BinaryAnalysis::AsmUnparser::basicBlockReasons |
Definition at line 766 of file AsmUnparser.h.
BasicBlockPredecessors Rose::BinaryAnalysis::AsmUnparser::basicBlockPredecessors |
Definition at line 767 of file AsmUnparser.h.
BasicBlockNoopUpdater Rose::BinaryAnalysis::AsmUnparser::basicBlockNoopUpdater |
Definition at line 768 of file AsmUnparser.h.
BasicBlockNoopWarning Rose::BinaryAnalysis::AsmUnparser::basicBlockNoopWarning |
Definition at line 769 of file AsmUnparser.h.
BasicBlockBody Rose::BinaryAnalysis::AsmUnparser::basicBlockBody |
Definition at line 770 of file AsmUnparser.h.
BasicBlockOutgoingStackDelta Rose::BinaryAnalysis::AsmUnparser::basicBlockOutgoingStackDelta |
Definition at line 771 of file AsmUnparser.h.
BasicBlockSuccessors Rose::BinaryAnalysis::AsmUnparser::basicBlockSuccessors |
Definition at line 772 of file AsmUnparser.h.
BasicBlockLineTermination Rose::BinaryAnalysis::AsmUnparser::basicBlockLineTermination |
Definition at line 773 of file AsmUnparser.h.
BasicBlockCleanup Rose::BinaryAnalysis::AsmUnparser::basicBlockCleanup |
Definition at line 774 of file AsmUnparser.h.
StaticDataSkipBackBegin Rose::BinaryAnalysis::AsmUnparser::staticDataSkipBackBegin |
Definition at line 776 of file AsmUnparser.h.
StaticDataBlockSeparation Rose::BinaryAnalysis::AsmUnparser::staticDataBlockSeparation |
Definition at line 777 of file AsmUnparser.h.
StaticDataRawBytes Rose::BinaryAnalysis::AsmUnparser::staticDataRawBytes |
Definition at line 778 of file AsmUnparser.h.
StaticDataBlockEntry Rose::BinaryAnalysis::AsmUnparser::staticDataBlockEntry |
Definition at line 779 of file AsmUnparser.h.
StaticDataDetails Rose::BinaryAnalysis::AsmUnparser::staticDataDetails |
Definition at line 780 of file AsmUnparser.h.
StaticDataComment Rose::BinaryAnalysis::AsmUnparser::staticDataComment |
Definition at line 781 of file AsmUnparser.h.
StaticDataLineTermination Rose::BinaryAnalysis::AsmUnparser::staticDataLineTermination |
Definition at line 782 of file AsmUnparser.h.
StaticDataDisassembler Rose::BinaryAnalysis::AsmUnparser::staticDataDisassembler |
Definition at line 783 of file AsmUnparser.h.
StaticDataSkipBackEnd Rose::BinaryAnalysis::AsmUnparser::staticDataSkipBackEnd |
Definition at line 784 of file AsmUnparser.h.
DataBlockBody Rose::BinaryAnalysis::AsmUnparser::dataBlockBody |
Definition at line 786 of file AsmUnparser.h.
DataBlockLineTermination Rose::BinaryAnalysis::AsmUnparser::dataBlockLineTermination |
Definition at line 787 of file AsmUnparser.h.
FunctionEntryAddress Rose::BinaryAnalysis::AsmUnparser::functionEntryAddress |
Definition at line 789 of file AsmUnparser.h.
FunctionSeparator Rose::BinaryAnalysis::AsmUnparser::functionSeparator |
Definition at line 790 of file AsmUnparser.h.
FunctionReasons Rose::BinaryAnalysis::AsmUnparser::functionReasons |
Definition at line 791 of file AsmUnparser.h.
FunctionName Rose::BinaryAnalysis::AsmUnparser::functionName |
Definition at line 792 of file AsmUnparser.h.
FunctionLineTermination Rose::BinaryAnalysis::AsmUnparser::functionLineTermination |
Definition at line 793 of file AsmUnparser.h.
FunctionComment Rose::BinaryAnalysis::AsmUnparser::functionComment |
Definition at line 794 of file AsmUnparser.h.
FunctionPredecessors Rose::BinaryAnalysis::AsmUnparser::functionPredecessors |
Definition at line 795 of file AsmUnparser.h.
FunctionSuccessors Rose::BinaryAnalysis::AsmUnparser::functionSuccessors |
Definition at line 796 of file AsmUnparser.h.
FunctionAttributes Rose::BinaryAnalysis::AsmUnparser::functionAttributes |
Definition at line 797 of file AsmUnparser.h.
FunctionBody Rose::BinaryAnalysis::AsmUnparser::functionBody |
Definition at line 798 of file AsmUnparser.h.
InterpName Rose::BinaryAnalysis::AsmUnparser::interpName |
Definition at line 800 of file AsmUnparser.h.
InterpBody Rose::BinaryAnalysis::AsmUnparser::interpBody |
Definition at line 801 of file AsmUnparser.h.
std::vector<bool> Rose::BinaryAnalysis::AsmUnparser::insn_is_noop |
Optional information about no-op sequences.
When a basic block is unparsed, the BasicBlockNoopUpdater callback (if present and enabled) will analyze its instructions and update the insn_is_noop vector. The vector is indexed by position of instruction within the block and indicates whehter that instruction is part of a no-op sequence. Note that if BasicBlockNoopUpdater is not called for a block, then the insn_is_noop vector will not be initialized. Even if it is initialized, the size of the vector may be less then the number of instructions because we don't store trailing false values. The vector is cleared by the BasicBlockCleanup callback.
Definition at line 863 of file AsmUnparser.h.
|
static |
Diagnostic messages.
Definition at line 953 of file AsmUnparser.h.
|
protected |
Callbacks for instruction unparsing.
Definition at line 969 of file AsmUnparser.h.
|
protected |
Callbacks for basic block unparsing.
Definition at line 970 of file AsmUnparser.h.
|
protected |
Callbacks for static data unparsing.
Definition at line 971 of file AsmUnparser.h.
|
protected |
Callbacks for data block unparsing.
Definition at line 972 of file AsmUnparser.h.
|
protected |
Callbacks for function unparsing.
Definition at line 973 of file AsmUnparser.h.
|
protected |
Callbacks for interpretation unparsing.
Definition at line 974 of file AsmUnparser.h.
|
protected |
This map is consulted whenever a constant is encountered.
If the constant is defined as a key of the map, then that element's string is used as a label. Populating this map is not as important as it once was, because now integers can be associated with other addressable AST nodes and labels are generated from them. For example, if 0x08042000 is the entry address of a function named "init", then it can be added to the LabelMap and the unparser will generate this assembly code:
If the SgAsmIntegerValueExpression that represents the 0x08042000 is associated with the SgAsmFunction node for the "init" function, then the same output is generated when the LabelMap is not populated. In fact, the new method can also generate code like this, where the integer is an offset from the entry point:
which isn't possible in general with the LabelMap mechanism.
Definition at line 995 of file AsmUnparser.h.
|
protected |
How output will be organized.
Definition at line 998 of file AsmUnparser.h.
|
protected |
Dictionaries used to convert register descriptors to register names.
Definition at line 1001 of file AsmUnparser.h.
|
protected |
Definition at line 1002 of file AsmUnparser.h.
|
protected |
Control flow graph.
If non-empty, then it is used for things like listing CFG predecessors of each basic block.
Definition at line 1008 of file AsmUnparser.h.
|
protected |
A mapping from SgAsmBlock to control flow graph vertex.
This map is updated when the control flow graph is modified by the add_control_flow_graph() method.
Definition at line 1012 of file AsmUnparser.h.
|
protected |
Function call graph.
This graph is built from the control flow graph whenever add_control_flow_graph() is called.
Definition at line 1015 of file AsmUnparser.h.
|
protected |
A mapping from SgAsmFunction to call graph vertex.
This map is updated when the control flow graph is modified by the add_control_flow_graph() method.
Definition at line 1019 of file AsmUnparser.h.