From 1b63177a56e8cd6196778d2b90295f03e96b5800 Mon Sep 17 00:00:00 2001 From: Amy Huang Date: Mon, 23 Nov 2020 16:29:04 -0800 Subject: [PATCH] Revert "[llvm-symbolizer] Switch to using native symbolizer by default on Windows" Breaks some asan tests on the buildbot. This reverts commit c74b427cb2a90309ee0c29df21ad1ca26390263c. --- lld/test/COFF/symbolizer-inline.s | 2 +- llvm/docs/CommandGuide/llvm-symbolizer.rst | 8 -------- llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h | 2 +- llvm/lib/DebugInfo/Symbolize/Symbolize.cpp | 7 +++++-- .../test/tools/llvm-symbolizer/pdb/pdb-columns.test | 2 ++ llvm/test/tools/llvm-symbolizer/pdb/pdb.test | 13 ++++++++----- llvm/tools/llvm-symbolizer/Opts.td | 2 +- llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp | 8 +------- 8 files changed, 19 insertions(+), 25 deletions(-) diff --git a/lld/test/COFF/symbolizer-inline.s b/lld/test/COFF/symbolizer-inline.s index 9a032f999866..c0db693f784c 100644 --- a/lld/test/COFF/symbolizer-inline.s +++ b/lld/test/COFF/symbolizer-inline.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj %s -o %t.obj -triple x86_64-windows-msvc # RUN: lld-link -entry:main -nodefaultlib %t.obj -out:%t.exe -pdb:%t.pdb -debug -# RUN: llvm-symbolizer --obj=%t.exe --relative-address \ +# RUN: llvm-symbolizer --obj=%t.exe --use-native-pdb-reader --relative-address \ # RUN: 0x1014 0x1018 0x101c 0x1023 0x1024 | FileCheck %s # Compiled from this cpp code, with modifications to add extra inline line and diff --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst b/llvm/docs/CommandGuide/llvm-symbolizer.rst index f2a8d8ef6801..c5d094f9552d 100644 --- a/llvm/docs/CommandGuide/llvm-symbolizer.rst +++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst @@ -354,14 +354,6 @@ OPTIONS Read command-line options from response file ``. -WINDOWS/PDB SPECIFIC OPTIONS ------------------------------ - -.. option:: --dia - - Use the Windows DIA SDK for symbolization. If the DIA SDK is not found, - llvm-symbolizer will fall back to the native implementation. - MACH-O SPECIFIC OPTIONS ----------------------- diff --git a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h index 1c8fa11660af..085e4bb4ccb8 100644 --- a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -43,7 +43,7 @@ public: bool Demangle = true; bool RelativeAddresses = false; bool UntagAddresses = false; - bool UseDIA = false; + bool UseNativePDBReader = false; std::string DefaultArch; std::vector DsymHints; std::string FallbackDebugPath; diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp index 3eb84a141b81..383e2c0d3054 100644 --- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -557,8 +557,11 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { using namespace pdb; std::unique_ptr Session; - PDB_ReaderType ReaderType = - Opts.UseDIA ? PDB_ReaderType::DIA : PDB_ReaderType::Native; + PDB_ReaderType ReaderType = PDB_ReaderType::Native; +#if LLVM_ENABLE_DIA_SDK + if (!Opts.UseNativePDBReader) + ReaderType = PDB_ReaderType::DIA; +#endif if (auto Err = loadDataForEXE(ReaderType, Objects.first->getFileName(), Session)) { Modules.emplace(ModuleName, std::unique_ptr()); diff --git a/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test b/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test index a564847ef94e..425d58d4d46f 100644 --- a/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test +++ b/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test @@ -8,6 +8,8 @@ RUN: echo 0x140006C40 >> %t.input RUN: echo 0x140006C70 >> %t.input RUN: llvm-symbolizer -obj="%p/Inputs/test-columns.exe" < %t.input \ RUN: | FileCheck %s +RUN: llvm-symbolizer -obj="%p/Inputs/test-columns.exe" -use-native-pdb-reader < %t.input \ +RUN: | FileCheck %s This tests that the symbolizer outputs column info when it is present in the pdb. diff --git a/llvm/test/tools/llvm-symbolizer/pdb/pdb.test b/llvm/test/tools/llvm-symbolizer/pdb/pdb.test index 46a1ae9814e6..d9e42416ad56 100644 --- a/llvm/test/tools/llvm-symbolizer/pdb/pdb.test +++ b/llvm/test/tools/llvm-symbolizer/pdb/pdb.test @@ -6,18 +6,17 @@ RUN: echo 0x4013D0 >> %t.input RUN: echo 0x4013E0 >> %t.input RUN: echo 0x4013F0 >> %t.input RUN: echo 0x401420 >> %t.input -RUN: llvm-symbolizer --obj="%p/Inputs/test.exe" < %t.input \ +RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" < %t.input \ RUN: | FileCheck %s RUN: llvm-symbolizer --obj="%p/Inputs/test.exe" --no-demangle < %t.input \ RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE -; Check that -dia works -RUN: llvm-symbolizer --dia --obj="%p/Inputs/test.exe" < %t.input \ +Test with native pdb reader. +RUN: llvm-symbolizer -use-native-pdb-reader -obj="%p/Inputs/test.exe" < %t.input \ RUN: | FileCheck %s -RUN: llvm-symbolizer --dia --obj="%p/Inputs/test.exe" --no-demangle < %t.input \ +RUN: llvm-symbolizer --use-native-pdb-reader --obj="%p/Inputs/test.exe" --no-demangle < %t.input \ RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE - Subtract ImageBase from all the offsets and run the test again with --relative-address. @@ -25,6 +24,10 @@ RUN: %python -c 'import sys;print("\n".join([hex(int(x, 16) - 0x400000) for x in RUN: | llvm-symbolizer --obj="%p/Inputs/test.exe" --no-demangle --relative-address \ RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE +RUN: %python -c 'import sys;print("\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin]))' < %t.input \ +RUN: | llvm-symbolizer --use-native-pdb-reader --obj="%p/Inputs/test.exe" --no-demangle --relative-address \ +RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE + CHECK: foo(void) CHECK-NEXT: test.cpp:10 CHECK: {{^private_symbol$}} diff --git a/llvm/tools/llvm-symbolizer/Opts.td b/llvm/tools/llvm-symbolizer/Opts.td index ac23639f130e..e8def4ff9a6a 100644 --- a/llvm/tools/llvm-symbolizer/Opts.td +++ b/llvm/tools/llvm-symbolizer/Opts.td @@ -41,7 +41,7 @@ defm print_source_context_lines : Eq<"print-source-context-lines", "Print N line def relative_address : F<"relative-address", "Interpret addresses as addresses relative to the image base">; def relativenames : F<"relativenames", "Strip the compilation directory from paths">; defm untag_addresses : B<"untag-addresses", "", "Remove memory tags from addresses before symbolization">; -def use_dia: F<"dia", "Use the DIA library to access symbols (Windows only)">; +def use_native_pdb_reader : F<"use-native-pdb-reader", "Use native PDB functionality">; def verbose : F<"verbose", "Print verbose line info">; def version : F<"version", "Display the version">; diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp index 875432bd6705..f57922b2c506 100644 --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -288,13 +288,7 @@ int main(int argc, char **argv) { Opts.RelativeAddresses = Args.hasArg(OPT_relative_address); Opts.UntagAddresses = Args.hasFlag(OPT_untag_addresses, OPT_no_untag_addresses, !IsAddr2Line); - Opts.UseDIA = Args.hasArg(OPT_use_dia); -#if !defined(LLVM_ENABLE_DIA_SDK) - if (Opts.UseDIA) { - WithColor::warning() << "DIA not available; using native PDB reader\n"; - Opts.UseDIA = false; - } -#endif + Opts.UseNativePDBReader = Args.hasArg(OPT_use_native_pdb_reader); Opts.UseSymbolTable = true; for (const opt::Arg *A : Args.filtered(OPT_dsym_hint_EQ)) {