<div dir="ltr">Yes, I know what the problem is.  I should have a fix soon</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 8, 2018 at 12:16 PM Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks!  That gives me a hint.  Will confirm after lunch<br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 8, 2018 at 12:15 PM Evgenii Stepanov <<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I put an explicit check in MutableBinaryByteStream::writeBytes and got<br>
this. Does it make sense?<br>
<br>
Uninitialized bytes in __msan_check_mem_is_initialized at offset 0<br>
inside [0x70600000008a, 2)<br>
==219859==WARNING: MemorySanitizer: use-of-uninitialized-value<br>
    #0 0x1de06d2 in llvm::MutableBinaryByteStream::writeBytes(unsigned<br>
int, llvm::ArrayRef<unsigned char>)<br>
/code/llvm-project/llvm/include/llvm/Support/BinaryByteStream.h:123:5<br>
    #1 0x1dcf6a6 in llvm::WritableBinaryStreamRef::writeBytes(unsigned<br>
int, llvm::ArrayRef<unsigned char>) const<br>
/code/llvm-project/llvm/lib/Support/BinaryStreamRef.cpp:123:24<br>
    #2 0x1de2dba in<br>
llvm::BinaryStreamWriter::writeBytes(llvm::ArrayRef<unsigned char>)<br>
/code/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp:29:24<br>
    #3 0x28d697c in llvm::Error<br>
llvm::BinaryStreamWriter::writeObject<llvm::support::detail::packed_endian_specific_integral<unsigned<br>
short, (llvm::support::endianness)1, 1ul><br>
>(llvm::support::detail::packed_endian_specific_integral<unsigned<br>
short, (llvm::support::endianness)1, 1ul> const&)<br>
/code/llvm-project/llvm/include/llvm/Support/BinaryStreamWriter.h:127:12<br>
    #4 0x28a2e88 in llvm::Error<br>
llvm::codeview::CodeViewRecordIO::mapObject<llvm::support::detail::packed_endian_specific_integral<unsigned<br>
short, (llvm::support::endianness)1, 1ul><br>
>(llvm::support::detail::packed_endian_specific_integral<unsigned<br>
short, (llvm::support::endianness)1, 1ul>&)<br>
/code/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h:51:22<br>
    #5 0x28a42ea in<br>
llvm::codeview::SymbolRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&,<br>
llvm::codeview::DefRangeRegisterSym&)<br>
/code/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp:264:3<br>
    #6 0x10413b8 in llvm::Error<br>
llvm::codeview::SymbolSerializer::visitKnownRecordImpl<llvm::codeview::DefRangeRegisterSym>(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&,<br>
llvm::codeview::DefRangeRegisterSym&)<br>
/code/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h:77:20<br>
    #7 0x1040fb0 in<br>
llvm::codeview::SymbolSerializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&,<br>
llvm::codeview::DefRangeRegisterSym&)<br>
/code/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def:221:1<br>
    #8 0x1040a0e in<br>
llvm::codeview::CVRecord<llvm::codeview::SymbolKind><br>
llvm::codeview::SymbolSerializer::writeOneSymbol<llvm::codeview::DefRangeRegisterSym>(llvm::codeview::DefRangeRegisterSym&,<br>
llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>&,<br>
llvm::codeview::CodeViewContainer)<br>
/code/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h:59:29<br>
    #9 0x103fcc6 in<br>
llvm::CodeViewYAML::detail::SymbolRecordImpl<llvm::codeview::DefRangeRegisterSym>::toCodeViewSymbol(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator,<br>
4096ul, 4096ul>&, llvm::codeview::CodeViewContainer) const<br>
/code/llvm-project/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp:209:12<br>
    #10 0xed62a1 in<br>
llvm::CodeViewYAML::SymbolRecord::toCodeViewSymbol(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator,<br>
4096ul, 4096ul>&, llvm::codeview::CodeViewContainer) const<br>
/code/llvm-project/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp:522:18<br>
    #11 0xe07cd6 in (anonymous<br>
namespace)::YAMLSymbolsSubsection::toCodeViewSubsection(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator,<br>
4096ul, 4096ul>&, llvm::codeview::StringsAndChecksums const&) const<br>
/code/llvm-project/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp:495:13<br>
    #12 0xbc0730 in<br>
llvm::CodeViewYAML::toCodeViewSubsectionList(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator,<br>
4096ul, 4096ul>&,<br>
llvm::ArrayRef<llvm::CodeViewYAML::YAMLDebugSubsection>,<br>
llvm::codeview::StringsAndChecksums const&)<br>
/code/llvm-project/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp:757:26<br>
    #13 0x69e9ff in<br>
toDebugS(llvm::ArrayRef<llvm::CodeViewYAML::YAMLDebugSubsection>,<br>
llvm::codeview::StringsAndChecksums const&,<br>
llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>&)<br>
/code/llvm-project/llvm/tools/yaml2obj/yaml2coff.cpp:178:11<br>
    #14 0x6444c3 in layoutCOFF(COFFParser&)<br>
/code/llvm-project/llvm/tools/yaml2obj/yaml2coff.cpp:232:13<br>
    #15 0x638021 in yaml2coff(llvm::COFFYAML::Object&,<br>
llvm::raw_ostream&)<br>
/code/llvm-project/llvm/tools/yaml2obj/yaml2coff.cpp:605:8<br>
    #16 0x5afcd6 in convertYAML(llvm::yaml::Input&,<br>
llvm::raw_ostream&)<br>
/code/llvm-project/llvm/tools/yaml2obj/yaml2obj.cpp:59:16<br>
    #17 0x5a84e8 in main<br>
/code/llvm-project/llvm/tools/yaml2obj/yaml2obj.cpp:94:13<br>
    #18 0x7fcc2e6baf44 in __libc_start_main<br>
/build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:287<br>
    #19 0x532918 in _start (/code/build-llvm-msan/bin/yaml2obj+0x532918)<br>
<br>
  Uninitialized value was created by a heap allocation<br>
    #0 0x59c9a9 in operator new(unsigned long)<br>
/code/llvm-project/compiler-rt/lib/msan/msan_new_delete.cc:45:35<br>
    #1 0x114d6d4 in __allocate<br>
/code/build-libcxx-msan//include/c++/v1/new:226:10<br>
    #2 0x114d6d4 in allocate /code/build-libcxx-msan//include/c++/v1/memory:1747<br>
    #3 0x114d6d4 in<br>
std::__1::shared_ptr<llvm::CodeViewYAML::detail::SymbolRecordImpl<llvm::codeview::DefRangeRegisterSym><br>
> std::__1::shared_ptr<llvm::CodeViewYAML::detail::SymbolRecordImpl<llvm::codeview::DefRangeRegisterSym><br>
>::make_shared<llvm::codeview::SymbolKind&>(llvm::codeview::SymbolKind&)<br>
/code/build-libcxx-msan//include/c++/v1/memory:4223<br>
    #4 0xf038fa in<br>
make_shared<llvm::CodeViewYAML::detail::SymbolRecordImpl<llvm::codeview::DefRangeRegisterSym>,<br>
llvm::codeview::SymbolKind &><br>
/code/build-libcxx-msan//include/c++/v1/memory:4594:12<br>
    #5 0xf038fa in<br>
_ZL19mapSymbolRecordImplIN4llvm12CodeViewYAML6detail16SymbolRecordImplINS0_8codeview19DefRangeRegisterSymEEEEvRNS0_4yaml2IOEPKcNS4_10SymbolKindERNS1_12SymbolRecordE<br>
/code/llvm-project/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp:566<br>
    #6 0xed804f in<br>
llvm::yaml::MappingTraits<llvm::CodeViewYAML::SymbolRecord>::mapping(llvm::yaml::IO&,<br>
llvm::CodeViewYAML::SymbolRecord&)<br>
/code/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def:221:1<br>
    #7 0xe0e11c in void<br>
llvm::yaml::detail::doMapping<llvm::CodeViewYAML::SymbolRecord>(llvm::yaml::IO&,<br>
llvm::CodeViewYAML::SymbolRecord&, llvm::yaml::EmptyContext&)<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:800:3<br>
    #8 0xe0d34b in<br>
_ZN4llvm4yaml7yamlizeINS_12CodeViewYAML12SymbolRecordENS0_12EmptyContextEEENSt3__19enable_ifIXsr24unvalidatedMappingTraitsIT_T0_EE5valueEvE4typeERNS0_2IOERS7_bRS8_<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:899:5<br>
    #9 0xe0c69a in<br>
_ZN4llvm4yaml7yamlizeINSt3__16vectorINS_12CodeViewYAML12SymbolRecordENS2_9allocatorIS5_EEEENS0_12EmptyContextEEENS2_9enable_ifIXsr18has_SequenceTraitsIT_EE5valueEvE4typeERNS0_2IOERSB_bRT0_<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:946:9<br>
    #10 0xe0b702 in void<br>
llvm::yaml::IO::processKey<std::__1::vector<llvm::CodeViewYAML::SymbolRecord,<br>
std::__1::allocator<llvm::CodeViewYAML::SymbolRecord> >,<br>
llvm::yaml::EmptyContext>(char const*,<br>
std::__1::vector<llvm::CodeViewYAML::SymbolRecord,<br>
std::__1::allocator<llvm::CodeViewYAML::SymbolRecord> >&, bool,<br>
llvm::yaml::EmptyContext&)<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:783:7<br>
    #11 0xe0ae32 in void<br>
llvm::yaml::IO::mapRequired<std::__1::vector<llvm::CodeViewYAML::SymbolRecord,<br>
std::__1::allocator<llvm::CodeViewYAML::SymbolRecord> > >(char const*,<br>
std::__1::vector<llvm::CodeViewYAML::SymbolRecord,<br>
std::__1::allocator<llvm::CodeViewYAML::SymbolRecord> >&)<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:692:11<br>
    #12 0xe05806 in (anonymous<br>
namespace)::YAMLSymbolsSubsection::map(llvm::yaml::IO&)<br>
/code/llvm-project/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp:353:6<br>
    #13 0xbb742f in<br>
llvm::yaml::MappingTraits<llvm::CodeViewYAML::YAMLDebugSubsection>::mapping(llvm::yaml::IO&,<br>
llvm::CodeViewYAML::YAMLDebugSubsection&)<br>
/code/llvm-project/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp:399:26<br>
    #14 0x1a075dc in void<br>
llvm::yaml::detail::doMapping<llvm::CodeViewYAML::YAMLDebugSubsection>(llvm::yaml::IO&,<br>
llvm::CodeViewYAML::YAMLDebugSubsection&, llvm::yaml::EmptyContext&)<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:800:3<br>
    #15 0x1a0680b in<br>
_ZN4llvm4yaml7yamlizeINS_12CodeViewYAML19YAMLDebugSubsectionENS0_12EmptyContextEEENSt3__19enable_ifIXsr24unvalidatedMappingTraitsIT_T0_EE5valueEvE4typeERNS0_2IOERS7_bRS8_<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:899:5<br>
    #16 0x1a05b5a in<br>
_ZN4llvm4yaml7yamlizeINSt3__16vectorINS_12CodeViewYAML19YAMLDebugSubsectionENS2_9allocatorIS5_EEEENS0_12EmptyContextEEENS2_9enable_ifIXsr18has_SequenceTraitsIT_EE5valueEvE4typeERNS0_2IOERSB_bRT0_<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:946:9<br>
    #17 0x1a04bc2 in void<br>
llvm::yaml::IO::processKey<std::__1::vector<llvm::CodeViewYAML::YAMLDebugSubsection,<br>
std::__1::allocator<llvm::CodeViewYAML::YAMLDebugSubsection> >,<br>
llvm::yaml::EmptyContext>(char const*,<br>
std::__1::vector<llvm::CodeViewYAML::YAMLDebugSubsection,<br>
std::__1::allocator<llvm::CodeViewYAML::YAMLDebugSubsection> >&, bool,<br>
llvm::yaml::EmptyContext&)<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:783:7<br>
    #18 0x1a042fb in<br>
_ZN4llvm4yaml2IO22mapOptionalWithContextINSt3__16vectorINS_12CodeViewYAML19YAMLDebugSubsectionENS3_9allocatorIS6_EEEENS0_12EmptyContextEEENS3_9enable_ifIXsr18has_SequenceTraitsIT_EE5valueEvE4typeEPKcRSC_RT0_<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:717:11<br>
    #19 0x19cbf96 in void<br>
llvm::yaml::IO::mapOptional<std::__1::vector<llvm::CodeViewYAML::YAMLDebugSubsection,<br>
std::__1::allocator<llvm::CodeViewYAML::YAMLDebugSubsection> > >(char<br>
const*, std::__1::vector<llvm::CodeViewYAML::YAMLDebugSubsection,<br>
std::__1::allocator<llvm::CodeViewYAML::YAMLDebugSubsection> >&)<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:702:5<br>
    #20 0x19c89bb in<br>
llvm::yaml::MappingTraits<llvm::COFFYAML::Section>::mapping(llvm::yaml::IO&,<br>
llvm::COFFYAML::Section&)<br>
/code/llvm-project/llvm/lib/ObjectYAML/COFFYAML.cpp:570:8<br>
    #21 0x1a5d9bc in void<br>
llvm::yaml::detail::doMapping<llvm::COFFYAML::Section>(llvm::yaml::IO&,<br>
llvm::COFFYAML::Section&, llvm::yaml::EmptyContext&)<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:800:3<br>
    #22 0x1a5cbdb in<br>
_ZN4llvm4yaml7yamlizeINS_8COFFYAML7SectionENS0_12EmptyContextEEENSt3__19enable_ifIXsr24unvalidatedMappingTraitsIT_T0_EE5valueEvE4typeERNS0_2IOERS7_bRS8_<br>
/code/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:899:5<br>
<br>
On Mon, Jan 8, 2018 at 11:50 AM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> In the meantime I'm trying to reproduce this on my linux box.  I have an<br>
> idea how to track it down if I can get a repro.<br>
><br>
> On Mon, Jan 8, 2018 at 11:32 AM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
>><br>
>> We were just discussing this in another thread.  And I mentioned that this<br>
>> is the exact same bug that happened several months ago.  At the time, you<br>
>> sent me this mail:<br>
>><br>
>> ---<br>
>> This is the write to the byte before the first uninitialized.<br>
>><br>
>> #0  __memmove_ssse3_back () at<br>
>> ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:2720<br>
>> #1  0x000000000044bb4c in __msan_memcpy () at<br>
>> /code/llvm/projects/compiler-rt/lib/msan/msan_interceptors.cc:1455<br>
>> #2  0x00000000007a3999 in writeBytes () at<br>
>> /code/llvm/include/llvm/Support/BinaryByteStream.h:121<br>
>> #3  writeBytes () at /code/llvm/lib/Support/BinaryStreamRef.cpp:59<br>
>> #4  0x00000000007a2f91 in writeBytes () at<br>
>> /code/llvm/lib/Support/BinaryStreamRef.cpp:129<br>
>> #5  0x00000000007a46fe in writeBytes () at<br>
>> /code/llvm/lib/Support/BinaryStreamWriter.cpp:29<br>
>> #6  0x00000000008de26e in commit () at<br>
>> /code/llvm/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp:25<br>
>> #7  0x000000000051bb9e in commit () at<br>
>> /code/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp:77<br>
>> #8  0x00000000004a50e1 in toDebugS () at<br>
>> /code/llvm/tools/yaml2obj/yaml2coff.cpp:193<br>
>> #9  layoutCOFF () at /code/llvm/tools/yaml2obj/yaml2coff.cpp:232<br>
>> #10 yaml2coff () at /code/llvm/tools/yaml2obj/yaml2coff.cpp:602<br>
>> #11 0x000000000049b3e7 in convertYAML () at<br>
>> /code/llvm/tools/yaml2obj/yaml2obj.cpp:59<br>
>> #12 main () at /code/llvm/tools/yaml2obj/yaml2obj.cpp:94<br>
>><br>
>> There are no writes to the uninitialized byte, accoring to gdb.<br>
>> ---<br>
>><br>
>> I don't know how you came up with this stack trace, but if it's not too<br>
>> much work, would you be able to generate a similar stack trace for this one?<br>
>><br>
>> On Mon, Jan 8, 2018 at 11:24 AM Evgenii Stepanov<br>
>> <<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>> wrote:<br>
>>><br>
>>> Hi,<br>
>>><br>
>>> MSan is not happy with this change:<br>
>>><br>
>>> <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12211" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12211</a><br>
>>><br>
>>> Uninitialized bytes in __interceptor_write at offset 316 inside<br>
>>> [0x720000085000, 1998)<br>
>>> ==5173==WARNING: MemorySanitizer: use-of-uninitialized-value<br>
>>>     #0 0x6cf04d in llvm::raw_fd_ostream::write_impl(char const*,<br>
>>> unsigned long)<br>
>>> /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/raw_ostream.cpp:600:19<br>
>>>     #1 0x4aaa8b in flush<br>
>>><br>
>>> /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/raw_ostream.h:142:7<br>
>>>     #2 0x4aaa8b in main<br>
>>> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/yaml2obj/yaml2obj.cpp:98<br>
>>>     #3 0x7f5d8f8b92b0 in __libc_start_main<br>
>>> (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)<br>
>>>     #4 0x43cd19 in _start<br>
>>><br>
>>> (/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/yaml2obj+0x43cd19)<br>
>>><br>
>>><br>
>>> On Fri, Jan 5, 2018 at 11:12 AM, Zachary Turner via llvm-commits<br>
>>> <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
>>> > Author: zturner<br>
>>> > Date: Fri Jan  5 11:12:40 2018<br>
>>> > New Revision: 321883<br>
>>> ><br>
>>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=321883&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=321883&view=rev</a><br>
>>> > Log:<br>
>>> > [PDB] Correctly link S_FILESTATIC records.<br>
>>> ><br>
>>> > This is not a record type that clang currently generates,<br>
>>> > but it is a record that is encountered in object files generated<br>
>>> > by cl.  This record is unusual in that it refers directly to<br>
>>> > the string table instead of indirectly to the string table via<br>
>>> > the FileChecksums table.  Because of this, it was previously<br>
>>> > overlooked and we weren't remapping the string indices at all.<br>
>>> > This would lead to crashes in MSVC when trying to display a<br>
>>> > variable whose debug info involved an S_FILESTATIC.<br>
>>> ><br>
>>> > Original bug report by Alexander Ganea<br>
>>> ><br>
>>> > Differential Revision: <a href="https://reviews.llvm.org/D41718" rel="noreferrer" target="_blank">https://reviews.llvm.org/D41718</a><br>
>>> ><br>
>>> > Modified:<br>
>>> >     llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp<br>
>>> >     llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.h<br>
>>> >     llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp<br>
>>> >     llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.h<br>
>>> ><br>
>>> > Modified: llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp?rev=321883&r1=321882&r2=321883&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp?rev=321883&r1=321882&r2=321883&view=diff</a><br>
>>> ><br>
>>> > ==============================================================================<br>
>>> > --- llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp (original)<br>
>>> > +++ llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp Fri Jan  5<br>
>>> > 11:12:40 2018<br>
>>> > @@ -848,14 +848,7 @@ Error DumpOutputStyle::dumpXme() {<br>
>>> >    return Error::success();<br>
>>> >  }<br>
>>> ><br>
>>> > -Error DumpOutputStyle::dumpStringTable() {<br>
>>> > -  printHeader(P, "String Table");<br>
>>> > -<br>
>>> > -  if (File.isObj()) {<br>
>>> > -    P.formatLine("Dumping string table is not supported for object<br>
>>> > files");<br>
>>> > -    return Error::success();<br>
>>> > -  }<br>
>>> > -<br>
>>> > +Error DumpOutputStyle::dumpStringTableFromPdb() {<br>
>>> >    AutoIndent Indent(P);<br>
>>> >    auto IS = getPdb().getStringTable();<br>
>>> >    if (!IS) {<br>
>>> > @@ -895,6 +888,36 @@ Error DumpOutputStyle::dumpStringTable()<br>
>>> >    return Error::success();<br>
>>> >  }<br>
>>> ><br>
>>> > +Error DumpOutputStyle::dumpStringTableFromObj() {<br>
>>> > +  iterateModuleSubsections<DebugStringTableSubsectionRef>(<br>
>>> > +      File, PrintScope{P, 4},<br>
>>> > +      [&](uint32_t Modi, const SymbolGroup &Strings,<br>
>>> > +          DebugStringTableSubsectionRef &Strings2) {<br>
>>> > +        BinaryStreamRef StringTableBuffer = Strings2.getBuffer();<br>
>>> > +        BinaryStreamReader Reader(StringTableBuffer);<br>
>>> > +        while (Reader.bytesRemaining() > 0) {<br>
>>> > +          StringRef Str;<br>
>>> > +          uint32_t Offset = Reader.getOffset();<br>
>>> > +          cantFail(Reader.readCString(Str));<br>
>>> > +          if (Str.empty())<br>
>>> > +            continue;<br>
>>> > +<br>
>>> > +          P.formatLine("{0} | {1}", fmt_align(Offset,<br>
>>> > AlignStyle::Right, 4),<br>
>>> > +                       Str);<br>
>>> > +        }<br>
>>> > +      });<br>
>>> > +  return Error::success();<br>
>>> > +}<br>
>>> > +<br>
>>> > +Error DumpOutputStyle::dumpStringTable() {<br>
>>> > +  printHeader(P, "String Table");<br>
>>> > +<br>
>>> > +  if (File.isPdb())<br>
>>> > +    return dumpStringTableFromPdb();<br>
>>> > +<br>
>>> > +  return dumpStringTableFromObj();<br>
>>> > +}<br>
>>> > +<br>
>>> >  static void buildDepSet(LazyRandomTypeCollection &Types,<br>
>>> >                          ArrayRef<TypeIndex> Indices,<br>
>>> >                          std::map<TypeIndex, CVType> &DepSet) {<br>
>>> > @@ -1124,6 +1147,7 @@ Error DumpOutputStyle::dumpModuleSymsFor<br>
>>> >        File, PrintScope{P, 2},<br>
>>> >        [&](uint32_t Modi, const SymbolGroup &Strings,<br>
>>> >            DebugSymbolsSubsectionRef &Symbols) {<br>
>>> > +        Dumper.setSymbolGroup(&Strings);<br>
>>> >          for (auto Symbol : Symbols) {<br>
>>> >            if (auto EC = Visitor.visitSymbolRecord(Symbol)) {<br>
>>> >              SymbolError = llvm::make_unique<Error>(std::move(EC));<br>
>>> > @@ -1165,8 +1189,8 @@ Error DumpOutputStyle::dumpModuleSymsFor<br>
>>> ><br>
>>> >          SymbolVisitorCallbackPipeline Pipeline;<br>
>>> >          SymbolDeserializer Deserializer(nullptr,<br>
>>> > CodeViewContainer::Pdb);<br>
>>> > -        MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes,<br>
>>> > Ids,<br>
>>> > -                                   Types);<br>
>>> > +        MinimalSymbolDumper Dumper(P, opts::dump::DumpSymRecordBytes,<br>
>>> > Strings,<br>
>>> > +                                   Ids, Types);<br>
>>> ><br>
>>> >          Pipeline.addCallbackToPipeline(Deserializer);<br>
>>> >          Pipeline.addCallbackToPipeline(Dumper);<br>
>>> ><br>
>>> > Modified: llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.h<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.h?rev=321883&r1=321882&r2=321883&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.h?rev=321883&r1=321882&r2=321883&view=diff</a><br>
>>> ><br>
>>> > ==============================================================================<br>
>>> > --- llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.h (original)<br>
>>> > +++ llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.h Fri Jan  5 11:12:40<br>
>>> > 2018<br>
>>> > @@ -75,6 +75,8 @@ private:<br>
>>> >    Error dumpSymbolStats();<br>
>>> >    Error dumpUdtStats();<br>
>>> >    Error dumpStringTable();<br>
>>> > +  Error dumpStringTableFromPdb();<br>
>>> > +  Error dumpStringTableFromObj();<br>
>>> >    Error dumpLines();<br>
>>> >    Error dumpInlineeLines();<br>
>>> >    Error dumpXmi();<br>
>>> ><br>
>>> > Modified: llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp?rev=321883&r1=321882&r2=321883&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp?rev=321883&r1=321882&r2=321883&view=diff</a><br>
>>> ><br>
>>> > ==============================================================================<br>
>>> > --- llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp (original)<br>
>>> > +++ llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp Fri Jan  5<br>
>>> > 11:12:40 2018<br>
>>> > @@ -10,6 +10,7 @@<br>
>>> >  #include "MinimalSymbolDumper.h"<br>
>>> ><br>
>>> >  #include "FormatUtil.h"<br>
>>> > +#include "InputFile.h"<br>
>>> >  #include "LinePrinter.h"<br>
>>> ><br>
>>> >  #include "llvm/DebugInfo/CodeView/CVRecord.h"<br>
>>> > @@ -18,6 +19,7 @@<br>
>>> >  #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"<br>
>>> >  #include "llvm/DebugInfo/CodeView/SymbolRecord.h"<br>
>>> >  #include "llvm/DebugInfo/CodeView/TypeRecord.h"<br>
>>> > +#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"<br>
>>> >  #include "llvm/Support/FormatVariadic.h"<br>
>>> ><br>
>>> >  using namespace llvm;<br>
>>> > @@ -450,6 +452,17 @@ Error MinimalSymbolDumper::visitKnownRec<br>
>>> >  Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,<br>
>>> > FileStaticSym &FS) {<br>
>>> >    P.format(" `{0}`", FS.Name);<br>
>>> >    AutoIndent Indent(P, 7);<br>
>>> > +  if (SymGroup) {<br>
>>> > +    Expected<StringRef> FileName =<br>
>>> > +        SymGroup->getNameFromStringTable(FS.ModFilenameOffset);<br>
>>> > +    if (FileName) {<br>
>>> > +      P.formatLine("type = {0}, file name = {1} ({2}), flags = {3}",<br>
>>> > +                   typeIndex(FS.Index), FS.ModFilenameOffset,<br>
>>> > *FileName,<br>
>>> > +                   formatLocalSymFlags(P.getIndentLevel() + 9,<br>
>>> > FS.Flags));<br>
>>> > +    }<br>
>>> > +    return Error::success();<br>
>>> > +  }<br>
>>> > +<br>
>>> >    P.formatLine("type = {0}, file name offset = {1}, flags = {2}",<br>
>>> >                 typeIndex(FS.Index), FS.ModFilenameOffset,<br>
>>> >                 formatLocalSymFlags(P.getIndentLevel() + 9, FS.Flags));<br>
>>> ><br>
>>> > Modified: llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.h<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.h?rev=321883&r1=321882&r2=321883&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.h?rev=321883&r1=321882&r2=321883&view=diff</a><br>
>>> ><br>
>>> > ==============================================================================<br>
>>> > --- llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.h (original)<br>
>>> > +++ llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.h Fri Jan  5<br>
>>> > 11:12:40 2018<br>
>>> > @@ -19,6 +19,7 @@ class LazyRandomTypeCollection;<br>
>>> ><br>
>>> >  namespace pdb {<br>
>>> >  class LinePrinter;<br>
>>> > +class SymbolGroup;<br>
>>> ><br>
>>> >  class MinimalSymbolDumper : public codeview::SymbolVisitorCallbacks {<br>
>>> >  public:<br>
>>> > @@ -26,11 +27,19 @@ public:<br>
>>> >                        codeview::LazyRandomTypeCollection &Ids,<br>
>>> >                        codeview::LazyRandomTypeCollection &Types)<br>
>>> >        : P(P), RecordBytes(RecordBytes), Ids(Ids), Types(Types) {}<br>
>>> > +  MinimalSymbolDumper(LinePrinter &P, bool RecordBytes,<br>
>>> > +                      const SymbolGroup &SymGroup,<br>
>>> > +                      codeview::LazyRandomTypeCollection &Ids,<br>
>>> > +                      codeview::LazyRandomTypeCollection &Types)<br>
>>> > +      : P(P), RecordBytes(RecordBytes), SymGroup(&SymGroup), Ids(Ids),<br>
>>> > +        Types(Types) {}<br>
>>> ><br>
>>> >    Error visitSymbolBegin(codeview::CVSymbol &Record) override;<br>
>>> >    Error visitSymbolBegin(codeview::CVSymbol &Record, uint32_t Offset)<br>
>>> > override;<br>
>>> >    Error visitSymbolEnd(codeview::CVSymbol &Record) override;<br>
>>> ><br>
>>> > +  void setSymbolGroup(const SymbolGroup *Group) { SymGroup = Group; }<br>
>>> > +<br>
>>> >  #define SYMBOL_RECORD(EnumName, EnumVal, Name)<br>
>>> > \<br>
>>> >    virtual Error visitKnownRecord(codeview::CVSymbol &CVR,<br>
>>> > \<br>
>>> >                                   codeview::Name &Record) override;<br>
>>> > @@ -45,6 +54,7 @@ private:<br>
>>> ><br>
>>> >    LinePrinter &P;<br>
>>> >    bool RecordBytes;<br>
>>> > +  const SymbolGroup *SymGroup = nullptr;<br>
>>> >    codeview::LazyRandomTypeCollection &Ids;<br>
>>> >    codeview::LazyRandomTypeCollection &Types;<br>
>>> >  };<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></blockquote></div>