summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Riss <friss@apple.com>2015-01-28 18:27:01 +0000
committerFrederic Riss <friss@apple.com>2015-01-28 18:27:01 +0000
commitd34551833fb1b033b97b155f5d10e20a7ef7c5cf (patch)
tree64cd962442b56dd5e10194e2ccb501d5709e1c6d
parent286f124da5e2ddf7aa1c2303093343b645c213b9 (diff)
downloadbcm5719-llvm-d34551833fb1b033b97b155f5d10e20a7ef7c5cf.tar.gz
bcm5719-llvm-d34551833fb1b033b97b155f5d10e20a7ef7c5cf.zip
[dsymutil] Add DwarfLinker class.
It's an empty shell for now. It's main method just opens the debug map objects and parses their Dwarf info. Test that we at least do that correctly. llvm-svn: 227337
-rw-r--r--llvm/test/tools/dsymutil/basic-linking.test54
-rw-r--r--llvm/tools/dsymutil/CMakeLists.txt1
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp58
-rw-r--r--llvm/tools/dsymutil/LLVMBuild.txt2
-rw-r--r--llvm/tools/dsymutil/Makefile2
5 files changed, 113 insertions, 4 deletions
diff --git a/llvm/test/tools/dsymutil/basic-linking.test b/llvm/test/tools/dsymutil/basic-linking.test
new file mode 100644
index 00000000000..adbd595c457
--- /dev/null
+++ b/llvm/test/tools/dsymutil/basic-linking.test
@@ -0,0 +1,54 @@
+RUN: llvm-dsymutil -v -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s
+RUN: llvm-dsymutil -v -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
+RUN: llvm-dsymutil -v -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE
+
+This test check the basic Dwarf linking process through the debug dumps.
+
+CHECK: DEBUG MAP OBJECT: {{.*}}basic1.macho.x86_64.o
+CHECK: Input compilation unit:
+CHECK-NEXT: TAG_compile_unit
+CHECK-NOT: TAG
+CHECK: AT_name {{.*}}basic1.c
+CHECK: DEBUG MAP OBJECT: {{.*}}basic2.macho.x86_64.o
+CHECK: Input compilation unit:
+CHECK-NEXT: TAG_compile_unit
+CHECK-NOT: TAG
+CHECK: AT_name {{.*}}basic2.c
+CHECK: DEBUG MAP OBJECT: {{.*}}basic3.macho.x86_64.o
+CHECK: Input compilation unit:
+CHECK-NEXT: TAG_compile_unit
+CHECK-NOT: TAG
+CHECK: AT_name {{.*}}basic3.c
+
+
+CHECK-LTO: DEBUG MAP OBJECT: {{.*}}basic-lto.macho.x86_64.o
+CHECK-LTO: Input compilation unit:
+CHECK-LTO-NEXT: TAG_compile_unit
+CHECK-LTO-NOT: TAG
+CHECK-LTO: AT_name {{.*}}basic1.c
+CHECK-LTO: Input compilation unit:
+CHECK-LTO-NEXT: TAG_compile_unit
+CHECK-LTO-NOT: TAG
+CHECK-LTO: AT_name {{.*}}basic2.c
+CHECK-LTO: Input compilation unit:
+CHECK-LTO-NEXT: TAG_compile_unit
+CHECK-LTO-NOT: TAG
+CHECK-LTO: AT_name {{.*}}basic3.c
+
+
+CHECK-ARCHIVE: DEBUG MAP OBJECT: {{.*}}basic1.macho.x86_64.o
+CHECK-ARCHIVE: Input compilation unit:
+CHECK-ARCHIVE-NEXT: TAG_compile_unit
+CHECK-ARCHIVE-NOT: TAG
+CHECK-ARCHIVE: AT_name {{.*}}basic1.c
+CHECK-ARCHIVE: DEBUG MAP OBJECT: {{.*}}libbasic.a(basic2.macho.x86_64.o)
+CHECK-ARCHIVE: Input compilation unit:
+CHECK-ARCHIVE-NEXT: TAG_compile_unit
+CHECK-ARCHIVE-NOT: TAG
+CHECK-ARCHIVE: AT_name {{.*}}basic2.c
+CHECK-ARCHIVE: DEBUG MAP OBJECT: {{.*}}libbasic.a(basic3.macho.x86_64.o)
+CHECK-ARCHIVE: Input compilation unit:
+CHECK-ARCHIVE-NEXT: TAG_compile_unit
+CHECK-ARCHIVE-NOT: TAG
+CHECK-ARCHIVE: AT_name {{.*}}basic3.c
+
diff --git a/llvm/tools/dsymutil/CMakeLists.txt b/llvm/tools/dsymutil/CMakeLists.txt
index bfe7c706391..c397e3ed36c 100644
--- a/llvm/tools/dsymutil/CMakeLists.txt
+++ b/llvm/tools/dsymutil/CMakeLists.txt
@@ -1,4 +1,5 @@
set(LLVM_LINK_COMPONENTS
+ DebugInfo
Object
Support
)
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index ad471055bd9..4af8efb03af 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -7,14 +7,68 @@
//
//===----------------------------------------------------------------------===//
#include "DebugMap.h"
+
+#include "BinaryHolder.h"
+#include "DebugMap.h"
#include "dsymutil.h"
+#include "llvm/DebugInfo/DWARFContext.h"
+#include "llvm/DebugInfo/DWARFDebugInfoEntry.h"
+#include <string>
namespace llvm {
namespace dsymutil {
-bool linkDwarf(StringRef OutputFilename, const DebugMap &DM, bool Verbose) {
- // Do nothing for now.
+namespace {
+
+/// \brief The core of the Dwarf linking logic.
+class DwarfLinker {
+public:
+ DwarfLinker(StringRef OutputFilename, bool Verbose)
+ : OutputFilename(OutputFilename), Verbose(Verbose), BinHolder(Verbose) {}
+
+ /// \brief Link the contents of the DebugMap.
+ bool link(const DebugMap &);
+
+private:
+ std::string OutputFilename;
+ bool Verbose;
+ BinaryHolder BinHolder;
+};
+
+bool DwarfLinker::link(const DebugMap &Map) {
+
+ if (Map.begin() == Map.end()) {
+ errs() << "Empty debug map.\n";
+ return false;
+ }
+
+ for (const auto &Obj : Map.objects()) {
+ if (Verbose)
+ outs() << "DEBUG MAP OBJECT: " << Obj->getObjectFilename() << "\n";
+ auto ErrOrObj = BinHolder.GetObjectFile(Obj->getObjectFilename());
+ if (std::error_code EC = ErrOrObj.getError()) {
+ errs() << Obj->getObjectFilename() << ": " << EC.message() << "\n";
+ continue;
+ }
+
+ DWARFContextInMemory DwarfContext(*ErrOrObj);
+
+ for (const auto &CU : DwarfContext.compile_units()) {
+ auto *CUDie = CU->getCompileUnitDIE(false);
+ if (Verbose) {
+ outs() << "Input compilation unit:";
+ CUDie->dump(outs(), CU.get(), 0);
+ }
+ }
+ }
+
return true;
}
}
+
+bool linkDwarf(StringRef OutputFilename, const DebugMap &DM, bool Verbose) {
+ DwarfLinker Linker(OutputFilename, Verbose);
+ return Linker.link(DM);
+}
+}
}
diff --git a/llvm/tools/dsymutil/LLVMBuild.txt b/llvm/tools/dsymutil/LLVMBuild.txt
index 24b9033c78c..dd9151e2b9a 100644
--- a/llvm/tools/dsymutil/LLVMBuild.txt
+++ b/llvm/tools/dsymutil/LLVMBuild.txt
@@ -19,4 +19,4 @@
type = Tool
name = llvm-dsymutil
parent = Tools
-required_libraries = Object Support
+required_libraries = DebugInfo Object Support
diff --git a/llvm/tools/dsymutil/Makefile b/llvm/tools/dsymutil/Makefile
index 9eda7dcabc0..fd437aa2ce3 100644
--- a/llvm/tools/dsymutil/Makefile
+++ b/llvm/tools/dsymutil/Makefile
@@ -9,7 +9,7 @@
LEVEL := ../..
TOOLNAME := llvm-dsymutil
-LINK_COMPONENTS := Object Support
+LINK_COMPONENTS := DebugInfo Object Support
# This tool has no plugins, optimize startup time.
TOOL_NO_EXPORTS := 1
OpenPOWER on IntegriCloud