From 43a34840ab5048b28108ff97445d030a233e0163 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 10 Sep 2019 15:53:18 +0000 Subject: [PATCH 1/2] Don't emit .gnu_pubnames when tuning for LLDB. LLDB reads the various .apple* accelerator tables (and in the near future: the DWARF 5 accelerator tables) which should make .gnu_pubnames redundant. This changes the Clang driver to no longer pass -ggnu-pubnames when tuning for LLDB. Thanks to David Blaikie for pointing this out! http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190422/thread.html#646062 rdar://problem/50142073 Differential Revision: https://reviews.llvm.org/D67373 llvm-svn: 371530 (cherry picked from commit f987f561fadc35fb597ce821b2deeb005f40bd77) --- clang/lib/Driver/ToolChains/Clang.cpp | 1 - clang/test/Driver/debug-options.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 9d311b4cb6f1a2..c3750eb3437c79 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3400,7 +3400,6 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || - DebuggerTuning == llvm::DebuggerKind::LLDB || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) if (!PubnamesArg || (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index dce72ff17d792d..b21f508f787145 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -193,7 +193,7 @@ // RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s // RUN: %clang -### -c -fdebug-ranges-base-address -fno-debug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s // -// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=GPUB %s +// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s // RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s // // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s From c54d96aa49c27742d57bd485e71b4bd839c8085c Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 21 Oct 2019 16:44:37 +0000 Subject: [PATCH 2/2] PCH debug info: Avoid appending the source directory to an absolute path When building a precompiled header in -fmodule-format=obj (i.e., `-gmodules) in an absolute path, the locig in CGDebugInfo::createCompileUnit would unconditionally append the source directory to the -main-file-name. This patch avoids that behavior for absolute paths. rdar://problem/46045865 Differential Revision: https://reviews.llvm.org/D69213 llvm-svn: 375423 (cherry picked from commit 122e7af03df6f4d4f64db016c7183d0045690558) --- clang/lib/CodeGen/CGDebugInfo.cpp | 6 ++--- .../test/PCH/debug-info-pch-container-path.c | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 clang/test/PCH/debug-info-pch-container-path.c diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index b247b36a7b7534..5f843c7706a60a 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -536,11 +536,11 @@ void CGDebugInfo::CreateCompileUnit() { // file to determine the real absolute path for the file. std::string MainFileDir; if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) { - MainFileDir = remapDIPath(MainFile->getDir()->getName()); - if (MainFileDir != ".") { + MainFileDir = MainFile->getDir()->getName(); + if (!llvm::sys::path::is_absolute(MainFileName)) { llvm::SmallString<1024> MainFileDirSS(MainFileDir); llvm::sys::path::append(MainFileDirSS, MainFileName); - MainFileName = MainFileDirSS.str(); + MainFileName = llvm::sys::path::remove_leading_dotslash(MainFileDirSS); } // If the main file name provided is identical to the input file name, and // if the input file is a preprocessed source, use the module name for diff --git a/clang/test/PCH/debug-info-pch-container-path.c b/clang/test/PCH/debug-info-pch-container-path.c new file mode 100644 index 00000000000000..efe49e48e2dc58 --- /dev/null +++ b/clang/test/PCH/debug-info-pch-container-path.c @@ -0,0 +1,22 @@ +// REQUIRES: asserts + +// Modules: +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: cd %t + +// RUN: %clang_cc1 -fmodule-format=obj -emit-pch \ +// RUN: -triple %itanium_abi_triple \ +// RUN: -fdebug-prefix-map=%t=BUILD \ +// RUN: -fdebug-prefix-map=%S=SOURCE \ +// RUN: -o %t/prefix.ll %S/debug-info-limited-struct.h \ +// RUN: -mllvm -debug-only=pchcontainer &>%t-container.ll +// RUN: cat %t-container.ll | FileCheck %s + +// CHECK: distinct !DICompileUnit( +// CHECK-SAME: language: DW_LANG_C99, +// CHECK-SAME: file: ![[FILE:[0-9]+]], +// CHECK: ![[FILE]] = !DIFile( +// CHECK-SAME: filename: "SOURCE/debug-info-limited-struct.h", +// CHECK-SAME: directory: "BUILD" +