ROSE  0.9.9.109
GraphViz.h
1 #ifndef ROSE_Partitioner2_GraphViz_H
2 #define ROSE_Partitioner2_GraphViz_H
3 
4 #include <ostream>
5 #include <BinaryNoOperation.h>
6 #include <boost/regex.hpp>
7 #include <Color.h>
8 #include <DwarfLineMapper.h>
9 #include <Partitioner2/ControlFlowGraph.h>
10 #include <Partitioner2/FunctionCallGraph.h>
11 
12 namespace Rose {
13 namespace BinaryAnalysis {
14 namespace Partitioner2 {
15 
17 namespace GraphViz {
18 
23 
25 ROSE_DLL_API std::string toString(const Attributes&);
26 
28 ROSE_DLL_API std::string quotedEscape(const std::string&);
29 
31 ROSE_DLL_API std::string htmlEscape(const std::string&);
32 
36 ROSE_DLL_API std::string escape(const std::string&);
37 
44 ROSE_DLL_API std::string concatenate(const std::string &oldStuff, const std::string &newStuff, const std::string &separator="");
45 
49 ROSE_DLL_API bool isId(const std::string &s);
50 
52 ROSE_DLL_API extern const size_t NO_ID;
53 
54 
60 class ROSE_DLL_API Organization {
61 private:
62  bool isSelected_;
63  std::string name_; // name used by GraphViz to identify this object
64  std::string label_; // label shown in rendered graph, includes delimiters, "" or <>
65  Attributes attributes_;
66  std::string subgraph_;
67 public:
72  Organization(): isSelected_(true) {}
73 
75  void select(bool b=true) { isSelected_ = b; }
76 
83  bool isSelected() const { return isSelected_; }
84 
90  const std::string &name() const { return name_; }
91  void name(const std::string &s) { name_ = s; }
100  const std::string& label() const {
101  static std::string empty = "\"\"";
102  return label_.empty() ? empty : label_;
103  }
104  void label(const std::string &s) { label_ = s; }
112  const Attributes& attributes() const { return attributes_; }
113  Attributes& attributes() { return attributes_; }
114  void attributes(const Attributes &a) { attributes_ = a; }
123  const std::string& subgraph() const { return subgraph_; }
124  void subgraph(const std::string &s) { subgraph_ = s; }
126 };
127 
129 // BaseEmitter
131 
136 template<class G>
137 class BaseEmitter {
138 public:
139  typedef G Graph;
140 
142  typedef std::vector<Organization> VertexOrganization;
143 
145  typedef std::vector<Organization> EdgeOrganization;
146 
149 
150 protected:
151  struct PseudoEdge {
152  typename G::ConstVertexIterator src, dst;
153  std::string label;
154  Attributes attributes;
155  PseudoEdge(const typename G::ConstVertexIterator &src, const typename G::ConstVertexIterator &dst,
156  const std::string &label)
157  : src(src), dst(dst), label(label) {}
158  };
159 
160  typedef Sawyer::Container::Map<size_t, size_t> VMap;// maps graph vertex ID to graphviz node ID
161 
162 protected:
163  Graph graph_; // graph being emitted
164  VertexOrganization vertexOrganization_; // which vertices are selected for output
165  EdgeOrganization edgeOrganization_; // which edges are selected for output
166  SubgraphOrganization subgraphOrganization_; // which subgraphs are selected for output
167  Attributes defaultGraphAttributes_; // default attributes for the graph as a whole
168  Attributes defaultNodeAttributes_; // default attributes for graph nodes (CFG vertices and other)
169  Attributes defaultEdgeAttributes_; // default attributes for graph edges
170  std::list<PseudoEdge> pseudoEdges_; // extra edges not present in the CFG but needed in the GraphViz
171  Color::HSV subgraphColor_; // background color for function subgraphs
172 
173 public:
178  BaseEmitter(): subgraphColor_(0, 0, 0.95) {}
179 
183  explicit BaseEmitter(const Graph &g)
184  : subgraphColor_(0, 0, 0.95) {
185  graph(g);
186  }
187 
189  void graph(const Graph &g) {
190  graph_ = g;
191  vertexOrganization_.clear();
192  vertexOrganization_.resize(g.nVertices());
193  edgeOrganization_.clear();
194  edgeOrganization_.resize(g.nEdges());
195  subgraphOrganization_.clear();
196  pseudoEdges_.clear();
197  }
198 
204  Attributes& defaultGraphAttributes() {
205  return defaultGraphAttributes_;
206  }
207  const Attributes& defaultGraphAttributes() const {
208  return defaultGraphAttributes_;
209  }
217  Attributes& defaultNodeAttributes() {
218  return defaultNodeAttributes_;
219  }
220  const Attributes& defaultNodeAttributes() const {
221  return defaultNodeAttributes_;
222  }
230  Attributes& defaultEdgeAttributes() {
231  return defaultEdgeAttributes_;
232  }
233  const Attributes& defaultEdgeAttributes() const {
234  return defaultEdgeAttributes_;
235  }
241  const Color::HSV& subgraphColor() const { return subgraphColor_; }
242  void subgraphColor(const Color::HSV &bg) { subgraphColor_ = bg; }
255  const VertexOrganization& vertexOrganization() const {
256  return vertexOrganization_;
257  }
258  VertexOrganization& vertexOrganization() {
259  return vertexOrganization_;
260  }
261  const Organization& vertexOrganization(size_t vertexId) const {
262  ASSERT_require(vertexId < vertexOrganization_.size());
263  return vertexOrganization_[vertexId];
264  }
265  Organization& vertexOrganization(size_t vertexId) {
266  ASSERT_require(vertexId < vertexOrganization_.size());
267  return vertexOrganization_[vertexId];
268  }
269  const Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) const {
270  return vertexOrganization(vertex->id());
271  }
272  const Organization& vertexOrganization(const typename G::Vertex &vertex) const {
273  return vertexOrganization(vertex.id());
274  }
275  Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) {
276  return vertexOrganization(vertex->id());
277  }
278  Organization& vertexOrganization(const typename G::Vertex &vertex) {
279  return vertexOrganization(vertex.id());
280  }
293  const EdgeOrganization& edgeOrganization() const {
294  return edgeOrganization_;
295  }
296  EdgeOrganization& edgeOrganization() {
297  return edgeOrganization_;
298  }
299  const Organization& edgeOrganization(size_t edgeId) const {
300  ASSERT_require(edgeId < edgeOrganization_.size());
301  return edgeOrganization_[edgeId];
302  }
303  Organization& edgeOrganization(size_t edgeId) {
304  ASSERT_require(edgeId < edgeOrganization_.size());
305  return edgeOrganization_[edgeId];
306  }
307  const Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) const {
308  return edgeOrganization(edge->id());
309  }
310  const Organization& edgeOrganization(const typename G::Edge &edge) const {
311  return edgeOrganization(edge.id());
312  }
313  Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) {
314  return edgeOrganization(edge->id());
315  }
316  Organization& edgeOrganization(const typename G::Edge &edge) {
317  return edgeOrganization(edge.id());
318  }
331  const SubgraphOrganization& subgraphOrganization() const {
332  return subgraphOrganization_;
333  }
334  SubgraphOrganization& subgraphOrganization() {
335  return subgraphOrganization_;
336  }
337  const Organization& subgraphOrganization(const std::string &name) const {
338  return subgraphOrganization_.getOrDefault(name);
339  }
340  Organization& subgraphOrganization(const std::string &name) {
341  return subgraphOrganization_.insertMaybeDefault(name);
342  }
349  void selectAll(bool b=true) {
351  selectAllEdges(b);
352  }
353 
355  void selectNone() {
356  pseudoEdges_.clear();
357  selectAllEdges(false);
358  selectAllVertices(false);
359  }
360 
365  void selectAllVertices(bool b=true) {
366  BOOST_FOREACH (Organization &org, vertexOrganization_)
367  org.select(b);
368  }
369 
374  void selectAllEdges(bool b=true) {
375  BOOST_FOREACH (Organization &org, edgeOrganization_)
376  org.select(b);
377  }
378 
382  void deselectParallelEdges();
383 
388  virtual void emit(std::ostream&) const;
389 
390 protected:
394  size_t emitVertex(std::ostream&, const typename G::ConstVertexIterator&, const Organization&, const VMap&) const;
395 
397  void emitEdge(std::ostream&, const typename G::ConstEdgeIterator&, const Organization&, const VMap&) const;
398 
399 };
400 
401 
403 // Base generator for Partitioner2::ControlFlowGraph
405 
432 class ROSE_DLL_API CfgEmitter: public BaseEmitter<ControlFlowGraph> {
433  const Partitioner &partitioner_;
434  bool useFunctionSubgraphs_; // should called functions be shown as subgraphs?
435  bool showReturnEdges_; // show E_FUNCTION_RETURN edges?
436  bool showInstructions_; // show instructions or only block address?
437  bool showInstructionAddresses_; // if instructions are shown, show addresses too?
438  bool showInstructionStackDeltas_; // show stack deltas for instructions
439  bool showInNeighbors_; // show neighbors for incoming edges to selected vertices?
440  bool showOutNeighbors_; // show neighbors for outgoing edges to selected vertices?
441  bool strikeNoopSequences_; // render no-op sequences in a different style
442  Color::HSV funcEnterColor_; // background color for function entrance blocks
443  Color::HSV funcReturnColor_; // background color for function return blocks
444  Color::HSV warningColor_; // background color for special nodes and warnings
445  DwarfLineMapper srcMapper_; // maps addresses to source code (optional)
446  static unsigned long versionDate_; // date code from "dot -V", like 20100126
447  NoOperation noOpAnalysis_;
448 
449 public:
457  explicit CfgEmitter(const Partitioner&);
458  CfgEmitter(const Partitioner&, const ControlFlowGraph&);
461  // Properties
463 
467  const Partitioner& partitioner() { return partitioner_; }
468 
476  bool useFunctionSubgraphs() const { return useFunctionSubgraphs_; }
477  void useFunctionSubgraphs(bool b) { useFunctionSubgraphs_ = b; }
487  bool showInstructions() const { return showInstructions_; }
488  void showInstructions(bool b) { showInstructions_ = b; }
497  bool showInstructionAddresses() const { return showInstructionAddresses_; }
498  void showInstructionAddresses(bool b) { showInstructionAddresses_ = b; }
508  bool showInstructionStackDeltas() const { return showInstructionStackDeltas_; }
509  void showInstructionStackDeltas(bool b) { showInstructionStackDeltas_ = b; }
520  bool strikeNoopSequences() const { return strikeNoopSequences_; }
521  void strikeNoopSequences(bool b) { strikeNoopSequences_ = b; }
531  const Color::HSV& funcEnterColor() const { return funcEnterColor_; }
532  void funcEnterColor(const Color::HSV &bg) { funcEnterColor_ = bg; }
538  const Color::HSV& funcReturnColor() const { return funcReturnColor_; }
539  void funcReturnColor(const Color::HSV &bg) { funcReturnColor_ = bg; }
545  const Color::HSV& warningColor() const { return warningColor_; }
546  void warningColor(const Color::HSV &bg) { warningColor_ = bg; }
555  bool showOutNeighbors() const { return showOutNeighbors_; }
556  void showOutNeighbors(bool b) { showOutNeighbors_ = b; }
567  bool showInNeighbors() const { return showInNeighbors_; }
568  void showInNeighbors(bool b) { showInNeighbors_ = b; }
577  bool showReturnEdges() const { return showReturnEdges_; }
578  void showReturnEdges(bool b) { showReturnEdges_ = b; }
586  const DwarfLineMapper& srcMapper() const { return srcMapper_; }
587  DwarfLineMapper& srcMapper() { return srcMapper_; }
588  void srcMapper(const DwarfLineMapper &mapper) { srcMapper_ = mapper; }
592  // Organization
594 
596  // Low-level vertex and edge selection
597 
603  void selectInterval(const AddressInterval&);
604 
606  void selectIntraFunction(const Function::Ptr&);
607 
611  void selectFunctionCallees(const Function::Ptr&);
612 
617  void selectFunctionCallers(const Function::Ptr&);
618 
622  void deselectReturnEdges();
623 
625  void deselectUnusedVertex(ControlFlowGraph::ConstVertexIterator);
626 
628  void deselectUnusedVertexType(VertexType);
629 
633  void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true);
634 
636  // High-level selectors
637 
643  CfgEmitter& selectWholeGraph();
644 
650  CfgEmitter& selectFunctionGraph(const Function::Ptr&);
651 
657  CfgEmitter& selectIntervalGraph(const AddressInterval &interval);
658 
660  // GraphViz emitters
661 
665  void emitWholeGraph(std::ostream &out) {
666  selectWholeGraph().emit(out);
667  }
668 
672  void emitFunctionGraph(std::ostream &out, const Function::Ptr &function) {
673  selectFunctionGraph(function).emit(out);
674  }
675 
679  void emitIntervalGraph(std::ostream &out, const AddressInterval &interval) {
680  selectIntervalGraph(interval).emit(out);
681  }
682 
683 
685  // Low-level emitters
686 
688  // Utilities
689 
693  static bool isInterFunctionEdge(const ControlFlowGraph::Edge&);
694  static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator &e) { return isInterFunctionEdge(*e); }
703  static Function::Ptr firstOwningFunction(const ControlFlowGraph::Vertex&);
704  static Function::Ptr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v) {
705  return firstOwningFunction(*v);
706  }
715  static FunctionSet owningFunctions(const ControlFlowGraph::Vertex&);
716  static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator &v) { return owningFunctions(*v); }
723  void assignFunctionSubgraphs();
724 
725 
727  // Formatting: these are expected to be overridden by subclasses
728 
733  virtual std::string sourceLocation(const ControlFlowGraph::ConstVertexIterator&) const;
734 
741  virtual std::string vertexLabel(const ControlFlowGraph::ConstVertexIterator&) const;
742  std::string vertexLabel(const ControlFlowGraph::Vertex&) const;
752  virtual std::string vertexLabelDetailed(const ControlFlowGraph::ConstVertexIterator&) const;
753  std::string vertexLabelDetailed(const ControlFlowGraph::Vertex&) const;
759  virtual Attributes vertexAttributes(const ControlFlowGraph::ConstVertexIterator&) const;
760  Attributes vertexAttributes(const ControlFlowGraph::Vertex&) const;
768  virtual std::string edgeLabel(const ControlFlowGraph::ConstEdgeIterator&) const;
769  std::string edgeLabel(const ControlFlowGraph::Edge&) const;
775  virtual Attributes edgeAttributes(const ControlFlowGraph::ConstEdgeIterator&) const;
776  Attributes edgeAttributes(const ControlFlowGraph::Edge&) const;
782  virtual std::string functionLabel(const Function::Ptr&) const;
783 
785  virtual Attributes functionAttributes(const Function::Ptr&) const;
786 
787 private:
788  void init();
789 
790  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
791  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
792  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
793  void nameVertices();
794 };
795 
796 
798 // Base emitter for Partitioner2::FunctionCallGraph
800 
802 class ROSE_DLL_API CgEmitter: public BaseEmitter<FunctionCallGraph::Graph> {
803  FunctionCallGraph cg_;
804  Color::HSV functionHighlightColor_; // highlight certain functions
805  boost::regex highlightNameMatcher_; // which functions to highlight
806 public:
807  explicit CgEmitter(const Partitioner &partitioner);
808  CgEmitter(const Partitioner &partitioner, const FunctionCallGraph &cg);
809  virtual std::string functionLabel(const Function::Ptr&) const;
810  virtual Attributes functionAttributes(const Function::Ptr&) const;
811  virtual void emitCallGraph(std::ostream &out) const;
812  virtual const FunctionCallGraph& callGraph() const { return cg_; }
813  virtual void callGraph(const FunctionCallGraph &cg);
814  virtual void highlight(const boost::regex&);
815 private:
816  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
817  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
818  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
819  void nameVertices();
820 };
821 
822 
824 // Callgraph emitter with inlined imports
826 
832 class ROSE_DLL_API CgInlinedEmitter: public CgEmitter {
833  boost::regex nameMatcher_;
834  typedef std::vector<Function::Ptr> InlinedFunctions;
836  Inlines inlines_;
837 public:
838  CgInlinedEmitter(const Partitioner &partitioner, const boost::regex &nameMatcher);
839  CgInlinedEmitter(const Partitioner &partitioner, const FunctionCallGraph &cg, const boost::regex &nameMatcher);
840  virtual const FunctionCallGraph& callGraph() const ROSE_OVERRIDE { return CgEmitter::callGraph(); }
841  virtual void callGraph(const FunctionCallGraph&) ROSE_OVERRIDE;
842  virtual std::string functionLabel(const Function::Ptr&) const ROSE_OVERRIDE;
843  virtual bool shouldInline(const Function::Ptr&) const;
844 };
845 
846 
848 // Reading layout position information from "dot"
850 
852 struct Coordinate {
853  double x;
854  double y;
855 };
856 
859  std::string name;
861  double width;
862  double height;
863 };
864 
873 struct EdgePosition {
874  std::vector<Coordinate> spline;
875 };
876 
879 
883 PositionGraph readPositions(std::istream&);
884 
885 
886 
887 
889 // Class template method implementations
891 
892 template<class G>
893 size_t
894 BaseEmitter<G>::emitVertex(std::ostream &out, const typename G::ConstVertexIterator &vertex,
895  const Organization &org, const VMap &vmap) const {
896  size_t id = NO_ID;
897  if (org.isSelected() && !vmap.getOptional(vertex->id()).assignTo(id)) {
898  id = vmap.size();
899  std::string name = org.name();
900  if (name.empty())
902  out <<name <<" [ label=" <<org.label() <<" ";
903  out <<toString(org.attributes()) <<" ];\n";
904  }
905  return id;
906 }
907 
908 template<class G>
909 void
910 BaseEmitter<G>::emitEdge(std::ostream &out, const typename G::ConstEdgeIterator &edge, const Organization &org,
911  const VMap &vmap) const {
912  ASSERT_require2(vmap.exists(edge->source()->id()), "edge source vertex has not yet been emitted");
913  ASSERT_require2(vmap.exists(edge->target()->id()), "edge target vertex has not yet been emitted");
914 
915  size_t sourceId = edge->source()->id();
916  std::string sourceName = vertexOrganization(sourceId).name();
917  if (sourceName.empty())
918  sourceName = StringUtility::numberToString(vmap[sourceId]);
919 
920  size_t targetId = edge->target()->id();
921  std::string targetName = vertexOrganization(targetId).name();
922  if (targetName.empty())
923  targetName = StringUtility::numberToString(vmap[targetId]);
924 
925  out <<sourceName <<" -> " <<targetName <<" [ label=" <<org.label() <<" " <<toString(org.attributes()) <<" ];\n";
926 }
927 
928 template<class G>
929 void
930 BaseEmitter<G>::emit(std::ostream &out) const {
931  VMap vmap; // GraphViz node ID for each graph vertex (modified by emit)
932 
933  out <<"digraph CFG {\n";
934  out <<" graph [ " <<toString(defaultGraphAttributes_) <<" ];\n";
935  out <<" node [ " <<toString(defaultNodeAttributes_) <<" ];\n";
936  out <<" edge [ " <<toString(defaultEdgeAttributes_) <<" ];\n";
937 
938  typedef std::map<std::string /*subgraph name*/, std::string/*subgraph content*/> Subgraphs;
939  Subgraphs subgraphs;
940 
941  // Emit vertices to subgraphs
942  for (typename G::ConstVertexIterator vertex=graph_.vertices().begin(); vertex!=graph_.vertices().end(); ++vertex) {
943  const Organization &org = vertexOrganization(vertex);
944  if (org.isSelected() && !vmap.exists(vertex->id())) {
945  std::ostringstream ss;
946  size_t gvid = emitVertex(ss, vertex, org, vmap);
947  vmap.insert(vertex->id(), gvid);
948  subgraphs[org.subgraph()] += ss.str();
949  }
950  }
951 
952  // Emit edges to subgraphs
953  for (typename G::ConstEdgeIterator edge=graph_.edges().begin(); edge!=graph_.edges().end(); ++edge) {
954  const Organization &org = edgeOrganization(edge);
955  if (org.isSelected() &&
956  vertexOrganization(edge->source()).isSelected() && vertexOrganization(edge->target()).isSelected()) {
957  std::ostringstream ss;
958  emitEdge(ss, edge, org, vmap);
959  subgraphs[org.subgraph()] += ss.str();
960  }
961  }
962 
963  // Emit named subgraphs to output
964  BOOST_FOREACH (const Subgraphs::value_type &node, subgraphs) {
965  const std::string &subgraphName = node.first;
966  const std::string &subgraphContent = node.second;
967  if (!subgraphName.empty()) {
968  out <<"\nsubgraph cluster_" <<subgraphName <<" {"
969  <<" label=" <<subgraphOrganization(subgraphName).label() <<" "
970  <<toString(subgraphOrganization(subgraphName).attributes()) <<"\n"
971  <<subgraphContent
972  <<"}\n";
973  }
974  }
975 
976  // Emit unnamed subgraph content without a surrounding subgraph construct (i.e., global graph)
977  Subgraphs::iterator unnamedSubgraph = subgraphs.find("");
978  if (unnamedSubgraph != subgraphs.end())
979  out <<unnamedSubgraph->second;
980 
981  // Emit pseudo edges
982  BOOST_FOREACH (const PseudoEdge &edge, pseudoEdges_) {
983  if (vertexOrganization(edge.src).isSelected() && vertexOrganization(edge.dst).isSelected()) {
984  std::string sourceName = vertexOrganization(edge.src).name();
985  std::string targetName = vertexOrganization(edge.dst).name();
986  out <<(sourceName.empty() ? StringUtility::numberToString(vmap[edge.src->id()]) : sourceName)
987  <<" -> "
988  <<(targetName.empty() ? StringUtility::numberToString(vmap[edge.dst->id()]) : targetName)
989  <<" [ label=" <<escape(edge.label) <<" ];\n";
990  }
991  }
992 
993  out <<"}\n";
994 }
995 
996 template<class G>
997 void
999  BOOST_FOREACH (const typename G::Vertex &src, graph_.vertices()) {
1000  if (vertexOrganization(src).isSelected()) {
1001  std::set<size_t> targets;
1002  BOOST_FOREACH (const typename G::Edge &edge, src.outEdges()) {
1003  if (edgeOrganization(edge).isSelected() && !targets.insert(edge.target()->id()).second)
1004  edgeOrganization(edge).select(false);
1005  }
1006  }
1007  }
1008 }
1009 
1010 } // namespace
1011 } // namespace
1012 } // namespace
1013 } // namespace
1014 
1015 #endif
size_t nVertices() const
Total number of vertices.
Definition: Graph.h:1670
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:539
const Color::HSV & warningColor() const
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:545
const VertexOrganization & vertexOrganization() const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:255
void srcMapper(const DwarfLineMapper &mapper)
Property: Address-to-source mapping.
Definition: GraphViz.h:588
const Organization & vertexOrganization(size_t vertexId) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:261
void showInstructionStackDeltas(bool b)
Property: show instruction stack deltas.
Definition: GraphViz.h:509
const Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:307
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:340
Coordinate center
Center of vertex in display plane units.
Definition: GraphViz.h:860
bool exists(const Key &key) const
Determine if a key exists.
Definition: Sawyer/Map.h:377
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:486
size_t nEdges() const
Total number of edges.
Definition: Graph.h:1680
Sawyer::Container::Map< std::string, Organization > SubgraphOrganization
Organizational information for subgraphs.
Definition: GraphViz.h:148
const Attributes & defaultNodeAttributes() const
Property: default graph node attributes.
Definition: GraphViz.h:220
void graph(const Graph &g)
Reset the graph.
Definition: GraphViz.h:189
Base class for generating GraphViz output.
Definition: GraphViz.h:137
const SubgraphOrganization & subgraphOrganization() const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:331
const Attributes & defaultGraphAttributes() const
Property: default graph attributes.
Definition: GraphViz.h:207
void selectAll(bool b=true)
Causes all vertices and edges to be selected.
Definition: GraphViz.h:349
Organization & edgeOrganization(size_t edgeId)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:303
void useFunctionSubgraphs(bool b)
Property: use function subgraphs.
Definition: GraphViz.h:477
void label(const std::string &s)
Label for object.
Definition: GraphViz.h:104
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:90
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:894
const Attributes & defaultEdgeAttributes() const
Property: default graph edge attributes.
Definition: GraphViz.h:233
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:476
void emitWholeGraph(std::ostream &out)
Dump entire control flow graph.
Definition: GraphViz.h:665
ROSE_DLL_API std::string escape(const std::string &)
Escape some value for GraphViz.
const Attributes & attributes() const
Attributes for object.
Definition: GraphViz.h:112
Value & insertMaybeDefault(const Key &key)
Conditionally insert a new key with default value.
Definition: Sawyer/Map.h:595
void emitEdge(std::ostream &, const typename G::ConstEdgeIterator &, const Organization &, const VMap &) const
Emit a single edge.
Definition: GraphViz.h:910
const Color::HSV & subgraphColor() const
Property: color to use for function subgraph background.
Definition: GraphViz.h:241
bool showInstructionAddresses() const
Property: show instruction addresses.
Definition: GraphViz.h:497
Creates GraphViz files from Partitioner data.
Definition: GraphViz.h:432
Colors in HSV space.
Definition: Color.h:72
Main namespace for the ROSE library.
bool isSelected() const
Determines whether an object is selected.
Definition: GraphViz.h:83
const Organization & edgeOrganization(const typename G::Edge &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:310
const EdgeOrganization & edgeOrganization() const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:293
void subgraph(const std::string &s)
Subgraph for object.
Definition: GraphViz.h:124
Map & clear()
Remove all nodes.
Definition: Sawyer/Map.h:616
Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:313
void showReturnEdges(bool b)
Property: show function return edges.
Definition: GraphViz.h:578
VertexType
Partitioner control flow vertex types.
Definition: BasicTypes.h:19
Sawyer::Container::Graph< VertexPosition, EdgePosition > PositionGraph
A graph with positioned vertices and edges.
Definition: GraphViz.h:878
Organization & vertexOrganization(size_t vertexId)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:265
void funcEnterColor(const Color::HSV &bg)
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:532
Sawyer::Container::Map< std::string, std::string > Attributes
GraphViz attributes.
Definition: GraphViz.h:22
bool showReturnEdges() const
Property: show function return edges.
Definition: GraphViz.h:577
Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:275
const DwarfLineMapper & srcMapper() const
Property: Address-to-source mapping.
Definition: GraphViz.h:586
const Organization & vertexOrganization(const typename G::Vertex &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:272
VertexOrganization & vertexOrganization()
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:258
std::vector< Organization > EdgeOrganization
Organizational information for edges.
Definition: GraphViz.h:145
virtual void emit(std::ostream &) const
Dump selected vertices, edges, and subgraphs.
Definition: GraphViz.h:930
bool showInstructionStackDeltas() const
Property: show instruction stack deltas.
Definition: GraphViz.h:508
bool showInNeighbors() const
Property: show incoming edges from neighbor vertices.
Definition: GraphViz.h:567
const std::string & label() const
Label for object.
Definition: GraphViz.h:100
Attributes & attributes()
Attributes for object.
Definition: GraphViz.h:113
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:217
void subgraphColor(const Color::HSV &bg)
Property: color to use for function subgraph background.
Definition: GraphViz.h:242
void deselectParallelEdges()
Deselect all but one parallel edge.
Definition: GraphViz.h:998
const Partitioner & partitioner()
Property: partitioner.
Definition: GraphViz.h:467
const Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:269
const Color::HSV & funcEnterColor() const
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:531
bool showOutNeighbors() const
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:555
bool strikeNoopSequences() const
Property: strike no-op sequences.
Definition: GraphViz.h:520
void emitIntervalGraph(std::ostream &out, const AddressInterval &interval)
Dump control flow graph for some address interval.
Definition: GraphViz.h:679
void clear()
Remove all vertices and edges.
Definition: Graph.h:1990
void select(bool b=true)
Select or deselect object.
Definition: GraphViz.h:75
void showOutNeighbors(bool b)
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:556
const Color::HSV & funcReturnColor() const
Property: color to use for background of function return nodes.
Definition: GraphViz.h:538
void selectAllEdges(bool b=true)
Causes all edges to be selected.
Definition: GraphViz.h:374
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:513
Attributes & defaultGraphAttributes()
Property: default graph attributes.
Definition: GraphViz.h:204
void name(const std::string &s)
Name for object.
Definition: GraphViz.h:91
Two dimensional display plane coordinate.
Definition: GraphViz.h:852
void warningColor(const Color::HSV &bg)
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:546
const Organization & edgeOrganization(size_t edgeId) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:299
SubgraphOrganization & subgraphOrganization()
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:334
std::vector< Organization > VertexOrganization
Organizational information for vertices.
Definition: GraphViz.h:142
void showInstructions(bool b)
Property: show basic block instructions.
Definition: GraphViz.h:488
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
Definition: Sawyer/Map.h:530
void showInNeighbors(bool b)
Property: show incoming edges from neighbor vertices.
Definition: GraphViz.h:568
void selectNone()
Deselects all vertices and edges.
Definition: GraphViz.h:355
Organization & vertexOrganization(const typename G::Vertex &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:278
const Organization & subgraphOrganization(const std::string &name) const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:337
void attributes(const Attributes &a)
Attributes for object.
Definition: GraphViz.h:114
void strikeNoopSequences(bool b)
Property: strike no-op sequences.
Definition: GraphViz.h:521
static Function::Ptr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v)
First function that owns a vertex.
Definition: GraphViz.h:704
static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator &e)
Returns true if the edge spans two different functions.
Definition: GraphViz.h:694
void selectAllVertices(bool b=true)
Causes all vertices to be selected.
Definition: GraphViz.h:365
DwarfLineMapper & srcMapper()
Property: Address-to-source mapping.
Definition: GraphViz.h:587
std::string name
Name of vertex as known to GraphViz.
Definition: GraphViz.h:859
Partitions instructions into basic blocks and functions.
Definition: Partitioner.h:289
Attributes & defaultEdgeAttributes()
Property: default graph edge attributes.
Definition: GraphViz.h:230
Analysis that looks for no-op equivalents.
void showInstructionAddresses(bool b)
Property: show instruction addresses.
Definition: GraphViz.h:498
size_t size() const
Number of nodes, keys, or values in this container.
Definition: Sawyer/Map.h:322
const std::string & subgraph() const
Subgraph for object.
Definition: GraphViz.h:123
EdgeOrganization & edgeOrganization()
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:296
std::vector< Coordinate > spline
Control points for the edge B-spline.
Definition: GraphViz.h:874
Organization & edgeOrganization(const typename G::Edge &edge)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:316
static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator &v)
Functions that own a vertex.
Definition: GraphViz.h:716
void emitFunctionGraph(std::ostream &out, const Function::Ptr &function)
Dump control flow graph for one function.
Definition: GraphViz.h:672
Build mappings between source locations and virtual addresses.
bool showInstructions() const
Property: show basic block instructions.
Definition: GraphViz.h:487