Commit Graph

398 Commits

Author SHA1 Message Date
Jake Hillion
5c3bb261c8 integration: add GLOB with CONFIGURE_DEPENDS to pick up files 2023-06-29 15:47:06 +01:00
Alastair Robertson
b50ab57e33 AddPadding: Move common code into a function 2023-06-29 14:10:05 +01:00
Alastair Robertson
cf583700fa Add missing namespace to folly::IOBuf container TOML
Required for CodeGen v2, which does not add "using namespace xxx" and
uses fully qualified names instead.
2023-06-29 11:59:07 +01:00
Alastair Robertson
24d707cf56 Flattener: Flatten class template parameters 2023-06-29 11:58:39 +01:00
Jake Hillion
ceafce8e1a ci: retry tests once on failure 2023-06-28 16:37:11 +01:00
Alastair Robertson
26fd44c26c CI: Fix code coverage collection
Multiple jobs are not allowed to persist the same files to a workspace.

This commit takes the lazy approach of splitting the type-graph and
non-type-graph jobs into different workspaces and creating a second
coverage job to avoid the conflict.
2023-06-28 16:11:50 +01:00
Alastair Robertson
04715e2015 TypeGraph: Create dummy containers
These represent types which don't store any interesting data for us to
measure, but which are required by a real container so can not be
replaced with our own generated class types.

std::allocator often has bad DWARF, so it must be replaced after the
DWARF is fixed up in Flattener. The others could be replaced earlier in
the transformation process if desired, but I've left them all together
for simplicity for now.

This fixes the folly::fbstring tests.
2023-06-28 16:11:50 +01:00
Alastair Robertson
4dc9007166 Integration tests: Set up CI testing for TypeGraph
CTest can't forward command line arguments to the test runner, so add
the option to using an environment variable to enable features instead.

CMake issue tracking the feature that would have been needed:
  https://gitlab.kitware.com/cmake/cmake/-/issues/20470

