ROSE  0.9.9.109
BinaryAnalysisUtils.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_BinaryAnalysisUtils_H
5 #define ROSE_BinaryAnalysisUtils_H
6 
7 #include "AsmUnparser_compat.h"
8 
9 namespace Rose {
10 namespace BinaryAnalysis { // documented elsewhere
11 
14 template<class Graph>
16  const Graph &cfg;
17  InsnCFGVertexWriter(Graph &cfg): cfg(cfg) {}
18  typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
19  void operator()(std::ostream &output, const Vertex &v) const {
20  SgAsmInstruction *insn = get_ast_node(cfg, v);
21  SgAsmX86Instruction *x86 = isSgAsmX86Instruction(insn);
22  SgAsmFunction *func = SageInterface::getEnclosingNode<SgAsmFunction>(insn);
23  output <<"[ label=\"[" <<v << "] " <<unparseInstructionWithAddress(insn) <<"\"";
24  if (insn->get_address()==func->get_entry_va()) {
25  output <<", style=filled, color=\"#cd853f\"";
26  } else if (x86 && x86_ret==x86->get_kind()) {
27  output <<", style=filled, color=\"#fed3a7\"";
28  }
29  output <<" ]";
30  }
31 };
32 
33 } // namespace
34 } // namespace
35 
36 #endif
Base class for machine instructions.
X86InstructionKind get_kind() const
Property: Instruction kind.
Represents a synthesized function.
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.
Main namespace for the ROSE library.
Represents one Intel x86 machine instruction.
A vertex property writer for instruction-based CFGs.
rose_addr_t get_entry_va() const
Property: Primary entry address.