<div dir="ltr">Ping</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Feb 28, 2017 at 8:08 AM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Looks like this change removed the need for the 'setForceChildren' API (by providing an alternative path for producing DWARF DIEs with present-yet-empty children lists) - could you remove it?</div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Fri, Jan 20, 2017 at 11:14 AM Chris Bieneman via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: cbieneman<br class="gmail_msg">
Date: Fri Jan 20 13:03:14 2017<br class="gmail_msg">
New Revision: 292634<br class="gmail_msg">
<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=292634&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=292634&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
[DWARF] [ObjectYAML] Adding APIs for unittesting<br class="gmail_msg">
<br class="gmail_msg">
Summary: This patch adds some new APIs to enable using the YAML DWARF representation in unit tests. The most basic new API is DWARFYAML::EmitDebugSections which converts a YAML string into a series of owned MemoryBuffer objects stored in a StringMap. The string map can then be used to construct a DWARFContext for parsing in place of an ObjectFile.<br class="gmail_msg">
<br class="gmail_msg">
Reviewers: dblaikie, clayborg<br class="gmail_msg">
<br class="gmail_msg">
Subscribers: mgorny, fhahn, jgosnell, aprantl, llvm-commits<br class="gmail_msg">
<br class="gmail_msg">
Differential Revision: <a href="https://reviews.llvm.org/D28828" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D28828</a><br class="gmail_msg">
<br class="gmail_msg">
Modified:<br class="gmail_msg">
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br class="gmail_msg">
llvm/trunk/include/llvm/ObjectYAML/DWARFEmitter.h<br class="gmail_msg">
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br class="gmail_msg">
llvm/trunk/lib/ObjectYAML/DWARFEmitter.cpp<br class="gmail_msg">
llvm/trunk/unittests/DebugInfo/DWARF/CMakeLists.txt<br class="gmail_msg">
llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=292634&r1=292633&r2=292634&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=292634&r1=292633&r2=292634&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)<br class="gmail_msg">
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Fri Jan 20 13:03:14 2017<br class="gmail_msg">
@@ -15,6 +15,7 @@<br class="gmail_msg">
#include "llvm/ADT/MapVector.h"<br class="gmail_msg">
#include "llvm/ADT/SmallString.h"<br class="gmail_msg">
#include "llvm/ADT/SmallVector.h"<br class="gmail_msg">
+#include "llvm/ADT/StringMap.h"<br class="gmail_msg">
#include "llvm/ADT/StringRef.h"<br class="gmail_msg">
#include "llvm/DebugInfo/DIContext.h"<br class="gmail_msg">
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"<br class="gmail_msg">
@@ -293,10 +294,16 @@ class DWARFContextInMemory : public DWAR<br class="gmail_msg">
<br class="gmail_msg">
SmallVector<SmallString<32>, 4> UncompressedSections;<br class="gmail_msg">
<br class="gmail_msg">
+ StringRef *MapSectionToMember(StringRef Name);<br class="gmail_msg">
+<br class="gmail_msg">
public:<br class="gmail_msg">
DWARFContextInMemory(const object::ObjectFile &Obj,<br class="gmail_msg">
const LoadedObjectInfo *L = nullptr);<br class="gmail_msg">
<br class="gmail_msg">
+ DWARFContextInMemory(const StringMap<std::unique_ptr<MemoryBuffer>> &Sections,<br class="gmail_msg">
+ uint8_t AddrSize,<br class="gmail_msg">
+ bool isLittleEndian = sys::IsLittleEndianHost);<br class="gmail_msg">
+<br class="gmail_msg">
bool isLittleEndian() const override { return IsLittleEndian; }<br class="gmail_msg">
uint8_t getAddressSize() const override { return AddressSize; }<br class="gmail_msg">
const DWARFSection &getInfoSection() override { return InfoSection; }<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/include/llvm/ObjectYAML/DWARFEmitter.h<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/DWARFEmitter.h?rev=292634&r1=292633&r2=292634&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/DWARFEmitter.h?rev=292634&r1=292633&r2=292634&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/include/llvm/ObjectYAML/DWARFEmitter.h (original)<br class="gmail_msg">
+++ llvm/trunk/include/llvm/ObjectYAML/DWARFEmitter.h Fri Jan 20 13:03:14 2017<br class="gmail_msg">
@@ -13,6 +13,14 @@<br class="gmail_msg">
#ifndef LLVM_OBJECTYAML_DWARFEMITTER_H<br class="gmail_msg">
#define LLVM_OBJECTYAML_DWARFEMITTER_H<br class="gmail_msg">
<br class="gmail_msg">
+#include "llvm/ADT/StringMap.h"<br class="gmail_msg">
+#include "llvm/ADT/StringRef.h"<br class="gmail_msg">
+#include "llvm/Support/Error.h"<br class="gmail_msg">
+#include "llvm/Support/Host.h"<br class="gmail_msg">
+#include "llvm/Support/MemoryBuffer.h"<br class="gmail_msg">
+#include <memory><br class="gmail_msg">
+#include <vector><br class="gmail_msg">
+<br class="gmail_msg">
namespace llvm {<br class="gmail_msg">
class raw_ostream;<br class="gmail_msg">
<br class="gmail_msg">
@@ -30,6 +38,10 @@ void EmitPubSection(llvm::raw_ostream &O<br class="gmail_msg">
void EmitDebugInfo(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);<br class="gmail_msg">
void EmitDebugLine(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);<br class="gmail_msg">
<br class="gmail_msg">
+Expected<StringMap<std::unique_ptr<MemoryBuffer>>><br class="gmail_msg">
+EmitDebugSections(StringRef YAMLString,<br class="gmail_msg">
+ bool IsLittleEndian = sys::IsLittleEndianHost);<br class="gmail_msg">
+<br class="gmail_msg">
} // namespace DWARFYAML<br class="gmail_msg">
} // namespace llvm<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=292634&r1=292633&r2=292634&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=292634&r1=292633&r2=292634&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Fri Jan 20 13:03:14 2017<br class="gmail_msg">
@@ -617,40 +617,7 @@ DWARFContextInMemory::DWARFContextInMemo<br class="gmail_msg">
name = name.substr(<br class="gmail_msg">
name.find_first_not_of("._z")); // Skip ".", "z" and "_" prefixes.<br class="gmail_msg">
<br class="gmail_msg">
- StringRef *SectionData =<br class="gmail_msg">
- StringSwitch<StringRef *>(name)<br class="gmail_msg">
- .Case("debug_info", &InfoSection.Data)<br class="gmail_msg">
- .Case("debug_abbrev", &AbbrevSection)<br class="gmail_msg">
- .Case("debug_loc", &LocSection.Data)<br class="gmail_msg">
- .Case("debug_line", &LineSection.Data)<br class="gmail_msg">
- .Case("debug_aranges", &ARangeSection)<br class="gmail_msg">
- .Case("debug_frame", &DebugFrameSection)<br class="gmail_msg">
- .Case("eh_frame", &EHFrameSection)<br class="gmail_msg">
- .Case("debug_str", &StringSection)<br class="gmail_msg">
- .Case("debug_ranges", &RangeSection)<br class="gmail_msg">
- .Case("debug_macinfo", &MacinfoSection)<br class="gmail_msg">
- .Case("debug_pubnames", &PubNamesSection)<br class="gmail_msg">
- .Case("debug_pubtypes", &PubTypesSection)<br class="gmail_msg">
- .Case("debug_gnu_pubnames", &GnuPubNamesSection)<br class="gmail_msg">
- .Case("debug_gnu_pubtypes", &GnuPubTypesSection)<br class="gmail_msg">
- .Case("debug_info.dwo", &InfoDWOSection.Data)<br class="gmail_msg">
- .Case("debug_abbrev.dwo", &AbbrevDWOSection)<br class="gmail_msg">
- .Case("debug_loc.dwo", &LocDWOSection.Data)<br class="gmail_msg">
- .Case("debug_line.dwo", &LineDWOSection.Data)<br class="gmail_msg">
- .Case("debug_str.dwo", &StringDWOSection)<br class="gmail_msg">
- .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)<br class="gmail_msg">
- .Case("debug_addr", &AddrSection)<br class="gmail_msg">
- .Case("apple_names", &AppleNamesSection.Data)<br class="gmail_msg">
- .Case("apple_types", &AppleTypesSection.Data)<br class="gmail_msg">
- .Case("apple_namespaces", &AppleNamespacesSection.Data)<br class="gmail_msg">
- .Case("apple_namespac", &AppleNamespacesSection.Data)<br class="gmail_msg">
- .Case("apple_objc", &AppleObjCSection.Data)<br class="gmail_msg">
- .Case("debug_cu_index", &CUIndexSection)<br class="gmail_msg">
- .Case("debug_tu_index", &TUIndexSection)<br class="gmail_msg">
- .Case("gdb_index", &GdbIndexSection)<br class="gmail_msg">
- // Any more debug info sections go here.<br class="gmail_msg">
- .Default(nullptr);<br class="gmail_msg">
- if (SectionData) {<br class="gmail_msg">
+ if (StringRef *SectionData = MapSectionToMember(name)) {<br class="gmail_msg">
*SectionData = data;<br class="gmail_msg">
if (name == "debug_ranges") {<br class="gmail_msg">
// FIXME: Use the other dwo range section when we emit it.<br class="gmail_msg">
@@ -811,4 +778,49 @@ DWARFContextInMemory::DWARFContextInMemo<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+DWARFContextInMemory::DWARFContextInMemory(<br class="gmail_msg">
+ const StringMap<std::unique_ptr<MemoryBuffer>> &Sections, uint8_t AddrSize,<br class="gmail_msg">
+ bool isLittleEndian)<br class="gmail_msg">
+ : IsLittleEndian(isLittleEndian), AddressSize(AddrSize) {<br class="gmail_msg">
+ for (const auto &SecIt : Sections) {<br class="gmail_msg">
+ if (StringRef *SectionData = MapSectionToMember(SecIt.first()))<br class="gmail_msg">
+ *SectionData = SecIt.second->getBuffer();<br class="gmail_msg">
+ }<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+StringRef *DWARFContextInMemory::MapSectionToMember(StringRef Name) {<br class="gmail_msg">
+ return StringSwitch<StringRef *>(Name)<br class="gmail_msg">
+ .Case("debug_info", &InfoSection.Data)<br class="gmail_msg">
+ .Case("debug_abbrev", &AbbrevSection)<br class="gmail_msg">
+ .Case("debug_loc", &LocSection.Data)<br class="gmail_msg">
+ .Case("debug_line", &LineSection.Data)<br class="gmail_msg">
+ .Case("debug_aranges", &ARangeSection)<br class="gmail_msg">
+ .Case("debug_frame", &DebugFrameSection)<br class="gmail_msg">
+ .Case("eh_frame", &EHFrameSection)<br class="gmail_msg">
+ .Case("debug_str", &StringSection)<br class="gmail_msg">
+ .Case("debug_ranges", &RangeSection)<br class="gmail_msg">
+ .Case("debug_macinfo", &MacinfoSection)<br class="gmail_msg">
+ .Case("debug_pubnames", &PubNamesSection)<br class="gmail_msg">
+ .Case("debug_pubtypes", &PubTypesSection)<br class="gmail_msg">
+ .Case("debug_gnu_pubnames", &GnuPubNamesSection)<br class="gmail_msg">
+ .Case("debug_gnu_pubtypes", &GnuPubTypesSection)<br class="gmail_msg">
+ .Case("debug_info.dwo", &InfoDWOSection.Data)<br class="gmail_msg">
+ .Case("debug_abbrev.dwo", &AbbrevDWOSection)<br class="gmail_msg">
+ .Case("debug_loc.dwo", &LocDWOSection.Data)<br class="gmail_msg">
+ .Case("debug_line.dwo", &LineDWOSection.Data)<br class="gmail_msg">
+ .Case("debug_str.dwo", &StringDWOSection)<br class="gmail_msg">
+ .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)<br class="gmail_msg">
+ .Case("debug_addr", &AddrSection)<br class="gmail_msg">
+ .Case("apple_names", &AppleNamesSection.Data)<br class="gmail_msg">
+ .Case("apple_types", &AppleTypesSection.Data)<br class="gmail_msg">
+ .Case("apple_namespaces", &AppleNamespacesSection.Data)<br class="gmail_msg">
+ .Case("apple_namespac", &AppleNamespacesSection.Data)<br class="gmail_msg">
+ .Case("apple_objc", &AppleObjCSection.Data)<br class="gmail_msg">
+ .Case("debug_cu_index", &CUIndexSection)<br class="gmail_msg">
+ .Case("debug_tu_index", &TUIndexSection)<br class="gmail_msg">
+ .Case("gdb_index", &GdbIndexSection)<br class="gmail_msg">
+ // Any more debug info sections go here.<br class="gmail_msg">
+ .Default(nullptr);<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
void DWARFContextInMemory::anchor() { }<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/ObjectYAML/DWARFEmitter.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/DWARFEmitter.cpp?rev=292634&r1=292633&r2=292634&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/DWARFEmitter.cpp?rev=292634&r1=292633&r2=292634&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/ObjectYAML/DWARFEmitter.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/ObjectYAML/DWARFEmitter.cpp Fri Jan 20 13:03:14 2017<br class="gmail_msg">
@@ -330,3 +330,42 @@ void DWARFYAML::EmitDebugLine(raw_ostrea<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
+<br class="gmail_msg">
+typedef void (*EmitFuncType)(raw_ostream &, const DWARFYAML::Data &);<br class="gmail_msg">
+<br class="gmail_msg">
+void EmitDebugSectionImpl(<br class="gmail_msg">
+ const DWARFYAML::Data &DI, EmitFuncType EmitFunc, StringRef Sec,<br class="gmail_msg">
+ StringMap<std::unique_ptr<MemoryBuffer>> &OutputBuffers) {<br class="gmail_msg">
+ std::string Data;<br class="gmail_msg">
+ raw_string_ostream DebugInfoStream(Data);<br class="gmail_msg">
+ EmitFunc(DebugInfoStream, DI);<br class="gmail_msg">
+ DebugInfoStream.flush();<br class="gmail_msg">
+ if (!Data.empty())<br class="gmail_msg">
+ OutputBuffers[Sec] = MemoryBuffer::getMemBufferCopy(Data);<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+Expected<StringMap<std::unique_ptr<MemoryBuffer>>><br class="gmail_msg">
+DWARFYAML::EmitDebugSections(StringRef YAMLString,<br class="gmail_msg">
+ bool IsLittleEndian) {<br class="gmail_msg">
+ StringMap<std::unique_ptr<MemoryBuffer>> DebugSections;<br class="gmail_msg">
+<br class="gmail_msg">
+ yaml::Input YIn(YAMLString);<br class="gmail_msg">
+<br class="gmail_msg">
+ DWARFYAML::Data DI;<br class="gmail_msg">
+ DI.IsLittleEndian = IsLittleEndian;<br class="gmail_msg">
+ YIn >> DI;<br class="gmail_msg">
+ if (YIn.error())<br class="gmail_msg">
+ return errorCodeToError(YIn.error());<br class="gmail_msg">
+<br class="gmail_msg">
+ EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugInfo, "debug_info",<br class="gmail_msg">
+ DebugSections);<br class="gmail_msg">
+ EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugLine, "debug_line",<br class="gmail_msg">
+ DebugSections);<br class="gmail_msg">
+ EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugStr, "debug_str",<br class="gmail_msg">
+ DebugSections);<br class="gmail_msg">
+ EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugAbbrev, "debug_abbrev",<br class="gmail_msg">
+ DebugSections);<br class="gmail_msg">
+ EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugAranges, "debug_aranges",<br class="gmail_msg">
+ DebugSections);<br class="gmail_msg">
+ return std::move(DebugSections);<br class="gmail_msg">
+}<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/unittests/DebugInfo/DWARF/CMakeLists.txt<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/CMakeLists.txt?rev=292634&r1=292633&r2=292634&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/CMakeLists.txt?rev=292634&r1=292633&r2=292634&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/unittests/DebugInfo/DWARF/CMakeLists.txt (original)<br class="gmail_msg">
+++ llvm/trunk/unittests/DebugInfo/DWARF/CMakeLists.txt Fri Jan 20 13:03:14 2017<br class="gmail_msg">
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS<br class="gmail_msg">
DebugInfoDWARF<br class="gmail_msg">
MC<br class="gmail_msg">
Object<br class="gmail_msg">
+ ObjectYAML<br class="gmail_msg">
Support<br class="gmail_msg">
)<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp?rev=292634&r1=292633&r2=292634&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp?rev=292634&r1=292633&r2=292634&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp Fri Jan 20 13:03:14 2017<br class="gmail_msg">
@@ -13,6 +13,8 @@<br class="gmail_msg">
#include "llvm/DebugInfo/DWARF/DWARFDie.h"<br class="gmail_msg">
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"<br class="gmail_msg">
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"<br class="gmail_msg">
+#include "llvm/ObjectYAML/DWARFYAML.h"<br class="gmail_msg">
+#include "llvm/ObjectYAML/DWARFEmitter.h"<br class="gmail_msg">
#include "llvm/Support/Dwarf.h"<br class="gmail_msg">
#include "llvm/Support/Host.h"<br class="gmail_msg">
#include "llvm/Support/TargetSelect.h"<br class="gmail_msg">
@@ -1157,41 +1159,35 @@ TEST(DWARFDebugInfo, TestChildIteratorsO<br class="gmail_msg">
EXPECT_EQ(begin, end);<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
-<br class="gmail_msg">
TEST(DWARFDebugInfo, TestEmptyChildren) {<br class="gmail_msg">
- // Test a DIE that says it has children in the abbreviation, but actually<br class="gmail_msg">
- // doesn't have any attributes, will not return anything during iteration.<br class="gmail_msg">
- // We do this by making sure the begin and end iterators are equal.<br class="gmail_msg">
- uint16_t Version = 4;<br class="gmail_msg">
-<br class="gmail_msg">
- const uint8_t AddrSize = sizeof(void *);<br class="gmail_msg">
- initLLVMIfNeeded();<br class="gmail_msg">
- Triple Triple = getHostTripleForAddrSize(AddrSize);<br class="gmail_msg">
- auto ExpectedDG = dwarfgen::Generator::create(Triple, Version);<br class="gmail_msg">
- if (HandleExpectedError(ExpectedDG))<br class="gmail_msg">
- return;<br class="gmail_msg">
- dwarfgen::Generator *DG = ExpectedDG.get().get();<br class="gmail_msg">
- dwarfgen::CompileUnit &CU = DG->addCompileUnit();<br class="gmail_msg">
-<br class="gmail_msg">
- // Scope to allow us to re-use the same DIE names<br class="gmail_msg">
- {<br class="gmail_msg">
- // Create a compile unit DIE that has an abbreviation that says it has<br class="gmail_msg">
- // children, but doesn't have any actual attributes. This helps us test<br class="gmail_msg">
- // a DIE that has only one child: a NULL DIE.<br class="gmail_msg">
- auto CUDie = CU.getUnitDIE();<br class="gmail_msg">
- CUDie.setForceChildren();<br class="gmail_msg">
- }<br class="gmail_msg">
-<br class="gmail_msg">
- MemoryBufferRef FileBuffer(DG->generate(), "dwarf");<br class="gmail_msg">
- auto Obj = object::ObjectFile::createObjectFile(FileBuffer);<br class="gmail_msg">
- EXPECT_TRUE((bool)Obj);<br class="gmail_msg">
- DWARFContextInMemory DwarfContext(*Obj.get());<br class="gmail_msg">
-<br class="gmail_msg">
+ const char *yamldata = "debug_abbrev:\n"<br class="gmail_msg">
+ " - Code: 0x00000001\n"<br class="gmail_msg">
+ " Tag: DW_TAG_compile_unit\n"<br class="gmail_msg">
+ " Children: DW_CHILDREN_yes\n"<br class="gmail_msg">
+ " Attributes:\n"<br class="gmail_msg">
+ "debug_info:\n"<br class="gmail_msg">
+ " - Length: 9\n"<br class="gmail_msg">
+ " Version: 4\n"<br class="gmail_msg">
+ " AbbrOffset: 0\n"<br class="gmail_msg">
+ " AddrSize: 8\n"<br class="gmail_msg">
+ " Entries:\n"<br class="gmail_msg">
+ " - AbbrCode: 0x00000001\n"<br class="gmail_msg">
+ " Values:\n"<br class="gmail_msg">
+ " - AbbrCode: 0x00000000\n"<br class="gmail_msg">
+ " Values:\n";<br class="gmail_msg">
+<br class="gmail_msg">
+ auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));<br class="gmail_msg">
+ EXPECT_TRUE((bool)ErrOrSections);<br class="gmail_msg">
+<br class="gmail_msg">
+ auto &DebugSections = *ErrOrSections;<br class="gmail_msg">
+<br class="gmail_msg">
+ DWARFContextInMemory DwarfContext(DebugSections, 8);<br class="gmail_msg">
+<br class="gmail_msg">
// Verify the number of compile units is correct.<br class="gmail_msg">
uint32_t NumCUs = DwarfContext.getNumCompileUnits();<br class="gmail_msg">
EXPECT_EQ(NumCUs, 1u);<br class="gmail_msg">
DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);<br class="gmail_msg">
-<br class="gmail_msg">
+<br class="gmail_msg">
// Get the compile unit DIE is valid.<br class="gmail_msg">
auto CUDie = U->getUnitDIE(false);<br class="gmail_msg">
EXPECT_TRUE(CUDie.isValid());<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
llvm-commits mailing list<br class="gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="gmail_msg">
</blockquote></div></blockquote></div>