[memprof] Make the raw binary format the default.

Set the default memprof serialization format as binary. 9 tests are
updated to use print_text=true. Also fixed an issue with concatenation
of default and test specified options (missing separator).

Differential Revision: https://reviews.llvm.org/D113617
This commit is contained in:
Snehasish Kumar 2021-11-10 14:37:15 -08:00
parent 545866cb05
commit aacaebc6c2
14 changed files with 32 additions and 31 deletions

View File

@ -35,7 +35,7 @@ MEMPROF_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true,
"realloc(p, 0) is equivalent to free(p) by default (Same as the " "realloc(p, 0) is equivalent to free(p) by default (Same as the "
"POSIX standard). If set to false, realloc(p, 0) will return a " "POSIX standard). If set to false, realloc(p, 0) will return a "
"pointer to an allocated space which can not be used.") "pointer to an allocated space which can not be used.")
MEMPROF_FLAG(bool, print_text, true, MEMPROF_FLAG(bool, print_text, false,
"If set, prints the heap profile in text format. Else use the raw binary serialization format.") "If set, prints the heap profile in text format. Else use the raw binary serialization format.")
MEMPROF_FLAG(bool, print_terse, false, MEMPROF_FLAG(bool, print_terse, false,
"If set, prints memory profile in a terse format. Only applicable if print_text = true.") "If set, prints memory profile in a terse format. Only applicable if print_text = true.")

View File

@ -1,8 +1,8 @@
// Check atexit option. // Check atexit option.
// RUN: %clangxx_memprof -O0 %s -o %t // RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr:atexit=1 %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr:atexit=1 %run %t 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=log_path=stderr:atexit=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOATEXIT // RUN: %env_memprof_opts=print_text=true:log_path=stderr:atexit=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOATEXIT
// CHECK: MemProfiler exit stats: // CHECK: MemProfiler exit stats:
// CHECK: Stats: {{[0-9]+}}M malloced ({{[0-9]+}}M for overhead) by {{[0-9]+}} calls // CHECK: Stats: {{[0-9]+}}M malloced ({{[0-9]+}}M for overhead) by {{[0-9]+}} calls

View File

@ -1,8 +1,8 @@
// Check print_module_map option. // Check print_module_map option.
// RUN: %clangxx_memprof -O0 %s -o %t // RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr:print_module_map=1 %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_module_map=1 %run %t 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=log_path=stderr:print_module_map=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOMAP // RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_module_map=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOMAP
// CHECK: Process memory map follows: // CHECK: Process memory map follows:
// CHECK: dump_process_map.cpp.tmp // CHECK: dump_process_map.cpp.tmp

View File

@ -3,19 +3,19 @@
// //
// RUN: %clangxx_memprof %s -o %t // RUN: %clangxx_memprof %s -o %t
// stderr log_path // stderr print_text=true:log_path
// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always // RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always
// Good log_path. // Good print_text=true:log_path.
// RUN: rm -f %t.log.* // RUN: rm -f %t.log.*
// RUN: %env_memprof_opts=log_path=%t.log %run %t // RUN: %env_memprof_opts=print_text=true:log_path=%t.log %run %t
// RUN: FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always < %t.log.* // RUN: FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always < %t.log.*
// Invalid log_path. // Invalid print_text=true:log_path.
// RUN: %env_memprof_opts=log_path=/dev/null/INVALID not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID --dump-input=always // RUN: %env_memprof_opts=print_text=true:log_path=/dev/null/INVALID not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID --dump-input=always
// Too long log_path. // Too long print_text=true:log_path.
// RUN: %env_memprof_opts=log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \ // RUN: %env_memprof_opts=print_text=true:log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LONG --dump-input=always // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LONG --dump-input=always
// Specifying the log name via the __memprof_profile_filename variable. // Specifying the log name via the __memprof_profile_filename variable.

View File

@ -1,8 +1,8 @@
// RUN: %clangxx_memprof -O0 %s -o %t // RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SUMMARY // RUN: %env_memprof_opts=print_text=true:log_path=stderr:allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SUMMARY
// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL // RUN: %env_memprof_opts=print_text=true:log_path=stderr:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
// Test print_summary // Test print_summary
// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=0:print_summary=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOSUMMARY // RUN: %env_memprof_opts=print_text=true:log_path=stderr:allocator_may_return_null=0:print_summary=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOSUMMARY
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,6 +1,6 @@
// RUN: %clangxx_memprof %s -o %t // RUN: %clangxx_memprof %s -o %t
// RUN: %env_memprof_opts=log_path=stdout %run %t | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck %s
#include <sanitizer/memprof_interface.h> #include <sanitizer/memprof_interface.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,7 @@
// RUN: %clangxx_memprof %s -o %t // RUN: %clangxx_memprof %s -o %t
// RUN: %env_memprof_opts=log_path=stdout %run %t | FileCheck --check-prefix=CHECK-TEXT %s // RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck --check-prefix=CHECK-TEXT %s
// RUN: %env_memprof_opts=log_path=stdout,print_text=false %run %t > %t.memprofraw // RUN: %env_memprof_opts=print_text=true:log_path=stdout,print_text=false %run %t > %t.memprofraw
// RUN: od -c -N 8 %t.memprofraw | FileCheck --check-prefix=CHECK-RAW %s // RUN: od -c -N 8 %t.memprofraw | FileCheck --check-prefix=CHECK-RAW %s
#include <sanitizer/memprof_interface.h> #include <sanitizer/memprof_interface.h>

