aliyun/plugsched

GCC optimization may cause failure when collecting struct

Closed this issue · 1 comments

For union bpf_attr, when visiting attr->bpf_fd || attr->file_flags, GCC will optimize these two u32 to one u64.

i.e., attr->bpf_fd & 0xBEEF || attr->file_flags & 0xDEAD
will become
tmp = *(struct unnamed_struct*)((unsigned long)attr+8)
tmp | 0xdead0000beef

and then op.field.name is None and cause sorting error.

For any complex union or structure, we can ignore the real name of the members and use a fixed fake name instead. In this case, the most important information is union name bpf_attr, other names, such as bpf_fd and file_flags, can be ignored if them are hard to get.