[lld] [llvm] [Symbolizer] Support for Missing Line Numbers. (PR #82240)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 14 16:18:10 PDT 2024
================
@@ -0,0 +1,402 @@
+## Test --skip-line-zero option.
+##
+## This test illustrates the usage of handcrafted assembly to produce the following line table.
+## Address Line Column File ISA Discriminator OpIndex Flags
+## ------------------ ------ ------ ------ --- ------------- ------- -------------
+## 0x0000000000001710 1 0 2 0 0 0 is_stmt
+## 0x0000000000001717 0 17 2 0 0 0 is_stmt prologue_end
+## 0x000000000000171a 2 15 2 0 0 0
+## 0x000000000000171f 2 3 2 0 0 0 epilogue_begin
+## 0x0000000000001721 2 3 2 0 0 0 end_sequence
+## 0x00000000000016c0 0 0 1 0 0 0 is_stmt
+## 0x00000000000016cf 3 29 1 0 0 0 is_stmt prologue_end
+## 0x00000000000016d5 0 25 1 0 0 0
+## 0x00000000000016da 3 18 1 0 0 0 epilogue_begin
+## 0x00000000000016e0 3 18 1 0 0 0 end_sequence
+
+# REQUIRES: x86-registered-target
+
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux --fdebug-prefix-map=%t="" %s -o %t.o
+
+## Check that without '--skip-line-zero', line number zero is displayed for the line-table entry which has no source correspondence.
+# RUN: llvm-symbolizer --obj=%t.o 0x16d5 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-DISABLE %s
+
+# APPROX-DISABLE:main
+# APPROX-DISABLE-NEXT:main.c:0:25
+
+## Check that with '--skip-line-zero', the last non-zero line in the current sequence is displayed.
+## If it fails to find in the current sequence then return the original computed line-zero for the queried address.
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero 0x16c0 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-FAIL-ACROSS-SEQ %s
+
+# APPROX-FAIL-ACROSS-SEQ:main
+# APPROX-FAIL-ACROSS-SEQ-NEXT:main.c:0:0
+
+## Check that with '--skip-line-zero', the last non-zero line in the current sequence is displayed.
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero 0x1717 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-WITHIN-SEQ %s
+
+# APPROX-WITHIN-SEQ:foo
+# APPROX-WITHIN-SEQ-NEXT:definitions.c:1:0 (approximate)
+
+## Check to ensure that '--skip-line-zero' only affects addresses having line-zero when more than one address is specified.
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero 0x16d5 0x16da | FileCheck --strict-whitespace --match-full-lines --check-prefixes=APPROX-ENABLE,NO-APPROX %s
+
+# APPROX-ENABLE:main
+# APPROX-ENABLE-NEXT:main.c:3:29 (approximate)
+# NO-APPROX:main
+# NO-APPROX-NEXT:main.c:3:18
+
+## Check to ensure that '--skip-line-zero' with '--verbose' enabled displays correct approximate flag in verbose ouptut.
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero --verbose 0x1717 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-VERBOSE %s
+
+# APPROX-VERBOSE:foo
+# APPROX-VERBOSE-NEXT: Filename: definitions.c
+# APPROX-VERBOSE-NEXT: Function start filename: definitions.c
+# APPROX-VERBOSE-NEXT: Function start line: 1
+# APPROX-VERBOSE-NEXT: Function start address: 0x1710
+# APPROX-VERBOSE-NEXT: Line: 1
+# APPROX-VERBOSE-NEXT: Column: 0
+# APPROX-VERBOSE-NEXT: Approximate: true
+
+## Check to ensure that '--skip-line-zero' with '--output-style=JSON' displays correct approximate flag in JSON output.
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero --output-style=JSON 0x1717 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-JSON %s
+
+# APPROX-JSON:[{"Address":"0x1717","ModuleName":"{{.*}}{{[/|\]+}}test{{[/|\]+}}tools{{[/|\]+}}llvm-symbolizer{{[/|\]+}}Output{{[/|\]+}}skip-line-zero.s.tmp.o","Symbol":[{"Approximate":true,"Column":0,"Discriminator":0,"FileName":"definitions.c","FunctionName":"foo","Line":1,"StartAddress":"0x1710","StartFileName":"definitions.c","StartLine":1}]}]
+
+#--- definitions.c
----------------
bd1976bris wrote:
I would put both foo and main in main.c. That way the dwarf only has to describe a single source file.
https://github.com/llvm/llvm-project/pull/82240
More information about the llvm-commits
mailing list