diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-08-31 13:10:54 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-08-31 13:10:54 +0000 |
commit | 8e864be70aa9cb226a7f2cf1c23340fa05dc15e5 (patch) | |
tree | d3925c7c7f64bbf7596528e2e4b4d8ab4d17cdcf | |
parent | d81e3146e30b5b0bb2b5c740405305d58fd18bf3 (diff) | |
download | bcm5719-llvm-8e864be70aa9cb226a7f2cf1c23340fa05dc15e5.tar.gz bcm5719-llvm-8e864be70aa9cb226a7f2cf1c23340fa05dc15e5.zip |
[llvm-objdump] Keep the memory buffer from the dSYM alive when using -g -dsym
When using -g and -dsym, llvm-objdump opens the dsym file and keeps the
MachOObjectFile alive, while the memory buffer that the MachOObjectFile
was based on gets destroyed.
Differential Revision: https://reviews.llvm.org/D51365
llvm-svn: 341209
-rw-r--r-- | llvm/test/tools/llvm-objdump/X86/macho-disassembly-g-dsym.test | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-objdump/X86/macho-disassembly-g-dsym.test b/llvm/test/tools/llvm-objdump/X86/macho-disassembly-g-dsym.test new file mode 100644 index 00000000000..7ed1110fcbe --- /dev/null +++ b/llvm/test/tools/llvm-objdump/X86/macho-disassembly-g-dsym.test @@ -0,0 +1,4 @@ +// RUN: dsymutil -f -oso-prepend-path=%p/../../dsymutil/ %p/../../dsymutil/Inputs/basic.macho.x86_64 -o %t1.dSYM +// RUN: llvm-objdump -d -g -dsym=%t1.dSYM %p/../../dsymutil/Inputs/basic.macho.x86_64 | FileCheck %s + +CHECK: Disassembly of section __TEXT,__text: diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index f10f7d076c9..c8c63ceac7f 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -6947,6 +6947,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, std::unique_ptr<DIContext> diContext; ObjectFile *DbgObj = MachOOF; + std::unique_ptr<MemoryBuffer> DSYMBuf; // Try to find debug info and set up the DIContext for it. if (UseDbg) { // A separate DSym file path was specified, parse it as a macho file, @@ -6964,6 +6965,8 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, if (DbgObjCheck.takeError()) report_error(MachOOF->getFileName(), DbgObjCheck.takeError()); DbgObj = DbgObjCheck.get().release(); + // We need to keep the file alive, because we're replacing DbgObj with it. + DSYMBuf = std::move(BufOrErr.get()); } // Setup the DIContext |