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

Side by Side Diff: base/profiler/native_stack_sampler_mac.cc

Issue 2859303002: Work-around ASAN problem in profiler (Closed)
Patch Set: Created 3 years, 7 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "base/profiler/native_stack_sampler.h" 5 #include "base/profiler/native_stack_sampler.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <libkern/OSByteOrder.h> 8 #include <libkern/OSByteOrder.h>
9 #include <libunwind.h> 9 #include <libunwind.h>
10 #include <mach-o/swap.h> 10 #include <mach-o/swap.h>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const char* LibSystemKernelName() { 159 const char* LibSystemKernelName() {
160 static char path[PATH_MAX]; 160 static char path[PATH_MAX];
161 static char* name = nullptr; 161 static char* name = nullptr;
162 if (name) 162 if (name)
163 return name; 163 return name;
164 164
165 Dl_info info; 165 Dl_info info;
166 dladdr(reinterpret_cast<void*>(_exit), &info); 166 dladdr(reinterpret_cast<void*>(_exit), &info);
167 strncpy(path, info.dli_fname, PATH_MAX); 167 strncpy(path, info.dli_fname, PATH_MAX);
168 name = path; 168 name = path;
169
170 #if !defined(ADDRESS_SANITIZER)
169 DCHECK_EQ(std::string(name), 171 DCHECK_EQ(std::string(name),
170 std::string("/usr/lib/system/libsystem_kernel.dylib")); 172 std::string("/usr/lib/system/libsystem_kernel.dylib"));
173 #endif
171 return name; 174 return name;
172 } 175 }
173 176
174 // Walks the stack represented by |thread_state|, calling back to the provided 177 // Walks the stack represented by |thread_state|, calling back to the provided
175 // lambda for each frame. 178 // lambda for each frame.
176 template <typename StackFrameCallback> 179 template <typename StackFrameCallback>
177 void WalkStack(const x86_thread_state64_t& thread_state, 180 void WalkStack(const x86_thread_state64_t& thread_state,
178 uintptr_t stack_top, 181 uintptr_t stack_top,
179 const StackFrameCallback& callback) { 182 const StackFrameCallback& callback) {
180 size_t frame_count = 0; 183 size_t frame_count = 0;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 462
460 std::unique_ptr<NativeStackSampler> NativeStackSampler::Create( 463 std::unique_ptr<NativeStackSampler> NativeStackSampler::Create(
461 PlatformThreadId thread_id, 464 PlatformThreadId thread_id,
462 AnnotateCallback annotator, 465 AnnotateCallback annotator,
463 NativeStackSamplerTestDelegate* test_delegate) { 466 NativeStackSamplerTestDelegate* test_delegate) {
464 return base::MakeUnique<NativeStackSamplerMac>(thread_id, annotator, 467 return base::MakeUnique<NativeStackSamplerMac>(thread_id, annotator,
465 test_delegate); 468 test_delegate);
466 } 469 }
467 470
468 } // namespace base 471 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698