Dwarves Archive on lore.kernel.org
 help / color / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: dwarves@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	bpf <bpf@vger.kernel.org>, Kernel Team <kernel-team@fb.com>,
	Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH dwarves] btf_loader: handle union forward declaration properly
Date: Wed, 21 Oct 2020 08:35:34 -0700
Message-ID: <CAEf4BzY4k4B5Pc93wSOWD-Hjw=_uoFjfByxc44uXAipV+PV96g@mail.gmail.com> (raw)
In-Reply-To: <20201009192607.699835-1-andrii@kernel.org>

On Fri, Oct 9, 2020 at 12:26 PM Andrii Nakryiko <andrii@kernel.org> wrote:
>
> Differentiate between struct and union forwards. For BTF_KIND_FWD this is
> determined by kflag. So teach btf_loader to use that bit to decide whether
> forward is for union or struct.
>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> ---
> N.B. This patch is based on top of tmp.libbtf_encoder branch.
>
> Also seems like non-forward declared union has a slightly different
> representation from struct (class). Not sure why it is so, but this change
> doesn't seem to break anything.
> ---

Ping on this one, let's include it with upcoming pahole 1.19 as well?

>
>  btf_loader.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/btf_loader.c b/btf_loader.c
> index 9b5da3a4997a..0cb23967fec3 100644
> --- a/btf_loader.c
> +++ b/btf_loader.c
> @@ -134,12 +134,13 @@ static struct type *type__new(uint16_t tag, strings_t name, size_t size)
>         return type;
>  }
>
> -static struct class *class__new(strings_t name, size_t size)
> +static struct class *class__new(strings_t name, size_t size, bool is_union)
>  {
>         struct class *class = tag__alloc(sizeof(*class));
> +       uint32_t tag = is_union ? DW_TAG_union_type : DW_TAG_structure_type;
>
>         if (class != NULL) {
> -               type__init(&class->type, DW_TAG_structure_type, name, size);
> +               type__init(&class->type, tag, name, size);
>                 INIT_LIST_HEAD(&class->vtable);
>         }
>
> @@ -228,7 +229,7 @@ static int create_members(struct btf_elf *btfe, const struct btf_type *tp,
>
>  static int create_new_class(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id)
>  {
> -       struct class *class = class__new(tp->name_off, tp->size);
> +       struct class *class = class__new(tp->name_off, tp->size, false);
>         int member_size = create_members(btfe, tp, &class->type);
>
>         if (member_size < 0)
> @@ -313,7 +314,7 @@ static int create_new_subroutine_type(struct btf_elf *btfe, const struct btf_typ
>
>  static int create_new_forward_decl(struct btf_elf *btfe, const struct btf_type *tp, uint32_t id)
>  {
> -       struct class *fwd = class__new(tp->name_off, 0);
> +       struct class *fwd = class__new(tp->name_off, 0, btf_kind(tp));
>
>         if (fwd == NULL)
>                 return -ENOMEM;
> --
> 2.24.1
>

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 19:26 Andrii Nakryiko
2020-10-21 15:35 ` Andrii Nakryiko [this message]
2020-10-21 16:38   ` Arnaldo Carvalho de Melo
2020-10-21 19:25 ` Arnaldo Carvalho de Melo
2020-10-21 19:47   ` Andrii Nakryiko
2020-10-21 20:15     ` Arnaldo Carvalho de Melo

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='CAEf4BzY4k4B5Pc93wSOWD-Hjw=_uoFjfByxc44uXAipV+PV96g@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=kernel-team@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

Dwarves Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dwarves/0 dwarves/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dwarves dwarves/ https://lore.kernel.org/dwarves \
		dwarves@vger.kernel.org
	public-inbox-index dwarves

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dwarves


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git