[lld] [llvm] [Symbolizer] Support for Missing Line Numbers. (PR #82240)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 7 13:40:18 PDT 2024
================
@@ -0,0 +1,606 @@
+# REQUIRES: x86-registered-target
+
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero 0x34d0 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-FAIL-ACROSS-SEQ %s
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero 0x34f0 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-WITHIN-SEQ %s
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero 0x34f0 0x3517 | FileCheck --strict-whitespace --match-full-lines --check-prefixes=APPROX-WITHIN-SEQ,NO-APPROX %s
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero --verbose 0x34f0 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-VERBOSE %s
+# RUN: llvm-symbolizer --obj=%t.o --skip-line-zero --output-style=JSON 0x34f0 | FileCheck --strict-whitespace --match-full-lines --check-prefix=APPROX-JSON %s
+
+# APPROX-FAIL-ACROSS-SEQ:add
+# APPROX-FAIL-ACROSS-SEQ-NEXT:definitions.h:0:49
+# APPROX-WITHIN-SEQ:main
+# APPROX-WITHIN-SEQ-NEXT:definitions.h:3:39 (approximate)
+# NO-APPROX:main
+# NO-APPROX-NEXT:main.c:9:2
+
+# APPROX-VERBOSE:main
+# APPROX-VERBOSE-NEXT: Filename: definitions.h
+# APPROX-VERBOSE-NEXT: Function start address: 0x34f0
+# APPROX-VERBOSE-NEXT: Line: 3
+# APPROX-VERBOSE-NEXT: Column: 39
+# APPROX-VERBOSE-NEXT: Approximate: true
+
+# APPROX-JSON:[{"Address":"0x34f0","ModuleName":"{{.*}}{{[/|\]+}}test{{[/|\]+}}tools{{[/|\]+}}llvm-symbolizer{{[/|\]+}}Output{{[/|\]+}}approximate-line-handcrafted.yaml.tmp.o","Symbol":[{"Approximate":true,"Column":39,"Discriminator":0,"FileName":"definitions.h","FunctionName":"main","Line":3,"StartAddress":"0x34f0","StartFileName":"","StartLine":0}]}]
+
+#--- definitions.h
+#extern inline __attribute__((section(".def_section"))) int dummy_function(){ return 1234; }
+#extern inline int add(int x, int y) { return (x + y); }
+#extern inline int sub(int x, int y) { return (x - y); }
+
+#--- main.c
+#include <stdio.h>
+#include "definitions.h"
+
+#int main(void) {
+ #int a = 10;
+ #int b = 100;
+ #printf("Dummy Function: %d \n",dummy_function());
+ #printf("Addition result: %d \n", add(a, b));
+ #printf("Subtraction result: %d \n", sub(a, b));
+ #return 0;
+#}
+
+#--- gen
+#clang -S -O3 -gline-tables-only --target=x86_64-pc-linux -fdebug-prefix-map=/proc/self/cwd="" -fdebug-prefix-map=./="" main.c -o main.s
+#sed -i '31s/ 2 / 0 /g' main.s
+#sed -i '64s/ 4 / 0 /g' main.s
+#clang -O3 -Wl,--section-start=.def_section=0x1000 -fdebug-prefix-map=/proc/self/cwd="" -fdebug-prefix-map=./="" -gline-tables-only --target=x86_64-pc-linux main.s -o main.o
+#obj2yaml main.o -o -
+
+#--- main.yaml
----------------
ampandey-1995 wrote:
We can't skip main.yaml here. The main.yaml is created from the final executable(main.o) using obj2yaml. This test requires complete executable to be furnished since we require the linker to map different VMA's for two sequences.
https://github.com/llvm/llvm-project/pull/82240
More information about the llvm-commits
mailing list