-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packing not emitted for some structs #233
Comments
I debugged it, and clang is giving us the wrong information: private void VisitRecordDecl(RecordDecl recordDecl)
{
...
var alignment = recordDecl.TypeForDecl.Handle.AlignOf; Even though though MINIDUMP_VM_POST_READ_CALLBACK and MINIDUMP_CALLBACK_INPUT are right next to each other with no change in packing, alignment is 4 for the former and 16 for the latter. |
I'm going to recheck this once #235 is merged. I'm hoping that this was resolved with Clang 12, but if not I'll look at potential workarounds. |
@sotteson1, I have a fix for this here: #258 |
Thanks @tannergooding! |
This is being reopened by #263. The fix ended up regressing a number of key scenarios and so I've started looking into an alternative fix, but said fix will require rebuilding libClangSharp and so needs some more work first. |
Upon further investigation, it looks like Clang doesn't expose the necessary metadata in any fashion I can discern. The only way I can determine to correctly detect packing here is to explicitly parse a file as both 32-bit and 64-bit and to compare the specified alignment against the computed "natural" alignment. |
Closing this. As indicated above, Clang doesn't and cannot surface the relevant metadata. Much of the time the In the cases where it is explicitly specified, but matches the default, Clang doesn't (but could) surface the relevant metadata. |
Hey @tannergooding can we revisit this issue? Consider #define DECLSPEC_ALIGN(x) __declspec(align(x))
typedef struct DECLSPEC_ALIGN(16) _BAZ {
unsigned int Foo;
} BAZ; This produces an AST of
I searched through the ClangSharp codebase for |
In hindsight, alignment != packing and I see you already attempted a solution with |
I'm traversing Include\10.0.19041.0\um\minidumpapiset.h, and in it I see:
Some emitted structs have Pack = 4 and some don't like the two below.
I tried rolling my own C versions of these and debugging to see if it makes a difference, and it does. The offsets to CallbackType are different between these two:
The text was updated successfully, but these errors were encountered: