This is an archive of the discontinued LLVM Phabricator instance.

[BPF] Support to emit debugInfo for extern variables
ClosedPublic

Authored by yonghong-song on Nov 25 2019, 2:11 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 bpf support to consume such info into BTF,
which can then be used by bpf loader. Function processFuncPrototypes()
only adds extern function definitions into BTF. The functions
with actual definition have been added to BTF in some other places.

Diff Detail

Event Timeline

yonghong-song created this revision.Nov 25 2019, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 25 2019, 2:11 PM

The corresponding clang/llvm patch which generates debuginfo for extern variables. https://reviews.llvm.org/D70696

ast added a comment.Nov 25 2019, 2:32 PM

clang side will expose debuginfo for extern variables and functions, while the backend support is for functions only? Or I'm misreading the patch.

The backend supports extern variable debug info as well. The following restrictions in the old code is removed.

 -    // Ignore external globals for now.
-    if (!Global.hasInitializer() && Global.hasExternalLinkage())
-      continue;

additional test case is added to ensure debuginfo for externs is indeed generated in BTF.

ast accepted this revision.Nov 25 2019, 2:54 PM

got it. lgtm

This revision is now accepted and ready to land.Nov 25 2019, 2:54 PM

extern variables can have attribute((weak)) attribute. Support it as well.

ast accepted this revision.Dec 7 2019, 11:10 AM

thanks for adding extra tests

This revision was automatically updated to reflect the committed changes.