brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · be0f5d5 Raw
34 lines · cpp
1// RUN: %clangxx_memprof %s -o %t2 3// RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck --check-prefix=CHECK-TEXT %s4// RUN: %env_memprof_opts=log_path=stdout %run %t > %t.memprofraw5// RUN: od -c -N 8 %t.memprofraw | FileCheck --check-prefix=CHECK-RAW %s6 7#include <sanitizer/memprof_interface.h>8#include <stdlib.h>9#include <string.h>10int main(int argc, char **argv) {11  char *x = (char *)malloc(10);12  memset(x, 0, 10);13  free(x);14  __memprof_profile_dump();15  x = (char *)malloc(10);16  memset(x, 0, 10);17  free(x);18  return 0;19}20// We should get 2 rounds of profile info, one from the explicit dump request,21// and one at exit.22//23// CHECK-TEXT: Recorded MIBs (incl. live on exit):24// CHECK-TEXT: Memory allocation stack id25// CHECK-TEXT: Stack for id26//27// CHECK-TEXT: Recorded MIBs (incl. live on exit):28// CHECK-TEXT: Memory allocation stack id29// CHECK-TEXT: Stack for id30//31// For the raw profile just check the header magic. The following check assumes that memprof32// runs on little endian architectures.33// CHECK-RAW: 0000000 201   r   f   o   r   p   m 37734