Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / memprof / TestCases / memprof_profile_dump.cpp
blobbe0f5d5e113f4884e3a29db87998ab00db021b39
1 // RUN: %clangxx_memprof %s -o %t
3 // RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck --check-prefix=CHECK-TEXT %s
4 // RUN: %env_memprof_opts=log_path=stdout %run %t > %t.memprofraw
5 // RUN: od -c -N 8 %t.memprofraw | FileCheck --check-prefix=CHECK-RAW %s
7 #include <sanitizer/memprof_interface.h>
8 #include <stdlib.h>
9 #include <string.h>
10 int 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;
20 // We should get 2 rounds of profile info, one from the explicit dump request,
21 // and one at exit.
23 // CHECK-TEXT: Recorded MIBs (incl. live on exit):
24 // CHECK-TEXT: Memory allocation stack id
25 // CHECK-TEXT: Stack for id
27 // CHECK-TEXT: Recorded MIBs (incl. live on exit):
28 // CHECK-TEXT: Memory allocation stack id
29 // CHECK-TEXT: Stack for id
31 // For the raw profile just check the header magic. The following check assumes that memprof
32 // runs on little endian architectures.
33 // CHECK-RAW: 0000000 201 r f o r p m 377