This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][BPF] Support to emit debugInfo for extern variables
AbandonedPublic

Authored by yonghong-song on Nov 22 2019, 3:50 PM.

Details

Summary

extern variable usage in BPF is different from traditional
pure user space application. Recent discussion in linux bpf
mailing list has two use cases where debug info types are
required to use extern variables:

This patch added clang support to emit debuginfo for extern variables,
and bpf support to consume such info into BTF, which can then be used
by bpf loader.

A few more things need to do:

  • currently, I added clang EmitGlobalDeclVariable() to emit debuginfo for extern variables. It might be possible to reuse existing EmitGlobalVariable(). Need double check.
  • BPF is C only, so I only tested C. I am not sure whether adding other language support is necessary at this point.
  • add clang test cases and a few more bpf backend tests.

But some early feedback will be great!

Diff Detail

Event Timeline

yonghong-song created this revision.Nov 22 2019, 3:50 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 22 2019, 3:50 PM

Seems to have a few things going on

  • the title talks about global variables
  • the description talks about extern types (guessing that's just a typo?)
  • the patch itself seems to have code that's visiting more functions? ( processFuncPrototypes )
  • & also I'd generally still prefer to see two patches for each piece of new debug info - first adding the functionality to LLVM, then second using that functionality in Clang (even though we're in the monorepo - these are still divisible patches that makes code review, revert, root cause analysis, etc, easier)

@dblaikie Thanks for the review. To address your comments below:

the title talks about global variables
the description talks about extern types (guessing that's just a typo?)

The title is "Support to emit debugInfo for extern variables". In the description, I am using "extern" variables as well. But in the implementation, I am using "GlobalDecl" or "GlobalDeclOnly". I indeed need to make naming convention consistent.

the patch itself seems to have code that's visiting more functions? ( processFuncPrototypes )

The proceessFuncPrototypes filtered any function without debug info and defined. So based on my testing, it only emits extern functions. But do let me know if I miss anything here.

& also I'd generally still prefer to see two patches for each piece of new debug info - first adding the functionality to LLVM, then second using that functionality in Clang (even though we're in the monorepo - these are still divisible patches that makes code review, revert, root cause analysis, etc, easier)

Agree. I will separate the patch into two separate patches as you suggested, add more tests for the clang patch and resubmit.

yonghong-song abandoned this revision.Nov 25 2019, 2:17 PM

@dblaikie As suggested, just submitted two separate patches:

Please help take a look. Thanks!

I will abandon this patch to avoid confusion.