All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, kernel-team@fb.com,
	yhs@fb.com, Eduard Zingerman <eddyz87@gmail.com>
Subject: [PATCH bpf-next v3 0/3] libbpf: btf_decl_tag attribute for btf dump in C format
Date: Thu, 10 Nov 2022 16:43:17 +0200	[thread overview]
Message-ID: <20221110144320.1075367-1-eddyz87@gmail.com> (raw)

Support for clang's __attribute__((btf_decl_tag("..."))) by
btf_dump__dump_type and btf_dump__dump_type_data functions.
Decl tag attributes are restored for:
- structs and unions
- struct and union fields
- typedefs
- global variables
- function prototype parameters

The attribute is restored using __btf_decl_tag macro that is printed
upon first call to btf_dump__dump_type function:

 #if __has_attribute(btf_decl_tag)
 #define __btf_decl_tag(x) __attribute__((btf_decl_tag(x)))
 #else
 #define __btf_decl_tag(x)
 #endif

To simplify testing of the btf_dump__dump_type_data the
prog_tests/btf_dump.c:test_btf_dump_case is extended to invoke
btf_dump__dump_type_data for each DATASEC object in the test case
binary file.

Changelog:
v2 -> v3:
- rebase to fix merge issues after recent hashmap interface update;
- call to btf_dump_assign_decl_tags removed from btf_dump__new as
  redundant.

v1 -> v2:
- prog_tests/btf_dump.c:test_btf_dump_case modified to print DATASECs
  using btf_dump__dump_type_data;
- support for decl tags applied to global variables and function
  prototype parameters;
- update to support interleaved calls to btf_dump__dump_type and
  btf__add_decl_tag (incremental dump);
- fix for potential double free error in btf_dump_assign_decl_tags;
- styling fixes suggested by Andrii.

RFC -> v1:
- support for decl tags applied to struct / union fields and typedefs;
- __btf_decl_tag macro;
- btf_dump->decl_tags hash and equal functions updated to use integer
  key instead of a pointer;
- realloc_decl_tags function removed;
- update for allocation logic in btf_dump_assign_decl_tags.

[v2]  https://lore.kernel.org/bpf/20221108153135.491383-1-eddyz87@gmail.com/
[v1]  https://lore.kernel.org/bpf/20221103134522.2764601-1-eddyz87@gmail.com/
[RFC] https://lore.kernel.org/bpf/20221025222802.2295103-4-eddyz87@gmail.com/

Eduard Zingerman (3):
  libbpf: __attribute__((btf_decl_tag("..."))) for btf dump in C format
  selftests/bpf: Dump data sections as part of btf_dump_test_case tests
  selftests/bpf: Tests for BTF_KIND_DECL_TAG dump in C format

 tools/lib/bpf/btf_dump.c                      | 181 +++++++++++++++-
 .../selftests/bpf/prog_tests/btf_dump.c       | 197 ++++++++++++++++--
 .../bpf/progs/btf_dump_test_case_decl_tag.c   |  65 ++++++
 3 files changed, 421 insertions(+), 22 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/btf_dump_test_case_decl_tag.c

-- 
2.34.1


             reply	other threads:[~2022-11-10 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 14:43 Eduard Zingerman [this message]
2022-11-10 14:43 ` [PATCH bpf-next v3 1/3] libbpf: __attribute__((btf_decl_tag("..."))) for btf dump in C format Eduard Zingerman
2022-11-11 18:58   ` Andrii Nakryiko
2022-11-11 21:30     ` Eduard Zingerman
2022-11-14 19:56       ` Andrii Nakryiko
2022-11-16  1:51         ` Eduard Zingerman
2022-11-18  0:21           ` Andrii Nakryiko
2022-11-15 20:45       ` Yonghong Song
2022-11-15 20:48         ` Yonghong Song
2022-11-10 14:43 ` [PATCH bpf-next v3 2/3] selftests/bpf: Dump data sections as part of btf_dump_test_case tests Eduard Zingerman
2022-11-11 19:07   ` Andrii Nakryiko
2022-11-10 14:43 ` [PATCH bpf-next v3 3/3] selftests/bpf: Tests for BTF_KIND_DECL_TAG dump in C format Eduard Zingerman
2022-11-11 19:07   ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110144320.1075367-1-eddyz87@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.