Re: [DynInst_API:] Struct size computation


Date: Fri, 05 Sep 2014 11:01:44 +0200
From: Fabian Mager <fabian.mager@xxxxxxxxxxxxxx>
Subject: Re: [DynInst_API:] Struct size computation
I'd guess that this is a bug in DyninstAPI's DWARF parsing. In symtabAPI/src/dwarfWalker.C, function DwarfWalker::parseStructUnionClass(), the code calculates a structure's size, but then doesn't do anything with the result (I'd guess this bug appeared with the DWARF rewrite from a couple years ago). I think the calculated size should be set in the new typeStruct/typeUnion objects via setSize().
Thanks for your help Matt!You're right, the size gets never set and the following snippet solves my issue for structs (didn't looked at other types).

--- a/symtabAPI/src/dwarfWalker.C
+++ b/symtabAPI/src/dwarfWalker.C
@@ -1091,6 +1091,7 @@ bool DwarfWalker::parseStructUnionClass()
        case DW_TAG_structure_type:
        case DW_TAG_class_type: {
            typeStruct *ts = new typeStruct( type_id(), curName());
+           ts->setSize(size);
containingType = dynamic_cast<fieldListType *>(tc()->addOrUpdateType(ts));
            break;
        }

Best regards,
Fabian
[← Prev in Thread] Current Thread [Next in Thread→]