--- /dev/null
+//===--- DWARFEmitter.h - -------------------------------------------*- C++
+//-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// \brief Common declarations for yaml2obj
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_OBJECTYAML_DWARFEMITTER_H
+#define LLVM_OBJECTYAML_DWARFEMITTER_H
+
+namespace llvm {
+class raw_ostream;
+
+namespace DWARFYAML {
+struct Data;
+struct PubSection;
+
+void EmitDebugAbbrev(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
+void EmitDebugStr(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
+
+void EmitDebugAranges(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
+void EmitPubSection(llvm::raw_ostream &OS,
+ const llvm::DWARFYAML::PubSection &Sect,
+ bool IsLittleEndian);
+void EmitDebugInfo(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
+void EmitDebugLine(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
+
+} // namespace DWARFYAML
+} // namespace llvm
+
+#endif
add_llvm_library(LLVMObjectYAML
- YAML.cpp
COFFYAML.cpp
+ DWARFEmitter.cpp
+ DWARFYAML.cpp
ELFYAML.cpp
MachOYAML.cpp
ObjectYAML.cpp
- DWARFYAML.cpp
+ YAML.cpp
)
-//===- yaml2dwarf - Convert YAML to DWARF binary data ---------------------===//
+//===- DWARFEmitter - Convert YAML to DWARF binary data -------------------===//
//
// The LLVM Compiler Infrastructure
//
//===----------------------------------------------------------------------===//
///
/// \file
-/// \brief The DWARF component of yaml2obj.
+/// \brief The DWARF component of yaml2obj. Provided as library code for tests.
///
//===----------------------------------------------------------------------===//
+#include "llvm/ObjectYAML/DWARFEmitter.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/LEB128.h"
OS.write(reinterpret_cast<char *>(FillData.data()), Size);
}
-void yaml2debug_str(raw_ostream &OS, const DWARFYAML::Data &DI) {
+void DWARFYAML::EmitDebugStr(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (auto Str : DI.DebugStrings) {
OS.write(Str.data(), Str.size());
OS.write('\0');
}
}
-void yaml2debug_abbrev(raw_ostream &OS, const DWARFYAML::Data &DI) {
+void DWARFYAML::EmitDebugAbbrev(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (auto AbbrevDecl : DI.AbbrevDecls) {
encodeULEB128(AbbrevDecl.Code, OS);
encodeULEB128(AbbrevDecl.Tag, OS);
}
}
-void yaml2debug_aranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
+void DWARFYAML::EmitDebugAranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (auto Range : DI.ARanges) {
auto HeaderStart = OS.tell();
writeInteger((uint32_t)Range.Length, OS, DI.IsLittleEndian);
}
}
-void yaml2pubsection(raw_ostream &OS, const DWARFYAML::PubSection &Sect,
- bool IsLittleEndian) {
+void DWARFYAML::EmitPubSection(raw_ostream &OS,
+ const DWARFYAML::PubSection &Sect,
+ bool IsLittleEndian) {
writeInteger((uint32_t)Sect.Length, OS, IsLittleEndian);
writeInteger((uint16_t)Sect.Version, OS, IsLittleEndian);
writeInteger((uint32_t)Sect.UnitOffset, OS, IsLittleEndian);
}
}
-void yaml2debug_info(raw_ostream &OS, const DWARFYAML::Data &DI) {
+void DWARFYAML::EmitDebugInfo(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (auto CU : DI.CompileUnits) {
writeInteger((uint32_t)CU.Length, OS, DI.IsLittleEndian);
}
}
-void yaml2FileEntry(raw_ostream &OS, const DWARFYAML::File &File) {
+void EmitFileEntry(raw_ostream &OS, const DWARFYAML::File &File) {
OS.write(File.Name.data(), File.Name.size());
OS.write('\0');
encodeULEB128(File.DirIdx, OS);
encodeULEB128(File.Length, OS);
}
-void yaml2debug_line(raw_ostream &OS, const DWARFYAML::Data &DI) {
+void DWARFYAML::EmitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (const auto LineTable : DI.DebugLines) {
writeInteger((uint32_t)LineTable.TotalLength, OS, DI.IsLittleEndian);
uint64_t SizeOfPrologueLength = 4;
OS.write('\0');
for (auto File : LineTable.Files)
- yaml2FileEntry(OS, File);
+ EmitFileEntry(OS, File);
OS.write('\0');
for (auto Op : LineTable.Opcodes) {
DI.IsLittleEndian);
break;
case dwarf::DW_LNE_define_file:
- yaml2FileEntry(OS, Op.FileEntry);
+ EmitFileEntry(OS, Op.FileEntry);
break;
case dwarf::DW_LNE_end_sequence:
break;
add_llvm_tool(yaml2obj
yaml2obj.cpp
yaml2coff.cpp
- yaml2dwarf.cpp
yaml2elf.cpp
yaml2macho.cpp
)
#include "yaml2obj.h"
#include "llvm/ObjectYAML/ObjectYAML.h"
+#include "llvm/ObjectYAML/DWARFEmitter.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MachO.h"
"Wrote too much data somewhere, section offsets don't line up.");
if (0 == strncmp(&Sec.segname[0], "__DWARF", 16)) {
if (0 == strncmp(&Sec.sectname[0], "__debug_str", 16)) {
- yaml2debug_str(OS, Obj.DWARF);
+ DWARFYAML::EmitDebugStr(OS, Obj.DWARF);
} else if (0 == strncmp(&Sec.sectname[0], "__debug_abbrev", 16)) {
- yaml2debug_abbrev(OS, Obj.DWARF);
+ DWARFYAML::EmitDebugAbbrev(OS, Obj.DWARF);
} else if (0 == strncmp(&Sec.sectname[0], "__debug_aranges", 16)) {
- yaml2debug_aranges(OS, Obj.DWARF);
+ DWARFYAML::EmitDebugAranges(OS, Obj.DWARF);
} else if (0 == strncmp(&Sec.sectname[0], "__debug_pubnames", 16)) {
- yaml2pubsection(OS, Obj.DWARF.PubNames, Obj.IsLittleEndian);
+ DWARFYAML::EmitPubSection(OS, Obj.DWARF.PubNames,
+ Obj.IsLittleEndian);
} else if (0 == strncmp(&Sec.sectname[0], "__debug_pubtypes", 16)) {
- yaml2pubsection(OS, Obj.DWARF.PubTypes, Obj.IsLittleEndian);
+ DWARFYAML::EmitPubSection(OS, Obj.DWARF.PubTypes,
+ Obj.IsLittleEndian);
} else if (0 == strncmp(&Sec.sectname[0], "__debug_info", 16)) {
- yaml2debug_info(OS, Obj.DWARF);
+ DWARFYAML::EmitDebugInfo(OS, Obj.DWARF);
} else if (0 == strncmp(&Sec.sectname[0], "__debug_line", 16)) {
- yaml2debug_line(OS, Obj.DWARF);
+ DWARFYAML::EmitDebugLine(OS, Obj.DWARF);
}
} else {
// Fills section data with 0xDEADBEEF
struct Object;
}
-namespace DWARFYAML {
-struct Data;
-struct PubSection;
-}
-
namespace yaml {
class Input;
struct YamlObjectFile;
int yaml2elf(llvm::ELFYAML::Object &Doc, llvm::raw_ostream &Out);
int yaml2macho(llvm::yaml::YamlObjectFile &Doc, llvm::raw_ostream &Out);
-void yaml2debug_abbrev(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
-void yaml2debug_str(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
-
-void yaml2debug_aranges(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
-void yaml2pubsection(llvm::raw_ostream &OS,
- const llvm::DWARFYAML::PubSection &Sect,
- bool IsLittleEndian);
-void yaml2debug_info(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
-void yaml2debug_line(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
-
#endif