1REQUIRES: x86_64-linux
2
3The input raw profile test has been generated from the following source code:
4
5```
6#include <sanitizer/memprof_interface.h>
7#include <stdlib.h>
8#include <string.h>
9int main(int argc, char **argv) {
10  char *x = (char *)malloc(10);
11  memset(x, 0, 10);
12  free(x);
13  __memprof_profile_dump();
14  x = (char *)malloc(10);
15  memset(x, 0, 10);
16  free(x);
17  return 0;
18}
19```
20
21The following commands were used to compile the source to a memprof instrumented
22executable and collect a raw binary format profile. Since the profile contains
23virtual addresses for the callstack, we do not expect the raw binary profile to
24be deterministic. The summary should be deterministic apart from changes to
25the shared libraries linked in which could change the number of segments
26recorded.
27
28```
29clang -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling \
30      -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer \
31      -fno-optimize-sibling-calls -m64 -Wl,-build-id source.c -o multi.memprofexe
32
33env MEMPROF_OPTIONS=log_path=stdout ./rawprofile.out > multi.memprofraw
34```
35
36RUN: llvm-profdata show --memory %p/Inputs/multi.memprofraw --profiled-binary %p/Inputs/multi.memprofexe -o - | FileCheck %s
37
38We expect 2 MIB entries, 1 each for the malloc calls in the program.
39
40CHECK:  MemprofProfile:
41CHECK-NEXT:  Summary:
42CHECK-NEXT:    Version: 1
43CHECK-NEXT:    NumSegments: 9
44CHECK-NEXT:    NumMibInfo: 2
45CHECK-NEXT:    NumAllocFunctions: 1
46CHECK-NEXT:    NumStackOffsets: 2
47
48CHECK:        SymbolName: main
49CHECK-NEXT:     LineOffset: 1
50CHECK-NEXT:     Column: 21
51
52CHECK:        SymbolName: main
53CHECK-NEXT:     LineOffset: 5
54CHECK-NEXT:     Column: 15
55