ROSE 0.11.145.147
|
Functions indexed by entry address.
This class is designed to be a highly-configurable way to print a table describing known functions. The way it works is the user adds functions to the AsmFunctionIndex object (explicitly, or by having this object traverse an AST), and then prints the object to an std::ostream. The index contains a list of functions to be included in the index, but it also contains a list of callbacks responsible for printing the table column headers and data.
For instance, to print an index of all functions sorted by function name and using the default table style, simply invoke this code:
If you want a list of functions sorted by decreasing size in bytes, you could do this:
Here's an example of augmenting the function index so that it always sorts the functions by entry address and it prints an extra column named "Hash" that consists of the first 16 characters of some computed function hash.
The output might look something like this:
Num Entry-Addr Begin-Addr End-Addr Insns/ Bytes Reason Kind Hash Name ---- ---------- ---------- ---------- ------------ ---------------- -------- ---------------- -------------------------------- 0 0x08048278 0x0804828e 0x0804828f 8/23 .C..S........... unknown _init 1 0x080482a0 0x080482a0 0x080482a6 1/6 .C.I............ unknown malloc@@plt 2 0x080482b0 0x080482b0 0x080482b6 1/6 .C.I............ unknown __libc_start_main@@plt 3 0x080482c0 0x080482e1 0x080482e2 14/34 E...S........... unknown _start 4 0x080482e4 0x08048304 0x08048305 15/33 .C..S........... unknown call_gmon_start 5 0x08048310 0x0804833e 0x0804833f 16/47 .C..S........... unknown __do_global_dtors_aux 6 0x08048340 0x08048362 0x08048363 13/35 .C..S........... unknown frame_dummy 7 0x08048364 0x080483bf 0x080483c0 29/92 ....S........... unknown 91badca44c59fae6 main 8 0x080483c0 0x08048411 0x08048412 34/82 ....S........... unknown __libc_csu_init 9 0x08048414 0x08048455 0x08048456 27/66 ....S........... unknown __libc_csu_fini 10 0x08048460 0x08048490 0x08048491 20/49 .C..S........... unknown __do_global_ctors_aux 11 0x08048494 0x080484ad 0x080484ae 12/26 .C..S........... unknown _fini ---- ---------- ---------- ---------- ------------ ---------------- -------- ---------------- --------------------------------
Definition at line 82 of file AsmFunctionIndex.h.
#include <Rose/BinaryAnalysis/AsmFunctionIndex.h>
Classes | |
class | BeginAddrCallback |
Print function minimum address. More... | |
class | CallingConventionCallback |
Print calling convention. More... | |
class | EndAddrCallback |
Print function ending address. More... | |
class | EntryAddrCallback |
Print function entry address. More... | |
class | Footnotes |
class | FootnotesCallback |
Footnotes at the end of the table. More... | |
class | MayReturnCallback |
Print whether function can return. More... | |
class | NameCallback |
Function name. More... | |
class | OutputCallback |
Base class for printing table cells. More... | |
class | ReasonCallback |
Print function reason bits. More... | |
class | RowIdCallback |
Print index row numbers. More... | |
class | SizeBytesCallback |
Print function size in bytes. More... | |
class | SizeInsnsCallback |
Print number of instructions in function. More... | |
struct | SortByBeginAddr |
Functor for sorting by function beginning address. More... | |
struct | SortByBytesSize |
Functor for sorting by number of bytes in function. More... | |
struct | SortByEntryAddr |
Functor for sorting by function entry virtual address. More... | |
struct | SortByInsnsSize |
Functor for sorting by number of instructions in function. More... | |
struct | SortByName |
Functor to sort functions by name. More... | |
class | StackDeltaCallback |
Print stack delta. More... | |
Public Member Functions | |
AsmFunctionIndex () | |
Constructs an empty index. | |
AsmFunctionIndex (SgNode *ast) | |
Constructs an index from an AST. | |
virtual void | add_function (SgAsmFunction *) |
Adds a function to the end of this index. | |
virtual void | add_functions (SgNode *ast) |
Adds functions to this index. | |
virtual void | clear () |
Clears the index. | |
virtual bool | empty () const |
Determines if an index is empty. | |
virtual size_t | size () const |
Returns the number of functions in the index. | |
template<class Comparator > | |
AsmFunctionIndex & | sort (Comparator comp, bool unique=false) |
Sort the functions in the index. | |
AsmFunctionIndex & | reverse () |
Reverse the order of the functions. | |
virtual void | print (std::ostream &) const |
Prints a function index to an output stream. | |
AsmFunctionIndex & | sort_by_entry_addr (bool unique=false) |
Specific sorting method. | |
AsmFunctionIndex & | sort_by_begin_addr (bool unique=false) |
Specific sorting method. | |
AsmFunctionIndex & | sort_by_ninsns (bool unique=false) |
Specific sorting method. | |
AsmFunctionIndex & | sort_by_nbytes (bool unique=false) |
Specific sorting method. | |
AsmFunctionIndex & | sort_by_name (bool unique=false) |
Specific sorting method. | |
Public Attributes | |
Rose::BinaryAnalysis::AsmFunctionIndex::RowIdCallback | rowIdCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::EntryAddrCallback | entryAddrCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::BeginAddrCallback | beginAddrCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::EndAddrCallback | endAddrCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::SizeInsnsCallback | sizeInsnsCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::SizeBytesCallback | sizeBytesCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::ReasonCallback | reasonCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::CallingConventionCallback | callingConventionCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::MayReturnCallback | mayReturnCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::StackDeltaCallback | stackDeltaCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::NameCallback | nameCallback |
Rose::BinaryAnalysis::AsmFunctionIndex::FootnotesCallback | footnotesCallback |
Protected Types | |
typedef std::vector< SgAsmFunction * > | Functions |
Protected Member Functions | |
virtual void | init () |
Initializes the callback lists. | |
Protected Attributes | |
Functions | functions |
Functions in index order. | |
Callbacks::List< OutputCallback > | output_callbacks |
List of callbacks to be invoked when printing columns. | |
|
protected |
Definition at line 500 of file AsmFunctionIndex.h.
|
inline |
|
inline |
Constructs an index from an AST.
Definition at line 94 of file AsmFunctionIndex.h.
References add_functions(), and init().
|
inlinevirtual |
Definition at line 99 of file AsmFunctionIndex.h.
|
virtual |
Adds a function to the end of this index.
The function is added regardless of whether it already exists.
|
virtual |
Adds functions to this index.
The specified AST is traversed and all SgAsmFunction nodes are added to this index. All encountered functions are added to the index in the order they are encountered regardless of whether they already exist.
Referenced by AsmFunctionIndex().
|
inlinevirtual |
Clears the index.
Removes all functions from the index, but does not change any callback lists.
Definition at line 110 of file AsmFunctionIndex.h.
References functions.
|
inlinevirtual |
Determines if an index is empty.
Returns true if the index contains no functions, false otherwise.
Definition at line 115 of file AsmFunctionIndex.h.
References functions.
|
inlinevirtual |
Returns the number of functions in the index.
Definition at line 120 of file AsmFunctionIndex.h.
References functions.
|
inline |
Sort the functions in the index.
The supplied functor takes two SgAsmFunction pointers as arguments and returns true if the first argument goes before the second argument in the specific strict weak ordering it defines, and false otherwise. If unique
is defined, then a final pass is made over the functions and any adjacent functions for which the Comparator::unique() method, which takes two SgAsmFunction pointer arguments, returns false will cause the second argument to be removed from the index.
Definition at line 205 of file AsmFunctionIndex.h.
References functions.
Referenced by sort_by_begin_addr(), sort_by_entry_addr(), sort_by_name(), sort_by_nbytes(), and sort_by_ninsns().
|
inline |
Specific sorting method.
This method is expected to be commonly used, so we define it here for convenience. If some other sorting method is needed, see the generic sort() method.
Definition at line 222 of file AsmFunctionIndex.h.
References sort().
|
inline |
Specific sorting method.
This method is expected to be commonly used, so we define it here for convenience. If some other sorting method is needed, see the generic sort() method.
Definition at line 223 of file AsmFunctionIndex.h.
References sort().
|
inline |
Specific sorting method.
This method is expected to be commonly used, so we define it here for convenience. If some other sorting method is needed, see the generic sort() method.
Definition at line 224 of file AsmFunctionIndex.h.
References sort().
|
inline |
Specific sorting method.
This method is expected to be commonly used, so we define it here for convenience. If some other sorting method is needed, see the generic sort() method.
Definition at line 225 of file AsmFunctionIndex.h.
References sort().
|
inline |
Specific sorting method.
This method is expected to be commonly used, so we define it here for convenience. If some other sorting method is needed, see the generic sort() method.
Definition at line 226 of file AsmFunctionIndex.h.
References sort().
|
inline |
Reverse the order of the functions.
This is typically called after sorting.
Definition at line 230 of file AsmFunctionIndex.h.
References functions.
|
protectedvirtual |
Initializes the callback lists.
This is invoked by the default constructor.
Referenced by AsmFunctionIndex(), and AsmFunctionIndex().
|
protected |
|
protected |
List of callbacks to be invoked when printing columns.
Definition at line 507 of file AsmFunctionIndex.h.