31 lines · cpp
1// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s2 3// This is actually:4// Memory allocation stack id = STACKID5// alloc_count 1, size (ave/min/max) 128.00 / 128 / 1286// but we need to look for them in the same CHECK to get the correct STACKID.7// CHECK: Memory allocation stack id = [[STACKID:[0-9]+]]{{[[:space:]].*}}alloc_count 1, size (ave/min/max) 128.00 / 128 / 1288// CHECK-NEXT: access_count (ave/min/max): 22.00 / 22 / 229 10#include <sanitizer/memprof_interface.h>11 12#include <stdlib.h>13#include <string.h>14int main(int argc, char **argv) {15 // CHECK: Stack for id [[STACKID]]:16 // CHECK-NEXT: #0 {{.*}} in operator new[](unsigned long)17 // CHECK-NEXT: #1 {{.*}} in main {{.*}}:[[@LINE+1]]18 char *x = new char[128];19 memset(x, 0xab, 128);20 __sanitizer_unaligned_load16(x + 15);21 __sanitizer_unaligned_load32(x + 15);22 __sanitizer_unaligned_load64(x + 15);23 24 __sanitizer_unaligned_store16(x + 15, 0);25 __sanitizer_unaligned_store32(x + 15, 0);26 __sanitizer_unaligned_store64(x + 15, 0);27 28 delete[] x;29 return 0;30}31