Skip to content

Commit bc36b44

Browse files
committed
[BPF] print_btf.py: Allow pointer types to have name
Pointer types in Rust have names in LLVM debug info. For example, the following code, with a struct containing pointer fields: ```rust pub struct Foo<'a> { a: &'a i32, } #[unsafe(no_mangle)] #[unsafe(link_section = "lsm/file_open")] pub fn foo(foo: &Foo) -> i32 { let Foo { a } = foo; **a } ``` Produces the following BTF: ``` [1] PTR '&rust_btf::Foo' type_id=2 [2] STRUCT 'Foo' size=8 vlen=1 'a' type_id=3 bits_offset=0 [3] PTR '&i32' type_id=4 [4] INT 'i32' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [5] FUNC_PROTO '(anon)' ret_type_id=4 vlen=1 'foo' type_id=1 [6] FUNC 'foo' type_id=5 linkage=global ``` Both the pointer type used in the function signature (`&Foo`) and the one stored in the struct (`&i32`) appear in BTF as named pointer types. Given that, stop issuing a warning for named pointer types in `print_btf.py`.
1 parent 891a2c3 commit bc36b44

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/test/CodeGen/BPF/BTF/print_btf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ def warn_nonzero(val, name):
160160
warn_nonzero(kflag, "kflag")
161161
warn_nonzero(vlen, "vlen")
162162

163+
elif kind == BTF_KIND_PTR:
164+
print(f"[{idx}] {kind_name} '{name}' type_id={size}")
165+
warn_nonzero(kflag, "kflag")
166+
warn_nonzero(vlen, "vlen")
167+
163168
elif kind in [
164-
BTF_KIND_PTR,
165169
BTF_KIND_CONST,
166170
BTF_KIND_VOLATILE,
167171
BTF_KIND_RESTRICT,

0 commit comments

Comments
 (0)