|
GTIRB-PPRINTER
v0.1.1
GrammaTech Intermediate Representation for Binaries: Pretty Printer
|
#include <PrettyPrinter.h>

Public Member Functions | |
| PrettyPrinterBase (gtirb::Context &context, gtirb::IR &ir, const string_range &skip_funcs, DebugStyle dbg) | |
| virtual | ~PrettyPrinterBase () |
| virtual std::ostream & | print (std::ostream &out) |
Protected Member Functions | |
| std::string | avoidRegNameConflicts (const std::string &x) |
| std::vector< std::string > * | getAmbiguousSymbol () |
| std::optional< std::string > | getContainerFunctionName (const gtirb::Addr x) const |
| const std::optional< const gtirb::Section * > | getContainerSection (const gtirb::Addr addr) const |
| std::optional< std::string > | getForwardedSymbolName (const gtirb::Symbol *symbol, bool isAbsolute) const |
| std::string | getFunctionName (gtirb::Addr x) const |
| virtual int | getGtirbOpIndex (int index, int opCount) const =0 |
| virtual std::string | getRegisterName (unsigned int reg) const |
| virtual const gtirb::SymAddrConst * | getSymbolicImmediate (const gtirb::SymbolicExpression *symex) |
| bool | isAmbiguousSymbol (const std::string &ea) const |
| bool | isInSkippedFunction (const gtirb::Addr x) const |
| bool | isInSkippedSection (const gtirb::Addr x) const |
| bool | isSectionSkipped (const std::string &name) |
| virtual void | printAddend (std::ostream &os, int64_t number, bool first=false) |
| virtual void | printAlignment (std::ostream &os, const gtirb::Addr addr) |
| virtual void | printBar (std::ostream &os, bool heavy=true) |
| virtual void | printBlock (std::ostream &os, const gtirb::Block &x) |
| virtual gtirb::Addr | printBlockOrWarning (std::ostream &os, const gtirb::Block &x, gtirb::Addr last) |
| virtual void | printComment (std::ostream &os, const gtirb::Addr ea) |
| virtual void | printDataObject (std::ostream &os, const gtirb::DataObject &dataObject) |
| virtual gtirb::Addr | printDataObjectOrWarning (std::ostream &os, const gtirb::DataObject &x, gtirb::Addr last) |
| virtual void | printEA (std::ostream &os, gtirb::Addr ea) |
| virtual void | printFunctionHeader (std::ostream &os, gtirb::Addr ea) |
| virtual void | printHeader (std::ostream &os)=0 |
| virtual void | printInstruction (std::ostream &os, const cs_insn &inst) |
| virtual void | printNonZeroDataObject (std::ostream &os, const gtirb::DataObject &dataObject) |
| virtual void | printOperand (std::ostream &os, const gtirb::SymbolicExpression *symbolic, const cs_insn &inst, uint64_t index) |
| virtual void | printOperandList (std::ostream &os, const gtirb::Addr ea, const cs_insn &inst) |
| virtual void | printOpImmediate (std::ostream &os, const gtirb::SymbolicExpression *symbolic, const cs_insn &inst, uint64_t index)=0 |
| virtual void | printOpIndirect (std::ostream &os, const gtirb::SymbolicExpression *symbolic, const cs_insn &inst, uint64_t index)=0 |
| virtual void | printOpRegdirect (std::ostream &os, const cs_insn &inst, const cs_x86_op &op)=0 |
| virtual void | printOverlapWarning (std::ostream &os, gtirb::Addr ea) |
| virtual void | printSectionHeader (std::ostream &os, const gtirb::Addr addr) |
| virtual void | printString (std::ostream &os, const gtirb::DataObject &x) |
| virtual void | printSymbolDefinitionsAtAddress (std::ostream &os, gtirb::Addr ea) |
| virtual void | printSymbolicData (std::ostream &os, const gtirb::SymbolicExpression *symbolic) |
| virtual void | printSymbolicExpression (std::ostream &os, const gtirb::SymAddrConst *sexpr, bool inData=false) |
| virtual void | printSymbolicExpression (std::ostream &os, const gtirb::SymAddrAddr *sexpr, bool inData=false) |
| virtual void | printSymbolReference (std::ostream &os, const gtirb::Symbol *symbol, bool inData) const |
| virtual void | printZeroDataObject (std::ostream &os, const gtirb::DataObject &dataObject) |
| bool | shouldExcludeDataElement (const gtirb::Section §ion, const gtirb::DataObject &dataObject) const |
| bool | skipEA (const gtirb::Addr x) const |
Static Protected Member Functions | |
| static std::string | AdaptRegister (const std::string &x) |
| static std::string | AvoidRegNameConflicts (const std::string &x) |
| static std::string | GetSizeName (uint64_t x) |
| static std::string | GetSizeName (const std::string &x) |
| static std::string | GetSizeSuffix (uint64_t x) |
| static std::string | GetSizeSuffix (const std::string &x) |
| static std::string | GetSymbolToPrint (gtirb::Addr x) |
Protected Attributes | |
| const std::unordered_set< std::string > | AsmArraySection |
| std::unordered_set< std::string > | AsmSkipFunction |
| Functions to avoid printing. More... | |
| std::unordered_set< std::string > | AsmSkipSection |
| Sections to avoid printing. More... | |
| gtirb::Context & | context |
| csh | csHandle |
| bool | debug |
| gtirb::IR & | ir |
| const std::string | StrNOP {"nop"} |
| const std::string | StrSection {".section"} |
| const std::string | StrSectionBSS {".bss"} |
| const std::string | StrSectionGlobal {".globl"} |
| const std::string | StrSectionText {".text"} |
| const std::string | StrSectionType {".type"} |
| const std::string | StrTab {" "} |
| const std::string | StrZeroByte {".byte 0x00"} |
| Constants to reduce (eliminate) magical strings inside the printer. More... | |
The pretty-printer interface. There is only one exposed function, print().
| gtirb_pprint::PrettyPrinterBase::PrettyPrinterBase | ( | gtirb::Context & | context, |
| gtirb::IR & | ir, | ||
| const string_range & | skip_funcs, | ||
| DebugStyle | dbg | ||
| ) |
|
virtual |
|
staticprotected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
Get the name of the function containing an effective address. This implementation assumes that functions are tightly packed within a module; that is, it assumes that all addresses from the start of one function to the next is part of the first. It also assumes that the body of the last function in a module extends to the end of the module.
The locations of the functions are found in the "functionEntry" AuxData table.
| x | the address to check |
|
protected |
|
protected |
|
protected |
|
protectedpure virtual |
Get the index of an operand in the GTIRB, given the index of the operand in the Capstone instruction.
NOTE: The GTIRB operands are indexed as if they were in an array: auto operands[] = {<unused>, src1, src2, ..., dst}
| index | the Capstone index of the operand |
| opCount | the total number of operands in the instruction |
Implemented in gtirb_pprint::AttPrettyPrinter, and gtirb_pprint::IntelPrettyPrinter.
|
protectedvirtual |
Reimplemented in gtirb_pprint::AttPrettyPrinter.
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protectedvirtual |
Return the SymAddrConst expression if it refers to a printed symbol.
| symex | the SymbolicExpression to check |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
virtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Print the block as long as it does not overlap with the address last. If it overlaps, print a warning instead. Return the ending address of the block if this was printed. Otherwise return last.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Print the dataObject as long as it does not overlap with the address last. If it overlaps, print a warning instead. Return the ending address of the block if this was printed. Otherwise return last.
|
protectedvirtual |
|
protectedvirtual |
|
protectedpure virtual |
Implemented in gtirb_pprint::AttPrettyPrinter, and gtirb_pprint::IntelPrettyPrinter.
|
protectedvirtual |
Print a single instruction to the stream. This implementation prints the mnemonic provided by Capstone, then calls printOperandList(). Thus, it is probably sufficient for most subclasses to configure Capstone to produce the correct mnemonics (e.g., to include an operand size suffix) and not modify this method.
| os | the output stream to print to |
| inst | the instruction to print |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedpure virtual |
Implemented in gtirb_pprint::AttPrettyPrinter, and gtirb_pprint::IntelPrettyPrinter.
|
protectedpure virtual |
Implemented in gtirb_pprint::AttPrettyPrinter, and gtirb_pprint::IntelPrettyPrinter.
|
protectedpure virtual |
Implemented in gtirb_pprint::AttPrettyPrinter, and gtirb_pprint::IntelPrettyPrinter.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
protected |
Functions to avoid printing.
|
protected |
Sections to avoid printing.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Constants to reduce (eliminate) magical strings inside the printer.
1.8.15