Files
clang-p2996/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp
Teresa Johnson a75b2e87e6 [MemProf] Add interface to dump profile
Add an interface so that the profile can be dumped on demand.

Differential Revision: https://reviews.llvm.org/D91768
2020-11-19 10:21:53 -08:00

24 lines
598 B
C++

// RUN: %clangxx_memprof %s -o %t
// RUN: %env_memprof_opts=log_path=stdout %run %t | FileCheck %s
#include <sanitizer/memprof_interface.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
char *x = (char *)malloc(10);
memset(x, 0, 10);
free(x);
__memprof_profile_dump();
x = (char *)malloc(10);
memset(x, 0, 10);
free(x);
return 0;
}
// We should get 2 rounds of profile info, one from the explicit dump request,
// and one at exit.
// CHECK: Memory allocation stack id
// CHECK: Stack for id
// CHECK: Memory allocation stack id
// CHECK: Stack for id