Skip to contentSkip to conversation

fprintf: Take inherited types' sizes into account when printing

PATCH New Pedro Falcato 1 participant 2 messages Oct 20, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fprintf: Take inherited types' sizes into account when printing

Previously, any struct/class that inherited a type had a BRAIN FART with a size difference of exactly the size of the inherited types.

Example:

struct S

{
    unsigned long a;
};

struct S2 : public S

{
    unsigned long b;
};

pahole output:

struct S {
        long unsigned int          a;                    /*     0     8 */

        /* size: 8, cachelines: 1, members: 1 */
        /* last cacheline: 8 bytes */
};
struct S2 : S {
        /* struct S                   <ancestor>; */     /*     0     8 */
        long unsigned int          b;                    /*     8     8 */

        /* size: 16, cachelines: 1, members: 2 */
        /* last cacheline: 16 bytes */

        /* BRAIN FART ALERT! 16 bytes != 8 (member bytes) + 0 (member bits) + 0 (byte holes) + 0 (bit holes), diff = 64 bits */
};

Take those into account.

---
 dwarves_fprintf.c | 3 ---
 1 file changed, 3 deletions(-)
dwarves_fprintf.c +0 -3
index ef8b82b..5c2d14d 100644
@@ -1735,9 +1735,6 @@ static size_t __class__fprintf(struct class *class, const struct cu *cu,
 		fputc('\n', fp);
 		++printed;
 
-		/* XXX for now just skip these */
-		if (tag_pos->tag == DW_TAG_inheritance)
-			continue;
 #if 0
 		/*
  		 * This one was being skipped but caused problems with:
Signature · 1 line
2.42.0
#1 lore raw

PATCH 2/2 README: Add guidance in patch sending

How to contribute changes isn't necessarily obvious if one only takes into account what's in the git repo (even the mailing list's email is hidden in a man page). Add some guidance for future contributors.

---
 README | 4 ++++
 1 file changed, 4 insertions(+)
README +4 -0
index f9aeef7..3bd7dd8 100644
@@ -21,3 +21,7 @@ cmake Options:
 You may need to update the libbpf git submodule:
 
 git submodule update --init --recursive
+
+Submitting patches:
+Please submit patches in git format-patch format to [email protected] (plain text emails only).
+Development roughly follows a simplified version of Linux kernel's Documentation/process/submitting-patches.rst.
Signature · 1 line
2.42.0