<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 12, 2014, at 4:42 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Wed, Nov 12, 2014 at 4:06 PM, Frédéric Riss<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:friss@apple.com" target="_blank" class="">friss@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><div class=""><div class="h5"><blockquote type="cite" class=""><div class="">On Nov 12, 2014, at 3:59 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Nov 12, 2014 at 3:48 PM, Frederic Riss<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:friss@apple.com" target="_blank" class="">friss@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: friss<br class="">Date: Wed Nov 12 17:48:04 2014<br class="">New Revision: 221835<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=221835&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=221835&view=rev</a><br class="">Log:<br class="">Allow DWARFFormValue::extractValue to be called with a null CU.<br class=""><br class="">Currently FormValues are only used for attributes of DIEs and thus<br class="">uers always have a CU lying around when calling into the FormValue<br class="">API.<br class="">Accelerator tables encode their information using the same Forms<br class="">as the attributes, thus it is natural to use DWARFFormValue to<br class="">extract/dump them. There is no CU in that case though. Allow the<br class="">API to be called with a null CU arguemnt by making the RelocMap<br class="">lookup conditional on the CU pointer validity. And document this<br class="">new behvior in the header. (Test coverage for this use of the API<br class="">comes in the DwarfAccelTable support patch)<br class=""><br class="">Modified:<br class=""> <span class="Apple-converted-space"> </span>llvm/trunk/include/llvm/DebugInfo/DWARFFormValue.h<br class=""> <span class="Apple-converted-space"> </span>llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp<br class=""><br class="">Modified: llvm/trunk/include/llvm/DebugInfo/DWARFFormValue.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARFFormValue.h?rev=221835&r1=221834&r2=221835&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARFFormValue.h?rev=221835&r1=221834&r2=221835&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/DebugInfo/DWARFFormValue.h (original)<br class="">+++ llvm/trunk/include/llvm/DebugInfo/DWARFFormValue.h Wed Nov 12 17:48:04 2014<br class="">@@ -57,6 +57,13 @@ public:<br class=""> bool isFormClass(FormClass FC) const;<br class=""><br class=""> void dump(raw_ostream &OS, const DWARFUnit *U) const;<br class="">+<br class="">+ /// \brief extracts a value in data at offset *offset_ptr.<br class="">+ ///<br class="">+ /// The passed DWARFUnit is allowed to be nullptr,<span class="Apple-converted-space"> </span></blockquote><div class=""><br class="">"to be null" (nullptr is just one null pointer literal - "null" is the general concept)<br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div class="">OK, I’ll fix that up.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">in which<br class="">+ /// case no relocation processing will be performed and some<br class="">+ /// kind of forms that depend on Unit information are disallowed.<br class=""></blockquote><div class=""><br class="">Disallowed is a bit vague - elegant failure? Assertion? I would probably prefer assertion failure, if that's reasonable/possible.<br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">With this patch, the extractValue fails, ie. it returns false. </div></div></div></blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">I prefer that over the assertion,<span class="Apple-converted-space"> </span></div></div></div></blockquote><div class=""><br class="">Why do you prefer that over an assertion? I assume that encoding isn't valid in the accelerator table - is the table self-describing (does it include the form code in the data read from the file? So it could, in theory (if mangled/fuzzed/etc) include a relocatable form?)? In that case I get where you're coming from, we shouldn't crash/assert on the bytes read from the file no matter how absurd they are.<br class=""></div></div></div></blockquote><div><br class=""></div><div>Yes, exactly. Moreover, the function prototype was already tailored to return success/failure, thus adding that as another failure more seemed natural.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">but then disallowed is misleading. I should maybe reword that as "will result in an extraction failure”.</div><div class=""><br class=""></div><div class="">Fred</div><div class=""><div class="h5"><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">+ /// \returns wether the extraction succeeded.<br class=""> bool extractValue(DataExtractor data, uint32_t *offset_ptr,<br class=""> const DWARFUnit *u);<br class=""> bool isInlinedCStr() const {<br class=""><br class="">Modified: llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp?rev=221835&r1=221834&r2=221835&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp?rev=221835&r1=221834&r2=221835&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp (original)<br class="">+++ llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp Wed Nov 12 17:48:04 2014<br class="">@@ -139,6 +139,8 @@ bool DWARFFormValue::extractValue(DataEx<br class=""> switch (Form) {<br class=""> case DW_FORM_addr:<br class=""> case DW_FORM_ref_addr: {<br class="">+ if (!cu)<br class="">+ return false; </blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"> uint16_t AddrSize =<br class=""> (Form == DW_FORM_addr)<br class=""> ? cu->getAddressByteSize()<br class="">@@ -179,8 +181,10 @@ bool DWARFFormValue::extractValue(DataEx<br class=""> break;<br class=""> case DW_FORM_data4:<br class=""> case DW_FORM_ref4: {<br class="">- RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr);<br class=""> Value.uval = data.getU32(offset_ptr);<br class="">+ if (!cu)<br class="">+ break;<br class="">+ RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);<br class=""> if (AI != cu->getRelocMap()->end())<br class=""> Value.uval += AI->second.second;<br class=""> break;<br class="">@@ -193,13 +197,12 @@ bool DWARFFormValue::extractValue(DataEx<br class=""> Value.sval = data.getSLEB128(offset_ptr);<br class=""> break;<br class=""> case DW_FORM_strp: {<br class="">- RelocAddrMap::const_iterator AI<br class="">- = cu->getRelocMap()->find(*offset_ptr);<br class="">- if (AI != cu->getRelocMap()->end()) {<br class="">- const std::pair<uint8_t, int64_t> &R = AI->second;<br class="">- Value.uval = data.getU32(offset_ptr) + R.second;<br class="">- } else<br class="">- Value.uval = data.getU32(offset_ptr);<br class="">+ Value.uval = data.getU32(offset_ptr);<br class="">+ if (!cu)<br class="">+ break;<br class="">+ RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);<br class="">+ if (AI != cu->getRelocMap()->end())<br class="">+ Value.uval += AI->second.second;<br class=""> break;<br class=""> }<br class=""> case DW_FORM_udata:<br class="">@@ -215,13 +218,12 @@ bool DWARFFormValue::extractValue(DataEx<br class=""> break;<br class=""> case DW_FORM_sec_offset: {<br class=""> // FIXME: This is 64-bit for DWARF64.<br class="">- RelocAddrMap::const_iterator AI<br class="">- = cu->getRelocMap()->find(*offset_ptr);<br class="">- if (AI != cu->getRelocMap()->end()) {<br class="">- const std::pair<uint8_t, int64_t> &R = AI->second;<br class="">- Value.uval = data.getU32(offset_ptr) + R.second;<br class="">- } else<br class="">- Value.uval = data.getU32(offset_ptr);<br class="">+ Value.uval = data.getU32(offset_ptr);<br class="">+ if (!cu)<br class="">+ break;<br class="">+ RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);<br class="">+ if (AI != cu->getRelocMap()->end())<br class="">+ Value.uval += AI->second.second;<br class=""> break;<br class=""> }<br class=""> case DW_FORM_flag_present:<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="">llvm-commits@cs.uiuc.edu</a><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></blockquote></div></div></div></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>