View File

@ -7,9 +7,9 @@
// RUN: %clang_memprof %s -ldl -pthread -o %t // RUN: %clang_memprof %s -ldl -pthread -o %t
// RUN: %run %t 0 3 // RUN: %run %t 0 3
// RUN: %run %t 2 3 // RUN: %run %t 2 3
// RUN: %env_memprof_opts=log_path=stderr:verbosity=2 %run %t 10 2 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr:verbosity=2 %run %t 10 2 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=log_path=stderr:verbosity=2:intercept_tls_get_addr=1 %run %t 10 2 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr:verbosity=2:intercept_tls_get_addr=1 %run %t 10 2 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=log_path=stderr:verbosity=2:intercept_tls_get_addr=0 %run %t 10 2 2>&1 | FileCheck %s --check-prefix=CHECK0 // RUN: %env_memprof_opts=print_text=true:log_path=stderr:verbosity=2:intercept_tls_get_addr=0 %run %t 10 2 2>&1 | FileCheck %s --check-prefix=CHECK0
// CHECK: ==__tls_get_addr: // CHECK: ==__tls_get_addr:
// CHECK: Creating thread 0 // CHECK: Creating thread 0
// CHECK: ==__tls_get_addr: // CHECK: ==__tls_get_addr:

View File

@ -3,10 +3,10 @@
// before exit. // before exit.
// RUN: %clang_memprof -O0 %s -o %t // RUN: %clang_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s
// RUN: %clang_memprof -DFREE -O0 %s -o %t // RUN: %clang_memprof -DFREE -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s
// This is actually: // This is actually:
// Memory allocation stack id = STACKID // Memory allocation stack id = STACKID

View File

@ -1,6 +1,6 @@
// Check profile with calls to memory intrinsics. // Check profile with calls to memory intrinsics.
// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s
// This is actually: // This is actually:
// Memory allocation stack id = STACKIDP // Memory allocation stack id = STACKIDP

View File

@ -3,14 +3,14 @@
// before exit. // before exit.
// RUN: %clangxx_memprof -O0 %s -o %t // RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_memprof -DFREE -O0 %s -o %t // RUN: %clangxx_memprof -DFREE -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s
// Try again with callbacks instead of inline sequences // Try again with callbacks instead of inline sequences
// RUN: %clangxx_memprof -mllvm -memprof-use-callbacks -O0 %s -o %t // RUN: %clangxx_memprof -mllvm -memprof-use-callbacks -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s
// This is actually: // This is actually:
// Memory allocation stack id = STACKID // Memory allocation stack id = STACKID

View File

@ -3,10 +3,10 @@
// deallocated before exit. // deallocated before exit.
// RUN: %clangxx_memprof -O0 %s -o %t // RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_memprof -DFREE -O0 %s -o %t // RUN: %clangxx_memprof -DFREE -O0 %s -o %t
// RUN: %env_memprof_opts=log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s // RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s
// CHECK: MIB:[[STACKID:[0-9]+]]/1/40.00/40/40/20.00/20/20/[[AVELIFETIME:[0-9]+]].00/[[AVELIFETIME]]/[[AVELIFETIME]]/{{[01]}}/0/0/0 // CHECK: MIB:[[STACKID:[0-9]+]]/1/40.00/40/40/20.00/20/20/[[AVELIFETIME:[0-9]+]].00/[[AVELIFETIME]]/[[AVELIFETIME]]/{{[01]}}/0/0/0
// CHECK: Stack for id [[STACKID]]: // CHECK: Stack for id [[STACKID]]:

View File

@ -1,4 +1,4 @@
// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s
// This is actually: // This is actually:
// Memory allocation stack id = STACKID // Memory allocation stack id = STACKID

View File

@ -33,6 +33,7 @@ default_memprof_opts = list(config.default_sanitizer_opts)
default_memprof_opts_str = ':'.join(default_memprof_opts) default_memprof_opts_str = ':'.join(default_memprof_opts)
if default_memprof_opts_str: if default_memprof_opts_str:
config.environment['MEMPROF_OPTIONS'] = default_memprof_opts_str config.environment['MEMPROF_OPTIONS'] = default_memprof_opts_str
default_memprof_opts_str += ':'
config.substitutions.append(('%env_memprof_opts=', config.substitutions.append(('%env_memprof_opts=',
'env MEMPROF_OPTIONS=' + default_memprof_opts_str)) 'env MEMPROF_OPTIONS=' + default_memprof_opts_str))