mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 11:09:05 +01:00
move all internal logic to oi::detail namespace
This commit is contained in:
parent
e19641efad
commit
d7cfcca30d
@ -29,9 +29,9 @@
|
|||||||
* translating these types to OID/OITB they cannot be compiled in, so we
|
* translating these types to OID/OITB they cannot be compiled in, so we
|
||||||
* represent the template arguments with member fields instead.
|
* represent the template arguments with member fields instead.
|
||||||
*
|
*
|
||||||
* Each type in this namespace corresponds 1-1 with a type in
|
* Each type in this namespace corresponds 1-1 with a type in oi::types::st,
|
||||||
* ObjectIntrospection::types::st, except Dynamic which references them all. See
|
* except Dynamic which references them all. See the types in st.h for the
|
||||||
* the types in st.h for the description of what each type contains.
|
* description of what each type contains.
|
||||||
*
|
*
|
||||||
* All types in this file include a constexpr constructor. This allows a single
|
* All types in this file include a constexpr constructor. This allows a single
|
||||||
* extern const variable in the JIT code to include pointer references to other
|
* extern const variable in the JIT code to include pointer references to other
|
||||||
@ -43,7 +43,7 @@
|
|||||||
#include <span>
|
#include <span>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
namespace ObjectIntrospection::types::dy {
|
namespace oi::types::dy {
|
||||||
|
|
||||||
class Unit;
|
class Unit;
|
||||||
class VarInt;
|
class VarInt;
|
||||||
@ -93,6 +93,6 @@ class List {
|
|||||||
Dynamic element;
|
Dynamic element;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ObjectIntrospection::types::dy
|
} // namespace oi::types::dy
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
* dynamic description of their type as the constexpr field `describe`. Compound
|
* dynamic description of their type as the constexpr field `describe`. Compound
|
||||||
* types compose appropriately.
|
* types compose appropriately.
|
||||||
*/
|
*/
|
||||||
namespace ObjectIntrospection::types::st {
|
namespace oi::types::st {
|
||||||
|
|
||||||
#ifdef DEFINE_DESCRIBE
|
#ifdef DEFINE_DESCRIBE
|
||||||
#include "oi/types/dy.h"
|
#include "oi/types/dy.h"
|
||||||
@ -280,6 +280,6 @@ class List
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ObjectIntrospection::types::st
|
} // namespace oi::types::st
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include "type_graph/TypeIdentifier.h"
|
#include "type_graph/TypeIdentifier.h"
|
||||||
#include "type_graph/Types.h"
|
#include "type_graph/Types.h"
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
using type_graph::AddChildren;
|
using type_graph::AddChildren;
|
||||||
using type_graph::AddPadding;
|
using type_graph::AddPadding;
|
||||||
using type_graph::AlignmentCalc;
|
using type_graph::AlignmentCalc;
|
||||||
@ -861,7 +863,8 @@ void CodeGen::generate(
|
|||||||
|
|
||||||
if (config_.features[Feature::TypedDataSegment]) {
|
if (config_.features[Feature::TypedDataSegment]) {
|
||||||
FuncGen::DefineDataSegmentDataBuffer(code);
|
FuncGen::DefineDataSegmentDataBuffer(code);
|
||||||
code += "using namespace ObjectIntrospection;\n";
|
code += "using namespace oi;\n";
|
||||||
|
code += "using namespace oi::detail;\n";
|
||||||
|
|
||||||
code += "namespace OIInternal {\nnamespace {\n";
|
code += "namespace OIInternal {\nnamespace {\n";
|
||||||
FuncGen::DefineBasicTypeHandlers(code);
|
FuncGen::DefineBasicTypeHandlers(code);
|
||||||
@ -927,3 +930,5 @@ void CodeGen::generate(
|
|||||||
std::cout << code;
|
std::cout << code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
12
oi/CodeGen.h
12
oi/CodeGen.h
@ -26,14 +26,16 @@
|
|||||||
#include "OICodeGen.h"
|
#include "OICodeGen.h"
|
||||||
|
|
||||||
struct drgn_type;
|
struct drgn_type;
|
||||||
|
namespace oi::detail {
|
||||||
class SymbolService;
|
class SymbolService;
|
||||||
|
}
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
class Class;
|
class Class;
|
||||||
class Member;
|
class Member;
|
||||||
class TypeGraph;
|
class TypeGraph;
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
class CodeGen {
|
class CodeGen {
|
||||||
public:
|
public:
|
||||||
@ -76,3 +78,5 @@ class CodeGen {
|
|||||||
std::string& code);
|
std::string& code);
|
||||||
void getClassTypeHandler(const type_graph::Class& c, std::string& code);
|
void getClassTypeHandler(const type_graph::Class& c, std::string& code);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string_view featureHelp(Feature f) {
|
std::string_view featureHelp(Feature f) {
|
||||||
@ -101,4 +101,4 @@ void featuresHelp(std::ostream& out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ObjectIntrospection
|
} // namespace oi::detail
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
X(JitTiming, "jit-timing") \
|
X(JitTiming, "jit-timing") \
|
||||||
X(PolymorphicInheritance, "polymorphic-inheritance")
|
X(PolymorphicInheritance, "polymorphic-inheritance")
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail {
|
||||||
|
|
||||||
enum class Feature {
|
enum class Feature {
|
||||||
UnknownFeature,
|
UnknownFeature,
|
||||||
@ -58,4 +58,4 @@ constexpr std::array allFeatures = {
|
|||||||
// Use "size+1" to account for UnknownFeature"
|
// Use "size+1" to account for UnknownFeature"
|
||||||
using FeatureSet = EnumBitset<Feature, allFeatures.size() + 1>;
|
using FeatureSet = EnumBitset<Feature, allFeatures.size() + 1>;
|
||||||
|
|
||||||
} // namespace ObjectIntrospection
|
} // namespace oi::detail
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
|
|
||||||
#include "oi/ContainerInfo.h"
|
#include "oi/ContainerInfo.h"
|
||||||
|
|
||||||
using ObjectIntrospection::Feature;
|
namespace oi::detail {
|
||||||
using ObjectIntrospection::FeatureSet;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const std::string typedValueFunc = R"(
|
const std::string typedValueFunc = R"(
|
||||||
@ -538,7 +536,7 @@ void FuncGen::DeclareGetContainer(std::string& testCode) {
|
|||||||
*/
|
*/
|
||||||
void FuncGen::DefineDataSegmentDataBuffer(std::string& testCode) {
|
void FuncGen::DefineDataSegmentDataBuffer(std::string& testCode) {
|
||||||
constexpr std::string_view func = R"(
|
constexpr std::string_view func = R"(
|
||||||
namespace ObjectIntrospection::DataBuffer {
|
namespace oi::detail::DataBuffer {
|
||||||
|
|
||||||
class DataSegment {
|
class DataSegment {
|
||||||
public:
|
public:
|
||||||
@ -560,7 +558,7 @@ void FuncGen::DefineDataSegmentDataBuffer(std::string& testCode) {
|
|||||||
uint8_t* buf;
|
uint8_t* buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ObjectIntrospection::DataBuffer
|
} // namespace oi::detail::DataBuffer
|
||||||
)";
|
)";
|
||||||
|
|
||||||
testCode.append(func);
|
testCode.append(func);
|
||||||
@ -632,3 +630,5 @@ void FuncGen::DefineBasicTypeHandlers(std::string& testCode) {
|
|||||||
testCode.append(tHandler);
|
testCode.append(tHandler);
|
||||||
testCode.append(voidHandler);
|
testCode.append(voidHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
29
oi/FuncGen.h
29
oi/FuncGen.h
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
class FuncGen {
|
class FuncGen {
|
||||||
public:
|
public:
|
||||||
static void DeclareStoreData(std::string& testCode);
|
static void DeclareStoreData(std::string& testCode);
|
||||||
@ -40,10 +42,10 @@ class FuncGen {
|
|||||||
|
|
||||||
bool DeclareGetSizeFuncs(std::string& testCode,
|
bool DeclareGetSizeFuncs(std::string& testCode,
|
||||||
const ContainerInfoRefSet& containerInfo,
|
const ContainerInfoRefSet& containerInfo,
|
||||||
ObjectIntrospection::FeatureSet features);
|
FeatureSet features);
|
||||||
bool DefineGetSizeFuncs(std::string& testCode,
|
bool DefineGetSizeFuncs(std::string& testCode,
|
||||||
const ContainerInfoRefSet& containerInfo,
|
const ContainerInfoRefSet& containerInfo,
|
||||||
ObjectIntrospection::FeatureSet features);
|
FeatureSet features);
|
||||||
|
|
||||||
static void DeclareGetContainer(std::string& testCode);
|
static void DeclareGetContainer(std::string& testCode);
|
||||||
|
|
||||||
@ -55,24 +57,21 @@ class FuncGen {
|
|||||||
const std::string& type,
|
const std::string& type,
|
||||||
const std::string& linkageName);
|
const std::string& linkageName);
|
||||||
|
|
||||||
static void DefineTopLevelGetSizeRef(
|
static void DefineTopLevelGetSizeRef(std::string& testCode,
|
||||||
std::string& testCode,
|
const std::string& rawType,
|
||||||
const std::string& rawType,
|
FeatureSet features);
|
||||||
ObjectIntrospection::FeatureSet features);
|
static void DefineTopLevelGetSizeRefTyped(std::string& testCode,
|
||||||
static void DefineTopLevelGetSizeRefTyped(
|
const std::string& rawType,
|
||||||
std::string& testCode,
|
FeatureSet features);
|
||||||
const std::string& rawType,
|
|
||||||
ObjectIntrospection::FeatureSet features);
|
|
||||||
static void DefineOutputType(std::string& testCode,
|
static void DefineOutputType(std::string& testCode,
|
||||||
const std::string& rawType);
|
const std::string& rawType);
|
||||||
|
|
||||||
static void DefineTopLevelGetSizeRefRet(std::string& testCode,
|
static void DefineTopLevelGetSizeRefRet(std::string& testCode,
|
||||||
const std::string& type);
|
const std::string& type);
|
||||||
|
|
||||||
static void DefineTopLevelGetSizeSmartPtr(
|
static void DefineTopLevelGetSizeSmartPtr(std::string& testCode,
|
||||||
std::string& testCode,
|
const std::string& rawType,
|
||||||
const std::string& rawType,
|
FeatureSet features);
|
||||||
ObjectIntrospection::FeatureSet features);
|
|
||||||
|
|
||||||
static void DefineGetSizeTypedValueFunc(std::string& testCode,
|
static void DefineGetSizeTypedValueFunc(std::string& testCode,
|
||||||
const std::string& ctype);
|
const std::string& ctype);
|
||||||
@ -80,3 +79,5 @@ class FuncGen {
|
|||||||
static void DefineDataSegmentDataBuffer(std::string& testCode);
|
static void DefineDataSegmentDataBuffer(std::string& testCode);
|
||||||
static void DefineBasicTypeHandlers(std::string& testCode);
|
static void DefineBasicTypeHandlers(std::string& testCode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -15,13 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail::headers {
|
||||||
namespace headers {
|
|
||||||
|
|
||||||
// These externs are provided by our build system. See resources/CMakeLists.txt
|
// These externs are provided by our build system. See resources/CMakeLists.txt
|
||||||
extern const std::string_view oi_OITraceCode_cpp;
|
extern const std::string_view oi_OITraceCode_cpp;
|
||||||
extern const std::string_view oi_types_st_h;
|
extern const std::string_view oi_types_st_h;
|
||||||
extern const std::string_view oi_types_dy_h;
|
extern const std::string_view oi_types_dy_h;
|
||||||
|
|
||||||
} // namespace headers
|
} // namespace oi::detail::headers
|
||||||
} // namespace ObjectIntrospection
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
*
|
*
|
||||||
* You can instrument some code with:
|
* You can instrument some code with:
|
||||||
* ```
|
* ```
|
||||||
* auto t = Metrics::Tracing("name_of_your_trace");
|
* auto t = metrics::Tracing("name_of_your_trace");
|
||||||
* [... some code ...]
|
* [... some code ...]
|
||||||
* t.stop();
|
* t.stop();
|
||||||
* ```
|
* ```
|
||||||
@ -40,13 +40,13 @@
|
|||||||
* Alternatively, you can use automatically deal with this in every return
|
* Alternatively, you can use automatically deal with this in every return
|
||||||
* point thanks to C++'s RAII:
|
* point thanks to C++'s RAII:
|
||||||
* ```
|
* ```
|
||||||
* Metrics::Tracing unused_var("name_of_your_trace");
|
* metrics::Tracing unused_var("name_of_your_trace");
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* When you want to collect the data, `::showTraces()` to print the data to
|
* When you want to collect the data, `::showTraces()` to print the data to
|
||||||
* stdout, and `::saveTraces(file)` to save it to disk using JSON.
|
* stdout, and `::saveTraces(file)` to save it to disk using JSON.
|
||||||
*/
|
*/
|
||||||
namespace ObjectIntrospection::Metrics {
|
namespace oi::detail::metrics {
|
||||||
|
|
||||||
static inline TraceFlags parseTraceFlags(const char* flags) {
|
static inline TraceFlags parseTraceFlags(const char* flags) {
|
||||||
if (flags == nullptr) {
|
if (flags == nullptr) {
|
||||||
@ -204,4 +204,4 @@ std::ostream& operator<<(std::ostream& out, const std::vector<Span>& spans) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ObjectIntrospection::Metrics
|
} // namespace oi::detail::metrics
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace ObjectIntrospection::Metrics {
|
namespace oi::detail::metrics {
|
||||||
|
|
||||||
constexpr auto traceEnvKey = "OID_METRICS_TRACE";
|
constexpr auto traceEnvKey = "OID_METRICS_TRACE";
|
||||||
constexpr auto outputEnvKey = "OID_METRICS_OUTPUT";
|
constexpr auto outputEnvKey = "OID_METRICS_OUTPUT";
|
||||||
@ -75,9 +75,9 @@ class Tracing final {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
* Metrics::Tracing("bad");
|
* metrics::Tracing("bad");
|
||||||
*
|
*
|
||||||
* Usage is Metrics::Tracing __varname_(...) The code above is an improper
|
* Usage is metrics::Tracing __varname_(...) The code above is an improper
|
||||||
* use of the Tracing library. The tracing object above is not stored in a
|
* use of the Tracing library. The tracing object above is not stored in a
|
||||||
* variable. So it is immediately destroyed and won't record the expected
|
* variable. So it is immediately destroyed and won't record the expected
|
||||||
* results. [[nodiscard]] flags the code above with a warning, which we
|
* results. [[nodiscard]] flags the code above with a warning, which we
|
||||||
@ -170,4 +170,4 @@ std::ostream& operator<<(std::ostream&, const TraceFlags&);
|
|||||||
std::ostream& operator<<(std::ostream&, const Span&);
|
std::ostream& operator<<(std::ostream&, const Span&);
|
||||||
std::ostream& operator<<(std::ostream&, const std::vector<Span>&);
|
std::ostream& operator<<(std::ostream&, const std::vector<Span>&);
|
||||||
|
|
||||||
} // namespace ObjectIntrospection::Metrics
|
} // namespace oi::detail::metrics
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "cea/object-introspection/internal/ManifoldCache.h"
|
#include "cea/object-introspection/internal/ManifoldCache.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
static std::optional<std::reference_wrapper<const std::string>> getEntName(
|
static std::optional<std::reference_wrapper<const std::string>> getEntName(
|
||||||
SymbolService& symbols, const irequest& req, OICache::Entity ent) {
|
SymbolService& symbols, const irequest& req, OICache::Entity ent) {
|
||||||
if (ent == OICache::Entity::FuncDescs ||
|
if (ent == OICache::Entity::FuncDescs ||
|
||||||
@ -250,3 +252,5 @@ std::string OICache::generateRemoteHash(const irequest& req) {
|
|||||||
LOG(INFO) << "generating remote hash from: " << remote_cache_id;
|
LOG(INFO) << "generating remote hash from: " << remote_cache_id;
|
||||||
return std::to_string(std::hash<std::string>{}(remote_cache_id));
|
return std::to_string(std::hash<std::string>{}(remote_cache_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "oi/OIParser.h"
|
#include "oi/OIParser.h"
|
||||||
#include "oi/SymbolService.h"
|
#include "oi/SymbolService.h"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace oi::detail {
|
||||||
|
|
||||||
class OICache {
|
class OICache {
|
||||||
public:
|
public:
|
||||||
@ -32,7 +32,7 @@ class OICache {
|
|||||||
: generatorConfig(generatorConfig) {
|
: generatorConfig(generatorConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path basePath{};
|
std::filesystem::path basePath{};
|
||||||
std::shared_ptr<SymbolService> symbols{};
|
std::shared_ptr<SymbolService> symbols{};
|
||||||
bool downloadedRemote = false;
|
bool downloadedRemote = false;
|
||||||
bool enableUpload = false;
|
bool enableUpload = false;
|
||||||
@ -60,7 +60,7 @@ class OICache {
|
|||||||
bool isEnabled() const {
|
bool isEnabled() const {
|
||||||
return !basePath.empty();
|
return !basePath.empty();
|
||||||
}
|
}
|
||||||
std::optional<fs::path> getPath(const irequest&, Entity) const;
|
std::optional<std::filesystem::path> getPath(const irequest&, Entity) const;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool store(const irequest&, Entity, const T&);
|
bool store(const irequest&, Entity, const T&);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -72,3 +72,5 @@ class OICache {
|
|||||||
private:
|
private:
|
||||||
std::string generateRemoteHash(const irequest&);
|
std::string generateRemoteHash(const irequest&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
static size_t g_level = 0;
|
static size_t g_level = 0;
|
||||||
|
|
||||||
#undef VLOG
|
#undef VLOG
|
||||||
@ -3773,3 +3775,5 @@ std::vector<std::string> OICodeGen::Config::toOptions() const {
|
|||||||
void OICodeGen::initializeCodeGen() {
|
void OICodeGen::initializeCodeGen() {
|
||||||
LOG(WARNING) << "OICodeGen::initializeCodeGen is no longer necessary";
|
LOG(WARNING) << "OICodeGen::initializeCodeGen is no longer necessary";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class SymbolService;
|
|
||||||
struct irequest;
|
struct irequest;
|
||||||
|
|
||||||
#include "oi/ContainerInfo.h"
|
#include "oi/ContainerInfo.h"
|
||||||
@ -36,8 +35,11 @@ extern "C" {
|
|||||||
#include <drgn.h>
|
#include <drgn.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace ObjectIntrospection;
|
namespace oi::detail {
|
||||||
namespace fs = std::filesystem;
|
class SymbolService;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
struct ParentMember {
|
struct ParentMember {
|
||||||
drgn_type* type;
|
drgn_type* type;
|
||||||
@ -59,7 +61,7 @@ class OICodeGen {
|
|||||||
|
|
||||||
bool useDataSegment;
|
bool useDataSegment;
|
||||||
FeatureSet features;
|
FeatureSet features;
|
||||||
std::set<fs::path> containerConfigPaths;
|
std::set<std::filesystem::path> containerConfigPaths;
|
||||||
std::set<std::string> defaultHeaders;
|
std::set<std::string> defaultHeaders;
|
||||||
std::set<std::string> defaultNamespaces;
|
std::set<std::string> defaultNamespaces;
|
||||||
std::vector<std::pair<std::string, std::string>> membersToStub;
|
std::vector<std::pair<std::string, std::string>> membersToStub;
|
||||||
@ -360,3 +362,5 @@ class OICodeGen {
|
|||||||
std::vector<std::string>& template_params_strings,
|
std::vector<std::string>& template_params_strings,
|
||||||
const std::string& nameWithoutTemplate);
|
const std::string& nameWithoutTemplate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -47,11 +47,12 @@ extern "C" {
|
|||||||
#include <llvm-c/Disassembler.h>
|
#include <llvm-c/Disassembler.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace llvm::object;
|
using namespace llvm::object;
|
||||||
using namespace ObjectIntrospection;
|
|
||||||
|
|
||||||
static const char* symbolLookupCallback(
|
static const char* symbolLookupCallback(
|
||||||
[[maybe_unused]] void* disInfo,
|
[[maybe_unused]] void* disInfo,
|
||||||
@ -467,7 +468,7 @@ static void debugDisAsm(
|
|||||||
bool OICompiler::compile(const std::string& code,
|
bool OICompiler::compile(const std::string& code,
|
||||||
const fs::path& sourcePath,
|
const fs::path& sourcePath,
|
||||||
const fs::path& objectPath) {
|
const fs::path& objectPath) {
|
||||||
Metrics::Tracing _("compile");
|
metrics::Tracing _("compile");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note to whoever: if you're having problems compiling code, especially
|
* Note to whoever: if you're having problems compiling code, especially
|
||||||
@ -588,7 +589,7 @@ std::optional<OICompiler::RelocResult> OICompiler::applyRelocs(
|
|||||||
uintptr_t baseRelocAddress,
|
uintptr_t baseRelocAddress,
|
||||||
const std::set<fs::path>& objectFiles,
|
const std::set<fs::path>& objectFiles,
|
||||||
const std::unordered_map<std::string, uintptr_t>& syntheticSymbols) {
|
const std::unordered_map<std::string, uintptr_t>& syntheticSymbols) {
|
||||||
Metrics::Tracing relocationTracing("relocation");
|
metrics::Tracing relocationTracing("relocation");
|
||||||
|
|
||||||
memMgr = std::make_unique<OIMemoryManager>(symbols, syntheticSymbols);
|
memMgr = std::make_unique<OIMemoryManager>(symbols, syntheticSymbols);
|
||||||
RuntimeDyld dyld(*memMgr, *memMgr);
|
RuntimeDyld dyld(*memMgr, *memMgr);
|
||||||
@ -666,3 +667,5 @@ std::optional<OICompiler::RelocResult> OICompiler::applyRelocs(
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "oi/SymbolService.h"
|
#include "oi/SymbolService.h"
|
||||||
#include "oi/X86InstDefs.h"
|
#include "oi/X86InstDefs.h"
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
class OIMemoryManager;
|
class OIMemoryManager;
|
||||||
@ -42,7 +44,7 @@ class OICompiler {
|
|||||||
public:
|
public:
|
||||||
/* Configuration option for `OICompiler` */
|
/* Configuration option for `OICompiler` */
|
||||||
struct Config {
|
struct Config {
|
||||||
ObjectIntrospection::FeatureSet features;
|
FeatureSet features;
|
||||||
|
|
||||||
std::vector<fs::path> userHeaderPaths{};
|
std::vector<fs::path> userHeaderPaths{};
|
||||||
std::vector<fs::path> sysHeaderPaths{};
|
std::vector<fs::path> sysHeaderPaths{};
|
||||||
@ -221,3 +223,5 @@ std::optional<std::vector<uintptr_t>> OICompiler::locateOpcodes(
|
|||||||
|
|
||||||
return locs;
|
return locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
25
oi/OID.cpp
25
oi/OID.cpp
@ -38,12 +38,11 @@ extern "C" {
|
|||||||
#include "oi/TimeUtils.h"
|
#include "oi/TimeUtils.h"
|
||||||
#include "oi/TreeBuilder.h"
|
#include "oi/TreeBuilder.h"
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
/* Global for signal handling */
|
/* Global for signal handling */
|
||||||
std::weak_ptr<OIDebugger> weak_oid;
|
std::weak_ptr<OIDebugger> weak_oid;
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
using namespace ObjectIntrospection;
|
|
||||||
|
|
||||||
// Using an enum inside a namespace here instead of an `enum class` because
|
// Using an enum inside a namespace here instead of an `enum class` because
|
||||||
// enums defined via `enum class` aren't implicitly convertible to `int`, and
|
// enums defined via `enum class` aren't implicitly convertible to `int`, and
|
||||||
// having to cast the argument for each call to `exit` would be ugly.
|
// having to cast the argument for each call to `exit` would be ugly.
|
||||||
@ -432,7 +431,7 @@ static ExitStatus::ExitStatus runScript(
|
|||||||
|
|
||||||
{ // Resume stopped thread before cleanup
|
{ // Resume stopped thread before cleanup
|
||||||
VLOG(1) << "Resuming stopped threads...";
|
VLOG(1) << "Resuming stopped threads...";
|
||||||
Metrics::Tracing __("resume_threads");
|
metrics::Tracing __("resume_threads");
|
||||||
while (oid->processTrap(oidConfig.pid, false) == OIDebugger::OID_CONT) {
|
while (oid->processTrap(oidConfig.pid, false) == OIDebugger::OID_CONT) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -457,7 +456,11 @@ static ExitStatus::ExitStatus runScript(
|
|||||||
return ExitStatus::Success;
|
return ExitStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
using namespace oi::detail;
|
||||||
|
|
||||||
int debugLevel = 1;
|
int debugLevel = 1;
|
||||||
Oid::Config oidConfig = {};
|
Oid::Config oidConfig = {};
|
||||||
std::string scriptFile;
|
std::string scriptFile;
|
||||||
@ -474,7 +477,7 @@ int main(int argc, char* argv[]) {
|
|||||||
bool logAllStructs = true;
|
bool logAllStructs = true;
|
||||||
bool dumpDataSegment = false;
|
bool dumpDataSegment = false;
|
||||||
|
|
||||||
Metrics::Tracing _("main");
|
metrics::Tracing _("main");
|
||||||
#ifndef OSS_ENABLE
|
#ifndef OSS_ENABLE
|
||||||
folly::InitOptions init;
|
folly::InitOptions init;
|
||||||
init.useGFlags(false);
|
init.useGFlags(false);
|
||||||
@ -679,8 +682,8 @@ int main(int argc, char* argv[]) {
|
|||||||
.jsonPath = jsonPath,
|
.jsonPath = jsonPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto featureSet = OIUtils::processConfigFile(oidConfig.configFile, features,
|
auto featureSet = utils::processConfigFile(oidConfig.configFile, features,
|
||||||
compilerConfig, codeGenConfig);
|
compilerConfig, codeGenConfig);
|
||||||
if (!featureSet) {
|
if (!featureSet) {
|
||||||
return ExitStatus::UsageError;
|
return ExitStatus::UsageError;
|
||||||
}
|
}
|
||||||
@ -708,11 +711,11 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Metrics::Tracing::isEnabled()) {
|
if (metrics::Tracing::isEnabled()) {
|
||||||
LOG(INFO) << "Will write metrics (" << Metrics::Tracing::isEnabled()
|
LOG(INFO) << "Will write metrics (" << metrics::Tracing::isEnabled()
|
||||||
<< ") in " << Metrics::Tracing::outputPath();
|
<< ") in " << metrics::Tracing::outputPath();
|
||||||
} else {
|
} else {
|
||||||
LOG(INFO) << "Will not write any metric: " << Metrics::Tracing::isEnabled();
|
LOG(INFO) << "Will not write any metric: " << metrics::Tracing::isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ExitStatus::Success;
|
return ExitStatus::Success;
|
||||||
|
@ -60,7 +60,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ObjectIntrospection;
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
constexpr int oidMagicId = 0x01DE8;
|
constexpr int oidMagicId = 0x01DE8;
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ bool OIDebugger::isGlobalDataProbeEnabled(void) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OIDebugger::parseScript(std::istream& script) {
|
bool OIDebugger::parseScript(std::istream& script) {
|
||||||
Metrics::Tracing _("parse_script");
|
metrics::Tracing _("parse_script");
|
||||||
|
|
||||||
OIScanner scanner(&script);
|
OIScanner scanner(&script);
|
||||||
OIParser parser(scanner, pdata);
|
OIParser parser(scanner, pdata);
|
||||||
@ -96,7 +97,7 @@ bool OIDebugger::parseScript(std::istream& script) {
|
|||||||
|
|
||||||
bool OIDebugger::patchFunctions(void) {
|
bool OIDebugger::patchFunctions(void) {
|
||||||
assert(pdata.numReqs() != 0);
|
assert(pdata.numReqs() != 0);
|
||||||
Metrics::Tracing _("patch_functions");
|
metrics::Tracing _("patch_functions");
|
||||||
|
|
||||||
for (const auto& preq : pdata) {
|
for (const auto& preq : pdata) {
|
||||||
VLOG(1) << "Type " << preq.type << " Func " << preq.func
|
VLOG(1) << "Type " << preq.type << " Func " << preq.func
|
||||||
@ -126,7 +127,7 @@ bool OIDebugger::patchFunctions(void) {
|
|||||||
uint64_t OIDebugger::singlestepInst(pid_t pid, struct user_regs_struct& regs) {
|
uint64_t OIDebugger::singlestepInst(pid_t pid, struct user_regs_struct& regs) {
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
Metrics::Tracing _("single_step_inst");
|
metrics::Tracing _("single_step_inst");
|
||||||
|
|
||||||
if (ptrace(PTRACE_SINGLESTEP, pid, 0, 0) == -1) {
|
if (ptrace(PTRACE_SINGLESTEP, pid, 0, 0) == -1) {
|
||||||
LOG(ERROR) << "Error in singlestep!";
|
LOG(ERROR) << "Error in singlestep!";
|
||||||
@ -740,7 +741,7 @@ OIDebugger::processTrapRet OIDebugger::processJitCodeRet(
|
|||||||
auto t{iter->second};
|
auto t{iter->second};
|
||||||
t->lifetime.stop();
|
t->lifetime.stop();
|
||||||
|
|
||||||
auto jitTrapProcessTime = Metrics::Tracing("jit_ret");
|
auto jitTrapProcessTime = metrics::Tracing("jit_ret");
|
||||||
|
|
||||||
VLOG(4) << "Hit the return path from vector. Redirect to " << std::hex
|
VLOG(4) << "Hit the return path from vector. Redirect to " << std::hex
|
||||||
<< t->trapAddr;
|
<< t->trapAddr;
|
||||||
@ -1526,7 +1527,7 @@ std::optional<typename Sys::RetType> OIDebugger::remoteSyscall(Args... _args) {
|
|||||||
static_assert(sizeof...(_args) == Sys::ArgsCount,
|
static_assert(sizeof...(_args) == Sys::ArgsCount,
|
||||||
"Wrong number of arguments");
|
"Wrong number of arguments");
|
||||||
|
|
||||||
Metrics::Tracing _("syscall");
|
metrics::Tracing _("syscall");
|
||||||
VLOG(1) << "syscall enter " << Sys::Name;
|
VLOG(1) << "syscall enter " << Sys::Name;
|
||||||
|
|
||||||
auto sym = symbols->locateSymbol("main");
|
auto sym = symbols->locateSymbol("main");
|
||||||
@ -1675,7 +1676,7 @@ std::optional<typename Sys::RetType> OIDebugger::remoteSyscall(Args... _args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OIDebugger::setupSegment(SegType seg) {
|
bool OIDebugger::setupSegment(SegType seg) {
|
||||||
Metrics::Tracing _("setup_segment");
|
metrics::Tracing _("setup_segment");
|
||||||
|
|
||||||
std::optional<void*> segAddr;
|
std::optional<void*> segAddr;
|
||||||
if (seg == SegType::text) {
|
if (seg == SegType::text) {
|
||||||
@ -1717,7 +1718,7 @@ bool OIDebugger::setupSegment(SegType seg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OIDebugger::unmapSegment(SegType seg) {
|
bool OIDebugger::unmapSegment(SegType seg) {
|
||||||
Metrics::Tracing _("unmap_segment");
|
metrics::Tracing _("unmap_segment");
|
||||||
auto addr =
|
auto addr =
|
||||||
(seg == SegType::text) ? segConfig.textSegBase : segConfig.dataSegBase;
|
(seg == SegType::text) ? segConfig.textSegBase : segConfig.dataSegBase;
|
||||||
auto size = (seg == SegType::text) ? textSegSize : dataSegSize;
|
auto size = (seg == SegType::text) ? textSegSize : dataSegSize;
|
||||||
@ -1762,7 +1763,7 @@ bool OIDebugger::unmapSegments(bool deleteSegConfFile) {
|
|||||||
* Unfortunately there is no cheap way to assert this.
|
* Unfortunately there is no cheap way to assert this.
|
||||||
*/
|
*/
|
||||||
bool OIDebugger::removeTraps(pid_t pid) {
|
bool OIDebugger::removeTraps(pid_t pid) {
|
||||||
Metrics::Tracing removeTrapsTracing("remove_traps");
|
metrics::Tracing removeTrapsTracing("remove_traps");
|
||||||
|
|
||||||
pid_t targetPid = pid ? pid : traceePid;
|
pid_t targetPid = pid ? pid : traceePid;
|
||||||
|
|
||||||
@ -2333,7 +2334,7 @@ void OIDebugger::restoreState(void) {
|
|||||||
<< activeTrapsCount;
|
<< activeTrapsCount;
|
||||||
assert(activeTrapsCount == 0);
|
assert(activeTrapsCount == 0);
|
||||||
|
|
||||||
Metrics::Tracing _("restore_state");
|
metrics::Tracing _("restore_state");
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
@ -2775,7 +2776,7 @@ static bool dumpDataSegment(const irequest& req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OIDebugger::processTargetData() {
|
bool OIDebugger::processTargetData() {
|
||||||
Metrics::Tracing _("process_target_data");
|
metrics::Tracing _("process_target_data");
|
||||||
|
|
||||||
std::vector<std::byte> buf{dataSegSize};
|
std::vector<std::byte> buf{dataSegSize};
|
||||||
if (!readTargetMemory(reinterpret_cast<void*>(segConfig.dataSegBase),
|
if (!readTargetMemory(reinterpret_cast<void*>(segConfig.dataSegBase),
|
||||||
@ -2928,3 +2929,5 @@ std::optional<std::string> OIDebugger::generateCode(const irequest& req) {
|
|||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "oi/TreeBuilder.h"
|
#include "oi/TreeBuilder.h"
|
||||||
#include "oi/X86InstDefs.h"
|
#include "oi/X86InstDefs.h"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace oi::detail {
|
||||||
|
|
||||||
class OIDebugger {
|
class OIDebugger {
|
||||||
OIDebugger(const OICodeGen::Config&, OICompiler::Config, TreeBuilder::Config);
|
OIDebugger(const OICodeGen::Config&, OICompiler::Config, TreeBuilder::Config);
|
||||||
@ -39,7 +39,7 @@ class OIDebugger {
|
|||||||
const OICodeGen::Config&,
|
const OICodeGen::Config&,
|
||||||
OICompiler::Config,
|
OICompiler::Config,
|
||||||
TreeBuilder::Config);
|
TreeBuilder::Config);
|
||||||
OIDebugger(fs::path,
|
OIDebugger(std::filesystem::path,
|
||||||
const OICodeGen::Config&,
|
const OICodeGen::Config&,
|
||||||
OICompiler::Config,
|
OICompiler::Config,
|
||||||
TreeBuilder::Config);
|
TreeBuilder::Config);
|
||||||
@ -77,11 +77,12 @@ class OIDebugger {
|
|||||||
return oidShouldExit;
|
return oidShouldExit;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setCacheBasePath(fs::path basePath) {
|
void setCacheBasePath(std::filesystem::path basePath) {
|
||||||
if (fs::exists(basePath.parent_path()) && !fs::exists(basePath)) {
|
if (std::filesystem::exists(basePath.parent_path()) &&
|
||||||
|
!std::filesystem::exists(basePath)) {
|
||||||
// Create cachedir if parent directory exists
|
// Create cachedir if parent directory exists
|
||||||
// TODO if returning false here, throw an error
|
// TODO if returning false here, throw an error
|
||||||
fs::create_directory(basePath);
|
std::filesystem::create_directory(basePath);
|
||||||
}
|
}
|
||||||
cache.basePath = std::move(basePath);
|
cache.basePath = std::move(basePath);
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ class OIDebugger {
|
|||||||
return std::get<2>(typeInfos.at(pdata.getReq().getReqForArg()));
|
return std::get<2>(typeInfos.at(pdata.getReq().getReqForArg()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCustomCodeFile(fs::path newCCT) {
|
void setCustomCodeFile(std::filesystem::path newCCT) {
|
||||||
customCodeFile = std::move(newCCT);
|
customCodeFile = std::move(newCCT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +244,8 @@ class OIDebugger {
|
|||||||
std::optional<std::string> generateCode(const irequest&);
|
std::optional<std::string> generateCode(const irequest&);
|
||||||
|
|
||||||
std::fstream segmentConfigFile;
|
std::fstream segmentConfigFile;
|
||||||
fs::path segConfigFilePath;
|
std::filesystem::path segConfigFilePath;
|
||||||
fs::path customCodeFile;
|
std::filesystem::path customCodeFile;
|
||||||
|
|
||||||
struct c {
|
struct c {
|
||||||
uintptr_t textSegBase{};
|
uintptr_t textSegBase{};
|
||||||
@ -293,3 +294,5 @@ class OIDebugger {
|
|||||||
static constexpr size_t prologueLength = 64;
|
static constexpr size_t prologueLength = 64;
|
||||||
static constexpr size_t constLength = 64;
|
static constexpr size_t constLength = 64;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "oi/Headers.h"
|
#include "oi/Headers.h"
|
||||||
#include "oi/OIUtils.h"
|
#include "oi/OIUtils.h"
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail {
|
||||||
|
|
||||||
std::unordered_map<std::string, std::string>
|
std::unordered_map<std::string, std::string>
|
||||||
OIGenerator::oilStrongToWeakSymbolsMap(drgnplusplus::program& prog) {
|
OIGenerator::oilStrongToWeakSymbolsMap(drgnplusplus::program& prog) {
|
||||||
@ -191,8 +191,8 @@ int OIGenerator::generate(fs::path& primaryObject, SymbolService& symbols) {
|
|||||||
OICodeGen::Config generatorConfig{};
|
OICodeGen::Config generatorConfig{};
|
||||||
OICompiler::Config compilerConfig{};
|
OICompiler::Config compilerConfig{};
|
||||||
|
|
||||||
auto features = OIUtils::processConfigFile(configFilePath, featuresMap,
|
auto features = utils::processConfigFile(configFilePath, featuresMap,
|
||||||
compilerConfig, generatorConfig);
|
compilerConfig, generatorConfig);
|
||||||
if (!features) {
|
if (!features) {
|
||||||
LOG(ERROR) << "failed to process config file";
|
LOG(ERROR) << "failed to process config file";
|
||||||
return -1;
|
return -1;
|
||||||
@ -223,4 +223,4 @@ int OIGenerator::generate(fs::path& primaryObject, SymbolService& symbols) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ObjectIntrospection
|
} // namespace oi::detail
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "oi/OICodeGen.h"
|
#include "oi/OICodeGen.h"
|
||||||
#include "oi/OICompiler.h"
|
#include "oi/OICompiler.h"
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail {
|
||||||
|
|
||||||
class OIGenerator {
|
class OIGenerator {
|
||||||
public:
|
public:
|
||||||
@ -61,4 +61,4 @@ class OIGenerator {
|
|||||||
SymbolService& symbols);
|
SymbolService& symbols);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ObjectIntrospection
|
} // namespace oi::detail
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "OIParser.tab.hh"
|
#include "OIParser.tab.hh"
|
||||||
#include "location.hh"
|
#include "location.hh"
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail {
|
||||||
|
|
||||||
class OIScanner : public yyFlexLexer {
|
class OIScanner : public yyFlexLexer {
|
||||||
public:
|
public:
|
||||||
@ -48,4 +48,4 @@ class OIScanner : public yyFlexLexer {
|
|||||||
OIParser::semantic_type* yylval = nullptr;
|
OIParser::semantic_type* yylval = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ObjectIntrospection
|
} // namespace oi::detail
|
||||||
|
10
oi/OILexer.l
10
oi/OILexer.l
@ -21,11 +21,11 @@
|
|||||||
#include "oi/OILexer.h"
|
#include "oi/OILexer.h"
|
||||||
#undef YY_DECL
|
#undef YY_DECL
|
||||||
#define YY_DECL \
|
#define YY_DECL \
|
||||||
int ObjectIntrospection::OIScanner::yylex(ObjectIntrospection::OIParser::semantic_type * const lval, \
|
int oi::detail::OIScanner::yylex(oi::detail::OIParser::semantic_type * const lval, \
|
||||||
ObjectIntrospection::OIParser::location_type *loc )
|
oi::detail::OIParser::location_type *loc )
|
||||||
|
|
||||||
/* typedef to make the returns for the tokens shorter */
|
/* typedef to make the returns for the tokens shorter */
|
||||||
using token = ObjectIntrospection::OIParser::token;
|
using token = oi::detail::OIParser::token;
|
||||||
|
|
||||||
/* update location on matching */
|
/* update location on matching */
|
||||||
#define YY_USER_ACTION loc->step(); loc->columns(yyleng);
|
#define YY_USER_ACTION loc->step(); loc->columns(yyleng);
|
||||||
@ -33,7 +33,7 @@ using token = ObjectIntrospection::OIParser::token;
|
|||||||
|
|
||||||
%option debug
|
%option debug
|
||||||
%option nodefault
|
%option nodefault
|
||||||
%option yyclass="ObjectIntrospection::OIScanner"
|
%option yyclass="oi::detail::OIScanner"
|
||||||
%option noyywrap
|
%option noyywrap
|
||||||
%option c++
|
%option c++
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ using token = ObjectIntrospection::OIParser::token;
|
|||||||
|
|
||||||
<<EOF>> {
|
<<EOF>> {
|
||||||
if (YYSTATE == COMMENT) {
|
if (YYSTATE == COMMENT) {
|
||||||
throw ObjectIntrospection::OIParser::syntax_error(
|
throw oi::detail::OIParser::syntax_error(
|
||||||
*loc, "unterminated /* comment");
|
*loc, "unterminated /* comment");
|
||||||
} else {
|
} else {
|
||||||
return( token::OI_EOF );
|
return( token::OI_EOF );
|
||||||
|
@ -35,6 +35,8 @@ extern "C" {
|
|||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace ObjectIntrospection {
|
||||||
|
|
||||||
|
using namespace oi::detail;
|
||||||
|
|
||||||
OILibraryImpl::OILibraryImpl(OILibrary* self, void* TemplateFunc)
|
OILibraryImpl::OILibraryImpl(OILibrary* self, void* TemplateFunc)
|
||||||
: _self(self), _TemplateFunc(TemplateFunc) {
|
: _self(self), _TemplateFunc(TemplateFunc) {
|
||||||
if (_self->opts.debugLevel != 0) {
|
if (_self->opts.debugLevel != 0) {
|
||||||
@ -84,7 +86,7 @@ void OILibraryImpl::initCompiler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OILibraryImpl::processConfigFile() {
|
bool OILibraryImpl::processConfigFile() {
|
||||||
auto features = OIUtils::processConfigFile(
|
auto features = utils::processConfigFile(
|
||||||
_self->opts.configFilePath,
|
_self->opts.configFilePath,
|
||||||
{
|
{
|
||||||
{Feature::ChaseRawPointers, _self->opts.chaseRawPointers},
|
{Feature::ChaseRawPointers, _self->opts.chaseRawPointers},
|
||||||
|
@ -39,9 +39,9 @@ class OILibraryImpl {
|
|||||||
|
|
||||||
void* _TemplateFunc;
|
void* _TemplateFunc;
|
||||||
|
|
||||||
OICompiler::Config compilerConfig{};
|
oi::detail::OICompiler::Config compilerConfig{};
|
||||||
OICodeGen::Config generatorConfig{};
|
oi::detail::OICodeGen::Config generatorConfig{};
|
||||||
std::shared_ptr<SymbolService> symbols{};
|
std::shared_ptr<oi::detail::SymbolService> symbols{};
|
||||||
|
|
||||||
struct c {
|
struct c {
|
||||||
void* textSegBase = nullptr;
|
void* textSegBase = nullptr;
|
||||||
|
@ -15,16 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the bison grammar responsible for generating the ObjectIntrospection::OIParser class.
|
* This is the bison grammar responsible for generating the oi::detail::OIParser
|
||||||
* This class gives us a number of things worth calling out here if only to
|
* class. This class gives us a number of things worth calling out here if only
|
||||||
* remind me later :-):
|
* to remind me later :-):
|
||||||
*
|
*
|
||||||
* - A variant interface that replaces the C union interface for the
|
* - A variant interface that replaces the C union interface for the
|
||||||
* parsers semantic values. Enabled by setting 'api.value.type variant' below.
|
* parsers semantic values. Enabled by setting 'api.value.type variant' below.
|
||||||
*/
|
*/
|
||||||
%skeleton "lalr1.cc"
|
%skeleton "lalr1.cc"
|
||||||
%defines
|
%defines
|
||||||
%define api.namespace {ObjectIntrospection}
|
%define api.namespace {oi::detail}
|
||||||
%define api.parser.class {OIParser}
|
%define api.parser.class {OIParser}
|
||||||
%define parse.trace
|
%define parse.trace
|
||||||
%define parse.error verbose
|
%define parse.error verbose
|
||||||
@ -32,14 +32,14 @@
|
|||||||
|
|
||||||
%code requires{
|
%code requires{
|
||||||
#include <list>
|
#include <list>
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail {
|
||||||
class OIScanner;
|
class OIScanner;
|
||||||
}
|
}
|
||||||
class ParseData;
|
class ParseData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ObjectIntrospection::OI_Parser constructor parameters. The scanner object is produced
|
* oi::detail::OIParser constructor parameters. The scanner object is produced
|
||||||
* by flex and is derived from the yyFlexLexer class. The parser calls
|
* by flex and is derived from the yyFlexLexer class. The parser calls
|
||||||
* its yylex() implementation to generate input tokens. The ParseData
|
* its yylex() implementation to generate input tokens. The ParseData
|
||||||
* object is spopulated by the lexer/parser introspection specifications
|
* object is spopulated by the lexer/parser introspection specifications
|
||||||
@ -100,7 +100,7 @@ oi_block: OI_PROBETYPE OI_COLON OI_FUNC OI_COLON oi_args
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ObjectIntrospection::OIParser::error(const location_type &l, const std::string &err_message)
|
oi::detail::OIParser::error(const location_type &l, const std::string &err_message)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "OI Parse Error: " << err_message << " at " << l;
|
LOG(ERROR) << "OI Parse Error: " << err_message << " at " << l;
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,11 @@
|
|||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
namespace OIUtils {
|
namespace oi::detail::utils {
|
||||||
|
|
||||||
using namespace ObjectIntrospection;
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
std::optional<ObjectIntrospection::FeatureSet> processConfigFile(
|
std::optional<FeatureSet> processConfigFile(
|
||||||
const std::string& configFilePath,
|
const std::string& configFilePath,
|
||||||
std::map<Feature, bool> featureMap,
|
std::map<Feature, bool> featureMap,
|
||||||
OICompiler::Config& compilerConfig,
|
OICompiler::Config& compilerConfig,
|
||||||
@ -173,7 +172,7 @@ std::optional<ObjectIntrospection::FeatureSet> processConfigFile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectIntrospection::FeatureSet featuresSet;
|
FeatureSet featuresSet;
|
||||||
for (auto [k, v] : featureMap) {
|
for (auto [k, v] : featureMap) {
|
||||||
if (v) {
|
if (v) {
|
||||||
featuresSet[k] = true;
|
featuresSet[k] = true;
|
||||||
@ -208,4 +207,4 @@ std::optional<ObjectIntrospection::FeatureSet> processConfigFile(
|
|||||||
return featuresSet;
|
return featuresSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OIUtils
|
} // namespace oi::detail::utils
|
||||||
|
13
oi/OIUtils.h
13
oi/OIUtils.h
@ -22,12 +22,11 @@
|
|||||||
#include "oi/OICodeGen.h"
|
#include "oi/OICodeGen.h"
|
||||||
#include "oi/OICompiler.h"
|
#include "oi/OICompiler.h"
|
||||||
|
|
||||||
namespace OIUtils {
|
namespace oi::detail::utils {
|
||||||
|
|
||||||
std::optional<ObjectIntrospection::FeatureSet> processConfigFile(
|
std::optional<FeatureSet> processConfigFile(const std::string& configFilePath,
|
||||||
const std::string& configFilePath,
|
std::map<Feature, bool> featureMap,
|
||||||
std::map<Feature, bool> featureMap,
|
OICompiler::Config& compilerConfig,
|
||||||
OICompiler::Config& compilerConfig,
|
OICodeGen::Config& generatorConfig);
|
||||||
OICodeGen::Config& generatorConfig);
|
|
||||||
|
|
||||||
} // namespace OIUtils
|
} // namespace oi::detail::utils
|
||||||
|
@ -34,6 +34,10 @@ extern "C" {
|
|||||||
#include "dwarf.h"
|
#include "dwarf.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct visitor : Ts... {
|
struct visitor : Ts... {
|
||||||
using Ts::operator()...;
|
using Ts::operator()...;
|
||||||
@ -885,3 +889,5 @@ std::optional<RootInfo> SymbolService::getRootType(const irequest& req) {
|
|||||||
|
|
||||||
return RootInfo{paramName, paramType};
|
return RootInfo{paramName, paramType};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -26,12 +26,12 @@
|
|||||||
#include "oi/Descs.h"
|
#include "oi/Descs.h"
|
||||||
#include "oi/TypeHierarchy.h"
|
#include "oi/TypeHierarchy.h"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
struct Dwfl;
|
struct Dwfl;
|
||||||
struct drgn_program;
|
struct drgn_program;
|
||||||
struct irequest;
|
struct irequest;
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
struct SymbolInfo {
|
struct SymbolInfo {
|
||||||
uint64_t addr;
|
uint64_t addr;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
@ -40,7 +40,7 @@ struct SymbolInfo {
|
|||||||
class SymbolService {
|
class SymbolService {
|
||||||
public:
|
public:
|
||||||
SymbolService(pid_t);
|
SymbolService(pid_t);
|
||||||
SymbolService(fs::path);
|
SymbolService(std::filesystem::path);
|
||||||
SymbolService(const SymbolService&) = delete;
|
SymbolService(const SymbolService&) = delete;
|
||||||
SymbolService& operator=(const SymbolService&) = delete;
|
SymbolService& operator=(const SymbolService&) = delete;
|
||||||
~SymbolService();
|
~SymbolService();
|
||||||
@ -64,13 +64,13 @@ class SymbolService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::variant<pid_t, fs::path> target;
|
std::variant<pid_t, std::filesystem::path> target;
|
||||||
struct Dwfl* dwfl{nullptr};
|
struct Dwfl* dwfl{nullptr};
|
||||||
struct drgn_program* prog{nullptr};
|
struct drgn_program* prog{nullptr};
|
||||||
|
|
||||||
bool loadModules();
|
bool loadModules();
|
||||||
bool loadModulesFromPid(pid_t);
|
bool loadModulesFromPid(pid_t);
|
||||||
bool loadModulesFromPath(const fs::path&);
|
bool loadModulesFromPath(const std::filesystem::path&);
|
||||||
|
|
||||||
std::vector<std::pair<uint64_t, uint64_t>> executableAddrs{};
|
std::vector<std::pair<uint64_t, uint64_t>> executableAddrs{};
|
||||||
bool hardDisableDrgn = false;
|
bool hardDisableDrgn = false;
|
||||||
@ -78,3 +78,5 @@ class SymbolService {
|
|||||||
protected:
|
protected:
|
||||||
SymbolService() = default; // For unit tests
|
SymbolService() = default; // For unit tests
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -25,6 +25,8 @@ extern "C" {
|
|||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Breakpoint traps (INT3) instructions are the primary mechanism used to
|
* Breakpoint traps (INT3) instructions are the primary mechanism used to
|
||||||
* transfer control from the traced process to the debugger. There are several
|
* transfer control from the traced process to the debugger. There are several
|
||||||
@ -114,7 +116,7 @@ class trapInfo {
|
|||||||
*/
|
*/
|
||||||
uintptr_t replayInstAddr{};
|
uintptr_t replayInstAddr{};
|
||||||
|
|
||||||
ObjectIntrospection::Metrics::Tracing lifetime{"trap"};
|
metrics::Tracing lifetime{"trap"};
|
||||||
|
|
||||||
trapInfo() = default;
|
trapInfo() = default;
|
||||||
trapInfo(trapType t, uint64_t ta, uint64_t po = 0, bool fv = false)
|
trapInfo(trapType t, uint64_t ta, uint64_t po = 0, bool fv = false)
|
||||||
@ -132,3 +134,5 @@ inline std::ostream& operator<<(std::ostream& out, const trapInfo& t) {
|
|||||||
return out << "Trap " << trapTypeDescs[t.trapKind] << " @"
|
return out << "Trap " << trapTypeDescs[t.trapKind] << " @"
|
||||||
<< (void*)t.trapAddr;
|
<< (void*)t.trapAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -39,6 +39,8 @@ extern "C" {
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
/* Tag indicating if the pointer has been followed or skipped */
|
/* Tag indicating if the pointer has been followed or skipped */
|
||||||
enum class TrackPointerTag : uint64_t {
|
enum class TrackPointerTag : uint64_t {
|
||||||
/* The content has been skipped.
|
/* The content has been skipped.
|
||||||
@ -229,7 +231,7 @@ void TreeBuilder::build(const std::vector<uint64_t>& data,
|
|||||||
|
|
||||||
oidDataIndex = 4; // HACK: OID's first 4 outputs are dummy 0s
|
oidDataIndex = 4; // HACK: OID's first 4 outputs are dummy 0s
|
||||||
|
|
||||||
ObjectIntrospection::Metrics::Tracing _("build_tree");
|
metrics::Tracing _("build_tree");
|
||||||
VLOG(1) << "Building tree...";
|
VLOG(1) << "Building tree...";
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -971,3 +973,5 @@ void TreeBuilder::JSON(NodeID id, std::ofstream& output) {
|
|||||||
}
|
}
|
||||||
output << "}";
|
output << "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -36,12 +36,14 @@ class DB;
|
|||||||
// Forward declared, comes from PaddingInfo.h
|
// Forward declared, comes from PaddingInfo.h
|
||||||
struct PaddingInfo;
|
struct PaddingInfo;
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
class TreeBuilder {
|
class TreeBuilder {
|
||||||
public:
|
public:
|
||||||
struct Config {
|
struct Config {
|
||||||
// Don't set default values for the config so the user gets
|
// Don't set default values for the config so the user gets
|
||||||
// an "unitialized field" warning if he missed any.
|
// an "unitialized field" warning if he missed any.
|
||||||
ObjectIntrospection::FeatureSet features;
|
FeatureSet features;
|
||||||
bool logAllStructs;
|
bool logAllStructs;
|
||||||
bool dumpDataSegment;
|
bool dumpDataSegment;
|
||||||
std::optional<std::string> jsonPath;
|
std::optional<std::string> jsonPath;
|
||||||
@ -118,3 +120,5 @@ class TreeBuilder {
|
|||||||
uint64_t dynamicSize,
|
uint64_t dynamicSize,
|
||||||
uint64_t memberSizes);
|
uint64_t memberSizes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
template <class>
|
template <class>
|
||||||
inline constexpr bool always_false_v = false;
|
inline constexpr bool always_false_v = false;
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail::exporters {
|
||||||
namespace exporters {
|
|
||||||
|
|
||||||
std::optional<TypeCheckingWalker::Element> TypeCheckingWalker::advance() {
|
std::optional<TypeCheckingWalker::Element> TypeCheckingWalker::advance() {
|
||||||
if (stack.empty()) {
|
if (stack.empty()) {
|
||||||
@ -76,5 +75,4 @@ std::optional<TypeCheckingWalker::Element> TypeCheckingWalker::advance() {
|
|||||||
el);
|
el);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace exporters
|
} // namespace oi::detail::exporters
|
||||||
} // namespace ObjectIntrospection
|
|
||||||
|
@ -36,8 +36,7 @@
|
|||||||
|
|
||||||
#include "oi/types/dy.h"
|
#include "oi/types/dy.h"
|
||||||
|
|
||||||
namespace ObjectIntrospection {
|
namespace oi::detail::exporters {
|
||||||
namespace exporters {
|
|
||||||
|
|
||||||
class TypeCheckingWalker {
|
class TypeCheckingWalker {
|
||||||
public:
|
public:
|
||||||
@ -74,5 +73,4 @@ class TypeCheckingWalker {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace exporters
|
} // namespace oi::detail::exporters
|
||||||
} // namespace ObjectIntrospection
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "oi/exporters/TypeCheckingWalker.h"
|
#include "oi/exporters/TypeCheckingWalker.h"
|
||||||
|
|
||||||
using namespace ObjectIntrospection;
|
using namespace oi;
|
||||||
using exporters::TypeCheckingWalker;
|
using oi::detail::exporters::TypeCheckingWalker;
|
||||||
|
|
||||||
TEST(TypeCheckingWalker, TestUnit) {
|
TEST(TypeCheckingWalker, TestUnit) {
|
||||||
// ASSIGN
|
// ASSIGN
|
||||||
|
@ -29,7 +29,7 @@ extern "C" {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using ref = std::reference_wrapper<T>;
|
using ref = std::reference_wrapper<T>;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass AddChildren::createPass(DrgnParser& drgnParser, SymbolService& symbols) {
|
Pass AddChildren::createPass(DrgnParser& drgnParser, SymbolService& symbols) {
|
||||||
auto fn = [&drgnParser, &symbols](TypeGraph& typeGraph) {
|
auto fn = [&drgnParser, &symbols](TypeGraph& typeGraph) {
|
||||||
@ -202,4 +202,4 @@ void AddChildren::enumerateChildClasses(SymbolService& symbols) {
|
|||||||
drgn_type_iterator_destroy(typesIterator);
|
drgn_type_iterator_destroy(typesIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -23,10 +23,12 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
class SymbolService;
|
|
||||||
struct drgn_type;
|
struct drgn_type;
|
||||||
|
namespace oi::detail {
|
||||||
|
class SymbolService;
|
||||||
|
}
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
class DrgnParser;
|
class DrgnParser;
|
||||||
class TypeGraph;
|
class TypeGraph;
|
||||||
@ -74,4 +76,4 @@ class AddChildren final : public RecursiveVisitor {
|
|||||||
std::unordered_map<std::string, std::vector<drgn_type*>> childClasses_;
|
std::unordered_map<std::string, std::vector<drgn_type*>> childClasses_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using ref = std::reference_wrapper<T>;
|
using ref = std::reference_wrapper<T>;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass AddPadding::createPass() {
|
Pass AddPadding::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -135,4 +135,4 @@ void AddPadding::addPadding(uint64_t paddingStartBits,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
class TypeGraph;
|
class TypeGraph;
|
||||||
|
|
||||||
@ -59,4 +59,4 @@ class AddPadding final : public RecursiveVisitor {
|
|||||||
std::vector<Member>& paddedMembers);
|
std::vector<Member>& paddedMembers);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using ref = std::reference_wrapper<T>;
|
using ref = std::reference_wrapper<T>;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass AlignmentCalc::createPass() {
|
Pass AlignmentCalc::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -76,4 +76,4 @@ void AlignmentCalc::visit(Class& c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AlignmentCalc
|
* AlignmentCalc
|
||||||
@ -46,4 +46,4 @@ class AlignmentCalc final : public RecursiveVisitor {
|
|||||||
std::unordered_set<Type*> visited_;
|
std::unordered_set<Type*> visited_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -27,7 +27,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
uint64_t get_drgn_type_size(struct drgn_type* type) {
|
uint64_t get_drgn_type_size(struct drgn_type* type) {
|
||||||
@ -499,4 +499,4 @@ DrgnParserError::~DrgnParserError() {
|
|||||||
drgn_error_destroy(err_);
|
drgn_error_destroy(err_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -27,7 +27,7 @@ struct drgn_error;
|
|||||||
|
|
||||||
struct ContainerInfo;
|
struct ContainerInfo;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DrgnParser
|
* DrgnParser
|
||||||
@ -110,4 +110,4 @@ class DrgnParserError : public std::runtime_error {
|
|||||||
struct drgn_error* err_ = nullptr;
|
struct drgn_error* err_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "TypeIdentifier.h"
|
#include "TypeIdentifier.h"
|
||||||
#include "oi/OICodeGen.h"
|
#include "oi/OICodeGen.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass EnforceCompatibility::createPass() {
|
Pass EnforceCompatibility::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -78,4 +78,4 @@ void EnforceCompatibility::visit(Class& c) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EnforceCompatibility
|
* EnforceCompatibility
|
||||||
@ -46,4 +46,4 @@ class EnforceCompatibility : public RecursiveVisitor {
|
|||||||
NodeTracker& tracker_;
|
NodeTracker& tracker_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "TypeGraph.h"
|
#include "TypeGraph.h"
|
||||||
#include "TypeIdentifier.h"
|
#include "TypeIdentifier.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass Flattener::createPass() {
|
Pass Flattener::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -212,4 +212,4 @@ void Flattener::visit(Container& c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flattener
|
* Flattener
|
||||||
@ -52,4 +52,4 @@ class Flattener : public RecursiveVisitor {
|
|||||||
std::vector<uint64_t> offset_stack_;
|
std::vector<uint64_t> offset_stack_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using ref = std::reference_wrapper<T>;
|
using ref = std::reference_wrapper<T>;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass NameGen::createPass() {
|
Pass NameGen::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -152,4 +152,4 @@ void NameGen::visit(Typedef& td) {
|
|||||||
accept(td.underlyingType());
|
accept(td.underlyingType());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
// TODO make all final
|
// TODO make all final
|
||||||
/*
|
/*
|
||||||
@ -55,4 +55,4 @@ class NameGen final : public RecursiveVisitor {
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NodeTracker
|
* NodeTracker
|
||||||
@ -67,4 +67,4 @@ class NodeTracker {
|
|||||||
std::vector<bool> visited_;
|
std::vector<bool> visited_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using ref = std::reference_wrapper<T>;
|
using ref = std::reference_wrapper<T>;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
void Pass::run(TypeGraph& typeGraph) {
|
void Pass::run(TypeGraph& typeGraph) {
|
||||||
fn_(typeGraph);
|
fn_(typeGraph);
|
||||||
@ -72,4 +72,4 @@ void PassManager::run(TypeGraph& typeGraph) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
class TypeGraph;
|
class TypeGraph;
|
||||||
class Type;
|
class Type;
|
||||||
@ -59,4 +59,4 @@ class PassManager {
|
|||||||
std::vector<Pass> passes_;
|
std::vector<Pass> passes_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Printer::Printer(std::ostream& out, size_t numTypes) : out_(out) {
|
Printer::Printer(std::ostream& out, size_t numTypes) : out_(out) {
|
||||||
if (numTypes == 0) {
|
if (numTypes == 0) {
|
||||||
@ -236,4 +236,4 @@ std::string Printer::align_str(uint64_t align) {
|
|||||||
return ", align: " + std::to_string(align);
|
return ", align: " + std::to_string(align);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Printer
|
* Printer
|
||||||
@ -60,4 +60,4 @@ class Printer : public ConstVisitor {
|
|||||||
std::unordered_map<const Type*, int> nodeNums_;
|
std::unordered_map<const Type*, int> nodeNums_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "TypeGraph.h"
|
#include "TypeGraph.h"
|
||||||
#include "TypeIdentifier.h"
|
#include "TypeIdentifier.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass Prune::createPass() {
|
Pass Prune::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -62,4 +62,4 @@ void Prune::visit(Class& c) {
|
|||||||
c.functions.shrink_to_fit();
|
c.functions.shrink_to_fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prune
|
* Prune
|
||||||
@ -48,4 +48,4 @@ class Prune : public RecursiveVisitor {
|
|||||||
NodeTracker& tracker_;
|
NodeTracker& tracker_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "AddPadding.h"
|
#include "AddPadding.h"
|
||||||
#include "TypeGraph.h"
|
#include "TypeGraph.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass RemoveMembers::createPass(
|
Pass RemoveMembers::createPass(
|
||||||
const std::vector<std::pair<std::string, std::string>>& membersToIgnore) {
|
const std::vector<std::pair<std::string, std::string>>& membersToIgnore) {
|
||||||
@ -75,4 +75,4 @@ bool RemoveMembers::ignoreMember(const std::string& typeName,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RemoveMembers
|
* RemoveMembers
|
||||||
@ -54,4 +54,4 @@ class RemoveMembers : public RecursiveVisitor {
|
|||||||
const std::vector<std::pair<std::string, std::string>>& membersToIgnore_;
|
const std::vector<std::pair<std::string, std::string>>& membersToIgnore_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "TypeGraph.h"
|
#include "TypeGraph.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass RemoveTopLevelPointer::createPass() {
|
Pass RemoveTopLevelPointer::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -42,4 +42,4 @@ void RemoveTopLevelPointer::visit(Pointer& p) {
|
|||||||
topLevelType_ = &p.pointeeType();
|
topLevelType_ = &p.pointeeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RemoveTopLevelPointer
|
* RemoveTopLevelPointer
|
||||||
@ -41,4 +41,4 @@ class RemoveTopLevelPointer : public LazyVisitor {
|
|||||||
Type* topLevelType_ = nullptr;
|
Type* topLevelType_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using ref = std::reference_wrapper<T>;
|
using ref = std::reference_wrapper<T>;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass TopoSorter::createPass() {
|
Pass TopoSorter::createPass() {
|
||||||
auto fn = [](TypeGraph& typeGraph) {
|
auto fn = [](TypeGraph& typeGraph) {
|
||||||
@ -148,4 +148,4 @@ void TopoSorter::acceptAfter(Type* type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TopoSorter
|
* TopoSorter
|
||||||
@ -56,4 +56,4 @@ class TopoSorter : public RecursiveVisitor {
|
|||||||
void acceptAfter(Type* type);
|
void acceptAfter(Type* type);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "TypeGraph.h"
|
#include "TypeGraph.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
NodeTracker& TypeGraph::resetTracker() noexcept {
|
NodeTracker& TypeGraph::resetTracker() noexcept {
|
||||||
tracker_.reset();
|
tracker_.reset();
|
||||||
@ -74,4 +74,4 @@ Primitive& TypeGraph::makeType<Primitive>(Primitive::Kind kind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "NodeTracker.h"
|
#include "NodeTracker.h"
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TypeGraph
|
* TypeGraph
|
||||||
@ -91,4 +91,4 @@ class TypeGraph {
|
|||||||
NodeId next_id_ = 0;
|
NodeId next_id_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "TypeGraph.h"
|
#include "TypeGraph.h"
|
||||||
#include "oi/ContainerInfo.h"
|
#include "oi/ContainerInfo.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
Pass TypeIdentifier::createPass(
|
Pass TypeIdentifier::createPass(
|
||||||
const std::vector<ContainerInfo>& passThroughTypes) {
|
const std::vector<ContainerInfo>& passThroughTypes) {
|
||||||
@ -115,4 +115,4 @@ void TypeIdentifier::visit(Container& c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
#include "oi/ContainerInfo.h"
|
#include "oi/ContainerInfo.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
class TypeGraph;
|
class TypeGraph;
|
||||||
|
|
||||||
@ -56,4 +56,4 @@ class TypeIdentifier : public RecursiveVisitor {
|
|||||||
const std::vector<ContainerInfo>& passThroughTypes_;
|
const std::vector<ContainerInfo>& passThroughTypes_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
#define X(OI_TYPE_NAME) \
|
#define X(OI_TYPE_NAME) \
|
||||||
void OI_TYPE_NAME::accept(Visitor& v) { \
|
void OI_TYPE_NAME::accept(Visitor& v) { \
|
||||||
@ -131,4 +131,4 @@ Type& stripTypedefs(Type& type) {
|
|||||||
return *t;
|
return *t;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
struct ContainerInfo;
|
struct ContainerInfo;
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
// Must be signed. "-1" represents "leaf node"
|
// Must be signed. "-1" represents "leaf node"
|
||||||
using NodeId = int32_t;
|
using NodeId = int32_t;
|
||||||
@ -589,6 +589,6 @@ class DummyAllocator : public Type {
|
|||||||
|
|
||||||
Type& stripTypedefs(Type& type);
|
Type& stripTypedefs(Type& type);
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
|
||||||
#undef DECLARE_ACCEPT
|
#undef DECLARE_ACCEPT
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Visitor
|
* Visitor
|
||||||
@ -145,4 +145,4 @@ class LazyConstVisitor : public ConstVisitor {
|
|||||||
#undef X
|
#undef X
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "oi/types/dy.h"
|
#include "oi/types/dy.h"
|
||||||
#include "oi/types/st.h"
|
#include "oi/types/st.h"
|
||||||
|
|
||||||
using namespace ObjectIntrospection;
|
using namespace oi;
|
||||||
|
|
||||||
class DummyDataBuffer {};
|
class DummyDataBuffer {};
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@ target_include_directories(resources PRIVATE ../)
|
|||||||
|
|
||||||
function(embed_headers output)
|
function(embed_headers output)
|
||||||
file(WRITE ${output} "#include \"oi/Headers.h\"\n\n")
|
file(WRITE ${output} "#include \"oi/Headers.h\"\n\n")
|
||||||
file(APPEND ${output} "namespace ObjectIntrospection {\n")
|
file(APPEND ${output} "namespace oi::detail::headers {\n")
|
||||||
file(APPEND ${output} "namespace headers {\n\n")
|
|
||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
../include/oi/types/dy.h
|
../include/oi/types/dy.h
|
||||||
@ -33,8 +32,7 @@ function(embed_headers output)
|
|||||||
file(APPEND ${output} "const std::string_view ${varname} = R\"CONTENTS(${contents})CONTENTS\";\n\n")
|
file(APPEND ${output} "const std::string_view ${varname} = R\"CONTENTS(${contents})CONTENTS\";\n\n")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
file(APPEND ${output} "} // namespace headers\n")
|
file(APPEND ${output} "} // namespace oi::detail::headers\n")
|
||||||
file(APPEND ${output} "} // namespace ObjectIntrospection\n")
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
embed_headers(${CMAKE_BINARY_DIR}/resources/headers.cpp)
|
embed_headers(${CMAKE_BINARY_DIR}/resources/headers.cpp)
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
#include "oi/type_graph/Types.h"
|
#include "oi/type_graph/Types.h"
|
||||||
|
|
||||||
using namespace type_graph;
|
namespace oi::detail::type_graph {
|
||||||
|
|
||||||
namespace type_graph {
|
|
||||||
class TypeGraph;
|
class TypeGraph;
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
|
||||||
|
using namespace oi::detail::type_graph;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TypeGraphParser
|
* TypeGraphParser
|
||||||
|
@ -3,8 +3,12 @@
|
|||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "oi/SymbolService.h"
|
#include "oi/SymbolService.h"
|
||||||
|
|
||||||
|
namespace oi::detail {
|
||||||
|
|
||||||
class MockSymbolService : public SymbolService {
|
class MockSymbolService : public SymbolService {
|
||||||
public:
|
public:
|
||||||
MockSymbolService() {
|
MockSymbolService() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace oi::detail
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include "oi/OICompiler.h"
|
#include "oi/OICompiler.h"
|
||||||
|
|
||||||
|
using namespace oi::detail;
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
/* Add the suffix operator _b to easily create array of uint8_t. */
|
/* Add the suffix operator _b to easily create array of uint8_t. */
|
||||||
|
@ -4,12 +4,16 @@
|
|||||||
|
|
||||||
#include "oi/type_graph/DrgnParser.h"
|
#include "oi/type_graph/DrgnParser.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail {
|
||||||
|
class SymbolService;
|
||||||
|
}
|
||||||
|
namespace oi::detail::type_graph {
|
||||||
class TypeGraph;
|
class TypeGraph;
|
||||||
}
|
}
|
||||||
class SymbolService;
|
|
||||||
struct drgn_type;
|
struct drgn_type;
|
||||||
|
|
||||||
|
using namespace oi::detail;
|
||||||
|
|
||||||
class DrgnParserTest : public ::testing::Test {
|
class DrgnParserTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
static void SetUpTestSuite() {
|
static void SetUpTestSuite() {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "oi/type_graph/NodeTracker.h"
|
#include "oi/type_graph/NodeTracker.h"
|
||||||
|
|
||||||
using namespace type_graph;
|
using namespace oi::detail::type_graph;
|
||||||
|
|
||||||
TEST(NodeTrackerTest, LeafNodes) {
|
TEST(NodeTrackerTest, LeafNodes) {
|
||||||
Primitive myint32{Primitive::Kind::Int32};
|
Primitive myint32{Primitive::Kind::Int32};
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
using ::testing::HasSubstr;
|
using ::testing::HasSubstr;
|
||||||
|
|
||||||
using namespace ObjectIntrospection;
|
using namespace oi::detail;
|
||||||
|
|
||||||
// Utilities
|
// Utilities
|
||||||
static ParseData parseString(const std::string& script) {
|
static ParseData parseString(const std::string& script) {
|
||||||
|
@ -6,9 +6,11 @@
|
|||||||
|
|
||||||
#include "oi/type_graph/Types.h"
|
#include "oi/type_graph/Types.h"
|
||||||
|
|
||||||
namespace type_graph {
|
namespace oi::detail::type_graph {
|
||||||
class Pass;
|
class Pass;
|
||||||
} // namespace type_graph
|
} // namespace oi::detail::type_graph
|
||||||
|
|
||||||
|
using namespace oi::detail;
|
||||||
|
|
||||||
void check(const std::vector<std::reference_wrapper<type_graph::Type>>& types,
|
void check(const std::vector<std::reference_wrapper<type_graph::Type>>& types,
|
||||||
std::string_view expected,
|
std::string_view expected,
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "oi/OIOpts.h"
|
#include "oi/OIOpts.h"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
using namespace ObjectIntrospection;
|
using namespace oi::detail;
|
||||||
|
|
||||||
constexpr static OIOpts opts{
|
constexpr static OIOpts opts{
|
||||||
OIOpt{'h', "help", no_argument, nullptr, "Print this message and exit."},
|
OIOpt{'h', "help", no_argument, nullptr, "Print this message and exit."},
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
using namespace ObjectIntrospection;
|
using namespace oi::detail;
|
||||||
|
|
||||||
constexpr static OIOpts opts{
|
constexpr static OIOpts opts{
|
||||||
OIOpt{'h', "help", no_argument, nullptr, "Print this message and exit"},
|
OIOpt{'h', "help", no_argument, nullptr, "Print this message and exit"},
|
||||||
|
Loading…
Reference in New Issue
Block a user