ROSE  0.10.13.0
GraphViz.h
1 #ifndef ROSE_Partitioner2_GraphViz_H
2 #define ROSE_Partitioner2_GraphViz_H
3 
4 #include <rosePublicConfig.h>
5 #ifdef ROSE_BUILD_BINARY_ANALYSIS_SUPPORT
6 
7 #include <ostream>
8 #include <BinaryNoOperation.h>
9 #include <boost/regex.hpp>
10 #include <Color.h>
11 #include <DwarfLineMapper.h>
12 #include <Partitioner2/ControlFlowGraph.h>
13 #include <Partitioner2/FunctionCallGraph.h>
14 
15 namespace Rose {
16 namespace BinaryAnalysis {
17 namespace Partitioner2 {
18 
20 namespace GraphViz {
21 
26 
28 ROSE_DLL_API std::string toString(const Attributes&);
29 
31 ROSE_DLL_API std::string quotedEscape(const std::string&);
32 
34 ROSE_DLL_API std::string htmlEscape(const std::string&);
35 
39 ROSE_DLL_API std::string escape(const std::string&);
40 
47 ROSE_DLL_API std::string concatenate(const std::string &oldStuff, const std::string &newStuff, const std::string &separator="");
48 
52 ROSE_DLL_API bool isId(const std::string &s);
53 
55 ROSE_DLL_API extern const size_t NO_ID;
56 
57 
63 class ROSE_DLL_API Organization {
64 private:
65  bool isSelected_;
66  std::string name_; // name used by GraphViz to identify this object
67  std::string label_; // label shown in rendered graph, includes delimiters, "" or <>
68  Attributes attributes_;
69  std::string subgraph_;
70 public:
75  Organization(): isSelected_(true) {}
76 
78  void select(bool b=true) { isSelected_ = b; }
79 
86  bool isSelected() const { return isSelected_; }
87 
93  const std::string &name() const { return name_; }
94  void name(const std::string &s) { name_ = s; }
103  const std::string& label() const {
104  static std::string empty = "\"\"";
105  return label_.empty() ? empty : label_;
106  }
107  void label(const std::string &s) { label_ = s; }
115  const Attributes& attributes() const { return attributes_; }
116  Attributes& attributes() { return attributes_; }
117  void attributes(const Attributes &a) { attributes_ = a; }
126  const std::string& subgraph() const { return subgraph_; }
127  void subgraph(const std::string &s) { subgraph_ = s; }
129 };
130 
132 // BaseEmitter
134 
139 template<class G>
140 class BaseEmitter {
141 public:
142  typedef G Graph;
143 
145  typedef std::vector<Organization> VertexOrganization;
146 
148  typedef std::vector<Organization> EdgeOrganization;
149 
152 
153 protected:
154  struct PseudoEdge {
155  typename G::ConstVertexIterator src, dst;
156  std::string label;
157  Attributes attributes;
158  PseudoEdge(const typename G::ConstVertexIterator &src, const typename G::ConstVertexIterator &dst,
159  const std::string &label)
160  : src(src), dst(dst), label(label) {}
161  };
162 
163  typedef Sawyer::Container::Map<size_t, size_t> VMap;// maps graph vertex ID to graphviz node ID
164 
165 protected:
166  Graph graph_; // graph being emitted
167  VertexOrganization vertexOrganization_; // which vertices are selected for output
168  EdgeOrganization edgeOrganization_; // which edges are selected for output
169  SubgraphOrganization subgraphOrganization_; // which subgraphs are selected for output
170  Attributes defaultGraphAttributes_; // default attributes for the graph as a whole
171  Attributes defaultNodeAttributes_; // default attributes for graph nodes (CFG vertices and other)
172  Attributes defaultEdgeAttributes_; // default attributes for graph edges
173  std::list<PseudoEdge> pseudoEdges_; // extra edges not present in the CFG but needed in the GraphViz
174  Color::HSV subgraphColor_; // background color for function subgraphs
175 
176 public:
181  BaseEmitter(): subgraphColor_(0, 0, 0.95) {}
182 
186  explicit BaseEmitter(const Graph &g)
187  : subgraphColor_(0, 0, 0.95) {
188  graph(g);
189  }
190 
192  void graph(const Graph &g) {
193  graph_ = g;
194  vertexOrganization_.clear();
195  vertexOrganization_.resize(g.nVertices());
196  edgeOrganization_.clear();
197  edgeOrganization_.resize(g.nEdges());
198  subgraphOrganization_.clear();
199  pseudoEdges_.clear();
200  }
201 
207  Attributes& defaultGraphAttributes() {
208  return defaultGraphAttributes_;
209  }
210  const Attributes& defaultGraphAttributes() const {
211  return defaultGraphAttributes_;
212  }
220  Attributes& defaultNodeAttributes() {
221  return defaultNodeAttributes_;
222  }
223  const Attributes& defaultNodeAttributes() const {
224  return defaultNodeAttributes_;
225  }
233  Attributes& defaultEdgeAttributes() {
234  return defaultEdgeAttributes_;
235  }
236  const Attributes& defaultEdgeAttributes() const {
237  return defaultEdgeAttributes_;
238  }
244  const Color::HSV& subgraphColor() const { return subgraphColor_; }
245  void subgraphColor(const Color::HSV &bg) { subgraphColor_ = bg; }
258  const VertexOrganization& vertexOrganization() const {
259  return vertexOrganization_;
260  }
261  VertexOrganization& vertexOrganization() {
262  return vertexOrganization_;
263  }
264  const Organization& vertexOrganization(size_t vertexId) const {
265  ASSERT_require(vertexId < vertexOrganization_.size());
266  return vertexOrganization_[vertexId];
267  }
268  Organization& vertexOrganization(size_t vertexId) {
269  ASSERT_require(vertexId < vertexOrganization_.size());
270  return vertexOrganization_[vertexId];
271  }
272  const Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) const {
273  return vertexOrganization(vertex->id());
274  }
275  const Organization& vertexOrganization(const typename G::Vertex &vertex) const {
276  return vertexOrganization(vertex.id());
277  }
278  Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) {
279  return vertexOrganization(vertex->id());
280  }
281  Organization& vertexOrganization(const typename G::Vertex &vertex) {
282  return vertexOrganization(vertex.id());
283  }
296  const EdgeOrganization& edgeOrganization() const {
297  return edgeOrganization_;
298  }
299  EdgeOrganization& edgeOrganization() {
300  return edgeOrganization_;
301  }
302  const Organization& edgeOrganization(size_t edgeId) const {
303  ASSERT_require(edgeId < edgeOrganization_.size());
304  return edgeOrganization_[edgeId];
305  }
306  Organization& edgeOrganization(size_t edgeId) {
307  ASSERT_require(edgeId < edgeOrganization_.size());
308  return edgeOrganization_[edgeId];
309  }
310  const Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) const {
311  return edgeOrganization(edge->id());
312  }
313  const Organization& edgeOrganization(const typename G::Edge &edge) const {
314  return edgeOrganization(edge.id());
315  }
316  Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) {
317  return edgeOrganization(edge->id());
318  }
319  Organization& edgeOrganization(const typename G::Edge &edge) {
320  return edgeOrganization(edge.id());
321  }
334  const SubgraphOrganization& subgraphOrganization() const {
335  return subgraphOrganization_;
336  }
337  SubgraphOrganization& subgraphOrganization() {
338  return subgraphOrganization_;
339  }
340  const Organization& subgraphOrganization(const std::string &name) const {
341  return subgraphOrganization_.getOrDefault(name);
342  }
343  Organization& subgraphOrganization(const std::string &name) {
344  return subgraphOrganization_.insertMaybeDefault(name);
345  }
352  void selectAll(bool b=true) {
354  selectAllEdges(b);
355  }
356 
358  void selectNone() {
359  pseudoEdges_.clear();
360  selectAllEdges(false);
361  selectAllVertices(false);
362  }
363 
368  void selectAllVertices(bool b=true) {
369  BOOST_FOREACH (Organization &org, vertexOrganization_)
370  org.select(b);
371  }
372 
377  void selectAllEdges(bool b=true) {
378  BOOST_FOREACH (Organization &org, edgeOrganization_)
379  org.select(b);
380  }
381 
385  void deselectParallelEdges();
386 
391  virtual void emit(std::ostream&) const;
392 
393 protected:
397  size_t emitVertex(std::ostream&, const typename G::ConstVertexIterator&, const Organization&, const VMap&) const;
398 
400  void emitEdge(std::ostream&, const typename G::ConstEdgeIterator&, const Organization&, const VMap&) const;
401 
402 };
403 
404 
406 // Base generator for Partitioner2::ControlFlowGraph
408 
435 class ROSE_DLL_API CfgEmitter: public BaseEmitter<ControlFlowGraph> {
436  const Partitioner &partitioner_;
437  bool useFunctionSubgraphs_; // should called functions be shown as subgraphs?
438  bool showReturnEdges_; // show E_FUNCTION_RETURN edges?
439  bool showInstructions_; // show instructions or only block address?
440  bool showInstructionAddresses_; // if instructions are shown, show addresses too?
441  bool showInstructionStackDeltas_; // show stack deltas for instructions
442  bool showInNeighbors_; // show neighbors for incoming edges to selected vertices?
443  bool showOutNeighbors_; // show neighbors for outgoing edges to selected vertices?
444  bool strikeNoopSequences_; // render no-op sequences in a different style
445  Color::HSV funcEnterColor_; // background color for function entrance blocks
446  Color::HSV funcReturnColor_; // background color for function return blocks
447  Color::HSV warningColor_; // background color for special nodes and warnings
448  DwarfLineMapper srcMapper_; // maps addresses to source code (optional)
449  static unsigned long versionDate_; // date code from "dot -V", like 20100126
450  NoOperation noOpAnalysis_;
451 
452 public:
460  explicit CfgEmitter(const Partitioner&);
461  CfgEmitter(const Partitioner&, const ControlFlowGraph&);
464  // Properties
466 
470  const Partitioner& partitioner() { return partitioner_; }
471 
479  bool useFunctionSubgraphs() const { return useFunctionSubgraphs_; }
480  void useFunctionSubgraphs(bool b) { useFunctionSubgraphs_ = b; }
490  bool showInstructions() const { return showInstructions_; }
491  void showInstructions(bool b) { showInstructions_ = b; }
500  bool showInstructionAddresses() const { return showInstructionAddresses_; }
501  void showInstructionAddresses(bool b) { showInstructionAddresses_ = b; }
511  bool showInstructionStackDeltas() const { return showInstructionStackDeltas_; }
512  void showInstructionStackDeltas(bool b) { showInstructionStackDeltas_ = b; }
523  bool strikeNoopSequences() const { return strikeNoopSequences_; }
524  void strikeNoopSequences(bool b) { strikeNoopSequences_ = b; }
534  const Color::HSV& funcEnterColor() const { return funcEnterColor_; }
535  void funcEnterColor(const Color::HSV &bg) { funcEnterColor_ = bg; }
541  const Color::HSV& funcReturnColor() const { return funcReturnColor_; }
542  void funcReturnColor(const Color::HSV &bg) { funcReturnColor_ = bg; }
548  const Color::HSV& warningColor() const { return warningColor_; }
549  void warningColor(const Color::HSV &bg) { warningColor_ = bg; }
558  bool showOutNeighbors() const { return showOutNeighbors_; }
559  void showOutNeighbors(bool b) { showOutNeighbors_ = b; }
570  bool showInNeighbors() const { return showInNeighbors_; }
571  void showInNeighbors(bool b) { showInNeighbors_ = b; }
580  bool showReturnEdges() const { return showReturnEdges_; }
581  void showReturnEdges(bool b) { showReturnEdges_ = b; }
589  const DwarfLineMapper& srcMapper() const { return srcMapper_; }
590  DwarfLineMapper& srcMapper() { return srcMapper_; }
591  void srcMapper(const DwarfLineMapper &mapper) { srcMapper_ = mapper; }
595  // Organization
597 
599  // Low-level vertex and edge selection
600 
606  void selectInterval(const AddressInterval&);
607 
609  void selectIntraFunction(const Function::Ptr&);
610 
614  void selectFunctionCallees(const Function::Ptr&);
615 
620  void selectFunctionCallers(const Function::Ptr&);
621 
625  void deselectReturnEdges();
626 
628  void deselectUnusedVertex(ControlFlowGraph::ConstVertexIterator);
629 
631  void deselectUnusedVertexType(VertexType);
632 
636  void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true);
637 
639  // High-level selectors
640 
646  CfgEmitter& selectWholeGraph();
647 
653  CfgEmitter& selectFunctionGraph(const Function::Ptr&);
654 
660  CfgEmitter& selectIntervalGraph(const AddressInterval &interval);
661 
663  // GraphViz emitters
664 
668  void emitWholeGraph(std::ostream &out) {
669  selectWholeGraph().emit(out);
670  }
671 
675  void emitFunctionGraph(std::ostream &out, const Function::Ptr &function) {
676  selectFunctionGraph(function).emit(out);
677  }
678 
682  void emitIntervalGraph(std::ostream &out, const AddressInterval &interval) {
683  selectIntervalGraph(interval).emit(out);
684  }
685 
686 
688  // Low-level emitters
689 
691  // Utilities
692 
696  static bool isInterFunctionEdge(const ControlFlowGraph::Edge&);
697  static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator &e) { return isInterFunctionEdge(*e); }
706  static Function::Ptr firstOwningFunction(const ControlFlowGraph::Vertex&);
707  static Function::Ptr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v) {
708  return firstOwningFunction(*v);
709  }
718  static FunctionSet owningFunctions(const ControlFlowGraph::Vertex&);
719  static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator &v) { return owningFunctions(*v); }
726  void assignFunctionSubgraphs();
727 
728 
730  // Formatting: these are expected to be overridden by subclasses
731 
736  virtual std::string sourceLocation(const ControlFlowGraph::ConstVertexIterator&) const;
737 
744  virtual std::string vertexLabel(const ControlFlowGraph::ConstVertexIterator&) const;
745  std::string vertexLabel(const ControlFlowGraph::Vertex&) const;
755  virtual std::string vertexLabelDetailed(const ControlFlowGraph::ConstVertexIterator&) const;
756  std::string vertexLabelDetailed(const ControlFlowGraph::Vertex&) const;
762  virtual Attributes vertexAttributes(const ControlFlowGraph::ConstVertexIterator&) const;
763  Attributes vertexAttributes(const ControlFlowGraph::Vertex&) const;
771  virtual std::string edgeLabel(const ControlFlowGraph::ConstEdgeIterator&) const;
772  std::string edgeLabel(const ControlFlowGraph::Edge&) const;
778  virtual Attributes edgeAttributes(const ControlFlowGraph::ConstEdgeIterator&) const;
779  Attributes edgeAttributes(const ControlFlowGraph::Edge&) const;
785  virtual std::string functionLabel(const Function::Ptr&) const;
786 
788  virtual Attributes functionAttributes(const Function::Ptr&) const;
789 
790 private:
791  void init();
792 
793  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
794  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
795  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
796  void nameVertices();
797 };
798 
799 
801 // Base emitter for Partitioner2::FunctionCallGraph
803 
805 class ROSE_DLL_API CgEmitter: public BaseEmitter<FunctionCallGraph::Graph> {
806  FunctionCallGraph cg_;
807  Color::HSV functionHighlightColor_; // highlight certain functions
808  boost::regex highlightNameMatcher_; // which functions to highlight
809 public:
810  explicit CgEmitter(const Partitioner &partitioner);
811  CgEmitter(const Partitioner &partitioner, const FunctionCallGraph &cg);
812  virtual std::string functionLabel(const Function::Ptr&) const;
813  virtual Attributes functionAttributes(const Function::Ptr&) const;
814  virtual void emitCallGraph(std::ostream &out) const;
815  virtual const FunctionCallGraph& callGraph() const { return cg_; }
816  virtual void callGraph(const FunctionCallGraph &cg);
817  virtual void highlight(const boost::regex&);
818 private:
819  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
820  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
821  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
822  void nameVertices();
823 };
824 
825 
827 // Callgraph emitter with inlined imports
829 
835 class ROSE_DLL_API CgInlinedEmitter: public CgEmitter {
836  boost::regex nameMatcher_;
837  typedef std::vector<Function::Ptr> InlinedFunctions;
839  Inlines inlines_;
840 public:
841  CgInlinedEmitter(const Partitioner &partitioner, const boost::regex &nameMatcher);
842  CgInlinedEmitter(const Partitioner &partitioner, const FunctionCallGraph &cg, const boost::regex &nameMatcher);
843  virtual const FunctionCallGraph& callGraph() const ROSE_OVERRIDE { return CgEmitter::callGraph(); }
844  virtual void callGraph(const FunctionCallGraph&) ROSE_OVERRIDE;
845  virtual std::string functionLabel(const Function::Ptr&) const ROSE_OVERRIDE;
846  virtual bool shouldInline(const Function::Ptr&) const;
847 };
848 
849 
851 // Reading layout position information from "dot"
853 
855 struct Coordinate {
856  double x;
857  double y;
858 };
859 
862  std::string name;
864  double width;
865  double height;
866 };
867 
876 struct EdgePosition {
877  std::vector<Coordinate> spline;
878 };
879 
882 
886 PositionGraph readPositions(std::istream&);
887 
888 
889 
890 
892 // Class template method implementations
894 
895 template<class G>
896 size_t
897 BaseEmitter<G>::emitVertex(std::ostream &out, const typename G::ConstVertexIterator &vertex,
898  const Organization &org, const VMap &vmap) const {
899  size_t id = NO_ID;
900  if (org.isSelected() && !vmap.getOptional(vertex->id()).assignTo(id)) {
901  id = vmap.size();
902  std::string name = org.name();
903  if (name.empty())
905  out <<name <<" [ label=" <<org.label() <<" ";
906  out <<toString(org.attributes()) <<" ];\n";
907  }
908  return id;
909 }
910 
911 template<class G>
912 void
913 BaseEmitter<G>::emitEdge(std::ostream &out, const typename G::ConstEdgeIterator &edge, const Organization &org,
914  const VMap &vmap) const {
915  ASSERT_require2(vmap.exists(edge->source()->id()), "edge source vertex has not yet been emitted");
916  ASSERT_require2(vmap.exists(edge->target()->id()), "edge target vertex has not yet been emitted");
917 
918  size_t sourceId = edge->source()->id();
919  std::string sourceName = vertexOrganization(sourceId).name();
920  if (sourceName.empty())
921  sourceName = StringUtility::numberToString(vmap[sourceId]);
922 
923  size_t targetId = edge->target()->id();
924  std::string targetName = vertexOrganization(targetId).name();
925  if (targetName.empty())
926  targetName = StringUtility::numberToString(vmap[targetId]);
927 
928  out <<sourceName <<" -> " <<targetName <<" [ label=" <<org.label() <<" " <<toString(org.attributes()) <<" ];\n";
929 }
930 
931 template<class G>
932 void
933 BaseEmitter<G>::emit(std::ostream &out) const {
934  VMap vmap; // GraphViz node ID for each graph vertex (modified by emit)
935 
936  out <<"digraph CFG {\n";
937  out <<" graph [ " <<toString(defaultGraphAttributes_) <<" ];\n";
938  out <<" node [ " <<toString(defaultNodeAttributes_) <<" ];\n";
939  out <<" edge [ " <<toString(defaultEdgeAttributes_) <<" ];\n";
940 
941  typedef std::map<std::string /*subgraph name*/, std::string/*subgraph content*/> Subgraphs;
942  Subgraphs subgraphs;
943 
944  // Emit vertices to subgraphs
945  for (typename G::ConstVertexIterator vertex=graph_.vertices().begin(); vertex!=graph_.vertices().end(); ++vertex) {
946  const Organization &org = vertexOrganization(vertex);
947  if (org.isSelected() && !vmap.exists(vertex->id())) {
948  std::ostringstream ss;
949  size_t gvid = emitVertex(ss, vertex, org, vmap);
950  vmap.insert(vertex->id(), gvid);
951  subgraphs[org.subgraph()] += ss.str();
952  }
953  }
954 
955  // Emit edges to subgraphs
956  for (typename G::ConstEdgeIterator edge=graph_.edges().begin(); edge!=graph_.edges().end(); ++edge) {
957  const Organization &org = edgeOrganization(edge);
958  if (org.isSelected() &&
959  vertexOrganization(edge->source()).isSelected() && vertexOrganization(edge->target()).isSelected()) {
960  std::ostringstream ss;
961  emitEdge(ss, edge, org, vmap);
962  subgraphs[org.subgraph()] += ss.str();
963  }
964  }
965 
966  // Emit named subgraphs to output
967  BOOST_FOREACH (const Subgraphs::value_type &node, subgraphs) {
968  const std::string &subgraphName = node.first;
969  const std::string &subgraphContent = node.second;
970  if (!subgraphName.empty()) {
971  out <<"\nsubgraph cluster_" <<subgraphName <<" {"
972  <<" label=" <<subgraphOrganization(subgraphName).label() <<" "
973  <<toString(subgraphOrganization(subgraphName).attributes()) <<"\n"
974  <<subgraphContent
975  <<"}\n";
976  }
977  }
978 
979  // Emit unnamed subgraph content without a surrounding subgraph construct (i.e., global graph)
980  Subgraphs::iterator unnamedSubgraph = subgraphs.find("");
981  if (unnamedSubgraph != subgraphs.end())
982  out <<unnamedSubgraph->second;
983 
984  // Emit pseudo edges
985  BOOST_FOREACH (const PseudoEdge &edge, pseudoEdges_) {
986  if (vertexOrganization(edge.src).isSelected() && vertexOrganization(edge.dst).isSelected()) {
987  std::string sourceName = vertexOrganization(edge.src).name();
988  std::string targetName = vertexOrganization(edge.dst).name();
989  out <<(sourceName.empty() ? StringUtility::numberToString(vmap[edge.src->id()]) : sourceName)
990  <<" -> "
991  <<(targetName.empty() ? StringUtility::numberToString(vmap[edge.dst->id()]) : targetName)
992  <<" [ label=" <<escape(edge.label) <<" ];\n";
993  }
994  }
995 
996  out <<"}\n";
997 }
998 
999 template<class G>
1000 void
1002  BOOST_FOREACH (const typename G::Vertex &src, graph_.vertices()) {
1003  if (vertexOrganization(src).isSelected()) {
1004  std::set<size_t> targets;
1005  BOOST_FOREACH (const typename G::Edge &edge, src.outEdges()) {
1006  if (edgeOrganization(edge).isSelected() && !targets.insert(edge.target()->id()).second)
1007  edgeOrganization(edge).select(false);
1008  }
1009  }
1010  }
1011 }
1012 
1013 } // namespace
1014 } // namespace
1015 } // namespace
1016 } // namespace
1017 
1018 #endif
1019 #endif
size_t nVertices() const
Total number of vertices.
Definition: Graph.h:1658
ROSE_DLL_API const size_t NO_ID
An invalid identification number.
void funcReturnColor(const Color::HSV &bg)
Property: color to use for background of function return nodes.
Definition: GraphViz.h:542
const Color::HSV & warningColor() const
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:548
const VertexOrganization & vertexOrganization() const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:258
void srcMapper(const DwarfLineMapper &mapper)
Property: Address-to-source mapping.
Definition: GraphViz.h:591
const Organization & vertexOrganization(size_t vertexId) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:264
void showInstructionStackDeltas(bool b)
Property: show instruction stack deltas.
Definition: GraphViz.h:512
const Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:310
PositionGraph readPositions(std::istream &)
Constructs graph positions from a file.
Organization & subgraphOrganization(const std::string &name)
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:343
Coordinate center
Center of vertex in display plane units.
Definition: GraphViz.h:863
bool exists(const Key &key) const
Determine if a key exists.
Definition: Sawyer/Map.h:441
ROSE_UTIL_API std::string numberToString(long long)
Convert an integer to a string.
Optional< Value > getOptional(const Key &key) const
Lookup and return a value or nothing.
Definition: Sawyer/Map.h:550
size_t nEdges() const
Total number of edges.
Definition: Graph.h:1668
Sawyer::Container::Map< std::string, Organization > SubgraphOrganization
Organizational information for subgraphs.
Definition: GraphViz.h:151
const Attributes & defaultNodeAttributes() const
Property: default graph node attributes.
Definition: GraphViz.h:223
void graph(const Graph &g)
Reset the graph.
Definition: GraphViz.h:192
Base class for generating GraphViz output.
Definition: GraphViz.h:140
const SubgraphOrganization & subgraphOrganization() const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:334
const Attributes & defaultGraphAttributes() const
Property: default graph attributes.
Definition: GraphViz.h:210
void selectAll(bool b=true)
Causes all vertices and edges to be selected.
Definition: GraphViz.h:352
Organization & edgeOrganization(size_t edgeId)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:306
void useFunctionSubgraphs(bool b)
Property: use function subgraphs.
Definition: GraphViz.h:480
void label(const std::string &s)
Label for object.
Definition: GraphViz.h:107
ROSE_DLL_API std::string toString(const Attributes &)
Convert attributes to GraphViz language string.
const std::string & name() const
Name for object.
Definition: GraphViz.h:93
size_t emitVertex(std::ostream &, const typename G::ConstVertexIterator &, const Organization &, const VMap &) const
Emit a single vertex if it hasn't been emitted already.
Definition: GraphViz.h:897
const Attributes & defaultEdgeAttributes() const
Property: default graph edge attributes.
Definition: GraphViz.h:236
ROSE_DLL_API std::string htmlEscape(const std::string &)
Escape characters that need to be escaped within GraphViz HTML literals.
ROSE_DLL_API std::string quotedEscape(const std::string &)
Escape characters that need to be escaped within GraphViz double quoted literals. ...
bool useFunctionSubgraphs() const
Property: use function subgraphs.
Definition: GraphViz.h:479
void emitWholeGraph(std::ostream &out)
Dump entire control flow graph.
Definition: GraphViz.h:668
ROSE_DLL_API std::string escape(const std::string &)
Escape some value for GraphViz.
const Attributes & attributes() const
Attributes for object.
Definition: GraphViz.h:115
Value & insertMaybeDefault(const Key &key)
Conditionally insert a new key with default value.
Definition: Sawyer/Map.h:659
void emitEdge(std::ostream &, const typename G::ConstEdgeIterator &, const Organization &, const VMap &) const
Emit a single edge.
Definition: GraphViz.h:913
const Color::HSV & subgraphColor() const
Property: color to use for function subgraph background.
Definition: GraphViz.h:244
bool showInstructionAddresses() const
Property: show instruction addresses.
Definition: GraphViz.h:500
Creates GraphViz files from Partitioner data.
Definition: GraphViz.h:435
Colors in HSV space.
Definition: Color.h:75
Main namespace for the ROSE library.
bool isSelected() const
Determines whether an object is selected.
Definition: GraphViz.h:86
const Organization & edgeOrganization(const typename G::Edge &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:313
const EdgeOrganization & edgeOrganization() const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:296
void subgraph(const std::string &s)
Subgraph for object.
Definition: GraphViz.h:127
Map & clear()
Remove all nodes.
Definition: Sawyer/Map.h:680
Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:316
void showReturnEdges(bool b)
Property: show function return edges.
Definition: GraphViz.h:581
VertexType
Partitioner control flow vertex types.
Definition: BasicTypes.h:44
Sawyer::Container::Graph< VertexPosition, EdgePosition > PositionGraph
A graph with positioned vertices and edges.
Definition: GraphViz.h:881
Organization & vertexOrganization(size_t vertexId)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:268
void funcEnterColor(const Color::HSV &bg)
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:535
Sawyer::Container::Map< std::string, std::string > Attributes
GraphViz attributes.
Definition: GraphViz.h:25
bool showReturnEdges() const
Property: show function return edges.
Definition: GraphViz.h:580
Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:278
const DwarfLineMapper & srcMapper() const
Property: Address-to-source mapping.
Definition: GraphViz.h:589
const Organization & vertexOrganization(const typename G::Vertex &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:275
VertexOrganization & vertexOrganization()
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:261
std::vector< Organization > EdgeOrganization
Organizational information for edges.
Definition: GraphViz.h:148
virtual void emit(std::ostream &) const
Dump selected vertices, edges, and subgraphs.
Definition: GraphViz.h:933
bool showInstructionStackDeltas() const
Property: show instruction stack deltas.
Definition: GraphViz.h:511
bool showInNeighbors() const
Property: show incoming edges from neighbor vertices.
Definition: GraphViz.h:570
const std::string & label() const
Label for object.
Definition: GraphViz.h:103
Attributes & attributes()
Attributes for object.
Definition: GraphViz.h:116
ROSE_DLL_API std::string concatenate(const std::string &oldStuff, const std::string &newStuff, const std::string &separator="")
Append a value to an existing string.
Attributes & defaultNodeAttributes()
Property: default graph node attributes.
Definition: GraphViz.h:220
void subgraphColor(const Color::HSV &bg)
Property: color to use for function subgraph background.
Definition: GraphViz.h:245
void deselectParallelEdges()
Deselect all but one parallel edge.
Definition: GraphViz.h:1001
const Partitioner & partitioner()
Property: partitioner.
Definition: GraphViz.h:470
const Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:272
const Color::HSV & funcEnterColor() const
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:534
bool showOutNeighbors() const
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:558
bool strikeNoopSequences() const
Property: strike no-op sequences.
Definition: GraphViz.h:523
void emitIntervalGraph(std::ostream &out, const AddressInterval &interval)
Dump control flow graph for some address interval.
Definition: GraphViz.h:682
void clear()
Remove all vertices and edges.
Definition: Graph.h:1978
void select(bool b=true)
Select or deselect object.
Definition: GraphViz.h:78
void showOutNeighbors(bool b)
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:559
const Color::HSV & funcReturnColor() const
Property: color to use for background of function return nodes.
Definition: GraphViz.h:541
void selectAllEdges(bool b=true)
Causes all edges to be selected.
Definition: GraphViz.h:377
ROSE_DLL_API bool isId(const std::string &s)
Determins if a string is a valid GraphViz ID.
const Value & getOrDefault(const Key &key) const
Lookup and return a value or a default.
Definition: Sawyer/Map.h:577
Attributes & defaultGraphAttributes()
Property: default graph attributes.
Definition: GraphViz.h:207
void name(const std::string &s)
Name for object.
Definition: GraphViz.h:94
Two dimensional display plane coordinate.
Definition: GraphViz.h:855
void warningColor(const Color::HSV &bg)
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:549
const Organization & edgeOrganization(size_t edgeId) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:302
SubgraphOrganization & subgraphOrganization()
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:337
std::vector< Organization > VertexOrganization
Organizational information for vertices.
Definition: GraphViz.h:145
void showInstructions(bool b)
Property: show basic block instructions.
Definition: GraphViz.h:491
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
Definition: Sawyer/Map.h:594
void showInNeighbors(bool b)
Property: show incoming edges from neighbor vertices.
Definition: GraphViz.h:571
void selectNone()
Deselects all vertices and edges.
Definition: GraphViz.h:358
Organization & vertexOrganization(const typename G::Vertex &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:281
const Organization & subgraphOrganization(const std::string &name) const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:340
void attributes(const Attributes &a)
Attributes for object.
Definition: GraphViz.h:117
void strikeNoopSequences(bool b)
Property: strike no-op sequences.
Definition: GraphViz.h:524
static Function::Ptr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v)
First function that owns a vertex.
Definition: GraphViz.h:707
static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator &e)
Returns true if the edge spans two different functions.
Definition: GraphViz.h:697
void selectAllVertices(bool b=true)
Causes all vertices to be selected.
Definition: GraphViz.h:368
DwarfLineMapper & srcMapper()
Property: Address-to-source mapping.
Definition: GraphViz.h:590
std::string name
Name of vertex as known to GraphViz.
Definition: GraphViz.h:862
Partitions instructions into basic blocks and functions.
Definition: Partitioner.h:321
Attributes & defaultEdgeAttributes()
Property: default graph edge attributes.
Definition: GraphViz.h:233
Analysis that looks for no-op equivalents.
void showInstructionAddresses(bool b)
Property: show instruction addresses.
Definition: GraphViz.h:501
size_t size() const
Number of nodes, keys, or values in this container.
Definition: Sawyer/Map.h:386
const std::string & subgraph() const
Subgraph for object.
Definition: GraphViz.h:126
EdgeOrganization & edgeOrganization()
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:299
std::vector< Coordinate > spline
Control points for the edge B-spline.
Definition: GraphViz.h:877
Organization & edgeOrganization(const typename G::Edge &edge)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:319
static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator &v)
Functions that own a vertex.
Definition: GraphViz.h:719
void emitFunctionGraph(std::ostream &out, const Function::Ptr &function)
Dump control flow graph for one function.
Definition: GraphViz.h:675
bool showInstructions() const
Property: show basic block instructions.
Definition: GraphViz.h:490