ROSE 0.11.145.147
SystemCall.h
1#ifndef ROSE_BinaryAnalysis_SystemCall_H
2#define ROSE_BinaryAnalysis_SystemCall_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/AbstractLocation.h>
7#include <Rose/BinaryAnalysis/SmtSolver.h>
8#include <boost/filesystem.hpp>
9#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
10#include <Rose/Exception.h>
11#include <Sawyer/Map.h>
12#include <string>
13#include <vector>
14
15namespace Rose {
16namespace BinaryAnalysis {
17
23public:
25 class Exception: public Rose::Exception {
26 public:
28 Exception(const std::string &mesg): Rose::Exception(mesg) {}
29
31 ~Exception() throw () {}
32 };
33
35 struct Declaration {
36 uint64_t id;
37 std::string name;
41 : id(0) {}
42
44 Declaration(uint64_t id, const std::string &name)
45 : id(id), name(name) {}
46 };
47
50
51private:
52 Declarations declarations_; // table describing all known system calls index by system call number
53 AbstractLocation ident_; // location that identifies the system call
54
55public:
56 virtual ~SystemCall() {}
57
59 void declare(const Declaration &declaration);
60
62 void declare(const std::vector<Declaration> &declarations);
63
65 void declare(const boost::filesystem::path &headerFileName);
66
68 const Declarations& declarations() const { return declarations_; }
69
72
74 std::vector<Declaration> lookup(const std::string &name) const;
75
77 static std::vector<Declaration> parseHeaderFile(const boost::filesystem::path &headerFileName);
78
85
92 const AbstractLocation& ident() const { return ident_; }
93 void ident(const AbstractLocation &location) { ident_ = location; }
110 const SmtSolver::Ptr &solver = SmtSolver::Ptr()) const;
111
113 virtual bool isSystemCall(SgAsmInstruction*) const;
114};
115
116} // namespace
117} // namespace
118
119#endif
120#endif
SmtSolverPtr Ptr
Reference counting pointer for SMT solvers.
Definition SmtSolver.h:45
Exceptions for system call analysis.
Definition SystemCall.h:25
Exception(const std::string &mesg)
Construct an exception with a message.
Definition SystemCall.h:28
Analyzes basic blocks to get system call names.
Definition SystemCall.h:22
void ident(const AbstractLocation &location)
Property: Abstract location that identifies the particular system call.
Definition SystemCall.h:93
void declare(const std::vector< Declaration > &declarations)
Declare multiple system calls.
SgAsmInstruction * hasSystemCall(const Partitioner2::BasicBlockPtr &) const
Determine whether a basic block has a system call.
virtual Sawyer::Optional< Declaration > analyze(const Partitioner2::PartitionerConstPtr &, const Partitioner2::BasicBlockPtr &, SgAsmInstruction *, const SmtSolver::Ptr &solver=SmtSolver::Ptr()) const
Analyze a basic block and return the system calls.
void declare(const boost::filesystem::path &headerFileName)
Declare multiple system calls by parsing a Linux header file.
static std::vector< Declaration > parseHeaderFile(const boost::filesystem::path &headerFileName)
Parse a Linux header file to obtain declarations for system calls.
Sawyer::Container::Map< uint64_t, Declaration > Declarations
Table of syscall declarations indexed by syscall IDs.
Definition SystemCall.h:49
void declare(const Declaration &declaration)
Declare a system call.
const Declarations & declarations() const
All declarations.
Definition SystemCall.h:68
Sawyer::Optional< Declaration > lookup(uint64_t id) const
Look up a system call by ID number.
std::vector< Declaration > lookup(const std::string &name) const
Look up system calls by name.
const AbstractLocation & ident() const
Property: Abstract location that identifies the particular system call.
Definition SystemCall.h:92
virtual bool isSystemCall(SgAsmInstruction *) const
Predicate to determine whether an instruction is a system call.
Base class for all ROSE exceptions.
Container associating values with keys.
Definition Sawyer/Map.h:72
Holds a value or nothing.
Definition Optional.h:56
Base class for machine instructions.
The ROSE library.
Declarative information about a system call.
Definition SystemCall.h:35
uint64_t id
Identification number.
Definition SystemCall.h:36
Declaration(uint64_t id, const std::string &name)
Constructor.
Definition SystemCall.h:44
std::string name
Name of system call.
Definition SystemCall.h:37