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 -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -Wl,-build-id source.c -o rawprofile.out
30
31env MEMPROF_OPTIONS=log_path=stdout ./rawprofile.out > multi.memprofraw
32```
33
34RUN: llvm-profdata show --memory %p/Inputs/multi.memprofraw -o - | FileCheck %s
35
36We expect 2 MIB entries, 1 each for the malloc calls in the program. Unlike the
37memprof-basic.test we do not see any allocation from glibc.
38
39CHECK: MemProf Profile 1
40CHECK:   Version: 1
41CHECK:   TotalSizeBytes: 864
42CHECK:   NumSegments: 9
43CHECK:   NumMIBInfo: 2
44CHECK:   NumStackOffsets: 2
45CHECK: MemProf Profile 2
46CHECK:   Version: 1
47CHECK:   TotalSizeBytes: 864
48CHECK:   NumSegments: 9
49CHECK:   NumMIBInfo: 2
50CHECK:   NumStackOffsets: 2
51