1 #ifndef ROSE_BinaryAnalysis_Partitioner2_Engine_H
2 #define ROSE_BinaryAnalysis_Partitioner2_Engine_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/Partitioner2/Exception.h>
8 #include <Rose/BinaryAnalysis/Partitioner2/Modules.h>
9 #include <Rose/BinaryAnalysis/SerialIo.h>
11 #include <Sawyer/DistinctList.h>
12 #include <Sawyer/SharedObject.h>
13 #include <Sawyer/SharedPointer.h>
16 namespace BinaryAnalysis {
17 namespace Partitioner2 {
176 friend class boost::serialization::access;
179 void serialize(S &s,
unsigned version) {
213 virtual std::vector<std::string>
specimen(
const std::vector<std::string>&)
const = 0;
219 virtual std::vector<std::string>
specimen(
const std::vector<std::string>&)
const override;
228 virtual std::vector<std::string>
specimen(
const std::vector<std::string>&)
const override;
239 virtual std::vector<std::string>
specimen(
const std::vector<std::string>&)
const override;
254 static Ptr instance();
257 void fixFunctionReturnEdge(
const Args&);
258 void fixFunctionCallEdges(
const Args&);
259 void addPossibleIndeterminateEdge(
const Args&);
292 ~BasicBlockWorkList();
294 BasicBlockWorkList(
const EnginePtr &engine,
size_t maxSorts);
297 static Ptr instance(
const EnginePtr &engine,
size_t maxSorts);
298 virtual bool operator()(
bool chain,
const AttachedBasicBlock &args)
override;
299 virtual bool operator()(
bool chain,
const DetachedBasicBlock &args)
override;
315 std::set<rose_addr_t> toBeExamined_;
316 std::set<rose_addr_t> wasExamined_;
317 rose_addr_t inProgress_;
318 std::vector<rose_addr_t> constants_;
326 static Ptr instance();
329 rose_addr_t inProgress();
353 std::vector<std::string> specimen_;
400 virtual
std::list<
Sawyer::CommandLine::SwitchGroup> commandLineSwitches();
407 std::list<
Sawyer::CommandLine::SwitchGroup> allCommandLineSwitches();
420 virtual
std::pair<
std::
string,
std::
string > specimenNameDocumentation() = 0;
428 static
std::list<
std::pair<
std::
string ,
std::
string >> allSpecimenNameDocumentation();
437 virtual
void addToParser(
Sawyer::CommandLine::Parser&);
444 void addAllToParser(
Sawyer::CommandLine::Parser&);
458 virtual
Sawyer::CommandLine::Parser commandLineParser(const
std::
string &purpose, const
std::
string &description);
472 static
void registerFactory(const
EnginePtr &factory);
480 static
bool deregisterFactory(const
EnginePtr &factory);
532 const PositionalArgumentParser&);
535 static
EnginePtr forge(const
std::vector<
std::
string> &arguments,
Sawyer::CommandLine::Parser&, const Settings&);
545 static
EnginePtr forge(
int argc,
char *argv[],
Sawyer::CommandLine::Parser&, const PositionalArgumentParser&, const Settings&);
548 static
EnginePtr forge(
int argc,
char *argv[],
Sawyer::CommandLine::Parser&, const PositionalArgumentParser&);
551 static
EnginePtr forge(
int argc,
char *argv[],
Sawyer::CommandLine::Parser&, const Settings&);
554 static
EnginePtr forge(
int argc,
char *argv[],
Sawyer::CommandLine::Parser&);
558 virtual
bool matchFactory(const
std::vector<
std::
string> &specimen) const = 0;
564 virtual
EnginePtr instanceFromFactory(const Settings&) = 0;
571 bool isFactory() const;
602 const
std::
string &purpose, const
std::
string &description);
604 const
std::
string &purpose, const
std::
string &description) = 0;
616 virtual
void reset();
644 Sawyer::CommandLine::ParserResult parseCommandLine(
int argc,
char *argv[],
645 const
std::
string &purpose, const
std::
string &description) ;
646 virtual
Sawyer::CommandLine::ParserResult parseCommandLine(const
std::vector<
std::
string> &args,
647 const
std::
string &purpose, const
std::
string &description);
683 ROSE_DEPRECATED("use
Partitioner::instanceFromRbaFile");
765 virtual
void checkSettings();
777 virtual
bool isRbaFile(const
std::
string&);
783 virtual
bool isNonContainer(const
std::
string&) = 0;
790 virtual
bool areContainersParsed() const = 0;
801 virtual
bool areSpecimensLoaded() const;
806 virtual
void adjustMemoryMap();
842 virtual Disassembler::BasePtr obtainDisassembler();
843 virtual Disassembler::BasePtr obtainDisassembler(const Disassembler::BasePtr &hint);
854 virtual
void checkCreatePartitionerPrerequisites() const;
878 virtual
void runPartitionerRecursive(const PartitionerPtr&) = 0;
884 virtual
void runPartitionerFinal(const PartitionerPtr&) = 0;
891 virtual
void runPartitioner(const PartitionerPtr&);
904 virtual
void labelAddresses(const PartitionerPtr&, const
Configuration&);
909 virtual
std::vector<
DataBlockPtr> makeConfiguredDataBlocks(const PartitionerPtr&, const Configuration&);
914 virtual
std::vector<
FunctionPtr> makeConfiguredFunctions(const PartitionerPtr&, const Configuration&);
921 virtual
void updateAnalysisResults(const PartitionerPtr&);
948 const
std::
string& name() const ;
949 void name(const
std::
string&);
958 const Settings& settings() const ;
959 Settings& settings() ;
960 void settings(const Settings&) ;
968 BasicBlockWorkList::
Ptr basicBlockWorkList() const ;
969 void basicBlockWorkList(const BasicBlockWorkList::
Ptr&) ;
986 Disassembler::BasePtr disassembler() const;
987 virtual
void disassembler(const Disassembler::BasePtr&);
997 SgAsmInterpretation* interpretation() const ;
998 virtual
void interpretation(SgAsmInterpretation*);
1015 const
std::vector<
std::
string>& specimen() const ;
1016 virtual
void specimen(const
std::vector<
std::
string>&);
1024 virtual
SgProject* roseFrontendReplacement(const
std::vector<
boost::filesystem::path> &fileNames) = 0;
virtual std::vector< std::string > specimen(const std::vector< std::string > &) const =0
Return specimen from positional arguments.
Settings for controling the engine behavior.
Base class for CFG-adjustment callbacks.
Base class for adjusting basic blocks during discovery.
virtual std::vector< std::string > specimen(const std::vector< std::string > &) const override
Return specimen from positional arguments.
GroupedPositionalArguments()
Constructor returning first group of arguments.
Settings that control the disassembler.
Engine for specimens containing machine instructions.
Base class for engines driving the partitioner.
Engine()=delete
Default constructor.
Main namespace for the ROSE library.
Up to first N arguments are the specimen.
Settings for loading specimens.
Settings that control building the AST.
Base class for binary state input and output.
Exception(const std::string &)
Construct an exception with a message string.
Name space for the entire library.
Arguments for attaching a basic block.
virtual std::vector< std::string > specimen(const std::vector< std::string > &) const override
Return specimen from positional arguments.
FirstPositionalArguments(size_t n)
Constructor returning up to n arguments.
virtual std::vector< std::string > specimen(const std::vector< std::string > &) const override
Return specimen from positional arguments.
Settings that control the engine partitioning.
Creates SharedPointer from this.
DisassemblerSettings disassembler
Settings for creating the disassembler.
Sawyer::SharedPointer< Engine > EnginePtr
Shared-ownership pointer for Engine.
virtual bool operator()(bool chain, const AttachedBasicBlock &attached) override
Called when basic block is attached or placeholder inserted.
AstConstructionSettings astConstruction
Settings for constructing the AST.
virtual bool operator()(bool chain, const Args &args) override
Callback method.
Base class for reference counted objects.
Arguments for detaching a basic block.
Arguments passed to the callback.
This class represents a source project, with a list of SgFile objects and global information about th...
PartitionerSettings partitioner
Settings for creating a partitioner.
How to parse positional command-line arguments.
LoaderSettings loader
Settings used during specimen loading.
Partitions instructions into basic blocks and functions.
Represents an interpretation of a binary container.
EngineSettings engine
Settings that control engine behavior.
Nth group of arguments are the specimen.
Container associating values with keys.
Return all positional arguments as the specimen.
Holds configuration information.