mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 19:19:05 +01:00
Fix TreeBuilder processing of zero-length array
TreeBuilder did not consider a zero-length array like a container and never read the array's sizeof stored in the data buffer, leading to a mismatch between bytes written vs read out of the buffer. Now, `TreeBuilder::isContainer` does consider zero-length array like a container and properly consume all the object sizes in the buffer.
This commit is contained in:
parent
fba0d527fd
commit
91ff9fceb9
@ -378,9 +378,20 @@ uint64_t TreeBuilder::next() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TreeBuilder::isContainer(const Variable& variable) {
|
bool TreeBuilder::isContainer(const Variable& variable) {
|
||||||
return th->containerTypeMap.contains(variable.type) ||
|
if (th->containerTypeMap.contains(variable.type)) {
|
||||||
(drgn_type_kind(variable.type) == DRGN_TYPE_ARRAY &&
|
return true;
|
||||||
drgn_type_length(variable.type) > 0);
|
}
|
||||||
|
|
||||||
|
if (drgn_type_kind(variable.type) == DRGN_TYPE_ARRAY) {
|
||||||
|
/* CodeGen v1 does not consider zero-length array as containers,
|
||||||
|
* but CodeGen v2 does. This discrepancy is handled here.
|
||||||
|
* TODO: Cleanup this workaround once CodeGen v1 is gone. See #453
|
||||||
|
*/
|
||||||
|
return config.features[Feature::TypeGraph] ||
|
||||||
|
drgn_type_length(variable.type) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeBuilder::isPrimitive(struct drgn_type* type) {
|
bool TreeBuilder::isPrimitive(struct drgn_type* type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user