Commit Graph

434 Commits

Author SHA1 Message Date
Alastair Robertson
3e8464e691 RemoveIgnored: Set names for removed members to AddPadding::MemberPrefix
This means they will be treated as padding, so CodeGen will not try to
store any data for them.
2023-07-12 14:40:10 +01:00
Alastair Robertson
e7549db949 TypeGraph: Introduce NodeTracker for efficient cycle detection
Added to Flattener and TypeIdentifier passes for now as a
proof-of-concept. Other passes can come later.
2023-07-12 14:39:56 +01:00
arsarwade
28b813c6db
Stop stubbing tuple (#224)
Summary:

Stubbing tuple without alignment info can cause failures. I added a test
case for this which failed before this fix but works now.

Test Plan:

Ran the test.
2023-07-11 09:10:40 -07:00
arsarwade
188a2a82d0
Add container without template params to container map (#223)
Summary:

If a container has 0 template params (e.g. IOBuf, IOBufQueue), it wasn't
being added to containerTypeMap. This causes the deserialization to go wrong
as TreeBuilder doesn't treat the types as container

Test Plan:

make test
2023-07-11 08:54:16 -07:00
Alastair Robertson
f676112bbc AddChildren: Filter out false children
Use fully qualified names to determine if a class is really the child of
our type. It may be that it is the child of another type with an
identical name in another namespace.
2023-07-11 13:52:39 +01:00
Alastair Robertson
94f8c1db49 DrgnParserTest: Split into reusable components 2023-07-11 13:52:39 +01:00
Alastair Robertson
11ca1b0b00 Flattener: Fix seg-fault in the case of specific bad DWARF
Also add negative tests for fixAllocatorParams(), covering this case and
more.
2023-07-11 13:52:15 +01:00
Alastair Robertson
df68002bd6 NameGen: Remove invalid characters from member names
GCC includes dots in vptr member names, e.g. "_vptr.MyClass". These
aren't valid in C++, so we must replace them.
2023-07-11 13:51:54 +01:00
Jake Hillion
02defdb859 comment existing typed data segment work 2023-07-10 21:09:43 +01:00
Alastair Robertson
43303ae6d3 Flattener: Pull up children of children 2023-07-10 16:40:29 +01:00
Jake Hillion
17633983b5 create strict mode and enable it for tests 2023-07-07 16:09:46 +01:00
Alastair Robertson
56b5873e77 TypeGraph: Rename visit(Type) functions to accept(Type)
visit(Type&) and visit(Type*) were helper functions than did cycle
detection and provided nicer syntax for the type.accept(*this) calls.

However, because they overloaded the visit() function, it was easy to
accidentally call a concrete visit method (e.g. visit(Class&)) instead
of the virtual-dispatching visit(Type&).

By changing the name of this wrapper, it will make it much more obvious
when code is introduced which bypasses the cycle detection.
2023-07-07 15:45:29 +01:00
Alastair Robertson
8cb082372e TypeIdentifier: Preserve container types
Pass-through-types represent classes to be turned into containers. We
don't want these to turn these containers into Dummy's on a second run
of TypeIdentifier.
2023-07-06 18:39:20 +01:00
Alastair Robertson
9c45e0f22a TypeIdentifier: Add unit tests for preserving types 2023-07-06 18:39:20 +01:00
Alastair Robertson
3ec81aaa5f TypeGraph: Add "--tree-builder-v2" flag
This will eventually be used to enable running with Tree Builder v2.

For now, when it is disabled it puts CodeGen v2 into compatibility mode,
disabling features which weren't present in CodeGen v1 so that its
output can be understood by Tree Builder v1.
2023-07-06 17:43:09 +01:00
Alastair Robertson
e1b16a3d7e TypeGraph: Switch from pointers to references
References must always have a value, so are semantically clearer than
pointers for variables which must always be set.

No functional changes.
2023-07-06 17:24:33 +01:00
Jake Hillion
2282ee1d63 drgn: elfutils: Implement 64-bits offsets reconstruction for CU/TU Index Table 2023-07-06 17:09:41 +01:00
Alastair Robertson
23efc8d2d6 TypeGraph: Add Node IDs to non-leaf types
These aren't used for anything yet, but should be useful for stable IDs
when printing nodes before and after passes and for faster cycle
detection than the current map of pointers.
2023-07-06 14:54:30 +01:00
Jake Hillion
608880e156 typed data segment: fix vector handler for custom allocators 2023-07-05 19:06:18 +01:00
Jake Hillion
b574eb7566 fix resources names with symlinks 2023-07-05 19:04:46 +01:00
Jake Hillion
b1e98ddf34 add drgn aranges & non-debug patches 2023-07-05 18:47:07 +01:00
Jake Hillion
099be82459 thrift isset: add type handler 2023-07-05 17:52:42 +01:00
Alastair Robertson
8805480653 TypeGraph: Make Primitive types singletons
Should save some memory and improve performance by not having loads of
copies of primitive types.
2023-07-05 16:06:57 +01:00
Alastair Robertson
0330ef8945 Take list of pass-through types from config instead of hardcoding
As we now store ContainerInfo objects in OICodeGen::Config, we can not
copy it any more. Change all places that took copies to take const
references instead.

The copy in OICodeGen modified membersToStub, the contents of which form
part of OICache's hash. However, as OICache also previously had its own
copy, it would not have been OICodeGen's modifications.
2023-07-05 13:39:19 +01:00
Alastair Robertson
e86ebb7aff TypeGraph: Support bitfields
- Change member and parent offsets to work in bits, not bytes
- Printer still displays offsets in bytes, with decimals when using
  bitfields
- AddPadding: Don't pad bitfields
- CodeGen: Emit code for bitfields
2023-07-05 13:23:23 +01:00
Alastair Robertson
c9bcf5e760 TopoSorter: Fix sorting of container template parameters
For std::vector and std::list, template parameters are not required to
be defined before they can be used. Delay sorting them until the end.

Also fix a CodeGen bug where we were defining typedefs in the middle of
the forward declarations. They only need to be defined when other types
are defined.
2023-07-05 13:10:28 +01:00
Alastair Robertson
5560624c0b Unit tests: Move last remaining tests onto using the type_graph_utils helpers 2023-07-04 17:18:43 +01:00
Alastair Robertson
00b46377a1 Unit tests: Remove unnecessary make_unique calls
This was a purely mechanical change made with some find-and-replace
macros.
2023-07-04 17:18:43 +01:00
Alastair Robertson
31050735d6 CodeGen: Add support for capturing Thrift isset data 2023-07-04 15:36:27 +01:00
Jake Hillion
01c9573acb add jit timing feature 2023-07-03 18:02:09 +01:00
Jake Hillion
63ac468a1f TypedDataSegment: clean up type of fixed suffix 2023-07-03 18:02:09 +01:00
Jake Hillion
3da628b852 help: improve feature descriptions 2023-07-03 16:57:43 +01:00
Jake Hillion
db243d9845 codegen: store prev defined containers as a class field 2023-07-03 16:04:08 +01:00
Jake Hillion
6aead62652 static types: place in own header for testing 2023-06-30 12:54:02 +01:00
Jake Hillion
8e48c6ca52 ci: enable testing for typed data segment 2023-06-29 17:31:29 +01:00
Jake Hillion
046e5f57bb add dummy handler to dummy containers 2023-06-29 17:31:29 +01:00
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