diff --git a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h index 43c89aafea9b..085e4bb4ccb8 100644 --- a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -49,7 +49,6 @@ public: std::string FallbackDebugPath; std::string DWPName; std::vector DebugFileDirectory; - std::function RecoverableErrorHandler = WithColor::defaultErrorHandler; }; LLVMSymbolizer() = default; diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp index ed53ea9712b6..383e2c0d3054 100644 --- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -68,8 +68,7 @@ LLVMSymbolizer::symbolizeCode(const ObjectFile &Obj, if (I != Modules.end()) return symbolizeCodeCommon(I->second.get(), ModuleOffset); - std::unique_ptr Context = - DWARFContext::create(Obj, nullptr, "", Opts.RecoverableErrorHandler); + std::unique_ptr Context = DWARFContext::create(Obj); Expected InfoOrErr = createModuleInfo(&Obj, std::move(Context), ModuleName); if (!InfoOrErr) @@ -573,8 +572,7 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { } } if (!Context) - Context = DWARFContext::create(*Objects.second, nullptr, Opts.DWPName, - Opts.RecoverableErrorHandler); + Context = DWARFContext::create(*Objects.second, nullptr, Opts.DWPName); return createModuleInfo(Objects.first, std::move(Context), ModuleName); } diff --git a/llvm/test/DebugInfo/symbolize-macho-universal-unknown-arch.test b/llvm/test/DebugInfo/symbolize-macho-universal-unknown-arch.test index b6b1ee77b8b7..744a0d3e5492 100644 --- a/llvm/test/DebugInfo/symbolize-macho-universal-unknown-arch.test +++ b/llvm/test/DebugInfo/symbolize-macho-universal-unknown-arch.test @@ -1,5 +1,5 @@ -RUN: not llvm-symbolizer --obj=%p/Inputs/macho-universal 0x1f84 2>&1 | FileCheck --implicit-check-not=main %s - -CHECK: LLVMSymbolizer: error reading file: Unknown architecture named: +RUN: llvm-symbolizer --obj=%p/Inputs/macho-universal 0x1f84 | FileCheck %s +CHECK-NOT: main CHECK: ?? +CHECK-NOT: main diff --git a/llvm/test/DebugInfo/symbolize-missing-file.test b/llvm/test/DebugInfo/symbolize-missing-file.test index bf148517f3c4..2762af4ff5da 100644 --- a/llvm/test/DebugInfo/symbolize-missing-file.test +++ b/llvm/test/DebugInfo/symbolize-missing-file.test @@ -1,3 +1,3 @@ -RUN: not llvm-symbolizer --obj=unexisting-file 0x1234 2>&1 | FileCheck %s +RUN: llvm-symbolizer --obj=unexisting-file 0x1234 2>&1 | FileCheck %s CHECK: LLVMSymbolizer: error reading file: {{[Nn]}}o such file or directory diff --git a/llvm/test/tools/llvm-symbolizer/input-base.test b/llvm/test/tools/llvm-symbolizer/input-base.test index f4b641ea626f..66244a7203c0 100644 --- a/llvm/test/tools/llvm-symbolizer/input-base.test +++ b/llvm/test/tools/llvm-symbolizer/input-base.test @@ -1,34 +1,33 @@ -# RUN: llvm-mc %s -o %t -filetype=obj -## llvm-symbolizer infers the number base from the form of the address. -# RUN: llvm-symbolizer -e %t -a 0x1234 | FileCheck %s -# RUN: llvm-symbolizer -e %t -a 0X1234 | FileCheck %s -# RUN: llvm-symbolizer -e %t -a 4660 | FileCheck %s -# RUN: llvm-symbolizer -e %t -a 011064 | FileCheck %s -# RUN: llvm-symbolizer -e %t -a 0b1001000110100 | FileCheck %s -# RUN: llvm-symbolizer -e %t -a 0B1001000110100 | FileCheck %s -# RUN: llvm-symbolizer -e %t -a 0o11064 | FileCheck %s +# llvm-symbolizer infers the number base from the form of the address. +RUN: llvm-symbolizer -e /dev/null -a 0x1234 | FileCheck %s +RUN: llvm-symbolizer -e /dev/null -a 0X1234 | FileCheck %s +RUN: llvm-symbolizer -e /dev/null -a 4660 | FileCheck %s +RUN: llvm-symbolizer -e /dev/null -a 011064 | FileCheck %s +RUN: llvm-symbolizer -e /dev/null -a 0b1001000110100 | FileCheck %s +RUN: llvm-symbolizer -e /dev/null -a 0B1001000110100 | FileCheck %s +RUN: llvm-symbolizer -e /dev/null -a 0o11064 | FileCheck %s -## llvm-symbolizer / StringRef::getAsInteger only accepts the 0o prefix in lowercase. -# RUN: llvm-symbolizer -e %t -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER +# llvm-symbolizer / StringRef::getAsInteger only accepts the 0o prefix in lowercase. +RUN: llvm-symbolizer -e /dev/null -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER -## llvm-addr2line always requires hexadecimal, but accepts an optional 0x prefix. -# RUN: llvm-addr2line -e %t -a 0x1234 | FileCheck %s -# RUN: llvm-addr2line -e %t -a 0X1234 | FileCheck %s -# RUN: llvm-addr2line -e %t -a 1234 | FileCheck %s -# RUN: llvm-addr2line -e %t -a 01234 | FileCheck %s -# RUN: llvm-addr2line -e %t -a 0b1010 | FileCheck %s --check-prefix=HEXADECIMAL-NOT-BINARY -# RUN: llvm-addr2line -e %t -a 0B1010 | FileCheck %s --check-prefix=HEXADECIMAL-NOT-BINARY -# RUN: llvm-addr2line -e %t -a 0o1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-LOWER -# RUN: llvm-addr2line -e %t -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER +# llvm-addr2line always requires hexadecimal, but accepts an optional 0x prefix. +RUN: llvm-addr2line -e /dev/null -a 0x1234 | FileCheck %s +RUN: llvm-addr2line -e /dev/null -a 0X1234 | FileCheck %s +RUN: llvm-addr2line -e /dev/null -a 1234 | FileCheck %s +RUN: llvm-addr2line -e /dev/null -a 01234 | FileCheck %s +RUN: llvm-addr2line -e /dev/null -a 0b1010 | FileCheck %s --check-prefix=HEXADECIMAL-NOT-BINARY +RUN: llvm-addr2line -e /dev/null -a 0B1010 | FileCheck %s --check-prefix=HEXADECIMAL-NOT-BINARY +RUN: llvm-addr2line -e /dev/null -a 0o1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-LOWER +RUN: llvm-addr2line -e /dev/null -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER -# CHECK: 0x1234 -# CHECK-NEXT: ?? +CHECK: 0x1234 +CHECK-NEXT: ?? -# HEXADECIMAL-NOT-BINARY: 0xb1010 -# HEXADECIMAL-NOT-BINARY: ?? +HEXADECIMAL-NOT-BINARY: 0xb1010 +HEXADECIMAL-NOT-BINARY: ?? -# INVALID-NOT-OCTAL-LOWER: 0o1234 -# INVALID-NOT-OCTAL-LOWER-NOT: ?? +INVALID-NOT-OCTAL-LOWER: 0o1234 +INVALID-NOT-OCTAL-LOWER-NOT: ?? -# INVALID-NOT-OCTAL-UPPER: 0O1234 -# INVALID-NOT-OCTAL-UPPER-NOT: ?? +INVALID-NOT-OCTAL-UPPER: 0O1234 +INVALID-NOT-OCTAL-UPPER-NOT: ?? diff --git a/llvm/test/tools/llvm-symbolizer/invalid-dwarf.s b/llvm/test/tools/llvm-symbolizer/invalid-dwarf.s deleted file mode 100644 index 027ccef00faa..000000000000 --- a/llvm/test/tools/llvm-symbolizer/invalid-dwarf.s +++ /dev/null @@ -1,205 +0,0 @@ -# REQUIRES: x86-registered-target -# Source: -# void f1() { } -# void f2() { } -# -# Build as: clang -ffunction-sections -gdwarf-5 -c test.c -# Hand modify the rnglist to include an invalid RLE encoding (42) -# -# RUN: llvm-mc -dwarf-version=5 %s -triple=x86_64-pc-linux -filetype=obj -o %t -# RUN: not llvm-symbolizer -obj=%t 0x0 2>&1 | FileCheck %s -# -# CHECK: error: decoding address ranges: unknown rnglists encoding 0x2a at offset 0x10 - - .text - .file "test.c" - .section .text.f1,"ax",@progbits - .globl f1 # -- Begin function f1 - .p2align 4, 0x90 - .type f1,@function -f1: # @f1 -.Lfunc_begin0: - .file 0 "/usr/local/google/home/blaikie/dev/scratch" "test.c" md5 0x39c2464ceaf7fd68a00d44ca40e99028 - .loc 0 1 0 # test.c:1:0 - .cfi_startproc -# %bb.0: # %entry - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset %rbp, -16 - movq %rsp, %rbp - .cfi_def_cfa_register %rbp -.Ltmp0: - .loc 0 1 13 prologue_end # test.c:1:13 - popq %rbp - .cfi_def_cfa %rsp, 8 - retq -.Ltmp1: -.Lfunc_end0: - .size f1, .Lfunc_end0-f1 - .cfi_endproc - # -- End function - .section .text.f2,"ax",@progbits - .globl f2 # -- Begin function f2 - .p2align 4, 0x90 - .type f2,@function -f2: # @f2 -.Lfunc_begin1: - .loc 0 2 0 # test.c:2:0 - .cfi_startproc -# %bb.0: # %entry - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset %rbp, -16 - movq %rsp, %rbp - .cfi_def_cfa_register %rbp -.Ltmp2: - .loc 0 2 13 prologue_end # test.c:2:13 - popq %rbp - .cfi_def_cfa %rsp, 8 - retq -.Ltmp3: -.Lfunc_end1: - .size f2, .Lfunc_end1-f2 - .cfi_endproc - # -- End function - .section .debug_abbrev,"",@progbits - .byte 1 # Abbreviation Code - .byte 17 # DW_TAG_compile_unit - .byte 1 # DW_CHILDREN_yes - .byte 37 # DW_AT_producer - .byte 37 # DW_FORM_strx1 - .byte 19 # DW_AT_language - .byte 5 # DW_FORM_data2 - .byte 3 # DW_AT_name - .byte 37 # DW_FORM_strx1 - .byte 114 # DW_AT_str_offsets_base - .byte 23 # DW_FORM_sec_offset - .byte 16 # DW_AT_stmt_list - .byte 23 # DW_FORM_sec_offset - .byte 27 # DW_AT_comp_dir - .byte 37 # DW_FORM_strx1 - .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr - .byte 85 # DW_AT_ranges - .byte 35 # DW_FORM_rnglistx - .byte 115 # DW_AT_addr_base - .byte 23 # DW_FORM_sec_offset - .byte 116 # DW_AT_rnglists_base - .byte 23 # DW_FORM_sec_offset - .byte 0 # EOM(1) - .byte 0 # EOM(2) - .byte 2 # Abbreviation Code - .byte 46 # DW_TAG_subprogram - .byte 0 # DW_CHILDREN_no - .byte 17 # DW_AT_low_pc - .byte 27 # DW_FORM_addrx - .byte 18 # DW_AT_high_pc - .byte 6 # DW_FORM_data4 - .byte 64 # DW_AT_frame_base - .byte 24 # DW_FORM_exprloc - .byte 3 # DW_AT_name - .byte 37 # DW_FORM_strx1 - .byte 58 # DW_AT_decl_file - .byte 11 # DW_FORM_data1 - .byte 59 # DW_AT_decl_line - .byte 11 # DW_FORM_data1 - .byte 63 # DW_AT_external - .byte 25 # DW_FORM_flag_present - .byte 0 # EOM(1) - .byte 0 # EOM(2) - .byte 0 # EOM(3) - .section .debug_info,"",@progbits -.Lcu_begin0: - .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit -.Ldebug_info_start0: - .short 5 # DWARF version number - .byte 1 # DWARF Unit Type - .byte 8 # Address Size (in bytes) - .long .debug_abbrev # Offset Into Abbrev. Section - .byte 1 # Abbrev [1] 0xc:0x36 DW_TAG_compile_unit - .byte 0 # DW_AT_producer - .short 12 # DW_AT_language - .byte 1 # DW_AT_name - .long .Lstr_offsets_base0 # DW_AT_str_offsets_base - .long .Lline_table_start0 # DW_AT_stmt_list - .byte 2 # DW_AT_comp_dir - .quad 0 # DW_AT_low_pc - .byte 0 # DW_AT_ranges - .long .Laddr_table_base0 # DW_AT_addr_base - .long .Lrnglists_table_base0 # DW_AT_rnglists_base - .byte 2 # Abbrev [2] 0x2b:0xb DW_TAG_subprogram - .byte 0 # DW_AT_low_pc - .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc - .byte 1 # DW_AT_frame_base - .byte 86 - .byte 3 # DW_AT_name - .byte 0 # DW_AT_decl_file - .byte 1 # DW_AT_decl_line - # DW_AT_external - .byte 2 # Abbrev [2] 0x36:0xb DW_TAG_subprogram - .byte 1 # DW_AT_low_pc - .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc - .byte 1 # DW_AT_frame_base - .byte 86 - .byte 4 # DW_AT_name - .byte 0 # DW_AT_decl_file - .byte 2 # DW_AT_decl_line - # DW_AT_external - .byte 0 # End Of Children Mark -.Ldebug_info_end0: - .section .debug_rnglists,"",@progbits - .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length -.Ldebug_list_header_start0: - .short 5 # Version - .byte 8 # Address size - .byte 0 # Segment selector size - .long 1 # Offset entry count -.Lrnglists_table_base0: - .long .Ldebug_ranges0-.Lrnglists_table_base0 -.Ldebug_ranges0: - .byte 42 # DW_RLE_startx_length - .byte 0 # start index - .uleb128 .Lfunc_end0-.Lfunc_begin0 # length - .byte 3 # DW_RLE_startx_length - .byte 1 # start index - .uleb128 .Lfunc_end1-.Lfunc_begin1 # length - .byte 0 # DW_RLE_end_of_list -.Ldebug_list_header_end0: - .section .debug_str_offsets,"",@progbits - .long 24 # Length of String Offsets Set - .short 5 - .short 0 -.Lstr_offsets_base0: - .section .debug_str,"MS",@progbits,1 -.Linfo_string0: - .asciz "clang version 12.0.0 (git@github.com:llvm/llvm-project.git 9a33f027ac7d73e14ae287e78ab554142d1cbc8f)" # string offset=0 -.Linfo_string1: - .asciz "test.c" # string offset=101 -.Linfo_string2: - .asciz "/usr/local/google/home/blaikie/dev/scratch" # string offset=108 -.Linfo_string3: - .asciz "f1" # string offset=151 -.Linfo_string4: - .asciz "f2" # string offset=154 - .section .debug_str_offsets,"",@progbits - .long .Linfo_string0 - .long .Linfo_string1 - .long .Linfo_string2 - .long .Linfo_string3 - .long .Linfo_string4 - .section .debug_addr,"",@progbits - .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution -.Ldebug_addr_start0: - .short 5 # DWARF version number - .byte 8 # Address size - .byte 0 # Segment selector size -.Laddr_table_base0: - .quad .Lfunc_begin0 - .quad .Lfunc_begin1 -.Ldebug_addr_end0: - .ident "clang version 12.0.0 (git@github.com:llvm/llvm-project.git 9a33f027ac7d73e14ae287e78ab554142d1cbc8f)" - .section ".note.GNU-stack","",@progbits - .addrsig - .section .debug_line,"",@progbits -.Lline_table_start0: - diff --git a/llvm/test/tools/llvm-symbolizer/sym.test b/llvm/test/tools/llvm-symbolizer/sym.test index 612485b8b1fe..73097b2c4b9b 100644 --- a/llvm/test/tools/llvm-symbolizer/sym.test +++ b/llvm/test/tools/llvm-symbolizer/sym.test @@ -31,8 +31,7 @@ RUN: llvm-symbolizer -i -print-address -p -obj=%p/Inputs/addr.exe < %p/Inputs/ad RUN: llvm-symbolizer --inlining=true --print-address -p --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s RUN: echo "0x1" > %t.input -## FIXME: Looks like this was meant to have an input file to test, but it isn't present - so this test probably isn't testing what it's intended to test -RUN: not llvm-symbolizer -obj=%p/Inputs/zero < %t.input | FileCheck -check-prefix="ZERO" %s +RUN: llvm-symbolizer -obj=%p/Inputs/zero < %t.input | FileCheck -check-prefix="ZERO" %s RUN: llvm-addr2line -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix=A2L %s RUN: llvm-addr2line -a -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2L,A2L_A %s diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp index e4061408a821..f57922b2c506 100644 --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -73,15 +73,12 @@ static cl::list ClInputAddresses(cl::Positional, cl::desc("..."), cl::ZeroOrMore); -static bool HasError = false; - template static bool error(Expected &ResOrErr) { if (ResOrErr) return false; logAllUnhandledErrors(ResOrErr.takeError(), errs(), "LLVMSymbolizer: error reading file: "); - HasError = true; return true; } @@ -293,10 +290,6 @@ int main(int argc, char **argv) { Args.hasFlag(OPT_untag_addresses, OPT_no_untag_addresses, !IsAddr2Line); Opts.UseNativePDBReader = Args.hasArg(OPT_use_native_pdb_reader); Opts.UseSymbolTable = true; - Opts.RecoverableErrorHandler = [&](Error E) { - HasError = true; - WithColor::defaultErrorHandler(std::move(E)); - }; for (const opt::Arg *A : Args.filtered(OPT_dsym_hint_EQ)) { StringRef Hint(A->getValue()); @@ -343,5 +336,5 @@ int main(int argc, char **argv) { Symbolizer, Printer); } - return HasError; + return 0; }