ROSE 0.11.145.147
Unparser/Base.h
1#ifndef ROSE_BinaryAnalysis_Unparser_Base_H
2#define ROSE_BinaryAnalysis_Unparser_Base_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/BasicTypes.h>
7#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
8#include <Rose/BinaryAnalysis/Partitioner2/ControlFlowGraph.h>
9#include <Rose/BinaryAnalysis/Partitioner2/FunctionCallGraph.h>
10#include <Rose/BinaryAnalysis/Reachability.h>
11#include <Rose/BinaryAnalysis/RegisterNames.h>
12#include <Rose/BinaryAnalysis/Unparser/EdgeArrows.h>
13#include <Rose/BinaryAnalysis/Unparser/Settings.h>
14#include <Rose/BitFlags.h>
15#include <Rose/Progress.h>
16
17#include <Sawyer/Map.h>
18#include <Sawyer/Message.h>
19#include <Sawyer/SharedObject.h>
20
21namespace Rose {
22namespace BinaryAnalysis {
23namespace Unparser {
24
26typedef std::map<uint64_t, std::string> LabelMap;
27
30
31// used internally to initialize mlog
32void initDiagnostics();
33
35// Supporting functions
37
42
44// Margins containing arrows
46
91
93// Output style
95
98 std::vector<Style> stack_;
99 Style current_;
100 Color::Colorization colorization_;
101
102public:
103 StyleStack() {}
104
108 Color::Colorization colorization() const { return colorization_; }
109 void colorization(const Color::Colorization c) { colorization_ = c; }
115 size_t push(const Style&);
116
120 void pop();
121
123 void popTo(size_t);
124
126 void reset();
127
129 size_t size() const;
130
136 const Style& current() const;
137
138private:
139 void merge(const Style &style); // merge style into current_
140 void mergeAll(); // recalculate current_ based on stack_
141};
142
145 StyleStack &stack_;
146 size_t n_;
147 Style current_;
148 Style previous_;
149public:
154 StyleGuard(StyleStack &stack, const Style &style)
155 : stack_(stack) {
156 previous_ = stack_.current();
157 n_ = stack_.push(style);
158 current_ = stack_.current();
159 }
160
161 StyleGuard(StyleStack &stack, const Style &first, const Style &second)
162 : stack_(stack) {
163 previous_ = stack_.current();
164 n_ = stack_.push(first);
165 stack_.push(second);
166 current_ = stack_.current();
167 }
168
169 ~StyleGuard() {
170 stack_.popTo(n_);
171 }
172
174 std::string render() const;
175
177 std::string restore() const;
178
180 const Style& current() const {
181 return current_;
182 }
183
185 const Style& previous() const {
186 return previous_;
187 }
188};
189
191// State of the unparser (the unparser itself is const during unparsing)
193
198class State {
199public:
202private:
205 Partitioner2::FunctionPtr currentFunction_;
206 Partitioner2::BasicBlockPtr currentBasicBlock_;
208 std::string nextInsnLabel_;
209 AddrString basicBlockLabels_;
210 RegisterNames registerNames_;
211 const Base &frontUnparser_;
212 std::vector<Reachability::ReasonFlags> cfgVertexReachability_;
213 Sawyer::Container::Map<Reachability::ReasonFlags::Vector, std::string> reachabilityNames_; // map reachability value to name
214 ArrowMargin intraFunctionCfgArrows_; // arrows for the intra-function control flow graphs
215 ArrowMargin intraFunctionBlockArrows_; // user-defined intra-function arrows to/from blocks
216 ArrowMargin globalBlockArrows_; // user-defined global arrows to/from blocks
217 bool cfgArrowsPointToInsns_; // arrows point to insns? else predecessor/successor lines
218 StyleStack styleStack_; // styles
219
220public:
222 virtual ~State();
223
226
229
236 const std::vector<Reachability::ReasonFlags> cfgVertexReachability() const;
237 void cfgVertexReachability(const std::vector<Reachability::ReasonFlags>&);
245
258 const ArrowMargin& intraFunctionCfgArrows() const { return intraFunctionCfgArrows_; }
259 ArrowMargin& intraFunctionCfgArrows() { return intraFunctionCfgArrows_; }
275 const ArrowMargin& intraFunctionBlockArrows() const { return intraFunctionBlockArrows_; }
276 ArrowMargin& intraFunctionBlockArrows() { return intraFunctionBlockArrows_; }
287 const ArrowMargin& globalBlockArrows() const { return globalBlockArrows_; }
288 ArrowMargin& globalBlockArrows() { return globalBlockArrows_; }
293
296
304 Sawyer::Optional<EdgeArrows::VertexId> currentPredSuccId() const { return currentPredSuccId_; }
305 void currentPredSuccId(Sawyer::Optional<EdgeArrows::VertexId> id) { currentPredSuccId_ = id; }
315 bool cfgArrowsPointToInsns() const { return cfgArrowsPointToInsns_; }
316 void cfgArrowsPointToInsns(bool b) { cfgArrowsPointToInsns_ = b; }
322 const StyleStack& styleStack() const { return styleStack_; }
323 StyleStack& styleStack() { return styleStack_; }
340 void reachabilityName(Reachability::Reason value, const std::string &name);
344 Partitioner2::FunctionPtr currentFunction() const;
345 void currentFunction(const Partitioner2::FunctionPtr&);
346
347 Partitioner2::BasicBlockPtr currentBasicBlock() const;
348 void currentBasicBlock(const Partitioner2::BasicBlockPtr&);
349
350 const std::string& nextInsnLabel() const;
351 void nextInsnLabel(const std::string&);
352
353 const RegisterNames& registerNames() const;
354 void registerNames(const RegisterNames &r);
355
356 const AddrString& basicBlockLabels() const;
357 AddrString& basicBlockLabels();
358
360 const Base& frontUnparser() const;
361};
362
364// Base unparser
366
414public:
416
417private:
418 Architecture::BaseConstPtr architecture_; // non-null architecture
419 Ptr nextUnparser_;
420
421protected:
422 explicit Base(const Architecture::BaseConstPtr&);
423 explicit Base(const Ptr &nextUnparser);
424
425public:
426 virtual Ptr copy() const = 0;
427 virtual ~Base();
428
438 virtual const Settings& settings() const = 0;
439 virtual Settings& settings() = 0;
440 void settings(const Settings &s) {
441 settings() = s;
442 }
452 Ptr nextUnparser() const { return nextUnparser_; }
453 void nextUnparser(Ptr next) { nextUnparser_ = next; }
460
468 void operator()(std::ostream&, const Partitioner2::PartitionerConstPtr&) const /*final*/;
469 void operator()(std::ostream&, const Partitioner2::PartitionerConstPtr&, SgAsmInstruction*) const /*final*/;
470 void operator()(std::ostream&, const Partitioner2::PartitionerConstPtr&, const Partitioner2::BasicBlockPtr&) const /*final*/;
471 void operator()(std::ostream&, const Partitioner2::PartitionerConstPtr&, const Partitioner2::DataBlockPtr&) const /*final*/;
472 void operator()(std::ostream&, const Partitioner2::PartitionerConstPtr&, const Partitioner2::FunctionPtr&) const /*final*/;
473 void operator()(std::ostream&, SgAsmInstruction*) const /*final*/;
481 std::string operator()(const Partitioner2::PartitionerConstPtr&, const Progress::Ptr& = Progress::Ptr()) const /*final*/;
482 std::string operator()(const Partitioner2::PartitionerConstPtr&, SgAsmInstruction*) const /*final*/;
483 std::string operator()(const Partitioner2::PartitionerConstPtr&, const Partitioner2::BasicBlockPtr&) const /*final*/;
484 std::string operator()(const Partitioner2::PartitionerConstPtr&, const Partitioner2::DataBlockPtr&) const /*final*/;
485 std::string operator()(const Partitioner2::PartitionerConstPtr&, const Partitioner2::FunctionPtr&) const /*final*/;
486 std::string operator()(SgAsmInstruction*) const /*final*/;
489public:
495 void unparse(std::ostream&, const Partitioner2::PartitionerConstPtr&, const Progress::Ptr& = Progress::Ptr()) const /*final*/;
496 void unparse(std::ostream&, const Partitioner2::PartitionerConstPtr&, SgAsmInstruction*) const /*final*/;
497 void unparse(std::ostream&, const Partitioner2::PartitionerConstPtr&, const Partitioner2::BasicBlockPtr&) const /*final*/;
498 void unparse(std::ostream&, const Partitioner2::PartitionerConstPtr&, const Partitioner2::DataBlockPtr&) const /*final*/;
499 void unparse(std::ostream&, const Partitioner2::PartitionerConstPtr&, const Partitioner2::FunctionPtr&) const /*final*/;
500 void unparse(std::ostream&, SgAsmInstruction*) const /*final*/;
501
502 std::string unparse(const Partitioner2::PartitionerConstPtr&, const Progress::Ptr& = Progress::Ptr()) const /*final*/;
503 std::string unparse(const Partitioner2::PartitionerConstPtr&, SgAsmInstruction*) const /*final*/;
504 std::string unparse(const Partitioner2::PartitionerConstPtr&, const Partitioner2::BasicBlockPtr&) const /*final*/;
505 std::string unparse(const Partitioner2::PartitionerConstPtr&, const Partitioner2::DataBlockPtr&) const /*final*/;
506 std::string unparse(const Partitioner2::PartitionerConstPtr&, const Partitioner2::FunctionPtr&) const /*final*/;
507 std::string unparse(SgAsmInstruction*) const /*final*/;
510public:
533 virtual void emitFunction(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
534 virtual void emitFunctionPrologue(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
535 virtual void emitFunctionBody(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
536 virtual void emitFunctionEpilogue(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
537
538 virtual void emitFunctionSourceLocation(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
539 virtual void emitFunctionReasons(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
540 virtual void emitFunctionCallers(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
541 virtual void emitFunctionCallees(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
542 virtual void emitFunctionComment(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
543 virtual void emitFunctionStackDelta(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
544 virtual void emitFunctionCallingConvention(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
545 virtual void emitFunctionNoopAnalysis(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
546 virtual void emitFunctionMayReturn(std::ostream&, const Partitioner2::FunctionPtr&, State&) const;
547
548 virtual void emitDataBlockSourceLocation(std::ostream&, const Partitioner2::DataBlockPtr&, State&) const;
549 virtual void emitDataBlock(std::ostream&, const Partitioner2::DataBlockPtr&, State&) const;
550 virtual void emitDataBlockPrologue(std::ostream&, const Partitioner2::DataBlockPtr&, State&) const;
551 virtual void emitDataBlockBody(std::ostream&, const Partitioner2::DataBlockPtr&, State&) const;
552 virtual void emitDataBlockEpilogue(std::ostream&, const Partitioner2::DataBlockPtr&, State&) const;
553
554 virtual void emitBasicBlock(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
555 virtual void emitBasicBlockPrologue(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
556 virtual void emitBasicBlockBody(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
557 virtual void emitBasicBlockEpilogue(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
558
559 virtual void emitBasicBlockSourceLocation(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
560 virtual void emitBasicBlockComment(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
561 virtual void emitBasicBlockSharing(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
562 virtual void emitBasicBlockPredecessors(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
563 virtual void emitBasicBlockSuccessors(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
564 virtual void emitBasicBlockReachability(std::ostream&, const Partitioner2::BasicBlockPtr&, State&) const;
565
566 virtual void emitInstruction(std::ostream&, SgAsmInstruction*, State&) const;
567 virtual void emitInstructionPrologue(std::ostream&, SgAsmInstruction*, State&) const;
568 virtual void emitInstructionBody(std::ostream&, SgAsmInstruction*, State&) const;
569 virtual void emitInstructionEpilogue(std::ostream&, SgAsmInstruction*, State&) const;
570
571 virtual void emitInstructionAddress(std::ostream&, SgAsmInstruction*, State&) const;
572 virtual void emitInstructionBytes(std::ostream&, SgAsmInstruction*, State&) const;
573 virtual void emitInstructionStackDelta(std::ostream&, SgAsmInstruction*, State&) const;
574 virtual void emitInstructionMnemonic(std::ostream&, SgAsmInstruction*, State&) const;
575 virtual void emitInstructionOperands(std::ostream&, SgAsmInstruction*, State&) const;
576 virtual void emitInstructionComment(std::ostream&, SgAsmInstruction*, State&) const;
577
578 virtual void emitInstructionSemantics(std::ostream&, SgAsmInstruction*, State&) const;
579
580 virtual void emitOperand(std::ostream&, SgAsmExpression*, State&) const;
581 virtual void emitOperandPrologue(std::ostream&, SgAsmExpression*, State&) const;
582 virtual void emitOperandBody(std::ostream&, SgAsmExpression*, State&) const;
583 virtual void emitOperandEpilogue(std::ostream&, SgAsmExpression*, State&) const;
584
585 virtual void emitExpression(std::ostream&, SgAsmExpression*, State&) const;
586 virtual void emitRegister(std::ostream&, RegisterDescriptor, State&) const;
587 virtual std::vector<std::string> emitUnsignedInteger(std::ostream&, const Sawyer::Container::BitVector&, State&) const;
588 virtual std::vector<std::string> emitSignedInteger(std::ostream&, const Sawyer::Container::BitVector&, State&) const;
589 virtual std::vector<std::string> emitInteger(std::ostream&, const Sawyer::Container::BitVector&, State&,
590 bool isSigned) const;
591 virtual bool emitAddress(std::ostream&, rose_addr_t, State&, bool always=true) const;
592 virtual bool emitAddress(std::ostream&, const Sawyer::Container::BitVector&, State&, bool always=true) const;
593 virtual void emitCommentBlock(std::ostream&, const std::string&, State&, const std::string &prefix = ";;; ") const;
594 virtual void emitTypeName(std::ostream&, SgAsmType*, State&) const;
595
596 virtual void emitLinePrefix(std::ostream&, State&) const;
599 //----- Other overrridable things -----
600public:
606 virtual void initializeState(State&) const;
607
613 virtual void updateIntraFunctionArrows(State&) const;
614
615 //----- Utility functions -----
616public:
618 static std::string leftJustify(const std::string&, size_t nchars);
619
625 static std::string juxtaposeColumns(const std::vector<std::string> &content, const std::vector<size_t> &minWidths,
626 const std::vector<std::pair<std::string, std::string> > &colorEscapes,
627 const std::string &columnSeparator = " ");
628
634 static bool ascendingSourceAddress(Partitioner2::ControlFlowGraph::ConstEdgeIterator a,
635 Partitioner2::ControlFlowGraph::ConstEdgeIterator b);
636
642 static bool ascendingTargetAddress(Partitioner2::ControlFlowGraph::ConstEdgeIterator a,
643 Partitioner2::ControlFlowGraph::ConstEdgeIterator b);
644
649 static std::vector<Partitioner2::ControlFlowGraph::ConstEdgeIterator>
650 orderedBlockPredecessors(const Partitioner2::PartitionerConstPtr&, const Partitioner2::BasicBlockPtr&);
651
656 static std::vector<Partitioner2::ControlFlowGraph::ConstEdgeIterator>
657 orderedBlockSuccessors(const Partitioner2::PartitionerConstPtr&, const Partitioner2::BasicBlockPtr&);
658};
659
661// Python API wrappers and functions
663
664#ifdef ROSE_ENABLE_PYTHON_API
665class PythonBase {
666 Base::Ptr base_;
667
668public:
669 PythonBase() {}
670
671 explicit PythonBase(const Base::Ptr &base)
672 : base_(base) {
673 ASSERT_not_null(base);
674 }
675
676 std::string unparse(const Partitioner2::PartitionerConstPtr &p) const {
677 return base_->unparse(p);
678 }
679
680 void print(const Partitioner2::PartitionerConstPtr &p) const {
681 base_->unparse(std::cout, p);
682 }
683};
684#endif
685
686} // namespace
687} // namespace
688} // namespace
689
690#endif
691#endif
Reason
Predefined bit flags for why something is reachable.
Describes (part of) a physical CPU register.
Convert a register descriptor to a name.
State associated with printing arrows in the margin.
Flags
Flags controlling the finer aspects of margin arrows.
@ POINTABLE_ENTITY_INSIDE
This flag is modified automatically by the emitLinePrefix function.
@ POINTABLE_ENTITY_START
Set this flag when you want the emitLinePrefix function to treat the next possible line as the start ...
@ POINTABLE_ENTITY_END
Set this flag when you want the emitLinePrefix function to treat the next line as the end of a pointa...
@ ALWAYS_RENDER
If set, then emit the prefix area even if we seem to be generating output that the unparser would oth...
void reset()
Reset the marging arrow state.
std::string render(Sawyer::Optional< EdgeArrows::VertexId > currentEntity)
Generate the string to print in the margin.
Sawyer::Optional< EdgeArrows::VertexId > latestEntity
Latest pointable entity that was encountered in the output.
EdgeArrows arrows
The arrows to be displayed.
BitFlags< Flags > flags
Flags that hold and/or control the output state.
Abstract base class for unparsers.
virtual void emitFunctionStackDelta(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual Settings & settings()=0
Property: Settings associated with this unparser.
virtual void emitInstructionPrologue(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
virtual void emitBasicBlockSuccessors(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
void operator()(std::ostream &, const Partitioner2::PartitionerConstPtr &, SgAsmInstruction *) const
Emit the entity to an output stream.
virtual void emitFunction(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
static bool ascendingSourceAddress(Partitioner2::ControlFlowGraph::ConstEdgeIterator a, Partitioner2::ControlFlowGraph::ConstEdgeIterator b)
Return true if edges are in order by source address.
void operator()(std::ostream &, const Partitioner2::PartitionerConstPtr &, const Partitioner2::BasicBlockPtr &) const
Emit the entity to an output stream.
virtual std::vector< std::string > emitInteger(std::ostream &, const Sawyer::Container::BitVector &, State &, bool isSigned) const
Mid-level unparser function.
virtual void emitDataBlockPrologue(std::ostream &, const Partitioner2::DataBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitInstructionOperands(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
virtual void emitFunctionReasons(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitTypeName(std::ostream &, SgAsmType *, State &) const
Mid-level unparser function.
void operator()(std::ostream &, const Partitioner2::PartitionerConstPtr &, const Partitioner2::DataBlockPtr &) const
Emit the entity to an output stream.
virtual void emitFunctionCallingConvention(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitInstructionBody(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
virtual void emitBasicBlockSharing(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
virtual void initializeState(State &) const
Finish initializing the unparser state.
virtual void emitFunctionPrologue(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitDataBlock(std::ostream &, const Partitioner2::DataBlockPtr &, State &) const
Mid-level unparser function.
virtual const Settings & settings() const =0
Property: Settings associated with this unparser.
static bool ascendingTargetAddress(Partitioner2::ControlFlowGraph::ConstEdgeIterator a, Partitioner2::ControlFlowGraph::ConstEdgeIterator b)
Return true if edges are in order by target address.
virtual void emitDataBlockEpilogue(std::ostream &, const Partitioner2::DataBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitInstructionEpilogue(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
void operator()(std::ostream &, SgAsmInstruction *) const
Emit the entity to an output stream.
virtual void emitCommentBlock(std::ostream &, const std::string &, State &, const std::string &prefix=";;; ") const
Mid-level unparser function.
virtual std::vector< std::string > emitSignedInteger(std::ostream &, const Sawyer::Container::BitVector &, State &) const
Mid-level unparser function.
void settings(const Settings &s)
Property: Settings associated with this unparser.
virtual void emitDataBlockBody(std::ostream &, const Partitioner2::DataBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitBasicBlockComment(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
static std::vector< Partitioner2::ControlFlowGraph::ConstEdgeIterator > orderedBlockPredecessors(const Partitioner2::PartitionerConstPtr &, const Partitioner2::BasicBlockPtr &)
Ordered incoming CFG edges.
virtual void emitInstructionBytes(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
virtual void emitOperand(std::ostream &, SgAsmExpression *, State &) const
Mid-level unparser function.
virtual void emitLinePrefix(std::ostream &, State &) const
Mid-level unparser function.
virtual void emitInstructionAddress(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
Ptr nextUnparser() const
Property: Next parser in chain.
void nextUnparser(Ptr next)
Property: Next parser in chain.
virtual void emitBasicBlockPrologue(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitBasicBlockReachability(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
virtual std::vector< std::string > emitUnsignedInteger(std::ostream &, const Sawyer::Container::BitVector &, State &) const
Mid-level unparser function.
virtual void emitOperandEpilogue(std::ostream &, SgAsmExpression *, State &) const
Mid-level unparser function.
virtual void emitFunctionMayReturn(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitDataBlockSourceLocation(std::ostream &, const Partitioner2::DataBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitBasicBlockEpilogue(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
void operator()(std::ostream &, const Partitioner2::PartitionerConstPtr &) const
Emit the entity to an output stream.
virtual bool emitAddress(std::ostream &, rose_addr_t, State &, bool always=true) const
Mid-level unparser function.
virtual void emitInstructionComment(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
std::string operator()(const Partitioner2::PartitionerConstPtr &, const Progress::Ptr &=Progress::Ptr()) const
Emit the entity to a string.
virtual void emitExpression(std::ostream &, SgAsmExpression *, State &) const
Mid-level unparser function.
static std::vector< Partitioner2::ControlFlowGraph::ConstEdgeIterator > orderedBlockSuccessors(const Partitioner2::PartitionerConstPtr &, const Partitioner2::BasicBlockPtr &)
Ordered outgoing CFG edges.
void operator()(std::ostream &, const Partitioner2::PartitionerConstPtr &, const Partitioner2::FunctionPtr &) const
Emit the entity to an output stream.
virtual void emitInstructionStackDelta(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
virtual void emitBasicBlock(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitBasicBlockPredecessors(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitRegister(std::ostream &, RegisterDescriptor, State &) const
Mid-level unparser function.
virtual void emitBasicBlockSourceLocation(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
virtual void emitFunctionCallers(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
static std::string juxtaposeColumns(const std::vector< std::string > &content, const std::vector< size_t > &minWidths, const std::vector< std::pair< std::string, std::string > > &colorEscapes, const std::string &columnSeparator=" ")
Render a table row.
virtual void emitBasicBlockBody(std::ostream &, const Partitioner2::BasicBlockPtr &, State &) const
Mid-level unparser function.
void unparse(std::ostream &, const Partitioner2::PartitionerConstPtr &, const Progress::Ptr &=Progress::Ptr()) const
High-level unparsing function.
virtual void emitFunctionEpilogue(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitInstruction(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
virtual void emitFunctionBody(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
Architecture::BaseConstPtr architecture() const
Property: Architecture.
virtual void emitInstructionMnemonic(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
virtual void emitFunctionComment(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitFunctionCallees(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitFunctionSourceLocation(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
virtual void emitInstructionSemantics(std::ostream &, SgAsmInstruction *, State &) const
Mid-level unparser function.
static std::string leftJustify(const std::string &, size_t nchars)
Render a string left justified.
virtual void emitOperandPrologue(std::ostream &, SgAsmExpression *, State &) const
Mid-level unparser function.
virtual void updateIntraFunctionArrows(State &) const
Calculate intra-function arrows.
virtual void emitOperandBody(std::ostream &, SgAsmExpression *, State &) const
Mid-level unparser function.
virtual void emitFunctionNoopAnalysis(std::ostream &, const Partitioner2::FunctionPtr &, State &) const
Mid-level unparser function.
Analysis to generate arrows from one basic block to another.
Definition EdgeArrows.h:30
bool cfgArrowsPointToInsns() const
Property: Whether CFG margin arrows point to instructions.
const std::vector< Reachability::ReasonFlags > cfgVertexReachability() const
Property: Reachability analysis results.
ArrowMargin & intraFunctionBlockArrows()
User-defined intra-function margin arrows.
ArrowMargin & globalBlockArrows()
User-defined arrows to basic blocks across entire output.
ArrowMargin & intraFunctionCfgArrows()
Control flow graph arrows within a function.
std::string reachabilityName(Reachability::ReasonFlags value) const
Assign a reachability name to a reachability value.
const Base & frontUnparser() const
First unparser in the chained list of unparsers.
const ArrowMargin & intraFunctionCfgArrows() const
Control flow graph arrows within a function.
Sawyer::Container::Map< rose_addr_t, std::string > AddrString
Map from address to string.
void thisIsBasicBlockFirstInstruction()
Call this when you're about to output the first instruction of a basic block.
void cfgArrowsPointToInsns(bool b)
Property: Whether CFG margin arrows point to instructions.
const StyleStack & styleStack() const
Property: Stack of styles.
Partitioner2::PartitionerConstPtr partitioner() const
Property: Partitioner, which may be null.
StyleStack & styleStack()
Property: Stack of styles.
Reachability::ReasonFlags isCfgVertexReachable(size_t vertexId) const
Returns reachability based on the cfgVertexReachability property.
void currentPredSuccId(Sawyer::Optional< EdgeArrows::VertexId > id)
Property: ID for CFG edge arrow endpoint.
void reachabilityName(Reachability::Reason value, const std::string &name)
Assign a reachability name to a reachability value.
const ArrowMargin & intraFunctionBlockArrows() const
User-defined intra-function margin arrows.
const Partitioner2::FunctionCallGraph & cg() const
Property: Call grap, which may be empty.
const ArrowMargin & globalBlockArrows() const
User-defined arrows to basic blocks across entire output.
Sawyer::Optional< EdgeArrows::VertexId > currentPredSuccId() const
Property: ID for CFG edge arrow endpoint.
void cfgVertexReachability(const std::vector< Reachability::ReasonFlags > &)
Property: Reachability analysis results.
void thisIsBasicBlockLastInstruction()
Call this when you're about to output the last instruction of a basic block.
Pushes a style and arranges for it to be popped later.
std::string render() const
Render style entry.
StyleGuard(StyleStack &stack, const Style &style)
Push style onto stack.
const Style & previous() const
Style before pushing.
std::string restore() const
Render style exit.
const Style & current() const
Current merged style.
size_t push(const Style &)
Push style onto stack.
const Style & current() const
Merged style.
size_t size() const
Number of styles on the stack.
void colorization(const Color::Colorization c)
Property: Colorization settings.
Color::Colorization colorization() const
Property: Colorization settings.
void popTo(size_t)
Pop until stack is a certain size.
void pop()
Pop top style from stack.
Stores a vector of enum bit flags.
A general, thread-safe way to report progress made on some task.
Definition Progress.h:167
Container associating values with keys.
Definition Sawyer/Map.h:72
Collection of streams.
Definition Message.h:1606
Represents no value.
Definition Optional.h:36
Holds a value or nothing.
Definition Optional.h:56
Base class for reference counted objects.
Base class for expressions.
Base class for machine instructions.
Base class for binary types.
std::shared_ptr< const Base > BaseConstPtr
Reference counted pointer for Architecture::Base.
std::map< uint64_t, std::string > LabelMap
Map from address to label.
Sawyer::Message::Facility mlog
Diagnostic output for unparsing.
std::string invalidRegister(SgAsmInstruction *, RegisterDescriptor, const RegisterDictionaryPtr &)
Constructs a string to describe the invalid register.
The ROSE library.
Sawyer support library.
Settings that control unparsing.
Control colored command output.
Definition Color.h:37