ROSE 0.11.145.147
Configuration.h
1#ifndef ROSE_BinaryAnalysis_Partitioner2_Configuration_H
2#define ROSE_BinaryAnalysis_Partitioner2_Configuration_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
6
7#include <Rose/FileSystem.h>
8#include <Sawyer/Map.h>
9#include <Sawyer/Optional.h>
10#include <Rose/SourceLocation.h>
11#include <set>
12#include <string>
13
14namespace Rose {
15namespace BinaryAnalysis {
16namespace Partitioner2 {
17
20 rose_addr_t address_ = 0;
21 std::string comment_;
23 std::set<rose_addr_t> successorVas_;
24 SourceLocation sourceLocation_;
25
26public:
27 // default constructor needed by some STL containers
29
31 explicit BasicBlockConfiguration(rose_addr_t va): address_(va) {}
32
36 rose_addr_t address() const { return address_; }
37
43 const std::string& comment() const { return comment_; }
44 BasicBlockConfiguration& comment(const std::string &s) { comment_ = s; return *this; }
50 const SourceLocation& sourceLocation() const { return sourceLocation_; }
51 BasicBlockConfiguration& sourceLocation(const SourceLocation &loc) { sourceLocation_ = loc; return *this; }
61 Sawyer::Optional<rose_addr_t> finalInstructionVa() const { return finalInsnVa_; }
62 BasicBlockConfiguration& finalInstructionVa(const Sawyer::Optional<rose_addr_t> &va) { finalInsnVa_ = va; return *this; }
72 const std::set<rose_addr_t>& successorVas() const { return successorVas_; }
73 std::set<rose_addr_t>& successorVas() { return successorVas_; }
74 BasicBlockConfiguration& successorVas(const std::set<rose_addr_t> &vas) { successorVas_ = vas; return *this; }
75 BasicBlockConfiguration& insertSuccessorVa(rose_addr_t va) { successorVas_.insert(va); return *this; }
76 BasicBlockConfiguration& clearSuccessorVas() { successorVas_.clear(); return *this; }
78};
79
80
83 rose_addr_t address_;
84 std::string name_;
85 std::string comment_;
86 SourceLocation sourceLocation_;
87
88public:
89 // Default constructor needed by some STL containers
90 DataBlockConfiguration(): address_(0) {}
91
93 explicit DataBlockConfiguration(rose_addr_t va): address_(va) {}
94
98 rose_addr_t address() const { return address_; }
99
105 const std::string &name() const { return name_; }
106 DataBlockConfiguration& name(const std::string &s) { name_ = s; return *this; }
114 const std::string& comment() const { return comment_; }
115 DataBlockConfiguration& comment(const std::string &s) { comment_ = s; return *this; }
121 const SourceLocation& sourceLocation() const { return sourceLocation_; }
122 DataBlockConfiguration& sourceLocation(const SourceLocation &loc) { sourceLocation_ = loc; return *this; }
124};
125
126
130 std::string name_, defaultName_, comment_;
131 Sawyer::Optional<int64_t> stackDelta_;
132 Sawyer::Optional<bool> mayReturn_;
133 SourceLocation sourceLocation_;
134
135public:
136 // default constructor needed by some STL containers
138
142 explicit FunctionConfiguration(rose_addr_t va, const std::string &name=""): address_(va), name_(name) {}
143 explicit FunctionConfiguration(const std::string &name): name_(name) {}
144 FunctionConfiguration(const Sawyer::Optional<rose_addr_t> &va, const std::string &name): address_(va), name_(name) {}
162 Sawyer::Optional<rose_addr_t> address() const { return address_; }
163
172 const std::string& name() const { return name_; }
173 FunctionConfiguration& name(const std::string &s);
181 const std::string& defaultName() const { return defaultName_; }
182 FunctionConfiguration& defaultName(const std::string &s) { defaultName_ = s; return *this; }
190 const std::string& comment() const { return comment_; }
191 FunctionConfiguration& comment(const std::string &s) { comment_ = s; return *this; }
197 const SourceLocation& sourceLocation() const { return sourceLocation_; }
198 FunctionConfiguration& sourceLocation(const SourceLocation &loc) { sourceLocation_ = loc; return *this; }
216 Sawyer::Optional<int64_t> stackDelta() const { return stackDelta_; }
217 FunctionConfiguration& stackDelta(const Sawyer::Optional<int64_t> &n) { stackDelta_ = n; return *this; }
231 Sawyer::Optional<bool> mayReturn() const { return mayReturn_; }
232 FunctionConfiguration& mayReturn(const Sawyer::Optional<bool> &b) { mayReturn_ = b; return *this; }
234};
235
240 rose_addr_t address_ = 0;
241 std::string name_;
242 std::string comment_;
243 SourceLocation sourceLocation_;
244
245public:
246 // Default constructor needed by STL containers
248
250 explicit AddressConfiguration(rose_addr_t va)
251 : address_(va) {}
252
256 rose_addr_t address() const { return address_; }
257
261 const std::string &name() const { return name_; }
262 AddressConfiguration& name(const std::string &s) { name_ = s; return *this; }
268 const std::string &comment() const { return comment_; }
269 AddressConfiguration& comment(const std::string &s) { comment_ = s; return *this; }
275 const SourceLocation& sourceLocation() const { return sourceLocation_; }
276 AddressConfiguration& sourceLocation(const SourceLocation &loc) { sourceLocation_ = loc; return *this; }
278};
279
282public:
288
289private:
290 BasicBlockConfigurations bblockConfigurations_;
291 DataBlockConfigurations dblockConfigurations_;
292 FunctionConfigurationsByAddress functionConfigurationsByAddress_;
293 FunctionConfigurationsByName functionConfigurationsByName_;
294 AddressConfigurations addressConfigurations_;
295
296public:
298 static std::string fileFormatDoc();
299
301 void loadFromFile(const FileSystem::Path &fileName);
302
306 const BasicBlockConfigurations& basicBlocks() const { return bblockConfigurations_; }
307 BasicBlockConfigurations& basicBlocks() { return bblockConfigurations_; }
314 const BasicBlockConfiguration& basicBlock(rose_addr_t) const;
315
319 const DataBlockConfigurations& dataBlocks() const { return dblockConfigurations_; }
320 DataBlockConfigurations& dataBlocks() { return dblockConfigurations_; }
327 const DataBlockConfiguration& dataBlock(rose_addr_t) const;
328
332 const FunctionConfigurationsByAddress& functionConfigurationsByAddress() const { return functionConfigurationsByAddress_; }
333 FunctionConfigurationsByAddress& functionConfigurationsByAddress() { return functionConfigurationsByAddress_; }
339 const FunctionConfigurationsByName& functionConfigurationsByName() const { return functionConfigurationsByName_; }
340 FunctionConfigurationsByName& functionConfigurationsByName() { return functionConfigurationsByName_; }
349 const FunctionConfiguration& function(rose_addr_t) const;
350 const FunctionConfiguration& function(const std::string &name) const;
356 const AddressConfigurations& addresses() const { return addressConfigurations_; }
357 AddressConfigurations& addresses() { return addressConfigurations_; }
363 const AddressConfiguration& address(rose_addr_t) const;
364
369
374
380 FunctionConfiguration& insertMaybeFunction(rose_addr_t va, const std::string &name="");
388
394
400
406
412
418 std::string basicBlockComment(rose_addr_t bblockVa) const;
419
425
430 std::set<rose_addr_t> basicBlockSuccessorVas(rose_addr_t bblockVa) const;
431
435 std::string dataBlockName(rose_addr_t dblockVa) const;
436
442 std::string dataBlockComment(rose_addr_t dblockVa) const;
443
449 std::string functionName(rose_addr_t functionVa) const;
450
456 std::string functionDefaultName(rose_addr_t functionVa) const;
457
467 std::string functionComment(rose_addr_t functionVa) const;
468 std::string functionComment(const std::string &functionName) const;
469 std::string functionComment(const FunctionPtr&) const;
479 Sawyer::Optional<int64_t> functionStackDelta(rose_addr_t functionVa) const;
495 Sawyer::Optional<bool> functionMayReturn(rose_addr_t functionVa) const;
505 std::string addressComment(rose_addr_t va) const;
506
512 std::string comment(rose_addr_t va) const;
513
515 void print(std::ostream&) const;
516};
517
518} // namespace
519} // namespace
520} // namespace
521
522std::ostream& operator<<(std::ostream&, const Rose::BinaryAnalysis::Partitioner2::Configuration&);
523
524#endif
525#endif
Configuration for individual addresses.
rose_addr_t address() const
Property: address.
AddressConfiguration & comment(const std::string &s)
Property: comment string.
AddressConfiguration & name(const std::string &s)
Property: name.
AddressConfiguration & sourceLocation(const SourceLocation &loc)
Property: Location of address within source code.
const std::string & comment() const
Property: comment string.
AddressConfiguration(rose_addr_t va)
Construct a new address configuration object.
const std::string & name() const
Property: name.
const SourceLocation & sourceLocation() const
Property: Location of address within source code.
Configuration information for a basic block.
const std::string & comment() const
Property: comment.
BasicBlockConfiguration & insertSuccessorVa(rose_addr_t va)
Property: control flow successors.
BasicBlockConfiguration & clearSuccessorVas()
Property: control flow successors.
BasicBlockConfiguration & sourceLocation(const SourceLocation &loc)
Property: location of basic block in source code.
Sawyer::Optional< rose_addr_t > finalInstructionVa() const
Property: last instruction.
BasicBlockConfiguration & successorVas(const std::set< rose_addr_t > &vas)
Property: control flow successors.
std::set< rose_addr_t > & successorVas()
Property: control flow successors.
const std::set< rose_addr_t > & successorVas() const
Property: control flow successors.
BasicBlockConfiguration & comment(const std::string &s)
Property: comment.
rose_addr_t address() const
Property: starting address.
BasicBlockConfiguration & finalInstructionVa(const Sawyer::Optional< rose_addr_t > &va)
Property: last instruction.
BasicBlockConfiguration(rose_addr_t va)
Configuration information for a basic block.
const SourceLocation & sourceLocation() const
Property: location of basic block in source code.
bool insertConfiguration(const BasicBlockConfiguration &)
Insert basic block configuration information.
Sawyer::Optional< int64_t > functionStackDelta(const std::string &functionName) const
Function stack delta.
std::string dataBlockName(rose_addr_t dblockVa) const
Data block name.
std::string addressComment(rose_addr_t va) const
Address comment.
const FunctionConfigurationsByName & functionConfigurationsByName() const
All function configuration details for configs that have no address.
FunctionConfiguration & insertMaybeFunction(rose_addr_t va, const std::string &name="")
Lookup or insert a function.
FunctionConfigurationsByName & functionConfigurationsByName()
All function configuration details for configs that have no address.
bool insertConfiguration(const AddressConfiguration &)
Insert address configuration information.
DataBlockConfiguration & insertMaybeDataBlock(rose_addr_t va)
Lookup or insert a data block.
const FunctionConfigurationsByAddress & functionConfigurationsByAddress() const
All function configuration details for function configs that have addresses.
std::string basicBlockComment(rose_addr_t bblockVa) const
Basic block comment.
const AddressConfigurations & addresses() const
All address configuration details.
BasicBlockConfigurations & basicBlocks()
All basic block configuration details.
DataBlockConfigurations & dataBlocks()
All data block configuration details.
const DataBlockConfiguration & dataBlock(rose_addr_t) const
Configuration for a particular data block.
std::string functionDefaultName(rose_addr_t functionVa) const
Function default name.
bool insertConfiguration(const FunctionConfiguration &)
Insert function configuration information.
void loadFromFile(const FileSystem::Path &fileName)
Loads configuration from a file.
Sawyer::Optional< int64_t > functionStackDelta(rose_addr_t functionVa) const
Function stack delta.
AddressConfigurations & addresses()
All address configuration details.
std::string functionComment(const std::string &functionName) const
Function comment.
Sawyer::Optional< bool > functionMayReturn(rose_addr_t functionVa) const
Function may-return status.
FunctionConfigurationsByAddress & functionConfigurationsByAddress()
All function configuration details for function configs that have addresses.
std::string comment(rose_addr_t va) const
Address comment.
const AddressConfiguration & address(rose_addr_t) const
Configuration for a particular address.
const DataBlockConfigurations & dataBlocks() const
All data block configuration details.
BasicBlockConfiguration & insertMaybeBasicBlock(rose_addr_t va)
Lookup or insert a basic block.
Sawyer::Optional< bool > functionMayReturn(const FunctionPtr &) const
Function may-return status.
std::string dataBlockComment(rose_addr_t dblockVa) const
Data block comment.
static std::string fileFormatDoc()
Documentation string describing the file format.
bool insertConfiguration(const DataBlockConfiguration &)
Insert data block configuration information.
const FunctionConfiguration & function(rose_addr_t) const
Configuration for a particular function.
AddressConfiguration & insertMaybeAddress(rose_addr_t va)
Lookup or insert address details.
Sawyer::Optional< int64_t > functionStackDelta(const FunctionPtr &) const
Function stack delta.
const BasicBlockConfigurations & basicBlocks() const
All basic block configuration details.
std::set< rose_addr_t > basicBlockSuccessorVas(rose_addr_t bblockVa) const
Basic block successor addresses.
const BasicBlockConfiguration & basicBlock(rose_addr_t) const
Configuration for a particular basic block.
std::string functionComment(const FunctionPtr &) const
Function comment.
void print(std::ostream &) const
Generate a YAML file.
Sawyer::Optional< rose_addr_t > basicBlockFinalInstructionVa(rose_addr_t bblockVa) const
Basic block final instruction address.
const FunctionConfiguration & function(const std::string &name) const
Configuration for a particular function.
FunctionConfiguration & insertMaybeFunction(const std::string &name)
Lookup or insert a function.
Sawyer::Optional< bool > functionMayReturn(const std::string &functionName) const
Function may-return status.
std::string functionComment(rose_addr_t functionVa) const
Function comment.
std::string functionName(rose_addr_t functionVa) const
Function name.
Configuration information for a data block.
const SourceLocation & sourceLocation() const
Property: Location of data block in source code.
DataBlockConfiguration & name(const std::string &s)
Property: name.
rose_addr_t address() const
Property: starting address.
const std::string & name() const
Property: name.
DataBlockConfiguration(rose_addr_t va)
Configuration information for a data block.
DataBlockConfiguration & sourceLocation(const SourceLocation &loc)
Property: Location of data block in source code.
const std::string & comment() const
Property: comment.
DataBlockConfiguration & comment(const std::string &s)
Property: comment.
Configuration information for a function.
FunctionConfiguration & defaultName(const std::string &s)
Property: default name.
const SourceLocation & sourceLocation() const
Property: Location of function in source code.
FunctionConfiguration & stackDelta(const Sawyer::Optional< int64_t > &n)
Property: stack delta.
const std::string & name() const
Property: name.
FunctionConfiguration(const std::string &name)
Configuration information for a function.
FunctionConfiguration & name(const std::string &s)
Property: name.
Sawyer::Optional< rose_addr_t > address() const
Property: address.
const std::string & defaultName() const
Property: default name.
const std::string & comment() const
Property: comment.
FunctionConfiguration & comment(const std::string &s)
Property: comment.
FunctionConfiguration & mayReturn(const Sawyer::Optional< bool > &b)
Property: may-return.
FunctionConfiguration & sourceLocation(const SourceLocation &loc)
Property: Location of function in source code.
FunctionConfiguration(const Sawyer::Optional< rose_addr_t > &va, const std::string &name)
Configuration information for a function.
FunctionConfiguration(rose_addr_t va, const std::string &name="")
Configuration information for a function.
Sawyer::Optional< bool > mayReturn() const
Property: may-return.
Sawyer::Optional< int64_t > stackDelta() const
Property: stack delta.
Information about a source location.
Container associating values with keys.
Definition Sawyer/Map.h:72
Holds a value or nothing.
Definition Optional.h:56
boost::filesystem::path Path
Name of entities in a filesystem.
The ROSE library.