ROSE  0.11.54.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 
6 #include <ostream>
7 #include <Rose/BinaryAnalysis/NoOperation.h>
8 #include <Rose/BinaryAnalysis/SourceLocations.h>
9 #include <boost/regex.hpp>
10 #include <Rose/Color.h>
11 #include <Rose/BinaryAnalysis/Partitioner2/ControlFlowGraph.h>
12 #include <Rose/BinaryAnalysis/Partitioner2/FunctionCallGraph.h>
13 
14 namespace Rose {
15 namespace BinaryAnalysis {
16 namespace Partitioner2 {
17 
19 namespace GraphViz {
20 
25 
27 ROSE_DLL_API std::string toString(const Attributes&);
28 
30 ROSE_DLL_API std::string quotedEscape(const std::string&);
31 
33 ROSE_DLL_API std::string htmlEscape(const std::string&);
34 
38 ROSE_DLL_API std::string escape(const std::string&);
39 
46 ROSE_DLL_API std::string concatenate(const std::string &oldStuff, const std::string &newStuff, const std::string &separator="");
47 
51 ROSE_DLL_API bool isId(const std::string &s);
52 
54 ROSE_DLL_API extern const size_t NO_ID;
55 
56 
62 class ROSE_DLL_API Organization {
63 private:
64  bool isSelected_;
65  std::string name_; // name used by GraphViz to identify this object
66  std::string label_; // label shown in rendered graph, includes delimiters, "" or <>
67  Attributes attributes_;
68  std::string subgraph_;
69 public:
74  Organization(): isSelected_(true) {}
75 
77  void select(bool b=true) { isSelected_ = b; }
78 
85  bool isSelected() const { return isSelected_; }
86 
92  const std::string &name() const { return name_; }
93  void name(const std::string &s) { name_ = s; }
102  const std::string& label() const {
103  static std::string empty = "\"\"";
104  return label_.empty() ? empty : label_;
105  }
106  void label(const std::string &s) { label_ = s; }
114  const Attributes& attributes() const { return attributes_; }
115  Attributes& attributes() { return attributes_; }
116  void attributes(const Attributes &a) { attributes_ = a; }
125  const std::string& subgraph() const { return subgraph_; }
126  void subgraph(const std::string &s) { subgraph_ = s; }
128 };
129 
131 // BaseEmitter
133 
138 template<class G>
139 class BaseEmitter {
140 public:
141  typedef G Graph;
142 
144  typedef std::vector<Organization> VertexOrganization;
145 
147  typedef std::vector<Organization> EdgeOrganization;
148 
151 
152 protected:
153  struct PseudoEdge {
154  typename G::ConstVertexIterator src, dst;
155  std::string label;
156  Attributes attributes;
157  PseudoEdge(const typename G::ConstVertexIterator &src, const typename G::ConstVertexIterator &dst,
158  const std::string &label)
159  : src(src), dst(dst), label(label) {}
160  };
161 
162  typedef Sawyer::Container::Map<size_t, size_t> VMap;// maps graph vertex ID to graphviz node ID
163 
164 protected:
165  Graph graph_; // graph being emitted
166  VertexOrganization vertexOrganization_; // which vertices are selected for output
167  EdgeOrganization edgeOrganization_; // which edges are selected for output
168  SubgraphOrganization subgraphOrganization_; // which subgraphs are selected for output
169  Attributes defaultGraphAttributes_; // default attributes for the graph as a whole
170  Attributes defaultNodeAttributes_; // default attributes for graph nodes (CFG vertices and other)
171  Attributes defaultEdgeAttributes_; // default attributes for graph edges
172  std::list<PseudoEdge> pseudoEdges_; // extra edges not present in the CFG but needed in the GraphViz
173  Color::HSV subgraphColor_; // background color for function subgraphs
174 
175 public:
180  BaseEmitter(): subgraphColor_(0, 0, 0.95) {}
181 
185  explicit BaseEmitter(const Graph &g)
186  : subgraphColor_(0, 0, 0.95) {
187  graph(g);
188  }
189 
191  void graph(const Graph &g) {
192  graph_ = g;
193  vertexOrganization_.clear();
194  vertexOrganization_.resize(g.nVertices());
195  edgeOrganization_.clear();
196  edgeOrganization_.resize(g.nEdges());
197  subgraphOrganization_.clear();
198  pseudoEdges_.clear();
199  }
200 
206  Attributes& defaultGraphAttributes() {
207  return defaultGraphAttributes_;
208  }
209  const Attributes& defaultGraphAttributes() const {
210  return defaultGraphAttributes_;
211  }
219  Attributes& defaultNodeAttributes() {
220  return defaultNodeAttributes_;
221  }
222  const Attributes& defaultNodeAttributes() const {
223  return defaultNodeAttributes_;
224  }
232  Attributes& defaultEdgeAttributes() {
233  return defaultEdgeAttributes_;
234  }
235  const Attributes& defaultEdgeAttributes() const {
236  return defaultEdgeAttributes_;
237  }
243  const Color::HSV& subgraphColor() const { return subgraphColor_; }
244  void subgraphColor(const Color::HSV &bg) { subgraphColor_ = bg; }
257  const VertexOrganization& vertexOrganization() const {
258  return vertexOrganization_;
259  }
260  VertexOrganization& vertexOrganization() {
261  return vertexOrganization_;
262  }
263  const Organization& vertexOrganization(size_t vertexId) const {
264  ASSERT_require(vertexId < vertexOrganization_.size());
265  return vertexOrganization_[vertexId];
266  }
267  Organization& vertexOrganization(size_t vertexId) {
268  ASSERT_require(vertexId < vertexOrganization_.size());
269  return vertexOrganization_[vertexId];
270  }
271  const Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) const {
272  return vertexOrganization(vertex->id());
273  }
274  const Organization& vertexOrganization(const typename G::Vertex &vertex) const {
275  return vertexOrganization(vertex.id());
276  }
277  Organization& vertexOrganization(const typename G::ConstVertexIterator &vertex) {
278  return vertexOrganization(vertex->id());
279  }
280  Organization& vertexOrganization(const typename G::Vertex &vertex) {
281  return vertexOrganization(vertex.id());
282  }
295  const EdgeOrganization& edgeOrganization() const {
296  return edgeOrganization_;
297  }
298  EdgeOrganization& edgeOrganization() {
299  return edgeOrganization_;
300  }
301  const Organization& edgeOrganization(size_t edgeId) const {
302  ASSERT_require(edgeId < edgeOrganization_.size());
303  return edgeOrganization_[edgeId];
304  }
305  Organization& edgeOrganization(size_t edgeId) {
306  ASSERT_require(edgeId < edgeOrganization_.size());
307  return edgeOrganization_[edgeId];
308  }
309  const Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) const {
310  return edgeOrganization(edge->id());
311  }
312  const Organization& edgeOrganization(const typename G::Edge &edge) const {
313  return edgeOrganization(edge.id());
314  }
315  Organization& edgeOrganization(const typename G::ConstEdgeIterator &edge) {
316  return edgeOrganization(edge->id());
317  }
318  Organization& edgeOrganization(const typename G::Edge &edge) {
319  return edgeOrganization(edge.id());
320  }
333  const SubgraphOrganization& subgraphOrganization() const {
334  return subgraphOrganization_;
335  }
336  SubgraphOrganization& subgraphOrganization() {
337  return subgraphOrganization_;
338  }
339  const Organization& subgraphOrganization(const std::string &name) const {
340  return subgraphOrganization_.getOrDefault(name);
341  }
342  Organization& subgraphOrganization(const std::string &name) {
343  return subgraphOrganization_.insertMaybeDefault(name);
344  }
351  void selectAll(bool b=true) {
353  selectAllEdges(b);
354  }
355 
357  void selectNone() {
358  pseudoEdges_.clear();
359  selectAllEdges(false);
360  selectAllVertices(false);
361  }
362 
367  void selectAllVertices(bool b=true) {
368  BOOST_FOREACH (Organization &org, vertexOrganization_)
369  org.select(b);
370  }
371 
376  void selectAllEdges(bool b=true) {
377  BOOST_FOREACH (Organization &org, edgeOrganization_)
378  org.select(b);
379  }
380 
384  void deselectParallelEdges();
385 
390  virtual void emit(std::ostream&) const;
391 
392 protected:
396  size_t emitVertex(std::ostream&, const typename G::ConstVertexIterator&, const Organization&, const VMap&) const;
397 
399  void emitEdge(std::ostream&, const typename G::ConstEdgeIterator&, const Organization&, const VMap&) const;
400 
401 };
402 
403 
405 // Base generator for Partitioner2::ControlFlowGraph
407 
434 class ROSE_DLL_API CfgEmitter: public BaseEmitter<ControlFlowGraph> {
435  const Partitioner &partitioner_;
436  bool useFunctionSubgraphs_; // should called functions be shown as subgraphs?
437  bool showReturnEdges_; // show E_FUNCTION_RETURN edges?
438  bool showInstructions_; // show instructions or only block address?
439  bool showInstructionAddresses_; // if instructions are shown, show addresses too?
440  bool showInstructionStackDeltas_; // show stack deltas for instructions
441  bool showInNeighbors_; // show neighbors for incoming edges to selected vertices?
442  bool showOutNeighbors_; // show neighbors for outgoing edges to selected vertices?
443  bool strikeNoopSequences_; // render no-op sequences in a different style
444  Color::HSV funcEnterColor_; // background color for function entrance blocks
445  Color::HSV funcReturnColor_; // background color for function return blocks
446  Color::HSV warningColor_; // background color for special nodes and warnings
447  SourceLocations srcMapper_; // maps addresses to source code (optional)
448  static unsigned long versionDate_; // date code from "dot -V", like 20100126
449  NoOperation noOpAnalysis_;
450 
451 public:
459  explicit CfgEmitter(const Partitioner&);
460  CfgEmitter(const Partitioner&, const ControlFlowGraph&);
463  // Properties
465 
469  const Partitioner& partitioner() { return partitioner_; }
470 
478  bool useFunctionSubgraphs() const { return useFunctionSubgraphs_; }
479  void useFunctionSubgraphs(bool b) { useFunctionSubgraphs_ = b; }
489  bool showInstructions() const { return showInstructions_; }
490  void showInstructions(bool b) { showInstructions_ = b; }
499  bool showInstructionAddresses() const { return showInstructionAddresses_; }
500  void showInstructionAddresses(bool b) { showInstructionAddresses_ = b; }
510  bool showInstructionStackDeltas() const { return showInstructionStackDeltas_; }
511  void showInstructionStackDeltas(bool b) { showInstructionStackDeltas_ = b; }
522  bool strikeNoopSequences() const { return strikeNoopSequences_; }
523  void strikeNoopSequences(bool b) { strikeNoopSequences_ = b; }
533  const Color::HSV& funcEnterColor() const { return funcEnterColor_; }
534  void funcEnterColor(const Color::HSV &bg) { funcEnterColor_ = bg; }
540  const Color::HSV& funcReturnColor() const { return funcReturnColor_; }
541  void funcReturnColor(const Color::HSV &bg) { funcReturnColor_ = bg; }
547  const Color::HSV& warningColor() const { return warningColor_; }
548  void warningColor(const Color::HSV &bg) { warningColor_ = bg; }
557  bool showOutNeighbors() const { return showOutNeighbors_; }
558  void showOutNeighbors(bool b) { showOutNeighbors_ = b; }
569  bool showInNeighbors() const { return showInNeighbors_; }
570  void showInNeighbors(bool b) { showInNeighbors_ = b; }
579  bool showReturnEdges() const { return showReturnEdges_; }
580  void showReturnEdges(bool b) { showReturnEdges_ = b; }
588  const SourceLocations& srcMapper() const { return srcMapper_; }
589  SourceLocations& srcMapper() { return srcMapper_; }
590  void srcMapper(const SourceLocations &mapper) { srcMapper_ = mapper; }
594  // Organization
596 
598  // Low-level vertex and edge selection
599 
605  void selectInterval(const AddressInterval&);
606 
608  void selectIntraFunction(const Function::Ptr&);
609 
613  void selectFunctionCallees(const Function::Ptr&);
614 
619  void selectFunctionCallers(const Function::Ptr&);
620 
624  void deselectReturnEdges();
625 
627  void deselectUnusedVertex(ControlFlowGraph::ConstVertexIterator);
628 
630  void deselectUnusedVertexType(VertexType);
631 
635  void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true);
636 
638  // High-level selectors
639 
645  CfgEmitter& selectWholeGraph();
646 
652  CfgEmitter& selectFunctionGraph(const Function::Ptr&);
653 
659  CfgEmitter& selectIntervalGraph(const AddressInterval &interval);
660 
662  // GraphViz emitters
663 
667  void emitWholeGraph(std::ostream &out) {
668  selectWholeGraph().emit(out);
669  }
670 
674  void emitFunctionGraph(std::ostream &out, const Function::Ptr &function) {
675  selectFunctionGraph(function).emit(out);
676  }
677 
681  void emitIntervalGraph(std::ostream &out, const AddressInterval &interval) {
682  selectIntervalGraph(interval).emit(out);
683  }
684 
685 
687  // Low-level emitters
688 
690  // Utilities
691 
695  static bool isInterFunctionEdge(const ControlFlowGraph::Edge&);
696  static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator &e) { return isInterFunctionEdge(*e); }
705  static Function::Ptr firstOwningFunction(const ControlFlowGraph::Vertex&);
706  static Function::Ptr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v) {
707  return firstOwningFunction(*v);
708  }
717  static FunctionSet owningFunctions(const ControlFlowGraph::Vertex&);
718  static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator &v) { return owningFunctions(*v); }
725  void assignFunctionSubgraphs();
726 
727 
729  // Formatting: these are expected to be overridden by subclasses
730 
735  virtual std::string sourceLocation(const ControlFlowGraph::ConstVertexIterator&) const;
736 
743  virtual std::string vertexLabel(const ControlFlowGraph::ConstVertexIterator&) const;
744  std::string vertexLabel(const ControlFlowGraph::Vertex&) const;
754  virtual std::string vertexLabelDetailed(const ControlFlowGraph::ConstVertexIterator&) const;
755  std::string vertexLabelDetailed(const ControlFlowGraph::Vertex&) const;
761  virtual Attributes vertexAttributes(const ControlFlowGraph::ConstVertexIterator&) const;
762  Attributes vertexAttributes(const ControlFlowGraph::Vertex&) const;
770  virtual std::string edgeLabel(const ControlFlowGraph::ConstEdgeIterator&) const;
771  std::string edgeLabel(const ControlFlowGraph::Edge&) const;
777  virtual Attributes edgeAttributes(const ControlFlowGraph::ConstEdgeIterator&) const;
778  Attributes edgeAttributes(const ControlFlowGraph::Edge&) const;
784  virtual std::string functionLabel(const Function::Ptr&) const;
785 
787  virtual Attributes functionAttributes(const Function::Ptr&) const;
788 
789 private:
790  void init();
791 
792  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
793  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
794  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
795  void nameVertices();
796 };
797 
798 
800 // Base emitter for Partitioner2::FunctionCallGraph
802 
804 class ROSE_DLL_API CgEmitter: public BaseEmitter<FunctionCallGraph::Graph> {
805  FunctionCallGraph cg_;
806  Color::HSV functionHighlightColor_; // highlight certain functions
807  boost::regex highlightNameMatcher_; // which functions to highlight
808 public:
809  explicit CgEmitter(const Partitioner &partitioner);
810  CgEmitter(const Partitioner &partitioner, const FunctionCallGraph &cg);
811  virtual std::string functionLabel(const Function::Ptr&) const;
812  virtual Attributes functionAttributes(const Function::Ptr&) const;
813  virtual void emitCallGraph(std::ostream &out) const;
814  virtual const FunctionCallGraph& callGraph() const { return cg_; }
815  virtual void callGraph(const FunctionCallGraph &cg);
816  virtual void highlight(const boost::regex&);
817 private:
818  // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
819  // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
820  // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
821  void nameVertices();
822 };
823 
824 
826 // Callgraph emitter with inlined imports
828 
834 class ROSE_DLL_API CgInlinedEmitter: public CgEmitter {
835  boost::regex nameMatcher_;
836  typedef std::vector<Function::Ptr> InlinedFunctions;
838  Inlines inlines_;
839 public:
840  CgInlinedEmitter(const Partitioner &partitioner, const boost::regex &nameMatcher);
841  CgInlinedEmitter(const Partitioner &partitioner, const FunctionCallGraph &cg, const boost::regex &nameMatcher);
842  virtual const FunctionCallGraph& callGraph() const ROSE_OVERRIDE { return CgEmitter::callGraph(); }
843  virtual void callGraph(const FunctionCallGraph&) ROSE_OVERRIDE;
844  virtual std::string functionLabel(const Function::Ptr&) const ROSE_OVERRIDE;
845  virtual bool shouldInline(const Function::Ptr&) const;
846 };
847 
848 
850 // Reading layout position information from "dot"
852 
854 struct Coordinate {
855  double x;
856  double y;
857 };
858 
861  std::string name;
863  double width;
864  double height;
865 };
866 
875 struct EdgePosition {
876  std::vector<Coordinate> spline;
877 };
878 
881 
885 PositionGraph readPositions(std::istream&);
886 
887 
888 
889 
891 // Class template method implementations
893 
894 template<class G>
895 size_t
896 BaseEmitter<G>::emitVertex(std::ostream &out, const typename G::ConstVertexIterator &vertex,
897  const Organization &org, const VMap &vmap) const {
898  size_t id = NO_ID;
899  if (org.isSelected() && !vmap.getOptional(vertex->id()).assignTo(id)) {
900  id = vmap.size();
901  std::string name = org.name();
902  if (name.empty())
904  out <<name <<" [ label=" <<org.label() <<" ";
905  out <<toString(org.attributes()) <<" ];\n";
906  }
907  return id;
908 }
909 
910 template<class G>
911 void
912 BaseEmitter<G>::emitEdge(std::ostream &out, const typename G::ConstEdgeIterator &edge, const Organization &org,
913  const VMap &vmap) const {
914  ASSERT_require2(vmap.exists(edge->source()->id()), "edge source vertex has not yet been emitted");
915  ASSERT_require2(vmap.exists(edge->target()->id()), "edge target vertex has not yet been emitted");
916 
917  size_t sourceId = edge->source()->id();
918  std::string sourceName = vertexOrganization(sourceId).name();
919  if (sourceName.empty())
920  sourceName = StringUtility::numberToString(vmap[sourceId]);
921 
922  size_t targetId = edge->target()->id();
923  std::string targetName = vertexOrganization(targetId).name();
924  if (targetName.empty())
925  targetName = StringUtility::numberToString(vmap[targetId]);
926 
927  out <<sourceName <<" -> " <<targetName <<" [ label=" <<org.label() <<" " <<toString(org.attributes()) <<" ];\n";
928 }
929 
930 template<class G>
931 void
932 BaseEmitter<G>::emit(std::ostream &out) const {
933  VMap vmap; // GraphViz node ID for each graph vertex (modified by emit)
934 
935  out <<"digraph CFG {\n";
936  out <<" graph [ " <<toString(defaultGraphAttributes_) <<" ];\n";
937  out <<" node [ " <<toString(defaultNodeAttributes_) <<" ];\n";
938  out <<" edge [ " <<toString(defaultEdgeAttributes_) <<" ];\n";
939 
940  typedef std::map<std::string /*subgraph name*/, std::string/*subgraph content*/> Subgraphs;
941  Subgraphs subgraphs;
942 
943  // Emit vertices to subgraphs
944  for (typename G::ConstVertexIterator vertex=graph_.vertices().begin(); vertex!=graph_.vertices().end(); ++vertex) {
945  const Organization &org = vertexOrganization(vertex);
946  if (org.isSelected() && !vmap.exists(vertex->id())) {
947  std::ostringstream ss;
948  size_t gvid = emitVertex(ss, vertex, org, vmap);
949  vmap.insert(vertex->id(), gvid);
950  subgraphs[org.subgraph()] += ss.str();
951  }
952  }
953 
954  // Emit edges to subgraphs
955  for (typename G::ConstEdgeIterator edge=graph_.edges().begin(); edge!=graph_.edges().end(); ++edge) {
956  const Organization &org = edgeOrganization(edge);
957  if (org.isSelected() &&
958  vertexOrganization(edge->source()).isSelected() && vertexOrganization(edge->target()).isSelected()) {
959  std::ostringstream ss;
960  emitEdge(ss, edge, org, vmap);
961  subgraphs[org.subgraph()] += ss.str();
962  }
963  }
964 
965  // Emit named subgraphs to output
966  BOOST_FOREACH (const Subgraphs::value_type &node, subgraphs) {
967  const std::string &subgraphName = node.first;
968  const std::string &subgraphContent = node.second;
969  if (!subgraphName.empty()) {
970  out <<"\nsubgraph cluster_" <<subgraphName <<" {"
971  <<" label=" <<subgraphOrganization(subgraphName).label() <<" "
972  <<toString(subgraphOrganization(subgraphName).attributes()) <<"\n"
973  <<subgraphContent
974  <<"}\n";
975  }
976  }
977 
978  // Emit unnamed subgraph content without a surrounding subgraph construct (i.e., global graph)
979  Subgraphs::iterator unnamedSubgraph = subgraphs.find("");
980  if (unnamedSubgraph != subgraphs.end())
981  out <<unnamedSubgraph->second;
982 
983  // Emit pseudo edges
984  BOOST_FOREACH (const PseudoEdge &edge, pseudoEdges_) {
985  if (vertexOrganization(edge.src).isSelected() && vertexOrganization(edge.dst).isSelected()) {
986  std::string sourceName = vertexOrganization(edge.src).name();
987  std::string targetName = vertexOrganization(edge.dst).name();
988  out <<(sourceName.empty() ? StringUtility::numberToString(vmap[edge.src->id()]) : sourceName)
989  <<" -> "
990  <<(targetName.empty() ? StringUtility::numberToString(vmap[edge.dst->id()]) : targetName)
991  <<" [ label=" <<escape(edge.label) <<" ];\n";
992  }
993  }
994 
995  out <<"}\n";
996 }
997 
998 template<class G>
999 void
1001  BOOST_FOREACH (const typename G::Vertex &src, graph_.vertices()) {
1002  if (vertexOrganization(src).isSelected()) {
1003  std::set<size_t> targets;
1004  BOOST_FOREACH (const typename G::Edge &edge, src.outEdges()) {
1005  if (edgeOrganization(edge).isSelected() && !targets.insert(edge.target()->id()).second)
1006  edgeOrganization(edge).select(false);
1007  }
1008  }
1009  }
1010 }
1011 
1012 } // namespace
1013 } // namespace
1014 } // namespace
1015 } // namespace
1016 
1017 #endif
1018 #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:541
const Color::HSV & warningColor() const
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:547
const VertexOrganization & vertexOrganization() const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:257
const Organization & vertexOrganization(size_t vertexId) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:263
void showInstructionStackDeltas(bool b)
Property: show instruction stack deltas.
Definition: GraphViz.h:511
const Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:309
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:342
Coordinate center
Center of vertex in display plane units.
Definition: GraphViz.h:862
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
SourceLocations & srcMapper()
Property: Address-to-source mapping.
Definition: GraphViz.h:589
Sawyer::Container::Map< std::string, Organization > SubgraphOrganization
Organizational information for subgraphs.
Definition: GraphViz.h:150
const Attributes & defaultNodeAttributes() const
Property: default graph node attributes.
Definition: GraphViz.h:222
void graph(const Graph &g)
Reset the graph.
Definition: GraphViz.h:191
Base class for generating GraphViz output.
Definition: GraphViz.h:139
const SubgraphOrganization & subgraphOrganization() const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:333
const Attributes & defaultGraphAttributes() const
Property: default graph attributes.
Definition: GraphViz.h:209
void selectAll(bool b=true)
Causes all vertices and edges to be selected.
Definition: GraphViz.h:351
Organization & edgeOrganization(size_t edgeId)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:305
void useFunctionSubgraphs(bool b)
Property: use function subgraphs.
Definition: GraphViz.h:479
void label(const std::string &s)
Label for object.
Definition: GraphViz.h:106
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:92
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:896
const Attributes & defaultEdgeAttributes() const
Property: default graph edge attributes.
Definition: GraphViz.h:235
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:478
void emitWholeGraph(std::ostream &out)
Dump entire control flow graph.
Definition: GraphViz.h:667
ROSE_DLL_API std::string escape(const std::string &)
Escape some value for GraphViz.
const Attributes & attributes() const
Attributes for object.
Definition: GraphViz.h:114
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:912
const Color::HSV & subgraphColor() const
Property: color to use for function subgraph background.
Definition: GraphViz.h:243
bool showInstructionAddresses() const
Property: show instruction addresses.
Definition: GraphViz.h:499
Creates GraphViz files from Partitioner data.
Definition: GraphViz.h:434
Colors in HSV space.
Definition: Rose/Color.h:177
Main namespace for the ROSE library.
bool isSelected() const
Determines whether an object is selected.
Definition: GraphViz.h:85
const Organization & edgeOrganization(const typename G::Edge &edge) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:312
const EdgeOrganization & edgeOrganization() const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:295
void subgraph(const std::string &s)
Subgraph for object.
Definition: GraphViz.h:126
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:315
void showReturnEdges(bool b)
Property: show function return edges.
Definition: GraphViz.h:580
VertexType
Partitioner control flow vertex types.
Sawyer::Container::Graph< VertexPosition, EdgePosition > PositionGraph
A graph with positioned vertices and edges.
Definition: GraphViz.h:880
Organization & vertexOrganization(size_t vertexId)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:267
void funcEnterColor(const Color::HSV &bg)
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:534
Sawyer::Container::Map< std::string, std::string > Attributes
GraphViz attributes.
Definition: GraphViz.h:24
bool showReturnEdges() const
Property: show function return edges.
Definition: GraphViz.h:579
Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:277
const SourceLocations & srcMapper() const
Property: Address-to-source mapping.
Definition: GraphViz.h:588
const Organization & vertexOrganization(const typename G::Vertex &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:274
VertexOrganization & vertexOrganization()
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:260
std::vector< Organization > EdgeOrganization
Organizational information for edges.
Definition: GraphViz.h:147
virtual void emit(std::ostream &) const
Dump selected vertices, edges, and subgraphs.
Definition: GraphViz.h:932
bool showInstructionStackDeltas() const
Property: show instruction stack deltas.
Definition: GraphViz.h:510
void srcMapper(const SourceLocations &mapper)
Property: Address-to-source mapping.
Definition: GraphViz.h:590
bool showInNeighbors() const
Property: show incoming edges from neighbor vertices.
Definition: GraphViz.h:569
const std::string & label() const
Label for object.
Definition: GraphViz.h:102
Attributes & attributes()
Attributes for object.
Definition: GraphViz.h:115
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:219
void subgraphColor(const Color::HSV &bg)
Property: color to use for function subgraph background.
Definition: GraphViz.h:244
void deselectParallelEdges()
Deselect all but one parallel edge.
Definition: GraphViz.h:1000
const Partitioner & partitioner()
Property: partitioner.
Definition: GraphViz.h:469
const Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex) const
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:271
const Color::HSV & funcEnterColor() const
Property: color to use for background of function entrance nodes.
Definition: GraphViz.h:533
bool showOutNeighbors() const
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:557
bool strikeNoopSequences() const
Property: strike no-op sequences.
Definition: GraphViz.h:522
void emitIntervalGraph(std::ostream &out, const AddressInterval &interval)
Dump control flow graph for some address interval.
Definition: GraphViz.h:681
void clear()
Remove all vertices and edges.
Definition: Graph.h:1978
void select(bool b=true)
Select or deselect object.
Definition: GraphViz.h:77
void showOutNeighbors(bool b)
Property: show outgoing edges to neighbor vertices.
Definition: GraphViz.h:558
const Color::HSV & funcReturnColor() const
Property: color to use for background of function return nodes.
Definition: GraphViz.h:540
void selectAllEdges(bool b=true)
Causes all edges to be selected.
Definition: GraphViz.h:376
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:206
void name(const std::string &s)
Name for object.
Definition: GraphViz.h:93
Two dimensional display plane coordinate.
Definition: GraphViz.h:854
void warningColor(const Color::HSV &bg)
Property: color to use for background of special nodes and for warnings.
Definition: GraphViz.h:548
const Organization & edgeOrganization(size_t edgeId) const
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:301
SubgraphOrganization & subgraphOrganization()
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:336
std::vector< Organization > VertexOrganization
Organizational information for vertices.
Definition: GraphViz.h:144
void showInstructions(bool b)
Property: show basic block instructions.
Definition: GraphViz.h:490
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:570
void selectNone()
Deselects all vertices and edges.
Definition: GraphViz.h:357
Organization & vertexOrganization(const typename G::Vertex &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition: GraphViz.h:280
const Organization & subgraphOrganization(const std::string &name) const
Property: Controls which subgraphs appear in the output, and how.
Definition: GraphViz.h:339
void attributes(const Attributes &a)
Attributes for object.
Definition: GraphViz.h:116
void strikeNoopSequences(bool b)
Property: strike no-op sequences.
Definition: GraphViz.h:523
static Function::Ptr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v)
First function that owns a vertex.
Definition: GraphViz.h:706
static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator &e)
Returns true if the edge spans two different functions.
Definition: GraphViz.h:696
void selectAllVertices(bool b=true)
Causes all vertices to be selected.
Definition: GraphViz.h:367
std::string name
Name of vertex as known to GraphViz.
Definition: GraphViz.h:861
Partitions instructions into basic blocks and functions.
Definition: Partitioner.h:290
Attributes & defaultEdgeAttributes()
Property: default graph edge attributes.
Definition: GraphViz.h:232
Analysis that looks for no-op equivalents.
Definition: NoOperation.h:15
void showInstructionAddresses(bool b)
Property: show instruction addresses.
Definition: GraphViz.h:500
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:125
EdgeOrganization & edgeOrganization()
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:298
std::vector< Coordinate > spline
Control points for the edge B-spline.
Definition: GraphViz.h:876
Organization & edgeOrganization(const typename G::Edge &edge)
Property: Controls which edges are to appear in the output, and how.
Definition: GraphViz.h:318
static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator &v)
Functions that own a vertex.
Definition: GraphViz.h:718
void emitFunctionGraph(std::ostream &out, const Function::Ptr &function)
Dump control flow graph for one function.
Definition: GraphViz.h:674
bool showInstructions() const
Property: show basic block instructions.
Definition: GraphViz.h:489