mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
2060a0491e
Create DrgnExporter to translate Type Graph "Type" nodes into drgn_type structs, suitable for use in OICache and TreeBuilder.
311 lines
9.8 KiB
TOML
311 lines
9.8 KiB
TOML
includes = ["functional", "memory"]
|
|
definitions = '''
|
|
struct RawNode {
|
|
int value;
|
|
struct RawNode* next;
|
|
};
|
|
|
|
struct UniqueNode {
|
|
int value;
|
|
std::unique_ptr<struct UniqueNode> next;
|
|
};
|
|
|
|
struct SharedNode {
|
|
int value;
|
|
std::shared_ptr<struct SharedNode> next;
|
|
};
|
|
|
|
template <typename T>
|
|
struct Wrapper {
|
|
Wrapper(T t_) : t(t_) {};
|
|
T t;
|
|
};
|
|
'''
|
|
[cases]
|
|
[cases.raw_ptr]
|
|
oil_disable = "oil can't chase pointers safely"
|
|
param_types = ["RawNode*"]
|
|
setup = '''
|
|
RawNode *first = new RawNode{1, nullptr};
|
|
RawNode *second = new RawNode{2, nullptr};
|
|
RawNode *third = new RawNode{3, nullptr};
|
|
first->next = second;
|
|
second->next = third;
|
|
third->next = first;
|
|
return first;
|
|
'''
|
|
cli_options = ["-fchase-raw-pointers"]
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"typeName": "ns_cycles::RawNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 32,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "ns_cycles::RawNode*",
|
|
"staticSize": 8,
|
|
"dynamicSize": 32,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::RawNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 16,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "ns_cycles::RawNode*",
|
|
"staticSize": 8,
|
|
"dynamicSize": 16,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::RawNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 0,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "ns_cycles::RawNode*",
|
|
"staticSize": 8,
|
|
"dynamicSize": 0
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
'''
|
|
|
|
[cases.raw_ptr_wrapped]
|
|
oil_disable = "oil can't chase pointers safely"
|
|
param_types = ["Wrapper<RawNode*>&"]
|
|
setup = '''
|
|
RawNode *first = new RawNode{1, nullptr};
|
|
RawNode *second = new RawNode{2, nullptr};
|
|
RawNode *third = new RawNode{3, nullptr};
|
|
first->next = second;
|
|
second->next = third;
|
|
third->next = first;
|
|
return Wrapper<RawNode*>(first);
|
|
'''
|
|
cli_options = ["-fchase-raw-pointers"]
|
|
expect_json = '''[{
|
|
"staticSize": 8,
|
|
"dynamicSize": 48,
|
|
"members": [{
|
|
"name": "t",
|
|
"typeName": "ns_cycles::RawNode*",
|
|
"staticSize": 8,
|
|
"dynamicSize": 48,
|
|
"members": [{
|
|
"typeName": "ns_cycles::RawNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 32,
|
|
"members": [
|
|
{ "name": "value", "typeName": "int32_t", "staticSize": 4, "dynamicSize": 0 },
|
|
{
|
|
"name": "next",
|
|
"typeName": "ns_cycles::RawNode*",
|
|
"staticSize": 8,
|
|
"dynamicSize": 32,
|
|
"members": [{
|
|
"typeName": "ns_cycles::RawNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 16,
|
|
"members": [
|
|
{ "name": "value", "typeName": "int32_t", "staticSize": 4, "dynamicSize": 0 },
|
|
{
|
|
"name": "next",
|
|
"typeName": "ns_cycles::RawNode*",
|
|
"staticSize": 8,
|
|
"dynamicSize": 16,
|
|
"members": [{
|
|
"typeName": "ns_cycles::RawNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 0,
|
|
"members": [
|
|
{ "name": "value", "typeName": "int32_t", "staticSize": 4, "dynamicSize": 0 },
|
|
{
|
|
"name": "next",
|
|
"typeName": "ns_cycles::RawNode*",
|
|
"staticSize": 8,
|
|
"dynamicSize": 0
|
|
}
|
|
]}]}]}]}]}]}]}]
|
|
'''
|
|
|
|
[cases.unique_ptr]
|
|
oil_skip = "cycles are broken" # https://github.com/facebookexperimental/object-introspection/issues/293
|
|
param_types = ["std::reference_wrapper<UniqueNode>&"]
|
|
setup = '''
|
|
auto first = std::make_unique<UniqueNode>();
|
|
auto firstPtr = first.get();
|
|
first->next = std::make_unique<UniqueNode>();
|
|
first->next->next = std::make_unique<UniqueNode>();
|
|
first->next->next->next = std::move(first);
|
|
return *firstPtr;
|
|
'''
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"typeName": "std::reference_wrapper<ns_cycles::UniqueNode>",
|
|
"staticSize": 8,
|
|
"dynamicSize": 48,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::UniqueNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 32,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "std::unique_ptr<ns_cycles::UniqueNode, default_delete<ns_cycles::UniqueNode>>",
|
|
"staticSize": 8,
|
|
"dynamicSize": 32,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::UniqueNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 16,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "std::unique_ptr<ns_cycles::UniqueNode, default_delete<ns_cycles::UniqueNode>>",
|
|
"staticSize": 8,
|
|
"dynamicSize": 16,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::UniqueNode",
|
|
"staticSize": 16,
|
|
"dynamicSize": 0,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "std::unique_ptr<ns_cycles::UniqueNode, default_delete<ns_cycles::UniqueNode>>",
|
|
"staticSize": 8,
|
|
"dynamicSize": 0
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
'''
|
|
|
|
[cases.shared_ptr]
|
|
oil_skip = "cycles are broken" # https://github.com/facebookexperimental/object-introspection/issues/293
|
|
param_types = ["std::reference_wrapper<SharedNode>&"]
|
|
setup = '''
|
|
auto first = std::make_shared<SharedNode>();
|
|
auto firstPtr = first.get();
|
|
first->next = std::make_shared<SharedNode>();
|
|
first->next->next = std::make_shared<SharedNode>();
|
|
first->next->next->next = first;
|
|
return *firstPtr;
|
|
'''
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"typeName": "std::reference_wrapper<ns_cycles::SharedNode>",
|
|
"staticSize": 8,
|
|
"dynamicSize": 72,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::SharedNode",
|
|
"staticSize": 24,
|
|
"dynamicSize": 48,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "std::shared_ptr<ns_cycles::SharedNode>",
|
|
"staticSize": 16,
|
|
"dynamicSize": 48,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::SharedNode",
|
|
"staticSize": 24,
|
|
"dynamicSize": 24,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "std::shared_ptr<ns_cycles::SharedNode>",
|
|
"staticSize": 16,
|
|
"dynamicSize": 24,
|
|
"members": [
|
|
{
|
|
"typeName": "ns_cycles::SharedNode",
|
|
"staticSize": 24,
|
|
"dynamicSize": 0,
|
|
"members": [
|
|
{
|
|
"typeName": "int32_t",
|
|
"staticSize": 4,
|
|
"dynamicSize": 0
|
|
},
|
|
{
|
|
"typeName": "std::shared_ptr<ns_cycles::SharedNode>",
|
|
"staticSize": 16,
|
|
"dynamicSize": 0
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
'''
|