Skip to content

BPF::init() failed on Kernel 5.18.4 with /virtual/main.c:4:12: error: use of undeclared identifier 'TASK_COMM_LEN' #4092

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

Closed
yzhao1012 opened this issue Jul 5, 2022 · 1 comment · Fixed by #4095

Comments

@yzhao1012
Copy link
Contributor

A rather simple BPF::init() call with a trivial BPF program written in BCC format:

  std::string program = R"(                                                                     
int on_sched_process_exit(struct tracepoint__sched__sched_process_exit* args) {                      
    uint64_t id = bpf_get_current_pid_tgid();                                                        
    uint32_t tgid = id >> 32;                                                                        
    uint32_t pid = id;                                                                               
    bpf_trace_printk("process_exit: %d %d\n", tgid, pid);                                            
    return 0;                                                                                        
}                                                                                                    
  )";                                                                                                
  BPF bpf;                                                                                  
  bpf.init(program);
}

Failed with error message:

/virtual/main.c:4:12: error: use of undeclared identifier 'TASK_COMM_LEN'
        char comm[TASK_COMM_LEN];
                  ^
1 error generated.

I suppose this is part of BCC's rewriting added this?

chenhengqi added a commit to chenhengqi/bcc that referenced this issue Jul 7, 2022
Commit 3087c61ed2c4 ([0]) changes `TASK_COMM_LEN` from macro to enum.
With this change, we have:
    field:char comm[TASK_COMM_LEN]; offset:8;       size:16;        signed:1;
in tracepoint format.

If users do NOT include proper headers, will result in:
    /virtual/main.c:4:12: error: use of undeclared identifier 'TASK_COMM_LEN'
            char comm[TASK_COMM_LEN];
                      ^
    1 error generated.

Let's handle this with BTF info.

Closes iovisor#4092.

  [0]: torvalds/linux@3087c61

Signed-off-by: Hengqi Chen <[email protected]>
@chenhengqi
Copy link
Collaborator

Just opened #4095 to fix this issue.

yonghong-song pushed a commit that referenced this issue Jul 10, 2022
Commit 3087c61ed2c4 ([0]) changes `TASK_COMM_LEN` from macro to enum.
With this change, we have:
    field:char comm[TASK_COMM_LEN]; offset:8;       size:16;        signed:1;
in tracepoint format.

If users do NOT include proper headers, will result in:
    /virtual/main.c:4:12: error: use of undeclared identifier 'TASK_COMM_LEN'
            char comm[TASK_COMM_LEN];
                      ^
    1 error generated.

Let's handle this with BTF info.

Closes #4092.

  [0]: torvalds/linux@3087c61

Signed-off-by: Hengqi Chen <[email protected]>
sterchelen pushed a commit to sterchelen/bcc that referenced this issue Sep 9, 2022
Commit 3087c61ed2c4 ([0]) changes `TASK_COMM_LEN` from macro to enum.
With this change, we have:
    field:char comm[TASK_COMM_LEN]; offset:8;       size:16;        signed:1;
in tracepoint format.

If users do NOT include proper headers, will result in:
    /virtual/main.c:4:12: error: use of undeclared identifier 'TASK_COMM_LEN'
            char comm[TASK_COMM_LEN];
                      ^
    1 error generated.

Let's handle this with BTF info.

Closes iovisor#4092.

  [0]: torvalds/linux@3087c61

Signed-off-by: Hengqi Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants