ROSE 0.11.145.147
FeasiblePath.h
1#ifndef ROSE_BinaryAnalysis_FeasiblePath_H
2#define ROSE_BinaryAnalysis_FeasiblePath_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/BasicTypes.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/SymbolicSemantics.h>
8#include <Rose/BinaryAnalysis/SmtSolver.h>
9#include <Rose/BinaryAnalysis/SymbolicExpressionParser.h>
10#include <Rose/BinaryAnalysis/Partitioner2/CfgPath.h>
11#include <Rose/Exception.h>
12#include <Sawyer/CommandLine.h>
13#include <Sawyer/Message.h>
14#include <boost/filesystem/path.hpp>
15#include <boost/logic/tribool.hpp>
16
17namespace Rose {
18namespace BinaryAnalysis {
19
25 // Types and public data members
27public:
29 class Exception: public Rose::Exception {
30 public:
31 Exception(const std::string &what)
32 : Rose::Exception(what) {}
33 ~Exception() throw () {}
34 };
35
42
48
55
57 enum IoMode { READ, WRITE };
58
60 enum MayOrMust { MAY, MUST };
61
63 typedef std::set<rose_addr_t> AddressSet;
64
71 struct Expression {
73 std::string parsable;
76 Expression() {}
77 /*implicit*/ Expression(const std::string &parsable): parsable(parsable) {}
78 /*implicit*/ Expression(const SymbolicExpressionPtr &expr): expr(expr) {}
79
80 void print(std::ostream&) const;
81 };
82
84 struct Settings {
85 // Path feasibility
90 size_t maxCallDepth;
92 std::vector<Expression> assertions;
93 std::vector<std::string> assertionLocations;
94 std::vector<rose_addr_t> summarizeFunctions;
96 std::string solverName;
103 std::vector<rose_addr_t> ipRewrite;
105 size_t maxExprSize;
108 // Null dereferences
109 struct NullDeref {
110 bool check;
113 rose_addr_t minValid;
115 NullDeref()
116 : check(false), mode(MUST), constOnly(false), minValid(1024) {}
119 std::string exprParserDoc;
128 };
129
144
147
156
171
174
179 public:
184
185 virtual ~PathProcessor() {}
186
203 virtual Action found(const FeasiblePath &analyzer, const Partitioner2::CfgPath &path,
205 const SmtSolverPtr &solver);
206
240 virtual Action nullDeref(const FeasiblePath &analyzer, const Partitioner2::CfgPath &path, SgAsmInstruction *insn,
243
283 virtual Action memoryIo(const FeasiblePath &analyzer, const Partitioner2::CfgPath &path, SgAsmInstruction *insn,
287 };
288
293 rose_addr_t address = 0;
294 int64_t stackDelta;
295 std::string name;
299
301 FunctionSummary(const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgFuncVertex, uint64_t stackDelta);
302 };
303
306
311 public:
314 protected:
316 public:
318 virtual void init(const FeasiblePath &analysis, FunctionSummary &summary /*in,out*/,
319 const Partitioner2::FunctionPtr &function,
320 Partitioner2::ControlFlowGraph::ConstVertexIterator cfgCallTarget) = 0;
321
326 virtual bool process(const FeasiblePath &analysis, const FunctionSummary &summary,
328
334 returnValue(const FeasiblePath &analysis, const FunctionSummary &summary,
336 };
337
339 // Private data members
341private:
342 Partitioner2::PartitionerConstPtr partitioner_; // binary analysis context, might be null
343 RegisterDictionaryPtr registers_; // registers augmented with "path" pseudo-register
344 RegisterDescriptor REG_RETURN_; // FIXME[Robb P Matzke 2016-10-11]: see source
345 Settings settings_;
346 FunctionSummaries functionSummaries_;
347 Partitioner2::CfgVertexMap vmap_; // relates CFG vertices to path vertices
348 Partitioner2::ControlFlowGraph paths_; // all possible paths, feasible or otherwise
349 Partitioner2::CfgConstVertexSet pathsBeginVertices_;// vertices of paths_ where searching starts
350 Partitioner2::CfgConstVertexSet pathsEndVertices_; // vertices of paths_ where searching stops
351 bool isDirectedSearch_ = true; // use pathsEndVertices_?
352 Partitioner2::CfgConstEdgeSet cfgAvoidEdges_; // CFG edges to avoid
353 Partitioner2::CfgConstVertexSet cfgEndAvoidVertices_;// CFG end-of-path and other avoidance vertices
354 FunctionSummarizer::Ptr functionSummarizer_; // user-defined function for handling function summaries
355 InstructionSemantics::BaseSemantics::StatePtr initialState_; // set by setInitialState.
356 static Sawyer::Attribute::Id POST_STATE; // stores semantic state after executing the insns for a vertex
357 static Sawyer::Attribute::Id POST_INSN_LENGTH; // path length in instructions at end of vertex
358 static Sawyer::Attribute::Id EFFECTIVE_K; // (double) effective maximimum path length
359
360 mutable SAWYER_THREAD_TRAITS::Mutex statsMutex_; // protects the following data member
361 Statistics stats_; // statistical results of the analysis
362
364 // Construction, destruction
366public:
369 virtual ~FeasiblePath();
370
372 void reset();
373
378 SAWYER_THREAD_TRAITS::LockGuard lock(statsMutex_);
379 stats_ = Statistics();
380 }
381
383 static void initDiagnostics();
384
385
387 // Settings affecting behavior
389public:
393 const Settings& settings() const { return settings_; }
394 Settings& settings() { return settings_; }
395 void settings(const Settings &s) { settings_ = s; }
403
405 static std::string expressionDocumentation();
406
407
409 // Overridable processing functions
411public:
419
426 virtual void
428 const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathsBeginVertex);
429
434 virtual void
436 const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu, size_t pathInsnIndex);
437
441 virtual void
442 processIndeterminateBlock(const Partitioner2::ControlFlowGraph::ConstVertexIterator &vertex,
444 size_t pathInsnIndex);
445
449 virtual void
450 processFunctionSummary(const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathsVertex,
452 size_t pathInsnIndex);
453
457 virtual void
459 const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathsVertex,
460 size_t pathInsnIndex);
461
463 virtual bool
464 shouldSummarizeCall(const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathVertex,
466 const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgCallTarget);
467
469 virtual bool
470 shouldInline(const Partitioner2::CfgPath &path, const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgCallTarget);
471
480 FunctionSummarizer::Ptr functionSummarizer() const { return functionSummarizer_; }
481 void functionSummarizer(const FunctionSummarizer::Ptr &f) { functionSummarizer_ = f; }
485 // Utilities
487public:
489 Partitioner2::ControlFlowGraph::ConstVertexIterator
490 pathToCfg(const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathVertex) const;
491
495
501
504
506 bool isFunctionCall(const Partitioner2::ControlFlowGraph::ConstVertexIterator&) const;
507
509 void printPathVertex(std::ostream &out, const Partitioner2::ControlFlowGraph::Vertex &pathVertex,
510 size_t &insnIdx /*in,out*/) const;
511
515 void printPath(std::ostream &out, const Partitioner2::CfgPath&) const;
516
522 const Partitioner2::ControlFlowGraph::ConstVertexIterator &beginVertex,
523 const Partitioner2::CfgConstVertexSet &endVertices);
524
526 // Functions for describing the search space
528public:
529
538 void
540 const Partitioner2::CfgConstVertexSet &cfgBeginVertices,
541 const Partitioner2::CfgConstVertexSet &cfgEndVertices,
544 void
546 const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgBeginVertex,
547 const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgEndVertex,
550 void
552 const Partitioner2::CfgConstVertexSet &cfgBeginVertices,
555 void
557 const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgBeginVertex,
567 bool isDirectedSearch() const {
568 return isDirectedSearch_;
569 }
570
572 // Functions for searching for paths
574public:
579 void depthFirstSearch(PathProcessor &pathProcessor);
580
581
583 // Functions for getting the results
585public:
591
596 return functionSummaries_;
597 }
598
603 const FunctionSummary& functionSummary(rose_addr_t entryVa) const;
604
606 const VarDetail& varDetail(const InstructionSemantics::BaseSemantics::StatePtr&, const std::string &varName) const;
607
610
613
616
623
630 static size_t pathLength(const Partitioner2::CfgPath&, int position = -1);
631
638 SAWYER_THREAD_TRAITS::LockGuard lock(statsMutex_);
639 return stats_;
640 }
641
643 // Private supporting functions
645private:
646 // Check that analysis settings are valid, or throw an exception.
647 void checkSettings() const;
648
649 static rose_addr_t virtualAddress(const Partitioner2::ControlFlowGraph::ConstVertexIterator &vertex);
650
651 void insertCallSummary(const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathsCallSite,
653 const Partitioner2::ControlFlowGraph::ConstEdgeIterator &cfgCallEdge);
654
655 boost::filesystem::path emitPathGraph(size_t callId, size_t graphId); // emit paths graph to "rose-debug" directory
656
657 // Pop an edge (or more) from the path and follow some other edge. Also, adjust the SMT solver's stack in a similar
658 // way. The SMT solver will have an initial state, plus one pushed state per edge of the path.
659 void backtrack(Partitioner2::CfgPath &path /*in,out*/, const SmtSolverPtr&);
660
661 // Process one edge of a path to find any path constraints. When called, the cpu's current state should be the virtual
662 // machine state at it exists just prior to executing the target vertex of the specified edge.
663 //
664 // Returns a null pointer if the edge's assertion is trivially unsatisfiable, such as when the edge points to a basic block
665 // whose address doesn't match the contents of the instruction pointer register after executing the edge's source
666 // block. Otherwise, returns a symbolic expression which must be tree if the edge is feasible. For trivially feasible
667 // edges, the return value is the constant 1 (one bit wide; i.e., true).
668 SymbolicExpressionPtr pathEdgeConstraint(const Partitioner2::ControlFlowGraph::ConstEdgeIterator &pathEdge,
670
671 // Parse the expression if it's a parsable string, otherwise return the expression as is. */
672 Expression parseExpression(Expression, const std::string &where, SymbolicExpressionParser&) const;
673
674 SymbolicExpressionPtr expandExpression(const Expression&, const SymbolicExpressionParser&);
675
676 // Based on the last vertex of the path, insert user-specified assertions into the SMT solver.
677 void insertAssertions(const SmtSolverPtr&, const Partitioner2::CfgPath&,
678 const std::vector<Expression> &assertions, bool atEndOfPath, const SymbolicExpressionParser&);
679
680 // Size of vertex. How much of "k" does this vertex consume?
681 static size_t vertexSize(const Partitioner2::ControlFlowGraph::ConstVertexIterator&);
682
683 // Information needed for adding user-supplied assertions to the solver.
684 struct Substitutions {
685 SymbolicExpressionParser exprParser;
686 std::vector<Expression> assertions;
689 };
690
691 // Insert the edge assertion and any applicable user assertions (after delayed expansion of the expressions' register
692 // and memory references), and run the solver, returning its result.
694 solvePathConstraints(const SmtSolverPtr&, const Partitioner2::CfgPath&, const SymbolicExpressionPtr &edgeAssertion,
695 const Substitutions&, bool atEndOfPath);
696
697 // Mark vertex as being reached
698 void markAsReached(const Partitioner2::ControlFlowGraph::ConstVertexIterator&);
699
700 // Top-level info for debugging
701 void dfsDebugHeader(Sawyer::Message::Stream &trace, Sawyer::Message::Stream &debug, size_t callId, size_t graphId);
702
703 // Top-level info for debugging a path.
704 void dfsDebugCurrentPath(Sawyer::Message::Stream&, const Partitioner2::CfgPath&, const SmtSolverPtr&, size_t effectiveK);
705
706 // Prepare substitutions for registers and memory based on user-supplied symbolic expressions.
707 Substitutions parseSubstitutions();
708
709 // Substitute registers and memory values into user-supplied symbolic expressions.
710 void makeSubstitutions(const Substitutions&, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&);
711
712 // Create an SMT solver. It will have an initial state plus, eventually, a transaction for each path edge.
713 SmtSolverPtr createSmtSolver();
714
715 // The parts of the instruction semantics framework
716 struct Semantics {
720 };
721
722 // Create the parts of the instruction semantics framework.
723 Semantics createSemantics(const Partitioner2::CfgPath&, PathProcessor&, const SmtSolverPtr&);
724
725 // Convert a position to an index. Negative positions measure from the end of the sequence so that -1 refers to the last
726 // element, -2 to the second-to-last element, etc. Non-negative positions are the same thing as an index. Returns nothing
727 // if the position is out of range.
728 static Sawyer::Optional<size_t> positionToIndex(int position, size_t nElmts);
729
730 // Obtain the incoming state for the specified path vertex. This is a pointer to the state, so copy it if you make changes.
731 // The incoming state for the first vertex is the specified initial state.
733 incomingState(const Partitioner2::CfgPath&, int position, const InstructionSemantics::BaseSemantics::StatePtr &initialState);
734
735 // Number of steps (e.g., instructions) up to but not including the specified path vertex.
736 size_t incomingStepCount(const Partitioner2::CfgPath&, int position);
737
738 // Number of steps (e.g., instructions) up to and including the specified path vertex.
739 size_t outgoingStepCount(const Partitioner2::CfgPath&, int position);
740
741 // Evaluate semantics up to and including the specified path vertex, returning the outgoing state for that vertex. If
742 // semantics fails, then returns a null state pointer.
743 InstructionSemantics::BaseSemantics::StatePtr evaluate(Partitioner2::CfgPath&, int position, const Semantics&);
744
745 // Check whether the last vertex of the path is feasible. Returns true if provably feasible, false if provably infeasible,
746 // or indeterminate if not provable one way or the other.
747 boost::logic::tribool isFeasible(Partitioner2::CfgPath&, const Substitutions&, const Semantics&, const SmtSolverPtr&);
748
749 // Safely call the path processor's "found" action for the path's final vertex and return its value.
750 PathProcessor::Action callPathProcessorFound(PathProcessor&, Partitioner2::CfgPath&, const Semantics&, const SmtSolverPtr&);
751
752 // Given an effective K value, adjust it based on how often the last vertex of the path has been visited. Returns a new
753 // effective K. As a special case, the new K is zero if the last vertex has been visited too often.
754 double adjustEffectiveK(Partitioner2::CfgPath&, double oldK);
755
756 // Given a path that ends with a function call, inline the function or a summary of the function, adjusting the paths_
757 // control flow graph.
758 void summarizeOrInline(Partitioner2::CfgPath&, const Semantics&);
759};
760
761} // namespace
762} // namespace
763
764std::ostream& operator<<(std::ostream&, const Rose::BinaryAnalysis::FeasiblePath::Expression&);
765
766// Convert string to feasible path expression during command-line parsing
767namespace Sawyer {
768 namespace CommandLine {
769 template<>
770 struct LexicalCast<Rose::BinaryAnalysis::FeasiblePath::Expression> {
771 static Rose::BinaryAnalysis::FeasiblePath::Expression convert(const std::string &src) {
773 }
774 };
775 }
776}
777
778#endif
779#endif
Exception for errors specific to feasible path analysis.
Base class for callbacks for function summaries.
virtual InstructionSemantics::SymbolicSemantics::SValuePtr returnValue(const FeasiblePath &analysis, const FunctionSummary &summary, const InstructionSemantics::SymbolicSemantics::RiscOperatorsPtr &ops)=0
Return value for function.
virtual void init(const FeasiblePath &analysis, FunctionSummary &summary, const Partitioner2::FunctionPtr &function, Partitioner2::ControlFlowGraph::ConstVertexIterator cfgCallTarget)=0
Invoked when a new summary is created.
Sawyer::SharedPointer< FunctionSummarizer > Ptr
Reference counting pointer.
virtual bool process(const FeasiblePath &analysis, const FunctionSummary &summary, const InstructionSemantics::SymbolicSemantics::RiscOperatorsPtr &ops)=0
Invoked when the analysis traverses the summary.
virtual Action memoryIo(const FeasiblePath &analyzer, const Partitioner2::CfgPath &path, SgAsmInstruction *insn, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &cpu, const SmtSolverPtr &solver, IoMode ioMode, const InstructionSemantics::BaseSemantics::SValuePtr &addr, const InstructionSemantics::BaseSemantics::SValuePtr &value)
Function invoked every time a memory reference occurs.
@ BREAK
Do not continue along this path.
virtual Action nullDeref(const FeasiblePath &analyzer, const Partitioner2::CfgPath &path, SgAsmInstruction *insn, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &cpu, const SmtSolverPtr &solver, IoMode ioMode, const InstructionSemantics::BaseSemantics::SValuePtr &addr)
Function invoked whenever a null pointer dereference is detected.
virtual Action found(const FeasiblePath &analyzer, const Partitioner2::CfgPath &path, const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu, const SmtSolverPtr &solver)
Function invoked whenever a complete path is found.
Feasible path analysis.
Statistics statistics() const
Cumulative statistics about prior analyses.
RegisterDescriptor REG_PATH
Descriptor of path pseudo-registers.
static Sawyer::CommandLine::SwitchGroup commandLineSwitches(Settings &settings)
Describe command-line switches.
void settings(const Settings &s)
Property: Settings used by this analysis.
IoMode
Read or write operation.
void setSearchBoundary(const Partitioner2::PartitionerConstPtr &partitioner, const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgBeginVertex, const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgEndVertex, const Partitioner2::CfgConstVertexSet &cfgAvoidVertices=Partitioner2::CfgConstVertexSet(), const Partitioner2::CfgConstEdgeSet &cfgAvoidEdges=Partitioner2::CfgConstEdgeSet())
Specify search boundary.
void setSearchBoundary(const Partitioner2::PartitionerConstPtr &partitioner, const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgBeginVertex, const Partitioner2::CfgConstVertexSet &cfgAvoidVertices=Partitioner2::CfgConstVertexSet(), const Partitioner2::CfgConstEdgeSet &cfgAvoidEdges=Partitioner2::CfgConstEdgeSet())
Specify search boundary.
Partitioner2::CfgConstVertexSet cfgToPaths(const Partitioner2::CfgConstVertexSet &) const
Convert CFG vertices to path vertices.
FeasiblePath()
Constructs a new feasible path analyzer.
bool isFunctionCall(const Partitioner2::ControlFlowGraph::ConstVertexIterator &) const
True if vertex is a function call.
double pathEffectiveK(const Partitioner2::CfgPath &) const
Effective maximum path length.
Sawyer::Container::Map< std::string, FeasiblePath::VarDetail > VarDetails
Variable detail by name.
void resetStatistics()
Reset only statistics.
virtual InstructionSemantics::BaseSemantics::DispatcherPtr buildVirtualCpu(const Partitioner2::PartitionerConstPtr &, const Partitioner2::CfgPath *, PathProcessor *, const SmtSolverPtr &)
Create the virtual CPU.
EdgeVisitOrder
Edge visitation order.
@ VISIT_NATURAL
Visit edges in their natural, forward order.
@ VISIT_RANDOM
Visit edges in random order.
@ VISIT_REVERSE
Visit edges in reverse of the natural order.
void setSearchBoundary(const Partitioner2::PartitionerConstPtr &partitioner, const Partitioner2::CfgConstVertexSet &cfgBeginVertices, const Partitioner2::CfgConstVertexSet &cfgEndVertices, const Partitioner2::CfgConstVertexSet &cfgAvoidVertices=Partitioner2::CfgConstVertexSet(), const Partitioner2::CfgConstEdgeSet &cfgAvoidEdges=Partitioner2::CfgConstEdgeSet())
Specify search boundary.
const VarDetail & varDetail(const InstructionSemantics::BaseSemantics::StatePtr &, const std::string &varName) const
Details about a variable.
virtual bool shouldInline(const Partitioner2::CfgPath &path, const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgCallTarget)
Determines whether a function call should be inlined.
bool isDirectedSearch() const
Property: Whether search is directed or not.
const FunctionSummaries & functionSummaries() const
Function summary information.
virtual void processVertex(const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu, const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathsVertex, size_t pathInsnIndex)
Process one vertex.
static InstructionSemantics::BaseSemantics::StatePtr pathPostState(const Partitioner2::CfgPath &, size_t vertexIdx)
Get the state at the end of the specified vertex.
virtual bool shouldSummarizeCall(const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathVertex, const Partitioner2::ControlFlowGraph &cfg, const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgCallTarget)
Determines whether a function call should be summarized instead of inlined.
Partitioner2::CfgConstEdgeSet cfgToPaths(const Partitioner2::CfgConstEdgeSet &) const
Convert CFG edges to path edges.
bool isAnyEndpointReachable(const Partitioner2::ControlFlowGraph &cfg, const Partitioner2::ControlFlowGraph::ConstVertexIterator &beginVertex, const Partitioner2::CfgConstVertexSet &endVertices)
Determine whether any ending vertex is reachable.
void depthFirstSearch(PathProcessor &pathProcessor)
Find all feasible paths.
virtual void processFunctionSummary(const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathsVertex, const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu, size_t pathInsnIndex)
Process a function summary vertex.
Partitioner2::PartitionerConstPtr partitioner() const
Property: Partitioner currently in use.
static std::string expressionDocumentation()
Documentation for the symbolic expression parser.
FunctionSummarizer::Ptr functionSummarizer() const
Property: Function summary handling.
static Sawyer::Message::Facility mlog
Diagnostic output.
InstructionSemantics::BaseSemantics::StatePtr initialState() const
Get the initial state before the first path vertex.
void printPathVertex(std::ostream &out, const Partitioner2::ControlFlowGraph::Vertex &pathVertex, size_t &insnIdx) const
Print one vertex of a path for debugging.
virtual void setInitialState(const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu, const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathsBeginVertex)
Initialize state for first vertex of path.
Partitioner2::ControlFlowGraph::ConstVertexIterator pathToCfg(const Partitioner2::ControlFlowGraph::ConstVertexIterator &pathVertex) const
Convert path vertex to a CFG vertex.
const VarDetails & varDetails(const InstructionSemantics::BaseSemantics::StatePtr &) const
Details about all variables by name.
void functionSummarizer(const FunctionSummarizer::Ptr &f)
Property: Function summary handling.
void setSearchBoundary(const Partitioner2::PartitionerConstPtr &partitioner, const Partitioner2::CfgConstVertexSet &cfgBeginVertices, const Partitioner2::CfgConstVertexSet &cfgAvoidVertices=Partitioner2::CfgConstVertexSet(), const Partitioner2::CfgConstEdgeSet &cfgAvoidEdges=Partitioner2::CfgConstEdgeSet())
Specify search boundary.
SemanticMemoryParadigm
Organization of semantic memory.
@ MAP_BASED_MEMORY
Fast but not precise.
@ LIST_BASED_MEMORY
Precise but slow.
virtual void processBasicBlock(const Partitioner2::BasicBlockPtr &bblock, const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu, size_t pathInsnIndex)
Process instructions for one basic block on the specified virtual CPU.
static size_t pathLength(const Partitioner2::CfgPath &, int position=-1)
Total length of path up to and including the specified vertex.
Settings & settings()
Property: Settings used by this analysis.
static void initDiagnostics()
Initialize diagnostic output.
SearchMode
How to search for paths.
@ SEARCH_SINGLE_DFS
Perform a depth first search.
@ SEARCH_SINGLE_BFS
Perform a breadth first search.
@ SEARCH_MULTI
Blast everything at once to the SMT solver.
const Settings & settings() const
Property: Settings used by this analysis.
bool pathEndsWithFunctionCall(const Partitioner2::CfgPath &) const
True if path ends with a function call.
const FunctionSummary & functionSummary(rose_addr_t entryVa) const
Function summary information.
Sawyer::Container::Map< rose_addr_t, FunctionSummary > FunctionSummaries
Summaries for multiple functions.
std::set< rose_addr_t > AddressSet
Set of basic block addresses.
virtual void processIndeterminateBlock(const Partitioner2::ControlFlowGraph::ConstVertexIterator &vertex, const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu, size_t pathInsnIndex)
Process an indeterminate block.
void reset()
Reset to initial state without changing settings.
void printPath(std::ostream &out, const Partitioner2::CfgPath &) const
Print the path to the specified output stream.
A path through a control flow graph.
Definition CfgPath.h:17
Describes (part of) a physical CPU register.
Satisfiable
Satisfiability constants.
Definition SmtSolver.h:87
Base class for all ROSE exceptions.
A collection of related switch declarations.
Container associating values with keys.
Definition Sawyer/Map.h:72
Collection of streams.
Definition Message.h:1606
Converts text to messages.
Definition Message.h:1396
Holds a value or nothing.
Definition Optional.h:56
Base class for reference counted objects.
Base class for machine instructions.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to symbolic RISC operations.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.
The ROSE library.
const size_t UNLIMITED
Effectively unlimited size.
Definition Constants.h:19
size_t Id
Attribute identification.
Definition Attribute.h:140
Sawyer support library.
SymbolicExpressionPtr expr
Symbolic expression.
AddressIntervalSet location
Location where constraint applies.
std::string parsable
String to be parsed as an expression.
Information stored per V_USER_DEFINED path vertex.
FunctionSummary()
Construct empty function summary.
std::string name
Name of summarized function.
FunctionSummary(const Partitioner2::ControlFlowGraph::ConstVertexIterator &cfgFuncVertex, uint64_t stackDelta)
Construct function summary with information.
int64_t stackDelta
Stack delta for summarized function.
rose_addr_t address
Address of summarized function.
rose_addr_t minValid
Minnimum address that is not treated as a null dereference.
bool constOnly
If true, check only constants or sets of constants.
MayOrMust mode
Check for addrs that may or must be null.
bool check
If true, look for null dereferences along the paths.
Settings that control this analysis.
struct Rose::BinaryAnalysis::FeasiblePath::Settings::NullDeref nullDeref
Settings for null-dereference analysis.
std::vector< rose_addr_t > summarizeFunctions
Functions to always summarize.
size_t maxPathLength
Limit path length in terms of number of instructions.
Sawyer::Optional< boost::chrono::duration< double > > smtTimeout
Max seconds allowed per SMT solve call.
SearchMode searchMode
Method to use when searching for feasible paths.
size_t maxVertexVisit
Max times to visit a particular vertex in one path.
Sawyer::Optional< rose_addr_t > initialStackPtr
Concrete value to use for stack pointer register initial value.
std::vector< std::string > assertionLocations
Locations at which "constraints" are checked.
bool processFinalVertex
Whether to process the last vertex of the path.
size_t maxCallDepth
Max length of path in terms of function calls.
bool ignoreSemanticFailure
Whether to ignore instructions with no semantic info.
std::vector< rose_addr_t > ipRewrite
An even number of from,to pairs for rewriting the insn ptr reg.
bool traceSemantics
Trace all instruction semantics operations.
bool nonAddressIsFeasible
Indeterminate/undiscovered vertices are feasible?
double kCycleCoefficient
Coefficient for adjusting maxPathLengh during CFG cycles.
SemanticMemoryParadigm memoryParadigm
Type of memory state when there's a choice to be made.
size_t maxRecursionDepth
Max path length in terms of recursive function calls.
std::string solverName
Type of SMT solver.
std::vector< Expression > assertions
Constraints to be satisfied at some point along the path.
bool trackingCodeCoverage
If set, track which block addresses are reached.
EdgeVisitOrder edgeVisitOrder
Order in which to visit edges.
size_t maxExprSize
Maximum symbolic expression size before replacement.
std::string exprParserDoc
String documenting how expressions are parsed, empty for default.
size_t maxPathLengthHits
Number of times settings.maxPathLength was hit (effective K).
size_t maxVertexVisitHits
Number of times settings.maxVertexVisit was hit.
size_t nPathsExplored
Number of paths explored.
size_t maxCallDepthHits
Number of times settings.maxCallDepth was hit.
Sawyer::Container::Map< rose_addr_t, size_t > reachedBlockVas
Number of times each basic block was reached.
size_t maxRecursionDepthHits
Number of times settings.maxRecursionDepth was hit.
Information about a variable seen on a path.
Sawyer::Optional< size_t > firstAccessIdx
Instruction position in path where this var was first read.
std::string firstAccessMode
How was variable first accessed ("read" or "write").
SymbolicExpressionPtr memAddress
Address where variable is located.
size_t memSize
Size of total memory access in bytes.
Sawyer::Optional< rose_addr_t > returnFrom
This variable is the return value from the specified function.
size_t memByteNumber
Byte number for memory access.
SgAsmInstruction * firstAccessInsn
Instruction address where this var was first read.