diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-03-04 10:19:21 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-03-07 17:00:43 -0300 |
commit | 1ecde473f9a07ac8c8d225119eac2192413f3271 (patch) | |
tree | 2a76b28e54891b7545150b43c8dced5ca02d4f5e | |
parent | f32ec0c79f3e8065e5b0e4aced65cba4cdf6675b (diff) | |
download | pahole-1ecde473f9a07ac8c8d225119eac2192413f3271.tar.gz |
fprintf: Don't ignore DW_TAG_inheritance in the sum of members check
Otherwise we end up with BFAs like this:
$ pahole -C StaticParticle objects/staticparticle.cpp.o
class StaticParticle : public CParticle {
public:
/* class CParticle <ancestor>; */ /* 0 24 */
/* XXX last struct has 1 hole */
void StaticParticle(class StaticParticle *, const class StaticParticle &);
void StaticParticle(class StaticParticle *, struct CPosition, class GraphicAnimation *, int);
virtual void ~StaticParticle(class StaticParticle *, int);
virtual class CParticle * clone(class StaticParticle *);
virtual void draw(class StaticParticle *);
virtual bool isVisible(const class StaticParticle *, const class CViewport &);
virtual void update(class StaticParticle *, int);
protected:
class GraphicAnimation * animation; /* 24 8 */
/* vtable has 4 entries: {
[2] = clone((null)),
[3] = draw((null)),
[4] = isVisible((null)),
[5] = update((null)),
} */
/* size: 32, cachelines: 1, members: 2 */
/* member types with holes: 1, total: 1 */
/* last cacheline: 32 bytes */
/* BRAIN FART ALERT! 32 bytes != 8 (member bytes) + 0 (member bits) + 0 (byte holes) + 0 (bit holes), diff = 192 bits */
};
Now we end up with:
$ pahole -C StaticParticle objects/staticparticle.cpp.o | tail -5
/* size: 32, cachelines: 1, members: 2 */
/* member types with holes: 1, total: 1 */
/* last cacheline: 32 bytes */
};
$
Reported-by: Matthias Schwarzott <zzam@gentoo.org>
Tested-by: Matthias Schwarzott <zzam@gentoo.org>
Closes: https://github.com/acmel/dwarves/issues/47
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarves_fprintf.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index 80d8a73a..a3c6221f 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -1820,8 +1820,12 @@ static size_t __class__fprintf(struct class *class, const struct cu *cu, ++printed; /* XXX for now just skip these */ - if (tag_pos->tag == DW_TAG_inheritance) + if (tag_pos->tag == DW_TAG_inheritance) { + // But do it for the sum_bytes, otherwised we'll get a BFA + // by missing the size of the ancestors. + sum_bytes += pos->byte_size; continue; + } #if 0 /* * This one was being skipped but caused problems with: |