llvm/llvm/test/tools/llvm-symbolizer/sym.test

# Source:
# #include <stdio.h>
# static inline int inctwo (int *a) {
#   printf ("%d\n",(*a)++);
#   return (*a)++;
# }
# static inline int inc (int *a) {
#   printf ("%d\n",inctwo(a));
#   return (*a)++;
# }
#
#
# int main () {
#   int x = 1;
#   return inc(&x);
# }
#
# Build as : clang -g -O2 addr.c

RUN: llvm-symbolizer --print-address --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s
RUN: llvm-symbolizer --addresses --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s
RUN: llvm-symbolizer -a --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s

CHECK: ??:0:0
CHECK-EMPTY:
CHECK-NEXT: 0x40054d
CHECK-NEXT: inctwo
CHECK-NEXT: {{[/\]+}}tmp{{[/\]+}}x.c:3:3
CHECK-NEXT: inc
CHECK-NEXT: {{[/\]+}}tmp{{[/\]+}}x.c:7:0
CHECK-NEXT: main
CHECK-NEXT: {{[/\]+}}tmp{{[/\]+}}x.c:14:0
CHECK-EMPTY:
CHECK-NEXT: ??
CHECK-NEXT: ??:0:0

RUN: llvm-symbolizer --inlining --print-address --pretty-print --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s 
RUN: llvm-symbolizer --inlining --print-address -p --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s
RUN: llvm-symbolizer --inlines --print-address --pretty-print --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s
RUN: llvm-symbolizer --inlines --print-address -p --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s
RUN: llvm-symbolizer -i --print-address --pretty-print --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s
RUN: llvm-symbolizer -i --print-address -p --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s

# Before 2020-08-04, asan_symbolize.py passed --inlining=true.
# Support this compatibility alias for a while.
RUN: llvm-symbolizer --inlining=true --print-address -p --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s

PRETTY: ??:0:0
PRETTY: {{[0x]+}}40054d: inctwo at {{[/\]+}}tmp{{[/\]+}}x.c:3:3
PRETTY:  (inlined by) inc at {{[/\]+}}tmp{{[/\]+}}x.c:7:0
PRETTY:  (inlined by) main at {{[/\]+}}tmp{{[/\]+}}x.c:14:0
PRETTY: ??:0:0

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
RUN: llvm-addr2line -f --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2L,A2L_F %s
RUN: llvm-addr2line -i --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2L,A2L_I %s
RUN: llvm-addr2line -fi --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2L,A2L_F,A2L_I,A2L_FI %s

RUN: llvm-addr2line -pa --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_A %s
RUN: llvm-addr2line -pf --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_F %s
RUN: llvm-addr2line -paf --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_AF %s
RUN: llvm-addr2line -pai --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_A,A2LP_I %s
RUN: llvm-addr2line -pfi --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_F,A2LP_FI %s
RUN: llvm-addr2line -pafi --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_AF,A2LP_FI %s

A2L:         ??:0
A2L_A-NEXT:  0x40054d
A2L_F-NEXT:  inctwo
A2L-NEXT:    {{[/\]+}}tmp{{[/\]+}}x.c:3{{$}}
A2L_FI-NEXT: inc{{$}}
A2L_I-NEXT:  {{[/\]+}}tmp{{[/\]+}}x.c:7{{$}}
A2L_FI-NEXT: main
A2L_I-NEXT:  {{[/\]+}}tmp{{[/\]+}}x.c:14{{$}}
A2L_F-NEXT:  ??
A2L-NEXT:    ??:0

A2LP:          ??:0
A2LP_A-NEXT:   0x40054d: {{[/\]+}}tmp{{[/\]+}}x.c:3{{$}}
A2LP_F-NEXT:   inctwo at {{[/\]+}}tmp{{[/\]+}}x.c:3{{$}}
A2LP_AF-NEXT:  0x40054d: inctwo at {{[/\]+}}tmp{{[/\]+}}x.c:3{{$}}
A2LP_I-NEXT:   {{[/\]+}}tmp{{[/\]+}}x.c:7{{$}}
A2LP_I-NEXT:   {{[/\]+}}tmp{{[/\]+}}x.c:14{{$}}
A2LP_FI-NEXT:   (inlined by) inc at {{[/\]+}}tmp{{[/\]+}}x.c:7{{$}}
A2LP_FI-NEXT:   (inlined by) main at {{[/\]+}}tmp{{[/\]+}}x.c:14{{$}}
A2LP-NEXT:     ??:0