1REQUIRES: x86_64-linux
2
3The input raw profile test has been generated from the following source code:
4
5```
6#include <stdlib.h>
7#include <string.h>
8int main(int argc, char **argv) {
9  char *x = (char *)malloc(10);
10  memset(x, 0, 10);
11  free(x);
12  x = (char *)malloc(10);
13  memset(x, 0, 10);
14  free(x);
15  return 0;
16}
17```
18
19The following commands were used to compile the source to a memprof instrumented
20executable and collect a raw binary format profile. Since the profile contains
21virtual addresses for the callstack, we do not expect the raw binary profile to
22be deterministic. The summary should be deterministic apart from changes to
23the shared libraries linked in which could change the number of segments
24recorded.
25
26```
27clang -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
28
29env MEMPROF_OPTIONS=log_path=stdout ./rawprofile.out > basic.memprofraw
30```
31
32RUN: llvm-profdata show --memory %p/Inputs/basic.memprofraw -o - | FileCheck %s
33
34We expect 3 MIB entries, 1 each for the malloc calls in the program and one
35additional entry from a realloc in glibc/libio/vasprintf.c.
36
37CHECK: MemProf Profile 1
38CHECK:   Version: 1
39CHECK:   TotalSizeBytes: 1016
40CHECK:   NumSegments: 9
41CHECK:   NumMIBInfo: 3
42CHECK:   NumStackOffsets: 3
43