From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
Andrii Nakryiko <andriin@fb.com>,
dwarves@vger.kernel.org, bpf@vger.kernel.org,
Alexei Starovoitov <ast@fb.com>, Yonghong Song <yhs@fb.com>
Subject: Re: [PATCH pahole 0/3] fix handling of bitfields in btf_loader
Date: Mon, 25 Feb 2019 15:59:49 -0300 [thread overview]
Message-ID: <20190225185949.GT31136@kernel.org> (raw)
In-Reply-To: <20190225160239.GR31136@kernel.org>
Em Mon, Feb 25, 2019 at 01:02:39PM -0300, Arnaldo Carvalho de Melo escreveu:
> So yeah, the BTF encoder/decoder is working just fine, the problem is in
> pahole's DWARF code, lemme see...
Please try the patch below, for me btfdiff continues to show no diff for
all types in my vmlinux and now it also produces the same output for
when the first element of a bitfield has its bit_size equal to its
byte_size * 8:
[acme@quaco pahole]$ btfdiff vmlinux
[acme@quaco pahole]$ btfdiff examples/andrii/hsw_tsx_tuning-gcc
[acme@quaco pahole]$ btfdiff examples/andrii/hsw_tsx_tuning-clang
[acme@quaco pahole]$ pahole examples/andrii/hsw_tsx_tuning-clang
union hsw_tsx_tuning {
struct {
u32 cycles_last_block; /* 0 4 */
u32 hle_abort:1; /* 4:31 4 */
u32 rtm_abort:1; /* 4:30 4 */
u32 instruction_abort:1; /* 4:29 4 */
u32 non_instruction_abort:1; /* 4:28 4 */
u32 retry:1; /* 4:27 4 */
u32 data_conflict:1; /* 4:26 4 */
u32 capacity_writes:1; /* 4:25 4 */
u32 capacity_reads:1; /* 4:24 4 */
}; /* 0 8 */
u64 value; /* 0 8 */
};
[acme@quaco pahole]$ pahole -F btf examples/andrii/hsw_tsx_tuning-clang
union hsw_tsx_tuning {
struct {
u32 cycles_last_block; /* 0 4 */
u32 hle_abort:1; /* 4:31 4 */
u32 rtm_abort:1; /* 4:30 4 */
u32 instruction_abort:1; /* 4:29 4 */
u32 non_instruction_abort:1; /* 4:28 4 */
u32 retry:1; /* 4:27 4 */
u32 data_conflict:1; /* 4:26 4 */
u32 capacity_writes:1; /* 4:25 4 */
u32 capacity_reads:1; /* 4:24 4 */
}; /* 0 8 */
u64 value; /* 0 8 */
};
[acme@quaco pahole]$
diff --git a/dwarf_loader.c b/dwarf_loader.c
index adef437109f6..37477fb23be3 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -607,7 +607,8 @@ static struct variable *variable__new(Dwarf_Die *die, struct cu *cu)
int tag__recode_dwarf_bitfield(struct tag *tag, struct cu *cu, uint16_t bit_size)
{
- uint16_t id;
+ int id;
+ uint16_t short_id;
struct tag *recoded;
/* in all the cases the name is at the same offset */
strings_t name = tag__namespace(tag)->name;
@@ -620,7 +621,7 @@ int tag__recode_dwarf_bitfield(struct tag *tag, struct cu *cu, uint16_t bit_size
struct tag *type = dtype->tag;
id = tag__recode_dwarf_bitfield(type, cu, bit_size);
- if (id == tag->type)
+ if (id < 0)
return id;
struct type *new_typedef = obstack_zalloc(&cu->obstack,
@@ -660,10 +661,9 @@ int tag__recode_dwarf_bitfield(struct tag *tag, struct cu *cu, uint16_t bit_size
* the dwarf_cu as in dwarf there are no such things
* as base_types of less than 8 bits, etc.
*/
- recoded = cu__find_base_type_by_sname_and_size(cu, name, bit_size, &id);
+ recoded = cu__find_base_type_by_sname_and_size(cu, name, bit_size, &short_id);
if (recoded != NULL)
- return id;
-
+ return short_id;
struct base_type *new_bt = obstack_zalloc(&cu->obstack,
sizeof(*new_bt));
@@ -683,10 +683,9 @@ int tag__recode_dwarf_bitfield(struct tag *tag, struct cu *cu, uint16_t bit_size
* the dwarf_cu as in dwarf there are no such things
* as enumeration_types of less than 8 bits, etc.
*/
- recoded = cu__find_enumeration_by_sname_and_size(cu, name,
- bit_size, &id);
+ recoded = cu__find_enumeration_by_sname_and_size(cu, name, bit_size, &short_id);
if (recoded != NULL)
- return id;
+ return short_id;
struct type *alias = tag__type(tag);
struct type *new_enum = obstack_zalloc(&cu->obstack, sizeof(*new_enum));
next prev parent reply other threads:[~2019-02-25 19:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 20:57 [PATCH pahole 0/3] fix handling of bitfields in btf_loader Andrii Nakryiko
2019-02-20 20:57 ` [PATCH pahole 1/3] btfdiff: support specifying custom pahole location Andrii Nakryiko
2019-02-20 20:57 ` [PATCH pahole 2/3] pahole: complete list of base type names Andrii Nakryiko
2019-02-20 20:57 ` [PATCH pahole 3/3] btf_loader: fix bitfield fixup code Andrii Nakryiko
2019-02-22 22:02 ` [PATCH pahole 0/3] fix handling of bitfields in btf_loader Arnaldo Carvalho de Melo
2019-02-22 23:23 ` Andrii Nakryiko
2019-02-25 16:02 ` Arnaldo Carvalho de Melo
2019-02-25 18:59 ` Arnaldo Carvalho de Melo [this message]
2019-02-25 19:42 ` Andrii Nakryiko
2019-02-25 20:08 ` encoding BTF on glibc was: " Arnaldo Carvalho de Melo
2019-02-25 20:51 ` Andrii Nakryiko
2019-02-25 21:36 ` Andrii Nakryiko
2019-02-26 0:34 ` Andrii Nakryiko
2019-02-26 5:37 ` Yonghong Song
2019-02-26 5:44 ` Alexei Starovoitov
2019-02-26 5:45 ` Andrii Nakryiko
2019-02-26 6:03 ` Yonghong Song
2019-02-26 17:22 ` Andrii Nakryiko
2019-02-26 17:24 ` Yonghong Song
2019-02-26 17:34 ` Andrii Nakryiko
2019-02-26 13:11 ` Arnaldo Carvalho de Melo
2019-02-26 17:14 ` Andrii Nakryiko
2019-02-26 17:45 ` 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=20190225185949.GT31136@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--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.