-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parser, xlators, printf, cg, ident: resolve forwards to real types
In contrast to libdtrace-ctf (which didn't reliably handle conflicted structs and unions at all and often just assumed they weren't conflicting, leading to corrupted type graphs), libctf's deduplicator reliably identifies conflicted structs and unions, and avoids getting caught in cycles while maximizing the number of shared types by routinely converting conflicted structs and unions into forwards and leaving the forward in the shared dict as a marker. This means that forwards can and do appear in the shared graph in places where they would be forbidden in C because there are things you can't do with incomplete types: you can see things like arrays of forwards. We'd rather not inflict this on our users, so introduce a new dt_type_resolve which is like ctf_type_resolve except that rather than returning a forward when called on a type in the shared dict, it hunts through the module list for the first non-forward with a matching name and suitable kind (so a forward to 'struct foo' will only match a real 'struct foo', not 'union foo'), returning the dict as well. It only returns a forward if no suitable complete type is found in any module at all. This search can be relatively expensive, because it might involve loading lots of modules, but it only happens when conflicted forwards are found, which isn't all that common: and correctness trumps performance anyway. This is made a bit more complex because there were several places where we weren't bothering to call ctf_type_resolve at all but where a resolution is nonetheless required in any case (e.g. dt_idsize_type) and a number of places where we were just *assuming* that ctf_type_resolve succeeded (most unwise). There are also a number of places where we need to track both the fp of the original type and the fp of the resolved type, notably in xlator-related code. A couple of places have to *avoid* searching for real types, in particular if a forward is found in the C and D dicts: dt_type_resolve takes a flag to turn this off. This was spotted heuristically (i.e. a test failed): I don't *think* there are any places where this needs doing that I missed, but I could be wrong. (In the future some of this commit may be unwindable, if and when libctf gains the ability to search for forwards in archives in the same way we are doing here. It seems like a worthwhile API addition.) Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
- Loading branch information
1 parent
e7d7c91
commit 57ff5be
Showing
10 changed files
with
362 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.