ROSE 0.11.145.192
ReturnValueUsed.h
1#ifndef ROSE_BinaryAnalysis_ReturnValueUsed_H
2#define ROSE_BinaryAnalysis_ReturnValueUsed_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/CallingConvention/BasicTypes.h>
7#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
8#include <Rose/BinaryAnalysis/Partitioner2/ControlFlowGraph.h>
9#include <Rose/BinaryAnalysis/RegisterParts.h>
10
11namespace Rose {
12namespace BinaryAnalysis {
13
17namespace ReturnValueUsed {
18
23
28
30// Miscellaneous small types
32
34 bool didConverge_; // Are the following data members valid (else only approximations)?
35 std::vector<Partitioner2::FunctionPtr> callees_;
36 RegisterParts returnRegistersUsed_;
37 RegisterParts returnRegistersUnused_;
38
39#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
40private:
41 friend class boost::serialization::access;
42
43 template<class S>
44 void serialize(S & s, const unsigned /*version*/) {
45 s & BOOST_SERIALIZATION_NVP(didConverge_);
46 s & BOOST_SERIALIZATION_NVP(callees_);
47 s & BOOST_SERIALIZATION_NVP(returnRegistersUsed_);
48 s & BOOST_SERIALIZATION_NVP(returnRegistersUnused_);
49 }
50#endif
51
52public:
55
63 bool didConverge() const;
64 void didConverge(bool);
68 const std::vector<Partitioner2::FunctionPtr> callees() const;
69
90private:
91 friend class Analysis;
92 void callees(const std::vector<Partitioner2::FunctionPtr>&);
93};
94
96// Main analysis class
98
99class Analysis {
100private:
101 typedef Sawyer::Container::Map<rose_addr_t /*call_site*/, CallSiteResults> CallSiteMap;
102
103private:
104 CallingConvention::Definition::Ptr defaultCallingConvention_;
105 CallSiteMap callSites_;
106 bool assumeCallerReturnsValue_;
107
108#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
109private:
110 friend class boost::serialization::access;
111
112 template<class S>
113 void serialize(S &s, const unsigned /*version*/) {
114 s & BOOST_SERIALIZATION_NVP(defaultCallingConvention_);
115 s & BOOST_SERIALIZATION_NVP(callSites_);
116 s & BOOST_SERIALIZATION_NVP(assumeCallerReturnsValue_);
117 }
118#endif
119
120public:
127
128 ~Analysis();
129
184
187 const Partitioner2::ControlFlowGraph::ConstVertexIterator&);
188
189private:
190 // Given a control flow graph vertex, if that vertex is a function call basic block then return a list of the known, called
191 // functions.
192 std::vector<Partitioner2::FunctionPtr>
193 findCallees(const Partitioner2::PartitionerConstPtr&, const Partitioner2::ControlFlowGraph::ConstVertexIterator &callSite);
194
195 // Given a control flow graph vertex, if that vertex is a function call basic block then return a list of all vertices that
196 // are known call-return points for that call.
197 std::vector<Partitioner2::ControlFlowGraph::ConstVertexIterator>
198 findReturnTargets(const Partitioner2::PartitionerConstPtr&,
199 const Partitioner2::ControlFlowGraph::ConstVertexIterator &callSite);
200};
201
202} // namespace
203} // namespace
204} // namespace
205
206#endif
207#endif
Holds a set of registers without regard for register boundaries.
bool assumeCallerReturnsValue() const
Property: Assume caller returns value(s).
CallingConvention::Definition::Ptr defaultCallingConvention() const
Property: Default calling convention.
CallSiteResults analyzeCallSite(const Partitioner2::PartitionerConstPtr &, const Partitioner2::ControlFlowGraph::ConstVertexIterator &)
Analyze a call site to see if a function's return value is used.
void assumeCallerReturnsValue(bool)
Property: Assume caller returns value(s).
void defaultCallingConvention(const CallingConvention::DefinitionPtr &)
Property: Default calling convention.
void clearResults()
Clear analysis results.
RegisterParts & returnRegistersUnused()
Property: Return registers that are unused in the caller.
const RegisterParts & returnRegistersUsed() const
Property: Return registers that are used in the caller.
RegisterParts & returnRegistersUsed()
Property: Return registers that are used in the caller.
const RegisterParts & returnRegistersUnused() const
Property: Return registers that are unused in the caller.
bool didConverge() const
Property: Did the analysis converge to a solution.
const std::vector< Partitioner2::FunctionPtr > callees() const
Property: Functions called at this site.
void returnRegistersUsed(const RegisterParts &)
Property: Return registers that are used in the caller.
void didConverge(bool)
Property: Did the analysis converge to a solution.
void returnRegistersUnused(const RegisterParts &)
Property: Return registers that are unused in the caller.
Container associating values with keys.
Definition Sawyer/Map.h:72
Collection of streams.
Definition Message.h:1606
void initDiagnostics()
Initialize diagnostics.
Sawyer::Message::Facility mlog
Facility for diagnostic output.
The ROSE library.