On Thu, Sep 14, 2017 at 8:07 PM, Radim Krčmář <rkrcmar@xxxxxxxxxx> wrote: > If we do not want to generate it with an external script, I think the > simplest is to have a separate file that looks like > > #define kvm_exit_reasons \ > KVM_EXIT(UNKNOWN, 0), \ > KVM_EXIT(EXCEPTION, 1), \ > ... > KVM_EXIT(HYPERV, 27) \ > > and include it from both places. The current exit definitions would be > > #define KVM_EXIT(reason, code) > KVM_EXIT_ ## reason = code > > #include <the/magic/file> > > enum { > kvm_exit_reasons > }; > > #undef kvm_exit_reasons > > and the trace > > #define KVM_EXIT(reason, code) > { code, "KVM_EXIT_" # reason } > #include <the/magic/file> > > ... > > __print_symbolic(__entry->reason, kvm_exit_reasons), > > ... > > #undef kvm_exit_reasons > > (Would also work with just "KVM_EXIT(UNKNOWN), ..." and small tweaks.) It can be done without a separate file: #define kvm_exit_reasons \ KVM_EXIT(UNKNOWN, 0), \ KVM_EXIT(EXCEPTION, 1), \ ... KVM_EXIT(HYPERV, 27) #define KVM_EXIT(reason, code) \ KVM_EXIT_ ## reason = code enum { kvm_exit_reasons }; #undef KVM_EXIT ^^^ goes in the general header #define KVM_EXIT(reason, code) \ { code, "KVM_EXIT_" # reason } ... _reasons[] = { kvm_exit_reasons }; #undef KVM_EXIT ^^^ goes in the trace header I.e. this is symbol manipulation, no need to have KVM_EXIT defined when it's "used".