aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2024-03-11 12:09:53 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2024-03-11 12:09:53 -0300
commit4faf35b97c3427d1e2eebd6d7c6d900813d8c73c (patch)
tree571ea8f4130125edaab68849251a66efd05f4fe6
parent47e83035c12c153b579db2e5fabd306a0d6f2d29 (diff)
downloadpahole-4faf35b97c3427d1e2eebd6d7c6d900813d8c73c.tar.gz
fprintf: Remove bogus deduction of negative hole from size of previous field
In the previous fix for the usage of padding from ancestor classes the negative hole was being deducted from the calculation of the previous member/ancestor that is done purely using the offsets of the current and previous fields, where it makes no sense to consider the hole, so revert that specific hunk, with it the "Bitfield combined with next fields" comment, which is wrong, is removed. Before: $ pahole -C Spell_AdjustVital objects/spell_adjustvital.cpp.o class Spell_AdjustVital : public SpellActionType { public: /* class SpellActionType <ancestor>; */ /* 0 16 */ /* XXX last struct has 4 bytes of padding */ void Spell_AdjustVital(class Spell_AdjustVital *); virtual int Cast(class Spell_AdjustVital *, class CUnit &, const class SpellType &, class CUnit * &, const Vec2i &); virtual void Parse(class Spell_AdjustVital *, lua_State *, int, int); /* Bitfield combined with next fields */ int HP; /* 12 4 */ int Mana; /* 16 4 */ int Shield; /* 20 4 */ int MaxMultiCast; /* 24 4 */ virtual void ~Spell_AdjustVital(class Spell_AdjustVital *, int); /* vtable has 2 entries: { [2] = Cast((null)), [3] = Parse((null)), } */ /* size: 32, cachelines: 1, members: 5 */ /* padding: 4 */ /* paddings: 1, sum paddings: 4 */ /* last cacheline: 32 bytes */ }; After: $ pahole -C Spell_AdjustVital objects/spell_adjustvital.cpp.o class Spell_AdjustVital : public SpellActionType { public: /* class SpellActionType <ancestor>; */ /* 0 16 */ /* XXX last struct has 4 bytes of padding */ void Spell_AdjustVital(class Spell_AdjustVital *); virtual int Cast(class Spell_AdjustVital *, class CUnit &, const class SpellType &, class CUnit * &, const Vec2i &); virtual void Parse(class Spell_AdjustVital *, lua_State *, int, int); int HP; /* 12 4 */ int Mana; /* 16 4 */ int Shield; /* 20 4 */ int MaxMultiCast; /* 24 4 */ virtual void ~Spell_AdjustVital(class Spell_AdjustVital *, int); /* vtable has 2 entries: { [2] = Cast((null)), [3] = Parse((null)), } */ /* size: 32, cachelines: 1, members: 5 */ /* padding: 4 */ /* paddings: 1, sum paddings: 4 */ /* last cacheline: 32 bytes */ }; $ Reported-by: Matthias Schwarzott <zzam@gentoo.org> Fixes: 47e83035c12c153b ("core: The padding in ancestor classes may be used in descendants") Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarves_fprintf.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c
index 613aeabe..f3bf96f5 100644
--- a/dwarves_fprintf.c
+++ b/dwarves_fprintf.c
@@ -1747,12 +1747,8 @@ static size_t __class__fprintf(struct class *class, const struct cu *cu,
cconf.indent, tabs);
}
} else {
- ssize_t cc_last_size = ((ssize_t)pos->byte_offset -
- (ssize_t)last->byte_offset);
- // Are we using the padding of an ancestor class (DW_TAG_inheritance)?
- if (last->tag.tag == DW_TAG_inheritance && last->hole < 0)
- cc_last_size += last->hole;
-
+ const ssize_t cc_last_size = ((ssize_t)pos->byte_offset -
+ (ssize_t)last->byte_offset);
if (cc_last_size > 0 &&
(size_t)cc_last_size < last_size) {
if (!cconf.suppress_comments) {