<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
h3
        {mso-style-priority:9;
        mso-style-link:"Heading 3 Char";
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:13.5pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.Heading3Char
        {mso-style-name:"Heading 3 Char";
        mso-style-priority:9;
        mso-style-link:"Heading 3";
        font-family:"Calibri Light",sans-serif;
        color:#1F3763;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:2.0cm 42.5pt 2.0cm 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi David,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">ASan complained when `MemoryBuffer` checked for the null terminator. The fix was to pass to `MemoryBuffer::getMemBuffer` the actual size of the section data, not including the termination byte of the string.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sorry for the late reply.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:10.5pt;color:#212121">Best Regards,</span><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.5pt;color:#212121">Igor Kudrin</span><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#212121"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.5pt;color:#212121">C++ Developer,</span><span style="color:#212121"> Access Softek, Inc.​</span><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#212121"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> David Blaikie <dblaikie@gmail.com> <br>
<b>Sent:</b> Tuesday, September 17, 2019 5:08<br>
<b>To:</b> Igor Kudrin <ikudrin@accesssoftek.com><br>
<b>Cc:</b> llvm-commits <llvm-commits@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm] r371510 - Reland [DWARF] Add a unit test for DWARFUnit::getLength().<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="mso-element:para-border-div;border:dotted #003333 1.0pt;padding:10.0pt 10.0pt 10.0pt 10.0pt;background:white">
<h3 style="background:white;border:none;padding:0cm"><span style="font-size:10.0pt;color:#FF6600">CAUTION:<strong><span style="font-family:"Calibri",sans-serif"> </span></strong></span><span style="font-size:10.0pt">This email originated from outside of the
 organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.  If you suspect potential phishing or spam email, report it to <a href="mailto:ReportSpam@accesssoftek.com">ReportSpam@accesssoftek.com</a><o:p></o:p></span></h3>
</div>
</div>
<div>
<div>
<p class="MsoNormal">What was the asan bot failure? What was the fix?<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Sep 10, 2019 at 4:52 AM Igor Kudrin via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Author: ikudrin<br>
Date: Tue Sep 10 04:54:32 2019<br>
New Revision: 371510<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=371510&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=371510&view=rev</a><br>
Log:<br>
Reland [DWARF] Add a unit test for DWARFUnit::getLength().<br>
<br>
This is a follow-up of rL369529, where the return value of<br>
DWARFUnit::getLength() was changed from uint32_t to uint64_t.<br>
The test checks that a unit header with Length > 4G can be successfully<br>
parsed and the value of the Length field is not truncated.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D67276" target="_blank">
https://reviews.llvm.org/D67276</a><br>
<br>
Modified:<br>
    llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp<br>
<br>
Modified: llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp?rev=371510&r1=371509&r2=371510&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp?rev=371510&r1=371509&r2=371510&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp (original)<br>
+++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp Tue Sep 10 04:54:32 2019<br>
@@ -3158,4 +3158,46 @@ TEST(DWARFDebugInfo, TestDWARFDieRangeIn<br>
   AssertRangesIntersect(Ranges, {{0x20, 0x21}, {0x2f, 0x31}});<br>
 }<br>
<br>
+TEST(DWARFDebugInfo, TestDWARF64UnitLength) {<br>
+  static const char DebugInfoSecRaw[] =<br>
+      "\xff\xff\xff\xff"                 // DWARF64 mark<br>
+      "\x88\x77\x66\x55\x44\x33\x22\x11" // Length<br>
+      "\x05\x00"                         // Version<br>
+      "\x01"                             // DW_UT_compile<br>
+      "\x04"                             // Address size<br>
+      "\0\0\0\0\0\0\0\0";                // Offset Into Abbrev. Sec.<br>
+  StringMap<std::unique_ptr<MemoryBuffer>> Sections;<br>
+  Sections.insert(std::make_pair(<br>
+      "debug_info", MemoryBuffer::getMemBuffer(StringRef(<br>
+                        DebugInfoSecRaw, sizeof(DebugInfoSecRaw) - 1))));<br>
+  auto Context = DWARFContext::create(Sections, /* AddrSize = */ 4,<br>
+                                      /* isLittleEndian = */ true);<br>
+  const auto &Obj = Context->getDWARFObj();<br>
+  Obj.forEachInfoSections([&](const DWARFSection &Sec) {<br>
+    DWARFUnitHeader Header;<br>
+    DWARFDataExtractor Data(Obj, Sec, /* IsLittleEndian = */ true,<br>
+                            /* AddressSize = */ 4);<br>
+    uint64_t Offset = 0;<br>
+    EXPECT_FALSE(Header.extract(*Context, Data, &Offset));<br>
+    // Header.extract() returns false because there is not enough space<br>
+    // in the section for the declared length. Anyway, we can check that<br>
+    // the properties are read correctly.<br>
+    ASSERT_EQ(DwarfFormat::DWARF64, Header.getFormat());<br>
+    ASSERT_EQ(0x1122334455667788ULL, Header.getLength());<br>
+    ASSERT_EQ(5, Header.getVersion());<br>
+    ASSERT_EQ(DW_UT_compile, Header.getUnitType());<br>
+    ASSERT_EQ(4, Header.getAddressByteSize());<br>
+<br>
+    // Check that the length can be correctly read in the unit class.<br>
+    DWARFUnitVector DummyUnitVector;<br>
+    DWARFSection DummySec;<br>
+    DWARFCompileUnit CU(*Context, Sec, Header, /* DA = */ 0, /* RS = */ 0,<br>
+                        /* LocSection = */ 0, /* SS = */ StringRef(),<br>
+                        /* SOS = */ DummySec, /* AOS = */ 0,<br>
+                        /* LS = */ DummySec, /* LE = */ true,<br>
+                        /* isDWO= */ false, DummyUnitVector);<br>
+    ASSERT_EQ(0x1122334455667788ULL, CU.getLength());<br>
+  });<br>
+}<br>
+<br>
 } // end anonymous namespace<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>