ROSE  0.11.145.0
GraphViz.h
1 #ifndef ROSE_BinaryAnalysis_Partitioner2_GraphViz_H
2 #define ROSE_BinaryAnalysis_Partitioner2_GraphViz_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 #include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
6 
7 #include <Rose/BinaryAnalysis/NoOperation.h>
8 #include <Rose/BinaryAnalysis/Partitioner2/ControlFlowGraph.h>
9 #include <Rose/BinaryAnalysis/Partitioner2/FunctionCallGraph.h>
10 #include <Rose/BinaryAnalysis/SourceLocations.h>
11 #include <Rose/Color.h>
12 
13 #include <boost/regex.hpp>
14 #include <ostream>
15 
16 namespace Rose {
17 namespace BinaryAnalysis {
18 namespace Partitioner2 {
19 
21 namespace GraphViz {
22 
27 
29 ROSE_DLL_API std::string toString(const Attributes&);
30 
32 ROSE_DLL_API std::string quotedEscape(const std::string&);
33 
35 ROSE_DLL_API std::string htmlEscape(const std::string&);
36 
40 ROSE_DLL_API std::string escape(const std::string&);
41 
48 ROSE_DLL_API std::string concatenate(const std::string &oldStuff, const std::string &newStuff, const std::string &separator="");
49 
53 ROSE_DLL_API bool isId(const std::string &s);
54 
56 ROSE_DLL_API extern const size_t NO_ID;
57 
58 
64 class ROSE_DLL_API Organization {
65 private:
66  bool isSelected_;
67  std::string name_; // name used by GraphViz to identify this object
68  std::string label_; // label shown in rendered graph, includes delimiters, "" or <>
69  Attributes attributes_;
70  std::string subgraph_;
71 public:
76  Organization(): isSelected_(true) {}
77 
79  void select(bool b=true) { isSelected_ = b; }
80 
87  bool isSelected() const { return isSelected_; }
88 
94  const std::string &name() const { return name_; }
95  void name(const std::string &s) { name_ = s; }
104  const std::string& label() const {
105  static std::string empty = "\"\"";
106  return label_.empty() ? empty : label_;
107  }
108  void label(const std::string &s) { label_ = s; }
116  const Attributes& attributes() const { return attributes_; }
117  Attributes& attributes() { return attributes_; }
118  void attributes(const Attributes &a) { attributes_ = a; }
127  const std::string& subgraph() const { return subgraph_; }
128  void subgraph(const std::string &s) { subgraph_ = s; }
130 };
131 
133 // BaseEmitter
135 
140 template<class G>
141 class BaseEmitter {
142 public:
143  typedef G Graph;
144 
146  typedef std::vector<Organization> VertexOrganization;
147 
149  typedef std::vector<Organization> EdgeOrganization;
150 
153 
154 protected:
155  struct PseudoEdge {
156  typename G::ConstVertexIterator src, dst;
157  std::string label;
158  Attributes attributes;
159  PseudoEdge(const typename G::ConstVertexIterator &src, const typename G::ConstVertexIterator &dst,
160  const std::string &label)
161  : src(src), dst(dst), label(label) {}
162  };
163 
164  typedef Sawyer::Container::Map<size_t, size_t> VMap;// maps graph vertex ID to graphviz node ID
165 
166 protected:
167  Graph graph_; // graph being emitted
168  VertexOrganization vertexOrganization_; // which vertices are selected for output
169  EdgeOrganization edgeOrganization_; // which edges are selected for output
170  SubgraphOrganization subgraphOrganization_; // which subgraphs are selected for output
171  Attributes defaultGraphAttributes_; // default attributes for the graph as a whole
172  Attributes defaultNodeAttributes_; // default attributes for graph nodes (CFG vertices and other)
173  Attributes defaultEdgeAttributes_; // default attributes for graph edges
174  std::list<PseudoEdge> pseudoEdges_; // extra edges not present in the CFG but needed in the GraphViz
175  Color::HSV subgraphColor_; // background color for function subgraphs
176 
177 public:
182  BaseEmitter(): subgraphColor_(0, 0, 0.95) {}
183 
187  explicit BaseEmitter(const Graph &g)
188  : subgraphColor_(0, 0, 0.95) {
189  graph(g);
190  }
191 
193  void graph(const Graph &g) {
194  graph_ = g;
195  vertexOrganization_.clear();
196  vertexOrganization_.resize(g.nVertices());
197  edgeOrganization_.clear();
198  edgeOrganization_.resize(g.nEdges());
199  subgraphOrganization_.clear();
200  pseudoEdges_.clear();
201  }
202 
208  Attributes& defaultGraphAttributes() {
209  return defaultGraphAttributes_;
210  }
211  const Attributes& defaultGraphAttributes() const {
212  return defaultGraphAttributes_;
213  }
221  Attributes& defaultNodeAttributes() {
222  return defaultNodeAttributes_;
223  }
224  const Attributes& defaultNodeAttributes() const {
225  return defaultNodeAttributes_;
226  }
234  Attributes& defaultEdgeAttributes() {
235  return defaultEdgeAttributes_;
236  }
237  const Attributes& defaultEdgeAttributes() const {
238  return defaultEdgeAttributes_;
239  }
245  const Color::HSV& subgraphColor() const { return subgraphColor_; }
246  void subgraphColor(const Color::HSV &bg) { subgraphColor_ = bg; }
259  const VertexOrganization& vertexOrganization() const {
260  return vertexOrganization_;
261  }
262  VertexOrganization& vertexOrganization() {
263  return vertexOrganization_;
264  }
265  const Organization& vertexOrganization(size_t vertexId) const {
266  ASSERT_require(vertexId < vertexOrganization_.size());
267  return vertexOrganization_[vertexId];
268  }
269  Organization& vertexOrganization(size_t vertexId) {
270  ASSERT_require(vertexId < vertexOrganization_.size());
271  return vertexOrganization_[vertexId];
272  }
273  const Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) const {
274  return vertexOrganization(vertex->id());
275  }
276  const Organization& vertexOrganization(const typename G::Vertex &vertex) const {
277  return vertexOrganization(vertex.id());
278  }
279  Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) {
280  return vertexOrganization(vertex->id());
281  }
282  Organization& vertexOrganization(const typename G::Vertex &vertex) {
283  return vertexOrganization(vertex.id());
284  }
297  const EdgeOrganization& edgeOrganization() const {
298  return edgeOrganization_;
299  }
300  EdgeOrganization& edgeOrganization() {
301  return edgeOrganization_;
302  }
303  const Organization& edgeOrganization(size_t edgeId) const {
304  ASSERT_require(edgeId < edgeOrganization_.size());
305  return edgeOrganization_[edgeId];
306  }
307  Organization& edgeOrganization(size_t edgeId) {
308  ASSERT_require(edgeId < edgeOrganization_.size());
309  return edgeOrganization_[edgeId];
310  }
311  const Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) const {
312  return edgeOrganization(edge->id());
313  }
314  const Organization& edgeOrganization(const typename G::Edge &edge) const {
315  return edgeOrganization(edge.id());
316  }
317  Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) {
318  return edgeOrganization(edge->id());
319  }
320  Organization& edgeOrganization(const typename G::Edge &edge) {
321  return edgeOrganization(edge.id());
322  }
335  const SubgraphOrganization& subgraphOrganization() const {
336  return subgraphOrganization_;
337  }
338  SubgraphOrganization& subgraphOrganization() {
339  return subgraphOrganization_;
340  }
341  const Organization& subgraphOrganization(const std::string &name) const {
342  return subgraphOrganization_.getOrDefault(name);
343  }
344  Organization& subgraphOrganization(const std::string &name) {
345  return subgraphOrganization_.insertMaybeDefault(name);
346  }
353  void selectAll(bool b=true) {
355  selectAllEdges(b);
356  }
357 
359  void selectNone() {
360  pseudoEdges_.clear();
361  selectAllEdges(false);
362  selectAllVertices(false);
363  }
364 
369  void selectAllVertices(bool b=true) {
370  for (Organization &org: vertexOrganization_)
371  org.select(b);
372  }
373 
378  void selectAllEdges(bool b=true) {
379  for (Organization &org: edgeOrganization_)
380  org.select(b);
381  }
382 
386  void deselectParallelEdges();
387 
392  virtual void emit(std::ostream&) const;
393 
394 protected:
398  size_t emitVertex(std::ostream&, const typename G::ConstVertexIterator&, const Organization&, const VMap&) const;
399 
401  void emitEdge(std::ostream&, const typename G::ConstEdgeIterator&, const Organization&, const VMap&) const;
402 
403 };
404 
405 
407 // Base generator for Partitioner2::ControlFlowGraph
409 
436 class ROSE_DLL_API CfgEmitter: public BaseEmitter<ControlFlowGraph> {
437  PartitionerConstPtr partitioner_; // not null
438  bool useFunctionSubgraphs_; // should called functions be shown as subgraphs?
439  bool showReturnEdges_; // show E_FUNCTION_RETURN edges?
440  bool showInstructions_; // show instructions or only block address?
441  bool showInstructionAddresses_; // if instructions are shown, show addresses too?
442  bool showInstructionStackDeltas_; // show stack deltas for instructions
443  bool showInNeighbors_; // show neighbors for incoming edges to selected vertices?
444  bool showOutNeighbors_; // show neighbors for outgoing edges to selected vertices?
445  bool strikeNoopSequences_; // render no-op sequences in a different style
446  Color::HSV funcEnterColor_; // background color for function entrance blocks
447  Color::HSV funcReturnColor_; // background color for function return blocks
448  Color::HSV warningColor_; // background color for special nodes and warnings
449  SourceLocations srcMapper_; // maps addresses to source code (optional)
450  static unsigned long versionDate_; // date code from "dot -V", like 20100126
451  NoOperation noOpAnalysis_;
452 
453 public:
461  explicit CfgEmitter(const PartitionerConstPtr&);
465  // Properties
467 
471  PartitionerConstPtr partitioner() { return partitioner_; }
472 
480  bool useFunctionSubgraphs() const { return useFunctionSubgraphs_; }
481  void useFunctionSubgraphs(bool b) { useFunctionSubgraphs_ = b; }
491  bool showInstructions() const { return showInstructions_; }
492  void showInstructions(bool b) { showInstructions_ = b; }
501  bool showInstructionAddresses() const { return showInstructionAddresses_; }
502  void showInstructionAddresses(bool b) { showInstructionAddresses_ = b; }
512  bool showInstructionStackDeltas() const { return showInstructionStackDeltas_; }
513  void showInstructionStackDeltas(bool b) { showInstructionStackDeltas_ = b; }
524  bool strikeNoopSequences() const { return strikeNoopSequences_; }
525  void strikeNoopSequences(bool b) { strikeNoopSequences_ = b; }
535  const Color::HSV& funcEnterColor() const { return funcEnterColor_; }
536  void funcEnterColor(const Color::HSV &bg) { funcEnterColor_ = bg; }
542  const Color::HSV& funcReturnColor() const { return funcReturnColor_; }
543  void funcReturnColor(const Color::HSV &bg) { funcReturnColor_ = bg; }
549  const Color::HSV& warningColor() const { return warningColor_; }
550  void warningColor(const Color::HSV &bg) { warningColor_ = bg; }
559  bool showOutNeighbors() const { return showOutNeighbors_; }
560  void showOutNeighbors(bool b) { showOutNeighbors_ = b; }
571  bool showInNeighbors() const { return showInNeighbors_; }
572  void showInNeighbors(bool b) { showInNeighbors_ = b; }
581  bool showReturnEdges() const { return showReturnEdges_; }
582  void showReturnEdges(bool b) { showReturnEdges_ = b; }
590  const SourceLocations& srcMapper() const { return srcMapper_; }
591  SourceLocations& srcMapper() { return srcMapper_; }
592  void srcMapper(const SourceLocations &mapper) { srcMapper_ = mapper; }
596  // Organization
598 
600  // Low-level vertex and edge selection
601 
607  void selectInterval(const AddressInterval&);
608 
610  void selectIntraFunction(const FunctionPtr&);
611 
615  void selectFunctionCallees(const FunctionPtr&);
616 
621  void selectFunctionCallers(const FunctionPtr&);
622 
626  void deselectReturnEdges();
627 
629  void deselectUnusedVertex(ControlFlowGraph::ConstVertexIterator);
630 
632  void deselectUnusedVertexType(VertexType);
633 
637  void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true);
638 
640  // High-level selectors
641 
647  CfgEmitter& selectWholeGraph();
648 
654  CfgEmitter& selectFunctionGraph(const FunctionPtr&);
655 
661  CfgEmitter& selectIntervalGraph(const AddressInterval &interval);
662 
664  // GraphViz emitters
665 
669  void emitWholeGraph(std::ostream&);
670 
674  void emitFunctionGraph(std::ostream&, const FunctionPtr&);
675 
679  void emitIntervalGraph(std::ostream&, const AddressInterval&);
680 
682  // Low-level emitters
683 
685  // Utilities
686 
690  static bool isInterFunctionEdge(const ControlFlowGraph::Edge&);
691  static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator&);
700  static FunctionPtr firstOwningFunction(const ControlFlowGraph::Vertex&);
701  static FunctionPtr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v) {
702  return firstOwningFunction(*v);
703  }
712  static FunctionSet owningFunctions(const ControlFlowGraph::Vertex&);
713  static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator&);
720  void assignFunctionSubgraphs();
721 
722 
724  // Formatting: these are expected to be overridden by subclasses
725 
730  virtual std::string sourceLocation(const ControlFlowGraph::ConstVertexIterator&) const;
731 
738  virtual std::string vertexLabel(const ControlFlowGraph::ConstVertexIterator&) const;
739  std::string vertexLabel(const ControlFlowGraph::Vertex&) const;
749  virtual std::string vertexLabelDetailed(const ControlFlowGraph::ConstVertexIterator&) const;
750  std::string vertexLabelDetailed(const ControlFlowGraph::Vertex&) const;
756  virtual Attributes vertexAttributes(const ControlFlowGraph::ConstVertexIterator&) const;
757  Attributes vertexAttributes(const ControlFlowGraph::Vertex&) const;
765  virtual std::string edgeLabel(const ControlFlowGraph::ConstEdgeIterator&) const;
766  std::string edgeLabel(const ControlFlowGraph::Edge&) const;
772  virtual Attributes edgeAttributes(const ControlFlowGraph::ConstEdgeIterator&) const;
773  Attributes edgeAttributes(const ControlFlowGraph::Edge&) const;
779  virtual std::string functionLabel(const FunctionPtr&) const;
780 
782  virtual Attributes functionAttributes(const FunctionPtr&) const;
783 
784 private:
785  void init();
786 
787  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
788  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
789  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
790  void nameVertices();
791 };
792 
793 
795 // Base emitter for Partitioner2::FunctionCallGraph
797 
799 class ROSE_DLL_API CgEmitter: public BaseEmitter<FunctionCallGraph::Graph> {
800  FunctionCallGraph cg_;
801  Color::HSV functionHighlightColor_; // highlight certain functions
802  boost::regex highlightNameMatcher_; // which functions to highlight
803 public:
804  explicit CgEmitter(const PartitionerConstPtr &partitioner);
805  CgEmitter(const PartitionerConstPtr &partitioner, const FunctionCallGraph &cg);
806  virtual std::string functionLabel(const FunctionPtr&) const;
807  virtual Attributes functionAttributes(const FunctionPtr&) const;
808  virtual void emitCallGraph(std::ostream &out) const;
809  virtual const FunctionCallGraph& callGraph() const { return cg_; }
810  virtual void callGraph(const FunctionCallGraph &cg);
811  virtual void highlight(const boost::regex&);
812 private:
813  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
814  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
815  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
816  void nameVertices();
817 };
818 
819 
821 // Callgraph emitter with inlined imports
823 
829 class ROSE_DLL_API CgInlinedEmitter: public CgEmitter {
830  boost::regex nameMatcher_;
831  typedef std::vector<FunctionPtr> InlinedFunctions;
833  Inlines inlines_;
834 public:
835  CgInlinedEmitter(const PartitionerConstPtr &partitioner, const boost::regex &nameMatcher);
836  CgInlinedEmitter(const PartitionerConstPtr &partitioner, const FunctionCallGraph &cg, const boost::regex &nameMatcher);
837  virtual const FunctionCallGraph& callGraph() const override { return CgEmitter::callGraph(); }
838  virtual void callGraph(const FunctionCallGraph&) override;
839  virtual std::string functionLabel(const FunctionPtr&) const override;
840  virtual bool shouldInline(const FunctionPtr&) const;
841 };
842 
843 
845 // Reading layout position information from "dot"
847 
849 struct Coordinate {
850  double x;
851  double y;
852 };
853 
856  std::string name;
858  double width;
859  double height;
860 };
861 
870 struct EdgePosition {
871  std::vector<Coordinate> spline;
872 };
873 
876 
880 PositionGraph readPositions(std::istream&);
881 
882 
883 
884 
886 // Class template method implementations
888 
889 template<class G>
890 size_t
891 BaseEmitter<G>::emitVertex(std::ostream &out, const typename G::ConstVertexIterator &vertex,
892  const Organization &org, const VMap &vmap) const {
893  size_t id = NO_ID;
894  if (org.isSelected() && !vmap.getOptional(vertex->id()).assignTo(id)) {
895  id = vmap.size();
896  std::string name = org.name();
897  if (name.empty())
899  out <<name <<" [ label=" <<org.label() <<" ";
900  out <<toString(org.attributes()) <<" ];\n";
901  }
902  return id;
903 }
904 
905 template<class G>
906 void
907 BaseEmitter<G>::emitEdge(std::ostream &out, const typename G::ConstEdgeIterator &edge, const Organization &org,
908  const VMap &vmap) const {
909  ASSERT_require2(vmap.exists(edge->source()->id()), "edge source vertex has not yet been emitted");
910  ASSERT_require2(vmap.exists(edge->target()->id()), "edge target vertex has not yet been emitted");
911 
912  size_t sourceId = edge->source()->id();
913  std::string sourceName = vertexOrganization(sourceId).name();
914  if (sourceName.empty())
915  sourceName = StringUtility::numberToString(vmap[sourceId]);
916 
917  size_t targetId = edge->target()->id();
918  std::string targetName = vertexOrganization(targetId).name();
919  if (targetName.empty())
920  targetName = StringUtility::numberToString(vmap[targetId]);
921 
922  out <<sourceName <<" -> " <<targetName <<" [ label=" <<org.label() <<" " <<toString(org.attributes()) <<" ];\n";
923 }
924 
925 template<class G>
926 void
927 BaseEmitter<G>::emit(std::ostream &out) const {
928  VMap vmap; // GraphViz node ID for each graph vertex (modified by emit)
929 
930  out <<"digraph CFG {\n";
931  out <<" graph [ " <<toString(defaultGraphAttributes_) <<" ];\n";
932  out <<" node [ " <<toString(defaultNodeAttributes_) <<" ];\n";
933  out <<" edge [ " <<toString(defaultEdgeAttributes_) <<" ];\n";
934 
935  typedef std::map<std::string /*subgraph name*/, std::string/*subgraph content*/> Subgraphs;
936  Subgraphs subgraphs;
937 
938  // Emit vertices to subgraphs
939  for (typename G::ConstVertexIterator vertex=graph_.vertices().begin(); vertex!=graph_.vertices().end(); ++vertex) {
940  const Organization &org = vertexOrganization(vertex);
941  if (org.isSelected() && !vmap.exists(vertex->id())) {
942  std::ostringstream ss;
943  size_t gvid = emitVertex(ss, vertex, org, vmap);
944  vmap.insert(vertex->id(), gvid);
945  subgraphs[org.subgraph()] += ss.str();
946  }
947  }
948 
949  // Emit edges to subgraphs
950  for (typename G::ConstEdgeIterator edge=graph_.edges().begin(); edge!=graph_.edges().end(); ++edge) {
951  const Organization &org = edgeOrganization(edge);
952  if (org.isSelected() &&
953  vertexOrganization(edge->source()).isSelected() && vertexOrganization(edge->target()).isSelected()) {
954  std::ostringstream ss;
955  emitEdge(ss, edge, org, vmap);
956  subgraphs[org.subgraph()] += ss.str();
957  }
958  }
959 
960  // Emit named subgraphs to output
961  for (const Subgraphs::value_type &node: subgraphs) {
962  const std::string &subgraphName = node.first;
963  const std::string &subgraphContent = node.second;
964  if (!subgraphName.empty()) {
965  out <<"\nsubgraph cluster_" <<subgraphName <<" {"
966  <<" label=" <<subgraphOrganization(subgraphName).label() <<" "
967  <<toString(subgraphOrganization(subgraphName).attributes()) <<"\n"
968  <<subgraphContent
969  <<"}\n";
970  }
971  }
972 
973  // Emit unnamed subgraph content without a surrounding subgraph construct (i.e., global graph)
974  Subgraphs::iterator unnamedSubgraph = subgraphs.find("");
975  if (unnamedSubgraph != subgraphs.end())
976  out <<unnamedSubgraph->second;
977 
978  // Emit pseudo edges
979  for (const PseudoEdge &edge: pseudoEdges_) {
980  if (vertexOrganization(edge.src).isSelected() && vertexOrganization(edge.dst).isSelected()) {
981  std::string sourceName = vertexOrganization(edge.src).name();
982  std::string targetName = vertexOrganization(edge.dst).name();
983  out <<(sourceName.empty() ? StringUtility::numberToString(vmap[edge.src->id()]) : sourceName)
984  <<" -> "
985  <<(targetName.empty() ? StringUtility::numberToString(vmap[edge.dst->id()]) : targetName)
986  <<" [ label=" <<escape(edge.label) <<" ];\n";
987  }
988  }
989 
990  out <<"}\n";
991 }
992 
993 template<class G>
994 void
996  for (const typename G::Vertex &src: graph_.vertices()) {
997  if (vertexOrganization(src).isSelected()) {
998  std::set<size_t> targets;
999  for (const typename G::Edge &edge: src.outEdges()) {
1000  if (edgeOrganization(edge).isSelected() && !targets.insert(edge.target()->id()).second)
1001  edgeOrganization(edge).select(false);
1002  }
1003  }
1004  }
1005 }
1006 
1007 } // namespace
1008 } // namespace
1009 } // namespace
1010 } // namespace
1011 
1012 #endif
1013 #endif
size_t nVertices() const
Total number of vertices.
Definition: Graph.h:1685
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:543
const Color::HSV & warningColor() const
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:549
const VertexOrganization & vertexOrganization() const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:259
const Organization & vertexOrganization(size_t vertexId) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:265
void showInstructionStackDeltas(bool b)
Property: show instruction stack deltas.
Definition: GraphViz.h:513
const Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:311
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:344
Coordinate center
Center of vertex in display plane units.
Definition: GraphViz.h:857
bool exists(const Key &key) const
Determine if a key exists.
Definition: Sawyer/Map.h:475
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:584
size_t nEdges() const
Total number of edges.
Definition: Graph.h:1695
SourceLocations & srcMapper()
Property: Address-to-source mapping.
Definition: GraphViz.h:591
Sawyer::Container::Map< std::string, Organization > SubgraphOrganization
Organizational information for subgraphs.
Definition: GraphViz.h:152
const Attributes & defaultNodeAttributes() const
Property: default graph node attributes.
Definition: GraphViz.h:224
void graph(const Graph &g)
Reset the graph.
Definition: GraphViz.h:193
Base class for generating GraphViz output.
Definition: GraphViz.h:141
const SubgraphOrganization & subgraphOrganization() const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:335
const Attributes & defaultGraphAttributes() const
Property: default graph attributes.
Definition: GraphViz.h:211
void selectAll(bool b=true)
Causes all vertices and edges to be selected.
Definition: GraphViz.h:353
Organization & edgeOrganization(size_t edgeId)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:307
void useFunctionSubgraphs(bool b)
Property: use function subgraphs.
Definition: GraphViz.h:481
void label(const std::string &s)
Label for object.
Definition: GraphViz.h:108
Bidirectional mapping between addresses and source locations.
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:94
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:891
const Attributes & defaultEdgeAttributes() const
Property: default graph edge attributes.
Definition: GraphViz.h:237
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:480
static FunctionPtr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v)
First function that owns a vertex.
Definition: GraphViz.h:701
ROSE_DLL_API std::string escape(const std::string &)
Escape some value for GraphViz.
const Attributes & attributes() const
Attributes for object.
Definition: GraphViz.h:116
Value & insertMaybeDefault(const Key &key)
Conditionally insert a new key with default value.
Definition: Sawyer/Map.h:693
PartitionerConstPtr partitioner()
Property: partitioner.
Definition: GraphViz.h:471
void emitEdge(std::ostream &, const typename G::ConstEdgeIterator &, const Organization &, const VMap &) const
Emit a single edge.
Definition: GraphViz.h:907
const Color::HSV & subgraphColor() const
Property: color to use for function subgraph background.
Definition: GraphViz.h:245
bool showInstructionAddresses() const
Property: show instruction addresses.
Definition: GraphViz.h:501
Creates GraphViz files from Partitioner data.
Definition: GraphViz.h:436
Colors in HSV space.
Definition: Color.h:177
Main namespace for the ROSE library.
bool isSelected() const
Determines whether an object is selected.
Definition: GraphViz.h:87
const Organization & edgeOrganization(const typename G::Edge &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:314
const EdgeOrganization & edgeOrganization() const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:297
void subgraph(const std::string &s)
Subgraph for object.
Definition: GraphViz.h:128
Map & clear()
Remove all nodes.
Definition: Sawyer/Map.h:714
Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:317
void showReturnEdges(bool b)
Property: show function return edges.
Definition: GraphViz.h:582
VertexType
Partitioner control flow vertex types.
Sawyer::Container::Graph< VertexPosition, EdgePosition > PositionGraph
A graph with positioned vertices and edges.
Definition: GraphViz.h:875
Organization & vertexOrganization(size_t vertexId)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:269
void funcEnterColor(const Color::HSV &bg)
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:536
Sawyer::Container::Map< std::string, std::string > Attributes
GraphViz attributes.
Definition: GraphViz.h:26
bool showReturnEdges() const
Property: show function return edges.
Definition: GraphViz.h:581
Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:279
const SourceLocations & srcMapper() const
Property: Address-to-source mapping.
Definition: GraphViz.h:590
const Organization & vertexOrganization(const typename G::Vertex &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:276
VertexOrganization & vertexOrganization()
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:262
std::vector< Organization > EdgeOrganization
Organizational information for edges.
Definition: GraphViz.h:149
virtual void emit(std::ostream &) const
Dump selected vertices, edges, and subgraphs.
Definition: GraphViz.h:927
bool showInstructionStackDeltas() const
Property: show instruction stack deltas.
Definition: GraphViz.h:512
void srcMapper(const SourceLocations &mapper)
Property: Address-to-source mapping.
Definition: GraphViz.h:592
bool showInNeighbors() const
Property: show incoming edges from neighbor vertices.
Definition: GraphViz.h:571
const std::string & label() const
Label for object.
Definition: GraphViz.h:104
Attributes & attributes()
Attributes for object.
Definition: GraphViz.h:117
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:221
void subgraphColor(const Color::HSV &bg)
Property: color to use for function subgraph background.
Definition: GraphViz.h:246
void deselectParallelEdges()
Deselect all but one parallel edge.
Definition: GraphViz.h:995
const Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:273
const Color::HSV & funcEnterColor() const
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:535
bool showOutNeighbors() const
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:559
bool strikeNoopSequences() const
Property: strike no-op sequences.
Definition: GraphViz.h:524
void clear()
Remove all vertices and edges.
Definition: Graph.h:2005
void select(bool b=true)
Select or deselect object.
Definition: GraphViz.h:79
void showOutNeighbors(bool b)
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:560
const Color::HSV & funcReturnColor() const
Property: color to use for background of function return nodes.
Definition: GraphViz.h:542
void selectAllEdges(bool b=true)
Causes all edges to be selected.
Definition: GraphViz.h:378
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:611
Attributes & defaultGraphAttributes()
Property: default graph attributes.
Definition: GraphViz.h:208
void name(const std::string &s)
Name for object.
Definition: GraphViz.h:95
Two dimensional display plane coordinate.
Definition: GraphViz.h:849
void warningColor(const Color::HSV &bg)
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:550
const Organization & edgeOrganization(size_t edgeId) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:303
SubgraphOrganization & subgraphOrganization()
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:338
std::vector< Organization > VertexOrganization
Organizational information for vertices.
Definition: GraphViz.h:146
void showInstructions(bool b)
Property: show basic block instructions.
Definition: GraphViz.h:492
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
Definition: Sawyer/Map.h:628
void showInNeighbors(bool b)
Property: show incoming edges from neighbor vertices.
Definition: GraphViz.h:572
void selectNone()
Deselects all vertices and edges.
Definition: GraphViz.h:359
Organization & vertexOrganization(const typename G::Vertex &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:282
const Organization & subgraphOrganization(const std::string &name) const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:341
void attributes(const Attributes &a)
Attributes for object.
Definition: GraphViz.h:118
void strikeNoopSequences(bool b)
Property: strike no-op sequences.
Definition: GraphViz.h:525
void selectAllVertices(bool b=true)
Causes all vertices to be selected.
Definition: GraphViz.h:369
std::string name
Name of vertex as known to GraphViz.
Definition: GraphViz.h:856
Attributes & defaultEdgeAttributes()
Property: default graph edge attributes.
Definition: GraphViz.h:234
Analysis that looks for no-op equivalents.
Definition: NoOperation.h:14
void showInstructionAddresses(bool b)
Property: show instruction addresses.
Definition: GraphViz.h:502
size_t size() const
Number of nodes, keys, or values in this container.
Definition: Sawyer/Map.h:420
const std::string & subgraph() const
Subgraph for object.
Definition: GraphViz.h:127
EdgeOrganization & edgeOrganization()
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:300
std::vector< Coordinate > spline
Control points for the edge B-spline.
Definition: GraphViz.h:871
Organization & edgeOrganization(const typename G::Edge &edge)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:320
bool showInstructions() const
Property: show basic block instructions.
Definition: GraphViz.h:491