• Yonghong Song's avatar
    adjust tracepoint field type based on size · 7c489469
    Yonghong Song authored
    Fix issue #1807
    
    tracepoint may have a format like this:
    (from syscalls/sys_enter_socket)
    	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
    	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
    	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
    	field:int common_pid;	offset:4;	size:4;	signed:1;
    
    	field:int __syscall_nr;	offset:8;	size:4;	signed:1;
    	field:int family;	offset:16;	size:8;	signed:0;
    	field:int type;	offset:24;	size:8;	signed:0;
    	field:int protocol;	offset:32;	size:8;	signed:0;
    
    Current rewriter generates:
        struct tracepoint__syscalls__sys_enter_socket {
    	    u64 __do_not_use__;
    	    int __syscall_nr;
    	    int family;
    	    int type;
    	    int protocol;
        };
    
    This is incorrect as in the above structure, offsets of
    `family`/`type`/`procotol` becomingg 12/16/20.
    
    This patch fixed the issue by adjusting field type based on its size.
    The new structure:
        struct tracepoint__syscalls__sys_enter_socket {
    	    u64 __do_not_use__;
    	    int __syscall_nr;
    	    s64 family;
    	    s64 type;
    	    s64 protocol;
        };
    The offsets of all fields are correct now.
    Signed-off-by: default avatarYonghong Song <yhs@fb.com>
    7c489469
tp_frontend_action.cc 8.32 KB