Re: BTF tag support in DWARF (notes for today's BPF Office Hours)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2023-01-05 at 19:30 +0100, Jose E. Marchesi wrote:
> We agreed in the meeting to implement Solution 2 below in both GCC and
> clang.
> 
> The DW_TAG_LLVM_annotation DIE number will be changed in order to make
> it possible for pahole to handle the current tags.  The number of the
> new tag will be shared by both GCC and clang.
> 
> Thanks everyone for the feedback.
> 
[...]

Hi Jose, David,

Recently I've been working on implementation of the agreed btf_type_tag
encoding scheme for clang [1] and pahole [2]. While working on this, I came
to a conclusion that instead of introducing new DWARF tag (0x6001) we can
reuse the same tag (0x6000), but have a different DW_AT_name field:
"btf_type_tag:v2" instead of "btf_type_tag".

For example, the following C code:

    struct st {
      int __attribute__((btf_type_tag("a"))) a;
    } g;

Produces the following DWARF when [1] is used:

0x00000029:   DW_TAG_structure_type
                DW_AT_name      ("st")
                ...

0x0000002e:     DW_TAG_member
                  DW_AT_name    ("a")
                  DW_AT_type    (0x00000038 "int")
                ...

0x00000038:   DW_TAG_base_type
                DW_AT_name      ("int")
                ...

0x0000003c:     DW_TAG_LLVM_annotation
                  DW_AT_name    ("btf_type_tag:v2")
                  DW_AT_const_value     ("a")

I think that this is a tad better than abandoning 0x6000 tag because of
two reasons:
- tag numbers are a limited resource;
- might simplify discussion with upstream.

(It also makes some implementation details a bit simpler, but this is not
 very significant).

What do you think?

Both [1] and [2] are in a workable state, but [2] lacks support for
subroutine types and "void *" for now. If you are onboard with this change
I'll proceed with finalizing [1] and [2]. (Also, ":v2" suffix might be not
the best, I'm open to naming suggestions).

As a somewhat orthogonal question, would it be possible for you to use the
same 0x6000 tag on GCC side? I looked at master branch of [3] but can't
find any mentions of btf_type_tag.

Thanks,
Eduard

[1] https://reviews.llvm.org/D143967
[2] https://github.com/eddyz87/dwarves/tree/btf-type-tag-v2
[3] git://gcc.gnu.org/git/gcc.git




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux