ROSE 0.11.145.147
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
16namespace Rose {
17namespace BinaryAnalysis {
18namespace Partitioner2 {
19
21namespace GraphViz {
22
27
29ROSE_DLL_API std::string toString(const Attributes&);
30
32ROSE_DLL_API std::string quotedEscape(const std::string&);
33
35ROSE_DLL_API std::string htmlEscape(const std::string&);
36
40ROSE_DLL_API std::string escape(const std::string&);
41
48ROSE_DLL_API std::string concatenate(const std::string &oldStuff, const std::string &newStuff, const std::string &separator="");
49
53ROSE_DLL_API bool isId(const std::string &s);
54
56ROSE_DLL_API extern const size_t NO_ID;
57
58
64class ROSE_DLL_API Organization {
65private:
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_;
71public:
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
140template<class G>
142public:
143 typedef G Graph;
144
146 typedef std::vector<Organization> VertexOrganization;
147
149 typedef std::vector<Organization> EdgeOrganization;
150
153
154protected:
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
166protected:
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
177public:
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
209 return defaultGraphAttributes_;
210 }
212 return defaultGraphAttributes_;
213 }
222 return defaultNodeAttributes_;
223 }
225 return defaultNodeAttributes_;
226 }
235 return defaultEdgeAttributes_;
236 }
238 return defaultEdgeAttributes_;
239 }
245 const Color::HSV& subgraphColor() const { return subgraphColor_; }
246 void subgraphColor(const Color::HSV &bg) { subgraphColor_ = bg; }
260 return vertexOrganization_;
261 }
263 return vertexOrganization_;
264 }
265 const Organization& vertexOrganization(size_t vertexId) const {
266 ASSERT_require(vertexId < vertexOrganization_.size());
267 return vertexOrganization_[vertexId];
268 }
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 }
298 return edgeOrganization_;
299 }
301 return edgeOrganization_;
302 }
303 const Organization& edgeOrganization(size_t edgeId) const {
304 ASSERT_require(edgeId < edgeOrganization_.size());
305 return edgeOrganization_[edgeId];
306 }
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 }
336 return subgraphOrganization_;
337 }
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) {
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
387
392 virtual void emit(std::ostream&) const;
393
394protected:
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
436class 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
453public:
466 // 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; }
597 // Organization
598
600 // Low-level vertex and edge selection
601
608
611
616
622
627
629 void deselectUnusedVertex(ControlFlowGraph::ConstVertexIterator);
630
633
637 void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true);
638
640 // High-level selectors
641
648
655
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&);
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
783
784private:
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
799class ROSE_DLL_API CgEmitter: public BaseEmitter<FunctionCallGraph::Graph> {
801 Color::HSV functionHighlightColor_; // highlight certain functions
802 boost::regex highlightNameMatcher_; // which functions to highlight
803public:
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&);
812private:
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
829class ROSE_DLL_API CgInlinedEmitter: public CgEmitter {
830 boost::regex nameMatcher_;
831 typedef std::vector<FunctionPtr> InlinedFunctions;
833 Inlines inlines_;
834public:
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
850 double x;
851 double y;
852};
853
856 std::string name;
858 double width;
859 double height;
860};
861
871 std::vector<Coordinate> spline;
872};
873
876
881
882
883
884
886// Class template method implementations
888
889template<class G>
890size_t
891BaseEmitter<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
905template<class G>
906void
907BaseEmitter<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
925template<class G>
926void
927BaseEmitter<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
993template<class G>
994void
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
Analysis that looks for no-op equivalents.
Definition NoOperation.h:14
Base class for generating GraphViz output.
Definition GraphViz.h:141
const Organization & vertexOrganization(size_t vertexId) const
Property: Controls which vertices are to appear in the output, and how.
Definition GraphViz.h:265
Organization & vertexOrganization(size_t vertexId)
Property: Controls which vertices are to appear in the output, and how.
Definition GraphViz.h:269
const Organization & subgraphOrganization(const std::string &name) const
Property: Controls which subgraphs appear in the output, and how.
Definition GraphViz.h:341
const EdgeOrganization & edgeOrganization() const
Property: Controls which edges are to appear in the output, and how.
Definition GraphViz.h:297
Attributes & defaultNodeAttributes()
Property: default graph node attributes.
Definition GraphViz.h:221
Attributes & defaultGraphAttributes()
Property: default graph attributes.
Definition GraphViz.h:208
EdgeOrganization & edgeOrganization()
Property: Controls which edges are to appear in the output, and how.
Definition GraphViz.h:300
const SubgraphOrganization & subgraphOrganization() const
Property: Controls which subgraphs appear in the output, and how.
Definition GraphViz.h:335
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
void subgraphColor(const Color::HSV &bg)
Property: color to use for function subgraph background.
Definition GraphViz.h:246
SubgraphOrganization & subgraphOrganization()
Property: Controls which subgraphs appear in the output, and how.
Definition GraphViz.h:338
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
void selectAllEdges(bool b=true)
Causes all edges to be selected.
Definition GraphViz.h:378
const Organization & edgeOrganization(size_t edgeId) const
Property: Controls which edges are to appear in the output, and how.
Definition GraphViz.h:303
void selectAllVertices(bool b=true)
Causes all vertices to be selected.
Definition GraphViz.h:369
Attributes & defaultEdgeAttributes()
Property: default graph edge attributes.
Definition GraphViz.h:234
Organization & edgeOrganization(size_t edgeId)
Property: Controls which edges are to appear in the output, and how.
Definition GraphViz.h:307
const Color::HSV & subgraphColor() const
Property: color to use for function subgraph background.
Definition GraphViz.h:245
const Attributes & defaultNodeAttributes() const
Property: default graph node attributes.
Definition GraphViz.h:224
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
void graph(const Graph &g)
Reset the graph.
Definition GraphViz.h:193
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
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
std::vector< Organization > VertexOrganization
Organizational information for vertices.
Definition GraphViz.h:146
const Attributes & defaultEdgeAttributes() const
Property: default graph edge attributes.
Definition GraphViz.h:237
Organization & subgraphOrganization(const std::string &name)
Property: Controls which subgraphs appear in the output, and how.
Definition GraphViz.h:344
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
Organization & vertexOrganization(const typename G::Vertex &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition GraphViz.h:282
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
virtual void emit(std::ostream &) const
Dump selected vertices, edges, and subgraphs.
Definition GraphViz.h:927
Organization & vertexOrganization(const typename G::ConstVertexIterator &vertex)
Property: Controls which vertices are to appear in the output, and how.
Definition GraphViz.h:279
void emitEdge(std::ostream &, const typename G::ConstEdgeIterator &, const Organization &, const VMap &) const
Emit a single edge.
Definition GraphViz.h:907
Organization & edgeOrganization(const typename G::ConstEdgeIterator &edge)
Property: Controls which edges are to appear in the output, and how.
Definition GraphViz.h:317
Organization & edgeOrganization(const typename G::Edge &edge)
Property: Controls which edges are to appear in the output, and how.
Definition GraphViz.h:320
void selectNone()
Deselects all vertices and edges.
Definition GraphViz.h:359
const VertexOrganization & vertexOrganization() const
Property: Controls which vertices are to appear in the output, and how.
Definition GraphViz.h:259
Sawyer::Container::Map< std::string, Organization > SubgraphOrganization
Organizational information for subgraphs.
Definition GraphViz.h:152
Creates GraphViz files from Partitioner data.
Definition GraphViz.h:436
static FunctionPtr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v)
First function that owns a vertex.
Definition GraphViz.h:701
virtual Attributes functionAttributes(const FunctionPtr &) const
Attributes for function vertex.
Attributes vertexAttributes(const ControlFlowGraph::Vertex &) const
Attributes for a CFG vertex.
const Color::HSV & warningColor() const
Property: color to use for background of special nodes and for warnings.
Definition GraphViz.h:549
bool showInstructionAddresses() const
Property: show instruction addresses.
Definition GraphViz.h:501
void warningColor(const Color::HSV &bg)
Property: color to use for background of special nodes and for warnings.
Definition GraphViz.h:550
void showInstructions(bool b)
Property: show basic block instructions.
Definition GraphViz.h:492
void useFunctionSubgraphs(bool b)
Property: use function subgraphs.
Definition GraphViz.h:481
virtual std::string functionLabel(const FunctionPtr &) const
Label for function vertex.
const Color::HSV & funcReturnColor() const
Property: color to use for background of function return nodes.
Definition GraphViz.h:542
std::string edgeLabel(const ControlFlowGraph::Edge &) const
Label for CFG edge.
static FunctionSet owningFunctions(const ControlFlowGraph::Vertex &)
Functions that own a vertex.
void srcMapper(const SourceLocations &mapper)
Property: Address-to-source mapping.
Definition GraphViz.h:592
void selectFunctionCallees(const FunctionPtr &)
Select outgoing edges to neighboring vertices.
static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator &)
Functions that own a vertex.
CfgEmitter & selectWholeGraph()
Selects graph elements for whole-graph output.
static bool isInterFunctionEdge(const ControlFlowGraph::Edge &)
Returns true if the edge spans two different functions.
CfgEmitter & selectFunctionGraph(const FunctionPtr &)
Selects the CFG for one function.
CfgEmitter(const PartitionerConstPtr &)
Constructor.
virtual std::string vertexLabel(const ControlFlowGraph::ConstVertexIterator &) const
Label for CFG vertex.
virtual std::string edgeLabel(const ControlFlowGraph::ConstEdgeIterator &) const
Label for CFG edge.
void selectFunctionCallers(const FunctionPtr &)
Select incoming edges from neighboring vertices.
void deselectReturnEdges()
Deselect all function return edges.
std::string vertexLabel(const ControlFlowGraph::Vertex &) const
Label for CFG vertex.
void emitFunctionGraph(std::ostream &, const FunctionPtr &)
Dump control flow graph for one function.
bool showOutNeighbors() const
Property: show outgoing edges to neighbor vertices.
Definition GraphViz.h:559
void funcEnterColor(const Color::HSV &bg)
Property: color to use for background of function entrance nodes.
Definition GraphViz.h:536
virtual Attributes vertexAttributes(const ControlFlowGraph::ConstVertexIterator &) const
Attributes for a CFG vertex.
bool showInstructions() const
Property: show basic block instructions.
Definition GraphViz.h:491
void showOutNeighbors(bool b)
Property: show outgoing edges to neighbor vertices.
Definition GraphViz.h:560
void selectInterval(const AddressInterval &)
Selects vertices in some interval.
void showInstructionStackDeltas(bool b)
Property: show instruction stack deltas.
Definition GraphViz.h:513
std::string vertexLabelDetailed(const ControlFlowGraph::Vertex &) const
Detailed label for CFG vertex.
virtual Attributes edgeAttributes(const ControlFlowGraph::ConstEdgeIterator &) const
Attributes for a CFG edge.
void assignFunctionSubgraphs()
Assign vertices and edges to subgraphs.
Attributes edgeAttributes(const ControlFlowGraph::Edge &) const
Attributes for a CFG edge.
void funcReturnColor(const Color::HSV &bg)
Property: color to use for background of function return nodes.
Definition GraphViz.h:543
bool strikeNoopSequences() const
Property: strike no-op sequences.
Definition GraphViz.h:524
SourceLocations & srcMapper()
Property: Address-to-source mapping.
Definition GraphViz.h:591
bool useFunctionSubgraphs() const
Property: use function subgraphs.
Definition GraphViz.h:480
void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true)
Select neighboring vertices.
void strikeNoopSequences(bool b)
Property: strike no-op sequences.
Definition GraphViz.h:525
static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator &)
Returns true if the edge spans two different functions.
virtual std::string vertexLabelDetailed(const ControlFlowGraph::ConstVertexIterator &) const
Detailed label for CFG vertex.
void showReturnEdges(bool b)
Property: show function return edges.
Definition GraphViz.h:582
bool showInstructionStackDeltas() const
Property: show instruction stack deltas.
Definition GraphViz.h:512
static FunctionPtr firstOwningFunction(const ControlFlowGraph::Vertex &)
First function that owns a vertex.
virtual std::string sourceLocation(const ControlFlowGraph::ConstVertexIterator &) const
Source location for vertex.
PartitionerConstPtr partitioner()
Property: partitioner.
Definition GraphViz.h:471
void emitIntervalGraph(std::ostream &, const AddressInterval &)
Dump control flow graph for some address interval.
void selectIntraFunction(const FunctionPtr &)
Select vertices and intra-function edges for one function.
CfgEmitter(const PartitionerConstPtr &, const ControlFlowGraph &)
Constructor.
bool showInNeighbors() const
Property: show incoming edges from neighbor vertices.
Definition GraphViz.h:571
void deselectUnusedVertex(ControlFlowGraph::ConstVertexIterator)
Deselect a vertex if it has no selected incident edges.
bool showReturnEdges() const
Property: show function return edges.
Definition GraphViz.h:581
void deselectUnusedVertexType(VertexType)
Deselect vertices of specified type if they have no selected incident edges.
void showInstructionAddresses(bool b)
Property: show instruction addresses.
Definition GraphViz.h:502
const Color::HSV & funcEnterColor() const
Property: color to use for background of function entrance nodes.
Definition GraphViz.h:535
void showInNeighbors(bool b)
Property: show incoming edges from neighbor vertices.
Definition GraphViz.h:572
void emitWholeGraph(std::ostream &)
Dump entire control flow graph.
CfgEmitter & selectIntervalGraph(const AddressInterval &interval)
Selects vertices that start within some interval.
const SourceLocations & srcMapper() const
Property: Address-to-source mapping.
Definition GraphViz.h:590
const std::string & name() const
Name for object.
Definition GraphViz.h:94
void subgraph(const std::string &s)
Subgraph for object.
Definition GraphViz.h:128
const std::string & label() const
Label for object.
Definition GraphViz.h:104
const Attributes & attributes() const
Attributes for object.
Definition GraphViz.h:116
void label(const std::string &s)
Label for object.
Definition GraphViz.h:108
void name(const std::string &s)
Name for object.
Definition GraphViz.h:95
bool isSelected() const
Determines whether an object is selected.
Definition GraphViz.h:87
void attributes(const Attributes &a)
Attributes for object.
Definition GraphViz.h:118
void select(bool b=true)
Select or deselect object.
Definition GraphViz.h:79
const std::string & subgraph() const
Subgraph for object.
Definition GraphViz.h:127
Attributes & attributes()
Attributes for object.
Definition GraphViz.h:117
Bidirectional mapping between addresses and source locations.
Colors in HSV space.
Definition Color.h:180
Container associating values with keys.
Definition Sawyer/Map.h:72
bool exists(const Key &key) const
Determine if a key exists.
Definition Sawyer/Map.h:493
size_t size() const
Number of nodes, keys, or values in this container.
Definition Sawyer/Map.h:438
Optional< Value > getOptional(const Key &key) const
Lookup and return a value or nothing.
Definition Sawyer/Map.h:602
Value & insertMaybeDefault(const Key &key)
Conditionally insert a new key with default value.
Definition Sawyer/Map.h:711
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
Definition Sawyer/Map.h:646
Map & clear()
Remove all nodes.
Definition Sawyer/Map.h:732
const Value & getOrDefault(const Key &key) const
Lookup and return a value or a default.
Definition Sawyer/Map.h:629
bool assignTo(U &out) const
Conditionally save a value.
Definition Optional.h:331
ROSE_DLL_API std::string htmlEscape(const std::string &)
Escape characters that need to be escaped within GraphViz HTML literals.
ROSE_DLL_API bool isId(const std::string &s)
Determins if a string is a valid GraphViz ID.
ROSE_DLL_API std::string toString(const Attributes &)
Convert attributes to GraphViz language string.
PositionGraph readPositions(std::istream &)
Constructs graph positions from a file.
Sawyer::Container::Graph< VertexPosition, EdgePosition > PositionGraph
A graph with positioned vertices and edges.
Definition GraphViz.h:875
ROSE_DLL_API std::string quotedEscape(const std::string &)
Escape characters that need to be escaped within GraphViz double quoted literals.
ROSE_DLL_API std::string escape(const std::string &)
Escape some value for GraphViz.
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.
Sawyer::Container::Map< std::string, std::string > Attributes
GraphViz attributes.
Definition GraphViz.h:26
ROSE_DLL_API const size_t NO_ID
An invalid identification number.
ROSE_UTIL_API std::string numberToString(long long)
Convert an integer to a string.
The ROSE library.
Two dimensional display plane coordinate.
Definition GraphViz.h:849
std::vector< Coordinate > spline
Control points for the edge B-spline.
Definition GraphViz.h:871
std::string name
Name of vertex as known to GraphViz.
Definition GraphViz.h:856
Coordinate center
Center of vertex in display plane units.
Definition GraphViz.h:857