facebookexperimental / object-introspection

Object Introspection (OI) enables on-demand, hierarchical profiling of objects in arbitrary C/C++ programs with no recompilation.
Apache License 2.0
160 stars 13 forks source link

tbv2: fix pointer codegen #461

Closed JakeHillion closed 7 months ago

JakeHillion commented 8 months ago

tbv2: fix pointer codegen

A previous change enabled running OIL tests with specific features enabled. This highlighted that pointer code generation under TreeBuilder-v2 was very broken. This change updates pointer code generation to work and enables the skipped tests. All enabled tests need expected_json_v2 added to them due to formatting differences.

Reformatted and rewrote the basic type handler that handles primitives and pointers. Removed the reliance on features to decide whether to generate for TreeBuilder-v2 as the intermediate features have been removed. Pointers are treated as containers with a capacity of 1 and a length of 0 if null/a cycle and 1 if followed. This holds for void pointers where, although they aren't followed, the length is still set.

There were a couple of other changes needed to enable these tests on TBv2 that aren't worth their own issues and PRs, I sneaked them in here.

Extra changes:

Closes #458.

Test plan:

codecov-commenter commented 8 months ago

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (4c047b5) 62.44% compared to head (03c81cb) 62.52%.

Files Patch % Lines
oi/CodeGen.cpp 66.66% 0 Missing and 3 partials :warning:
oi/type_graph/TopoSorter.cpp 75.00% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #461 +/- ## ========================================== + Coverage 62.44% 62.52% +0.07% ========================================== Files 123 123 Lines 12021 12034 +13 Branches 1958 1958 ========================================== + Hits 7507 7524 +17 + Misses 3569 3563 -6 - Partials 945 947 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.