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 -no-pie \ 32 source.c -o multi.memprofexe 33 34env MEMPROF_OPTIONS=log_path=stdout ./multi.memprofexe > multi.memprofraw 35``` 36 37RUN: llvm-profdata show --memory %p/Inputs/multi.memprofraw --profiled-binary %p/Inputs/multi.memprofexe -o - | FileCheck %s 38 39We expect 2 MIB entries, 1 each for the malloc calls in the program. 40 41CHECK: MemprofProfile: 42CHECK-NEXT: Summary: 43CHECK-NEXT: Version: 1 44CHECK-NEXT: NumSegments: 9 45CHECK-NEXT: NumMibInfo: 2 46CHECK-NEXT: NumAllocFunctions: 1 47CHECK-NEXT: NumStackOffsets: 2 48 49CHECK: SymbolName: main 50CHECK-NEXT: LineOffset: 1 51CHECK-NEXT: Column: 21 52 53CHECK: SymbolName: main 54CHECK-NEXT: LineOffset: 5 55CHECK-NEXT: Column: 15 56