xref: /llvm-project/llvm/test/tools/llvm-debuginfo-analyzer/DWARF/01-dwarf-select-logical-elements.test (revision c5ce3b136cfaafd656dbce3665b1d6a39845fa88)
1; REQUIRES: x86-registered-target
2
3; Test case 1 - General options
4
5; test.cpp
6;  1  using INTPTR = const int *;
7;  2  int foo(INTPTR ParamPtr, unsigned ParamUnsigned, bool ParamBool) {
8;  3    if (ParamBool) {
9;  4      typedef int INTEGER;
10;  5      const INTEGER CONSTANT = 7;
11;  6      return CONSTANT;
12;  7    }
13;  8    return ParamUnsigned;
14;  9  }
15
16; Select logical elements.
17; The following prints all 'instructions', 'symbols' and 'types' that
18; contain 'inte' or 'movl' in their names or types, using a tab layout
19; and given the number of matches.
20
21; RUN: llvm-debuginfo-analyzer --attribute=level \
22; RUN:                         --select-nocase --select-regex \
23; RUN:                         --select=INTe --select=movl \
24; RUN:                         --report=list \
25; RUN:                         --print=symbols,types,instructions,summary \
26; RUN:                         %p/Inputs/test-dwarf-clang.o 2>&1 | \
27; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s
28
29; ONE:      Logical View:
30; ONE-NEXT: [000]           {File} 'test-dwarf-clang.o'
31; ONE-EMPTY:
32; ONE-NEXT: [001]           {CompileUnit} 'test.cpp'
33; ONE-NEXT: [004]           {Code} 'movl	$0x7, -0x1c(%rbp)'
34; ONE-NEXT: [004]           {Code} 'movl	$0x7, -0x4(%rbp)'
35; ONE-NEXT: [003]           {Code} 'movl	%eax, -0x4(%rbp)'
36; ONE-NEXT: [003]           {Code} 'movl	%esi, -0x14(%rbp)'
37; ONE-NEXT: [004]           {Code} 'movl	-0x14(%rbp), %eax'
38; ONE-NEXT: [003]           {Code} 'movl	-0x4(%rbp), %eax'
39; ONE-NEXT: [003]     4     {TypeAlias} 'INTEGER' -> 'int'
40; ONE-NEXT: [004]     5     {Variable} 'CONSTANT' -> 'const INTEGER'
41; ONE-EMPTY:
42; ONE-NEXT: -----------------------------
43; ONE-NEXT: Element      Total    Printed
44; ONE-NEXT: -----------------------------
45; ONE-NEXT: Scopes           3          0
46; ONE-NEXT: Symbols          4          1
47; ONE-NEXT: Types            2          1
48; ONE-NEXT: Lines           17          6
49; ONE-NEXT: -----------------------------
50; ONE-NEXT: Total           26          8
51
52; RUN: llvm-debuginfo-analyzer --attribute=level \
53; RUN:                         --select-regex --select-nocase \
54; RUN:                         --select=INTe \
55; RUN:                         --report=list \
56; RUN:                         --print=symbols,types \
57; RUN:                         %p/Inputs/test-dwarf-clang.o \
58; RUN:                         %p/Inputs/test-dwarf-gcc.o 2>&1 | \
59; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s
60
61; TWO:      Logical View:
62; TWO-NEXT: [000]           {File} 'test-dwarf-clang.o'
63; TWO-EMPTY:
64; TWO-NEXT: [001]           {CompileUnit} 'test.cpp'
65; TWO-NEXT: [003]     4     {TypeAlias} 'INTEGER' -> 'int'
66; TWO-NEXT: [004]     5     {Variable} 'CONSTANT' -> 'const INTEGER'
67; TWO-EMPTY:
68; TWO-NEXT: Logical View:
69; TWO-NEXT: [000]           {File} 'test-dwarf-gcc.o'
70; TWO-EMPTY:
71; TWO-NEXT: [001]           {CompileUnit} 'test.cpp'
72; TWO-NEXT: [004]     4     {TypeAlias} 'INTEGER' -> 'int'
73; TWO-NEXT: [004]     5     {Variable} 'CONSTANT' -> 'const INTEGER'
74
75; Select logical elements based on linkage names.
76; The following prints all symbols that
77; contain "_Z3fooPKijb" in their linkage names, using a tab layout
78; and given the number of matches.
79
80; RUN: llvm-debuginfo-analyzer --attribute=level \
81; RUN:                         --select=_Z3fooPKijb \
82; RUN:                         --report=list \
83; RUN:                         --print=symbols \
84; RUN:                         %p/Inputs/pr-57040-test-dwarf-clang.o \
85; RUN:                         %p/Inputs/pr-57040-test-dwarf-gcc.o 2>&1 | \
86; RUN: FileCheck --strict-whitespace -check-prefix=THREE %s
87
88; THREE:      Logical View:
89; THREE-NEXT: [000]           {File} 'pr-57040-test-dwarf-clang.o'
90; THREE-EMPTY:
91; THREE-NEXT: [001]           {CompileUnit} 'test.cpp'
92; THREE-NEXT: [002]     2     {Function} extern not_inlined 'foo' -> 'int'
93; THREE-EMPTY:
94; THREE:      Logical View:
95; THREE-NEXT: [000]           {File} 'pr-57040-test-dwarf-gcc.o'
96; THREE-EMPTY:
97; THREE-NEXT: [001]           {CompileUnit} 'test.cpp'
98; THREE-NEXT: [002]     2     {Function} extern not_inlined 'foo' -> 'int'
99