Page MenuHomePhabricator

Modify DWARFFormValue to remember the DWARFUnit that it was decoded with.

Authored by clayborg on Oct 27 2016, 5:17 PM.



Modifying DWARFFormValue to remember the DWARFUnit that it was encoded with can simplify the usage of instances of this class. Previously users would have to try and pass in the same DWARFUnit that was used to decode the form value and there was a possibility that a different DWARFUnit might be supplied to the functions that extract values (strings, CU relative references, addresses) and cause problems. This fixes this potential issue by storing the DWARFUnit inside the DWARFFormValue so that this mistake can't be made. Instances of DWARFFormValue are not stored permanently and are used as temporary values, so the increase in size of an instance of DWARFFormValue isn't a big deal. This makes decoding form values more bullet proof and is a change that will be used by future modifications.

Diff Detail

Event Timeline

clayborg updated this revision to Diff 76137.Oct 27 2016, 5:17 PM
clayborg retitled this revision from to Modify DWARFFormValue to remember the DWARFUnit that it was decoded with..
clayborg updated this object.
clayborg set the repository for this revision to rL LLVM.
aprantl edited edge metadata.Oct 28 2016, 4:12 PM

Can you say anything about the impact this change has on the memory footprint? Do we typically keep many DWARFFormValues around?


You can doxygen'ify this by using

dwarf::Form Form; ///< Form for this value.


/// Form for this value.
dwarf::Form Form;

A DataExtractor is only a StringRef + 2x uint8_t. Are we saving anything by passing it by reference?

All DWARFFormValue objects are temporaries. I mentioned in the original description that this won't affect memory because of this.


This is how it was, I didn't change it, but I can add the doxygen /// if desired.


It just avoids the copy. It passes one pointer for the reference versus 2 pointers + 2 uint8_t values.

This is probably fine then. Fred, this touches a bunch of dsymutil code — any concerns?

friss edited edge metadata.Oct 28 2016, 5:24 PM

Looks globally good. Some nits:


llvm-dsymutil has a helper that does the same computation. Please add this helper and remove dsymutil's one in a preliminary commit.


If the FormValue holds the Unit, let's stop passing it around in small helpers like this. RefValue->getUnit() can be used below.


U is just unused here AFAICS, just remove it.

aprantl accepted this revision.Oct 29 2016, 11:05 AM
aprantl edited edge metadata.

LGTM (with feedback addressed).

This revision is now accepted and ready to land.Oct 29 2016, 11:05 AM

I will fix the one issue Fred Riss asked for and commit.


I will fix this.


I will fix this in a commit that is coming up soon. I am going to make a DWARFDIE class that encapsulates both the DwarfUnit and the DWARFDebugInfoEntryMinimal into one unit so all raw DWARFUnit objects will no longer be passed around. So I am going to defer fixing this until that patch since the new patch will take care of this.

clayborg closed this revision.Oct 31 2016, 9:55 AM

Committed with SVN revision 285594.