Dwarves Archive on lore.kernel.org
 help / color / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	dwarves@vger.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 17:15:23 -0300
Message-ID: <20201021201523.GA2385845@kernel.org> (raw)
In-Reply-To: <CAEf4BzaCXKYOeyTN74Zm1gbjyBSmBCi1XpgvqKn8-E+ZusrGeA@mail.gmail.com>

Em Wed, Oct 21, 2020 at 12:47:30PM -0700, Andrii Nakryiko escreveu:
> On Wed, Oct 21, 2020 at 12:25 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > > @@ -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));
> *FACEPALM*... This should be btf_kflag(tp) instead. I'll use btfdiff
> on all my patches from now on, sorry about this!


I'll retest when you resubmit.

One other thing I like to use is 'fullcircle':

# See how your DW_AT_producer looks like and find the
# right regexp to get after the GCC version string, this one
# seems good enough for Red Hat/Fedora/CentOS that look like:
#   DW_AT_producer    : (indirect string, offset: 0x3583): GNU C89 8.2.1 20181215 (Red Hat 8.2.1-6) -mno-sse -mno-mmx
# So we need from -mno-sse onwards

CFLAGS=$(readelf -wi $file | grep -w DW_AT_producer | sed -r      's/.*\)( -[[:alnum:]]+.*)+/\1/g')

# Check if we managed to do the sed or if this is something like GNU AS
[ "${CFLAGS/DW_AT_producer/}" != "${CFLAGS}" ] && exit

${pfunct_bin} --compile $file > $c_output
gcc $CFLAGS -c -g $c_output -o $o_output
${codiff_bin} -q -s $file $o_output

$ pfunct --help |& grep compile
      --compile[=FUNCTION]   Generate compilable source code with types

It generates code for all functions in a .o that touch its parameters
and right before those functions it regenerates all the types, so you go
from type information to C code that gets compiled with the same
compiler command line setting (obtained from DW_AT_producer for DWARF)
with type information and then it compares the original type information
with the one generated from the regenerated "original" source code.

Right now it works only with DWARF, because for it we derive the packed
attribute (pahole does that for BTF too) but, unlike bpftool btf it
doesn't add the needed padding for __alignment__ things, and DWARF
provides that info.

I'll work on that eventually and then fullcircle will do it for both
DWARF and for BTF.

- Arnaldo

      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
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 [this message]

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:

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

  git send-email \
    --in-reply-to=20201021201523.GA2385845@kernel.org \
    --to=acme@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=kernel-team@fb.com \


* 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 \
	public-inbox-index dwarves

Example config snippet for mirrors

Newsgroup available over NNTP:

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