Skip to content

Commit

Permalink
dwarf_loader: Fix sorting of Rust structs
Browse files Browse the repository at this point in the history
We may have structs with fields on the same offset, don't move anything
in that case, otherwise we get into an eternal loop, doh.

Tested with the Linux kernel built with CONFIG_RUST + all the code
examples, first Rust struct where this happened was:

  (gdb) p type->namespace.name
  $2 = 0x7fffda938497 "((), char)"
  (gdb) p type->nr_members
  $3 = 2
  (gdb) p current_member->name
  $4 = 0x7fffda918f36 "__1"
  (gdb) p next_member->name
  $5 = 0x7fffda91765c "__0"
  (gdb) p current_member->byte_offset
  $6 = 0
  (gdb) p next_member->byte_offset
  $7 = 0

But this shows that --lang_exclude should be better positioned as we're
now needlessly loading all the tags for Rust DWARF to then just trow it
away at the cu__filter() in pahole :-\

Too late in the 1.25 release cycle for that, optimize it in 1.26.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
acmel committed Feb 14, 2023
1 parent c4eb189 commit 1231b6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dwarf_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2857,7 +2857,7 @@ static int type__sort_by_offset(struct tag *tag, struct cu *cu, void *cookie __m

struct class_member *next_member = list_entry(current_member->tag.node.next, typeof(*current_member), tag.node);

if (current_member->byte_offset < next_member->byte_offset)
if (current_member->byte_offset <= next_member->byte_offset)
continue;

list_del(&current_member->tag.node);
Expand Down

0 comments on commit 1231b6b

Please sign in to comment.