Tests which aren't passing yet have been disabled in CI.
2023-06-27 16:40:54 +01:00
Alastair Robertson
1bb0c62987 Flattener: Attempt to take params from parent allocator in case of bad DWARF 2023-06-27 14:06:02 +01:00
Jon Haslam
5204753497
remove unused old code from trace code (#186) 2023-06-27 11:31:05 +01:00
Jon Haslam
7bb23386f1
feature flag jit-logging (#183) 2023-06-26 18:44:18 +01:00
Alastair Robertson
f5b5885666 TypeGraph: Make original fully qualified names available for Class types
The worry about doing this earlier was performance, but on a further
reading of the code, both legacy OICodeGen and new DrgnParser have been
calling into drgn_type_fully_qualified_name() for every class for a long
time already.
2023-06-26 16:11:24 +01:00
Alastair Robertson
4bfa932b9b DrgnParser: Handle enum values in template params
We want to use the fully qualified name for scoped enums to keep the C++
compiler happy. When a parameter expects an enum value, we must supply
an enum value and not its underlying integer value.

Before:
  isset_bitset<1, 0>

After:
  isset_bitset<1, apache::thrift::detail::IssetBitsetOption::Unpacked>
2023-06-26 15:13:21 +01:00
Jake Hillion
f130f3c470 features: add GenJitDebug 2023-06-26 14:39:38 +01:00
Alastair Robertson
b0ef913b19 NameGen: Handle containers with zero template params
Previously we always deleted the last two characters and appended a `>`.

Old:
  MyContaine>

New:
  MyContainer
2023-06-26 11:27:38 +01:00
Alastair Robertson
4c96b65038 Flattener: Handle classes which inherit from containers
Turn the parent container into a member so that we process it along
with any extra members that this derived class has.
2023-06-23 19:51:19 +01:00
Alastair Robertson
6dce2d1c33 Printer: Improvements for displaying large type graphs
- Don't truncate output above 30k characters
- Include enough padding at the begining of lines to account for large
  node IDs
2023-06-23 15:55:42 +01:00
Alastair Robertson
5b6a9434b7 Tests: Use shared functions from type_graph_utils 2023-06-23 15:55:42 +01:00
Alastair Robertson
02b764157d Tests: Add a CodeGen test 2023-06-23 14:23:53 +01:00
Alastair Robertson
2edd781f9d TypeGraph: Split CodeGen into separate functions for testing 2023-06-23 14:23:53 +01:00
Alastair Robertson
a1537ab6aa Unit Tests: Create MockSymbolService 2023-06-23 14:23:53 +01:00
Alastair Robertson
3120e8173c Code Coverage: Reduce irrelevant partial branch matches
The C++ compiler generates implicit branches for exception handling,
which is particularly common when calling standard library functions.

It's not generally useful to have tests for the case when
std::vector::push_back fails due to an out-of-memory condition, so in
this PR we use a feature in the latest lcov release to filter out these
compiler-generated branches.

Our code coverage numbers consequently go way up!
2023-06-23 13:03:36 +01:00
Jake Hillion
40c7a9afb7 features: clean up old flags 2023-06-23 11:25:43 +01:00
Jake Hillion
b0aa7a8c93 TypedDataSegment: implementation 2023-06-19 19:06:04 +01:00
Jake Hillion
edaf499ced TypedDataSegment: add handlers for all tested types 2023-06-19 19:06:04 +01:00
Jake Hillion
77667e5741 tests: add polymorphic class tests with no extra features 2023-06-19 19:06:04 +01:00
Thierry Treyer
3b752fde13 Formatting 2023-06-19 19:13:16 +02:00
Thierry Treyer
32152bf5cf Introduce OIRP to dump RocksDB 2023-06-19 19:13:16 +02:00
Thierry Treyer
6e691daefc OITB support for -f/-F feature flags 2023-06-19 19:13:16 +02:00
Thierry Treyer
4e730fbc95 OIP prints location expressions 2023-06-19 19:13:16 +02:00
Thierry Treyer
aea1e12004 OIP prints 'this'as an arg for methods 2023-06-19 19:13:16 +02:00
Thierry Treyer
f28bdfca48 Fix TypeHierarchy's type 2023-06-19 19:13:16 +02:00
Alastair Robertson
226e0cfa84 Add copyright header to all source files 2023-06-15 10:30:29 -07:00
Jake Hillion
6f2ce7871c set function oi_name to null rather than garbage 2023-06-14 17:25:18 +02:00
Jon Haslam
cac9b99974
ensure oi_name is never a nullptr (#165) 2023-06-12 16:47:34 -07:00
Jake Hillion
ad28fb64b2
elfutils: leak cu_tree to avoid double free (#164) 2023-06-12 16:35:46 -07:00
Jake Hillion
4c331fb5a2 clean up common.h 2023-06-09 13:15:17 +02:00
Alastair Robertson
62575a7c3e TypeGraph: Respect [[codegen.ignore]] config value 2023-06-05 13:38:54 +01:00
Jake Hillion
91dc954d40 CMake: add elfutils to rpath for dynamic builds 2023-06-02 17:52:53 +02:00
Jake Hillion
167df106cc drgn: add split dwarf support 2023-06-02 17:52:53 +02:00
Jake Hillion
a6d7f90f50 integration_py: fix expected sizes 2023-05-31 19:00:10 +02:00
Alastair Robertson
2d28b20d46 TypeGraph: Fix multi dimensional arrays
Multi dimensional arrays are not flattened into 1-D arrays when using
TypeGraph. Update TreeBuilder to account for this.

By not flattening arrays, we are able to produce more descriptive
results.

The disadvantage is that we must now recurse inside arrays
containing only primitives. A better solution to requiring flattening
would be the planned work to not recurse into any static types (not just
primitives). This would also apply to multi-dimensional arrays of
primtivies.
2023-05-31 16:53:38 +01:00
Alastair Robertson
784b900218 TypeGraph: Replace allocators with DummyAllocator
When we were previously removing allocators, we were only able to work
with containers whose allocators appeared as their last template
parameter.

Now we can replace allocators in the middle of a parameter list.

This fixes tests for folly::sorted_vector_set.
2023-05-31 15:49:37 +01:00
Alastair Robertson
e1bc5c7b5e Tests: Split common code out into type_graph_utils 2023-05-31 15:49:37 +01:00
Alastair Robertson
3a7a647a73 TypeGraph: Apply qualifiers to template params
This is necessary when replacing the allocator of a map type, for
example.

`std::map<int, int>` will need an allocator which allocates elements of
type `std::pair<const int, int>>`
2023-05-31 15:49:37 +01:00
Alastair Robertson
1723611411 Turn FeatureSet into a generic EnumBitset 2023-05-31 14:05:51 +01:00
Alastair Robertson
cfc3cc0221 TypeGraph: Handle alias templates
This fixes the test failure for std::conditional_t
2023-05-30 17:59:42 +01:00
Alastair Robertson
3d91603c8e TypeGraph: Fix std::string container
std::basic_string takes three template parameters:
1. CharT
2. Traits
3. Allocator

The Traits parameter was causing issues, as it requires a type which
exposes certain things, e.g. `Traits::value_type`.

We have a few options to resolve this:
1. Remove this parameter, as we do for allocators
    Cons: removing a template parameter doesn't work if other
    parameters appear after it

2. Stub this parameter, as we do for hashers/comparators
    Cons: we need to hardcode an implementation that satisfies the
    `Traits::value_type` requirements

3. Leave the parameter as-is
    Cons: will not work if a non-standard Traits is used

    By using the real implementation of this Traits parameter
    (normally `std::char_traits<CharT>`), we get one that we know will
    work as long as it is defined in a stdlib header.

Option 3 is what we use in this patch. Instead of adding more
configuration options to the container TOML file format (e.g.
`params_to_keep = [1]`), we add `std::char_traits` as a dummy
container type. Now, whenever `std::char_traits` appears, it will be
left as-is, i.e. not removed, replaced or reverse-engineered.

This is the same approach previously used for Thrift's isset_bitset.
2023-05-30 17:17:29 +01:00
Alastair Robertson
27c6ee10c3 OID: Use new TypeGraph CodeGen when requested
This adds a new feature flag, "type-graph", which controls whether to
use legacy OICodeGen or the new TypeGraph-based CodeGen.
2023-05-30 16:40:47 +01:00
Alastair Robertson
e01b3fd327 TypeGraph: Add new CodeGen
This code mostly works, but is obviously not complete. This commit just
adds the code and tests, but does not enable it in OID or OIL.
2023-05-30 16:40:47 +01:00