ROSE 0.11.145.147
BinaryAnalysis/Utility.h
1// This file contains binary analysis utilities that are either not a critical part of the analysis framework, or which cannot
2// be easily incorporated into the main header files because they would introduce circular #include dependencies.
3
4#ifndef ROSE_BinaryAnalysis_Utility_H
5#define ROSE_BinaryAnalysis_Utility_H
6#include <featureTests.h>
7#ifdef ROSE_ENABLE_BINARY_ANALYSIS
8
9#include "AsmUnparser_compat.h"
10
11namespace Rose {
12namespace BinaryAnalysis { // documented elsewhere
13
16template<class Graph>
18 const Graph &cfg;
19 InsnCFGVertexWriter(Graph &cfg): cfg(cfg) {}
20 typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
21 void operator()(std::ostream &output, const Vertex &v) const {
22 SgAsmInstruction *insn = get_ast_node(cfg, v);
23 SgAsmX86Instruction *x86 = isSgAsmX86Instruction(insn);
24 SgAsmFunction *func = SageInterface::getEnclosingNode<SgAsmFunction>(insn);
25 output <<"[ label=\"[" <<v << "] " <<insn->toString() <<"\"";
26 if (insn->get_address()==func->get_entryVa()) {
27 output <<", style=filled, color=\"#cd853f\"";
28 } else if (x86 && x86_ret==x86->get_kind()) {
29 output <<", style=filled, color=\"#fed3a7\"";
30 }
31 output <<" ]";
32 }
33};
34
35} // namespace
36} // namespace
37
38#endif
39#endif
Represents a synthesized function.
rose_addr_t const & get_entryVa() const
Property: Primary entry address.
Base class for machine instructions.
virtual std::string toString() const
Converts the instruction to a string.
rose_addr_t const & get_address() const
Property: Starting virtual address.
Represents one Intel x86 machine instruction.
Rose::BinaryAnalysis::X86InstructionKind const & get_kind() const
Property: Instruction kind.
Sawyer::Container::Graph< V, E >::VertexValue get_ast_node(const Sawyer::Container::Graph< V, E > &cfg, size_t vertexId)
Return the AST node associated with a vertex.
The ROSE library.
A vertex property writer for instruction-based CFGs.