Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: runtime/vm/malloc_hooks_test.cc

Issue 3001473002: [vm] Fix flaky crash in StackTraceMallocHookLengthTest. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && !defined(TARGET_ARCH_DBC) 7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && !defined(TARGET_ARCH_DBC)
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 12 matching lines...) Expand all
23 for (uintptr_t i = 0; i < size; ++i) { 23 for (uintptr_t i = 0; i < size; ++i) {
24 buffer[i] = i; 24 buffer[i] = i;
25 } 25 }
26 } 26 }
27 27
28 class EnableMallocHooksScope : public ValueObject { 28 class EnableMallocHooksScope : public ValueObject {
29 public: 29 public:
30 EnableMallocHooksScope() { 30 EnableMallocHooksScope() {
31 saved_enable_malloc_hooks_ = FLAG_profiler_native_memory; 31 saved_enable_malloc_hooks_ = FLAG_profiler_native_memory;
32 FLAG_profiler_native_memory = true; 32 FLAG_profiler_native_memory = true;
33 Profiler::InitAllocationSampleBuffer();
34 MallocHooks::InitOnce(); 33 MallocHooks::InitOnce();
35 MallocHooks::ResetStats(); 34 MallocHooks::ResetStats();
36 } 35 }
37 36
38 ~EnableMallocHooksScope() { 37 ~EnableMallocHooksScope() {
39 MallocHooks::TearDown(); 38 MallocHooks::TearDown();
40 FLAG_profiler_native_memory = saved_enable_malloc_hooks_; 39 FLAG_profiler_native_memory = saved_enable_malloc_hooks_;
41 } 40 }
42 41
43 private: 42 private:
44 bool saved_enable_malloc_hooks_; 43 bool saved_enable_malloc_hooks_;
45 }; 44 };
46 45
47 class EnableMallocHooksAndStacksScope : public EnableMallocHooksScope { 46 class EnableMallocHooksAndStacksScope : public EnableMallocHooksScope {
48 public: 47 public:
49 EnableMallocHooksAndStacksScope() { 48 EnableMallocHooksAndStacksScope() {
50 saved_enable_stack_traces_ = MallocHooks::stack_trace_collection_enabled(); 49 saved_enable_stack_traces_ = MallocHooks::stack_trace_collection_enabled();
51 MallocHooks::set_stack_trace_collection_enabled(true); 50 MallocHooks::set_stack_trace_collection_enabled(true);
52 if (!FLAG_profiler) { 51 if (!FLAG_profiler) {
53 FLAG_profiler = true; 52 FLAG_profiler = true;
54 Profiler::InitOnce(); 53 Profiler::InitOnce();
55 } 54 }
55 MallocHooks::ResetStats();
56 } 56 }
57 57
58 ~EnableMallocHooksAndStacksScope() { 58 ~EnableMallocHooksAndStacksScope() {
59 MallocHooks::set_stack_trace_collection_enabled(saved_enable_stack_traces_); 59 MallocHooks::set_stack_trace_collection_enabled(saved_enable_stack_traces_);
60 } 60 }
61 61
62 private: 62 private:
63 bool saved_enable_stack_traces_; 63 bool saved_enable_stack_traces_;
64 }; 64 };
65 65
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 EXPECT_SUBSTRING("\"dart::TestCase::Run()\"", json); 190 EXPECT_SUBSTRING("\"dart::TestCase::Run()\"", json);
191 EXPECT_SUBSTRING("\"dart::TestCaseBase::RunTest()\"", json); 191 EXPECT_SUBSTRING("\"dart::TestCaseBase::RunTest()\"", json);
192 EXPECT_SUBSTRING("\"main\"", json); 192 EXPECT_SUBSTRING("\"main\"", json);
193 193
194 free(var); 194 free(var);
195 } 195 }
196 196
197 }; // namespace dart 197 }; // namespace dart
198 198
199 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) 199 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698