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

Side by Side Diff: chrome/browser/chromeos/libc_close_tracking.cc

Issue 2757123002: Cleaner fall-back stack capture for --enable-heap-profiling=native. (Closed)
Patch Set: Fix OS_NACL Created 3 years, 9 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <sys/syscall.h> 6 #include <sys/syscall.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const int ret = IGNORE_EINTR(syscall(SYS_close, fd)); 112 const int ret = IGNORE_EINTR(syscall(SYS_close, fd));
113 // Captures errno and restores it later in case it is changed. 113 // Captures errno and restores it later in case it is changed.
114 const ErrnoCapture close_errno; 114 const ErrnoCapture close_errno;
115 115
116 // Return if tracking is not enabled for the current process. 116 // Return if tracking is not enabled for the current process.
117 if (!g_stack_tracker || !g_stack_tracker->ShouldTrack()) 117 if (!g_stack_tracker || !g_stack_tracker->ShouldTrack())
118 return ret; 118 return ret;
119 119
120 // Capture stack for successful close. 120 // Capture stack for successful close.
121 if (ret == 0) { 121 if (ret == 0) {
122 #if HAVE_TRACE_STACK_FRAME_POINTERS && !defined(MEMORY_SANITIZER) 122 #if HAVE_TRACE_STACK_FRAME_POINTERS() && !defined(MEMORY_SANITIZER)
123 // Use TraceStackFramePointers because the backtrack() based default 123 // Use TraceStackFramePointers because the backtrack() based default
124 // capturing gets only the last stack frame and is not useful. 124 // capturing gets only the last stack frame and is not useful.
125 // With the exception of when MSAN is enabled. See comments for why 125 // With the exception of when MSAN is enabled. See comments for why
126 // StackTraceTest.TraceStackFramePointers is disabled in MSAN builds. 126 // StackTraceTest.TraceStackFramePointers is disabled in MSAN builds.
127 const void* frames[64]; 127 const void* frames[64];
128 const size_t frame_count = 128 const size_t frame_count =
129 base::debug::TraceStackFramePointers(frames, arraysize(frames), 0); 129 base::debug::TraceStackFramePointers(frames, arraysize(frames), 0);
130 g_stack_tracker->SetStack(fd, base::debug::StackTrace(frames, frame_count)); 130 g_stack_tracker->SetStack(fd, base::debug::StackTrace(frames, frame_count));
131 #else 131 #else
132 // Use default StackTrace when TraceStackFramePointers is not available. 132 // Use default StackTrace when TraceStackFramePointers is not available.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const base::debug::StackTrace* GetLastCloseStackForTest(int fd) { 178 const base::debug::StackTrace* GetLastCloseStackForTest(int fd) {
179 return g_stack_tracker ? g_stack_tracker->GetStack(fd) : nullptr; 179 return g_stack_tracker ? g_stack_tracker->GetStack(fd) : nullptr;
180 } 180 }
181 181
182 void SetCloseTrackingIgnorePidForTest(bool ignore_pid) { 182 void SetCloseTrackingIgnorePidForTest(bool ignore_pid) {
183 DCHECK(g_stack_tracker); 183 DCHECK(g_stack_tracker);
184 g_stack_tracker->set_ignore_pid(ignore_pid); 184 g_stack_tracker->set_ignore_pid(ignore_pid);
185 } 185 }
186 186
187 } // namespace chromeos 187 } // namespace chromeos
OLDNEW
« base/trace_event/memory_dump_manager.cc ('K') | « base/trace_event/memory_dump_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698