diff --git a/compiler-rt/lib/memprof/memprof_allocator.cpp b/compiler-rt/lib/memprof/memprof_allocator.cpp --- a/compiler-rt/lib/memprof/memprof_allocator.cpp +++ b/compiler-rt/lib/memprof/memprof_allocator.cpp @@ -252,6 +252,8 @@ InsertLiveBlocks(); if (print_text) { + if (!flags()->print_terse) + Printf("Recorded MIBs (incl. live on exit):\n"); MIBMap.ForEach(PrintCallback, reinterpret_cast(flags()->print_terse)); StackDepotPrintAll(); @@ -288,6 +290,10 @@ MemInfoBlock newMIB(user_requested_size, c, m->timestamp_ms, curtime, m->cpu_id, GetCpuId()); InsertOrMerge(m->alloc_context_id, newMIB, A->MIBMap); + // Lookup the flag here since the c-style callback doesn't allow + // capturing the print_text member easily. + if (flags()->print_text) + newMIB.Print(m->alloc_context_id, flags()->print_terse); }, this); } diff --git a/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp b/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp --- a/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp +++ b/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx_memprof %s -o %t +// RUN: %clangxx_memprof -Wl,-build-id %s -o %t // RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck --check-prefix=CHECK-TEXT %s // RUN: %env_memprof_opts=print_text=true:log_path=stdout,print_text=false %run %t > %t.memprofraw @@ -19,8 +19,16 @@ } // We should get 2 rounds of profile info, one from the explicit dump request, // and one at exit. +// +// CHECK-TEXT: Live on exit: +// CHECK-TEXT: Memory allocation stack id +// CHECK-TEXT: Recorded MIBs (incl. live on exit): // CHECK-TEXT: Memory allocation stack id // CHECK-TEXT: Stack for id +// +// CHECK-TEXT: Live on exit: +// CHECK-TEXT: Memory allocation stack id +// CHECK-TEXT: Recorded MIBs (incl. live on exit): // CHECK-TEXT: Memory allocation stack id // CHECK-TEXT: Stack for id //