ROSE 0.11.145.192
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 showInNeighbors_; // show neighbors for incoming edges to selected vertices?
443 bool showOutNeighbors_; // show neighbors for outgoing edges to selected vertices?
444 bool strikeNoopSequences_; // render no-op sequences in a different style
445 Color::HSV funcEnterColor_; // background color for function entrance blocks
446 Color::HSV funcReturnColor_; // background color for function return blocks
447 Color::HSV warningColor_; // background color for special nodes and warnings
448 SourceLocations srcMapper_; // maps addresses to source code (optional)
449 static unsigned long versionDate_; // date code from "dot -V", like 20100126
450 NoOperation noOpAnalysis_;
451
452public:
465 // Properties
466
470 PartitionerConstPtr partitioner() { return partitioner_; }
471
479 bool useFunctionSubgraphs() const { return useFunctionSubgraphs_; }
480 void useFunctionSubgraphs(bool b) { useFunctionSubgraphs_ = b; }
490 bool showInstructions() const { return showInstructions_; }
491 void showInstructions(bool b) { showInstructions_ = b; }
500 bool showInstructionAddresses() const { return showInstructionAddresses_; }
501 void showInstructionAddresses(bool b) { showInstructionAddresses_ = b; }
512 bool strikeNoopSequences() const { return strikeNoopSequences_; }
513 void strikeNoopSequences(bool b) { strikeNoopSequences_ = b; }
523 const Color::HSV& funcEnterColor() const { return funcEnterColor_; }
524 void funcEnterColor(const Color::HSV &bg) { funcEnterColor_ = bg; }
530 const Color::HSV& funcReturnColor() const { return funcReturnColor_; }
531 void funcReturnColor(const Color::HSV &bg) { funcReturnColor_ = bg; }
537 const Color::HSV& warningColor() const { return warningColor_; }
538 void warningColor(const Color::HSV &bg) { warningColor_ = bg; }
547 bool showOutNeighbors() const { return showOutNeighbors_; }
548 void showOutNeighbors(bool b) { showOutNeighbors_ = b; }
559 bool showInNeighbors() const { return showInNeighbors_; }
560 void showInNeighbors(bool b) { showInNeighbors_ = b; }
569 bool showReturnEdges() const { return showReturnEdges_; }
570 void showReturnEdges(bool b) { showReturnEdges_ = b; }
578 const SourceLocations& srcMapper() const { return srcMapper_; }
579 SourceLocations& srcMapper() { return srcMapper_; }
580 void srcMapper(const SourceLocations &mapper) { srcMapper_ = mapper; }
585 // Organization
586
588 // Low-level vertex and edge selection
589
596
599
604
610
615
617 void deselectUnusedVertex(ControlFlowGraph::ConstVertexIterator);
618
621
625 void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true);
626
628 // High-level selectors
629
636
643
650
652 // GraphViz emitters
653
657 void emitWholeGraph(std::ostream&);
658
662 void emitFunctionGraph(std::ostream&, const FunctionPtr&);
663
667 void emitIntervalGraph(std::ostream&, const AddressInterval&);
668
670 // Low-level emitters
671
673 // Utilities
674
678 static bool isInterFunctionEdge(const ControlFlowGraph::Edge&);
679 static bool isInterFunctionEdge(const ControlFlowGraph::ConstEdgeIterator&);
688 static FunctionPtr firstOwningFunction(const ControlFlowGraph::Vertex&);
689 static FunctionPtr firstOwningFunction(const ControlFlowGraph::ConstVertexIterator &v) {
690 return firstOwningFunction(*v);
691 }
700 static FunctionSet owningFunctions(const ControlFlowGraph::Vertex&);
701 static FunctionSet owningFunctions(const ControlFlowGraph::ConstVertexIterator&);
709
710
712 // Formatting: these are expected to be overridden by subclasses
713
718 virtual std::string sourceLocation(const ControlFlowGraph::ConstVertexIterator&) const;
719
726 virtual std::string vertexLabel(const ControlFlowGraph::ConstVertexIterator&) const;
727 std::string vertexLabel(const ControlFlowGraph::Vertex&) const;
736 virtual std::string vertexLabelDetailed(const ControlFlowGraph::ConstVertexIterator&) const;
737 std::string vertexLabelDetailed(const ControlFlowGraph::Vertex&) const;
743 virtual Attributes vertexAttributes(const ControlFlowGraph::ConstVertexIterator&) const;
744 Attributes vertexAttributes(const ControlFlowGraph::Vertex&) const;
752 virtual std::string edgeLabel(const ControlFlowGraph::ConstEdgeIterator&) const;
753 std::string edgeLabel(const ControlFlowGraph::Edge&) const;
759 virtual Attributes edgeAttributes(const ControlFlowGraph::ConstEdgeIterator&) const;
760 Attributes edgeAttributes(const ControlFlowGraph::Edge&) const;
766 virtual std::string functionLabel(const FunctionPtr&) const;
767
770
771private:
772 void init();
773
774 // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
775 // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
776 // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
777 void nameVertices();
778};
779
780
782// Base emitter for Partitioner2::FunctionCallGraph
784
786class ROSE_DLL_API CgEmitter: public BaseEmitter<FunctionCallGraph::Graph> {
788 Color::HSV functionHighlightColor_; // highlight certain functions
789 boost::regex highlightNameMatcher_; // which functions to highlight
790public:
791 explicit CgEmitter(const PartitionerConstPtr &partitioner);
792 CgEmitter(const PartitionerConstPtr &partitioner, const FunctionCallGraph &cg);
793 virtual std::string functionLabel(const FunctionPtr&) const;
794 virtual Attributes functionAttributes(const FunctionPtr&) const;
795 virtual void emitCallGraph(std::ostream &out) const;
796 virtual const FunctionCallGraph& callGraph() const { return cg_; }
797 virtual void callGraph(const FunctionCallGraph &cg);
798 virtual void highlight(const boost::regex&);
799private:
800 // Give GraphViz identifying names to some vertices. The names assigned by this method are used internally by GraphViz, but
801 // encoding some information into thse names (instead of using integers) is useful mainly if we try to parse the GraphViz
802 // output later -- it gives us a way to relate GraphViz's vertex identifiers back to the original ROSE CFG vertices.
803 void nameVertices();
804};
805
806
808// Callgraph emitter with inlined imports
810
816class ROSE_DLL_API CgInlinedEmitter: public CgEmitter {
817 boost::regex nameMatcher_;
818 typedef std::vector<FunctionPtr> InlinedFunctions;
820 Inlines inlines_;
821public:
822 CgInlinedEmitter(const PartitionerConstPtr &partitioner, const boost::regex &nameMatcher);
823 CgInlinedEmitter(const PartitionerConstPtr &partitioner, const FunctionCallGraph &cg, const boost::regex &nameMatcher);
824 virtual const FunctionCallGraph& callGraph() const override { return CgEmitter::callGraph(); }
825 virtual void callGraph(const FunctionCallGraph&) override;
826 virtual std::string functionLabel(const FunctionPtr&) const override;
827 virtual bool shouldInline(const FunctionPtr&) const;
828};
829
830
832// Reading layout position information from "dot"
834
837 double x;
838 double y;
839};
840
843 std::string name;
845 double width;
846 double height;
847};
848
858 std::vector<Coordinate> spline;
859};
860
863
868
869
870
871
873// Class template method implementations
875
876template<class G>
877size_t
878BaseEmitter<G>::emitVertex(std::ostream &out, const typename G::ConstVertexIterator &vertex,
879 const Organization &org, const VMap &vmap) const {
880 size_t id = NO_ID;
881 if (org.isSelected() && !vmap.getOptional(vertex->id()).assignTo(id)) {
882 id = vmap.size();
883 std::string name = org.name();
884 if (name.empty())
886 out <<name <<" [ label=" <<org.label() <<" ";
887 out <<toString(org.attributes()) <<" ];\n";
888 }
889 return id;
890}
891
892template<class G>
893void
894BaseEmitter<G>::emitEdge(std::ostream &out, const typename G::ConstEdgeIterator &edge, const Organization &org,
895 const VMap &vmap) const {
896 ASSERT_require2(vmap.exists(edge->source()->id()), "edge source vertex has not yet been emitted");
897 ASSERT_require2(vmap.exists(edge->target()->id()), "edge target vertex has not yet been emitted");
898
899 size_t sourceId = edge->source()->id();
900 std::string sourceName = vertexOrganization(sourceId).name();
901 if (sourceName.empty())
902 sourceName = StringUtility::numberToString(vmap[sourceId]);
903
904 size_t targetId = edge->target()->id();
905 std::string targetName = vertexOrganization(targetId).name();
906 if (targetName.empty())
907 targetName = StringUtility::numberToString(vmap[targetId]);
908
909 out <<sourceName <<" -> " <<targetName <<" [ label=" <<org.label() <<" " <<toString(org.attributes()) <<" ];\n";
910}
911
912template<class G>
913void
914BaseEmitter<G>::emit(std::ostream &out) const {
915 VMap vmap; // GraphViz node ID for each graph vertex (modified by emit)
916
917 out <<"digraph CFG {\n";
918 out <<" graph [ " <<toString(defaultGraphAttributes_) <<" ];\n";
919 out <<" node [ " <<toString(defaultNodeAttributes_) <<" ];\n";
920 out <<" edge [ " <<toString(defaultEdgeAttributes_) <<" ];\n";
921
922 typedef std::map<std::string /*subgraph name*/, std::string/*subgraph content*/> Subgraphs;
923 Subgraphs subgraphs;
924
925 // Emit vertices to subgraphs
926 for (typename G::ConstVertexIterator vertex=graph_.vertices().begin(); vertex!=graph_.vertices().end(); ++vertex) {
927 const Organization &org = vertexOrganization(vertex);
928 if (org.isSelected() && !vmap.exists(vertex->id())) {
929 std::ostringstream ss;
930 size_t gvid = emitVertex(ss, vertex, org, vmap);
931 vmap.insert(vertex->id(), gvid);
932 subgraphs[org.subgraph()] += ss.str();
933 }
934 }
935
936 // Emit edges to subgraphs
937 for (typename G::ConstEdgeIterator edge=graph_.edges().begin(); edge!=graph_.edges().end(); ++edge) {
938 const Organization &org = edgeOrganization(edge);
939 if (org.isSelected() &&
940 vertexOrganization(edge->source()).isSelected() && vertexOrganization(edge->target()).isSelected()) {
941 std::ostringstream ss;
942 emitEdge(ss, edge, org, vmap);
943 subgraphs[org.subgraph()] += ss.str();
944 }
945 }
946
947 // Emit named subgraphs to output
948 for (const Subgraphs::value_type &node: subgraphs) {
949 const std::string &subgraphName = node.first;
950 const std::string &subgraphContent = node.second;
951 if (!subgraphName.empty()) {
952 out <<"\nsubgraph cluster_" <<subgraphName <<" {"
953 <<" label=" <<subgraphOrganization(subgraphName).label() <<" "
954 <<toString(subgraphOrganization(subgraphName).attributes()) <<"\n"
955 <<subgraphContent
956 <<"}\n";
957 }
958 }
959
960 // Emit unnamed subgraph content without a surrounding subgraph construct (i.e., global graph)
961 Subgraphs::iterator unnamedSubgraph = subgraphs.find("");
962 if (unnamedSubgraph != subgraphs.end())
963 out <<unnamedSubgraph->second;
964
965 // Emit pseudo edges
966 for (const PseudoEdge &edge: pseudoEdges_) {
967 if (vertexOrganization(edge.src).isSelected() && vertexOrganization(edge.dst).isSelected()) {
968 std::string sourceName = vertexOrganization(edge.src).name();
969 std::string targetName = vertexOrganization(edge.dst).name();
970 out <<(sourceName.empty() ? StringUtility::numberToString(vmap[edge.src->id()]) : sourceName)
971 <<" -> "
972 <<(targetName.empty() ? StringUtility::numberToString(vmap[edge.dst->id()]) : targetName)
973 <<" [ label=" <<escape(edge.label) <<" ];\n";
974 }
975 }
976
977 out <<"}\n";
978}
979
980template<class G>
981void
983 for (const typename G::Vertex &src: graph_.vertices()) {
984 if (vertexOrganization(src).isSelected()) {
985 std::set<size_t> targets;
986 for (const typename G::Edge &edge: src.outEdges()) {
987 if (edgeOrganization(edge).isSelected() && !targets.insert(edge.target()->id()).second)
988 edgeOrganization(edge).select(false);
989 }
990 }
991 }
992}
993
994} // namespace
995} // namespace
996} // namespace
997} // namespace
998
999#endif
1000#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:982
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:878
virtual void emit(std::ostream &) const
Dump selected vertices, edges, and subgraphs.
Definition GraphViz.h:914
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:894
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:689
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:537
bool showInstructionAddresses() const
Property: show instruction addresses.
Definition GraphViz.h:500
void warningColor(const Color::HSV &bg)
Property: color to use for background of special nodes and for warnings.
Definition GraphViz.h:538
void showInstructions(bool b)
Property: show basic block instructions.
Definition GraphViz.h:491
void useFunctionSubgraphs(bool b)
Property: use function subgraphs.
Definition GraphViz.h:480
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:530
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:580
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:547
void funcEnterColor(const Color::HSV &bg)
Property: color to use for background of function entrance nodes.
Definition GraphViz.h:524
virtual Attributes vertexAttributes(const ControlFlowGraph::ConstVertexIterator &) const
Attributes for a CFG vertex.
bool showInstructions() const
Property: show basic block instructions.
Definition GraphViz.h:490
void showOutNeighbors(bool b)
Property: show outgoing edges to neighbor vertices.
Definition GraphViz.h:548
void selectInterval(const AddressInterval &)
Selects vertices in some interval.
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:531
bool strikeNoopSequences() const
Property: strike no-op sequences.
Definition GraphViz.h:512
SourceLocations & srcMapper()
Property: Address-to-source mapping.
Definition GraphViz.h:579
bool useFunctionSubgraphs() const
Property: use function subgraphs.
Definition GraphViz.h:479
void selectNeighbors(bool selectInEdges=true, bool selectOutEdges=true)
Select neighboring vertices.
void strikeNoopSequences(bool b)
Property: strike no-op sequences.
Definition GraphViz.h:513
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:570
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:470
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:559
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:569
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:501
const Color::HSV & funcEnterColor() const
Property: color to use for background of function entrance nodes.
Definition GraphViz.h:523
void showInNeighbors(bool b)
Property: show incoming edges from neighbor vertices.
Definition GraphViz.h:560
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:578
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:862
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:836
std::vector< Coordinate > spline
Control points for the edge B-spline.
Definition GraphViz.h:858
std::string name
Name of vertex as known to GraphViz.
Definition GraphViz.h:843
Coordinate center
Center of vertex in display plane units.
Definition GraphViz.h:844