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