| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trace_event/heap_profiler_allocation_context_tracker.h" | 5 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| 11 #include "base/debug/debugging_flags.h" |
| 11 #include "base/debug/leak_annotations.h" | 12 #include "base/debug/leak_annotations.h" |
| 12 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 13 #include "base/threading/thread_local_storage.h" | 14 #include "base/threading/thread_local_storage.h" |
| 14 #include "base/trace_event/heap_profiler_allocation_context.h" | 15 #include "base/trace_event/heap_profiler_allocation_context.h" |
| 15 | 16 |
| 16 #if defined(OS_LINUX) || defined(OS_ANDROID) | 17 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 17 #include <sys/prctl.h> | 18 #include <sys/prctl.h> |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 200 } |
| 200 case CaptureMode::NATIVE_STACK: | 201 case CaptureMode::NATIVE_STACK: |
| 201 { | 202 { |
| 202 // Backtrace contract requires us to return bottom frames, i.e. | 203 // Backtrace contract requires us to return bottom frames, i.e. |
| 203 // from main() and up. Stack unwinding produces top frames, i.e. | 204 // from main() and up. Stack unwinding produces top frames, i.e. |
| 204 // from this point and up until main(). We request many frames to | 205 // from this point and up until main(). We request many frames to |
| 205 // make sure we reach main(), and then copy bottom portion of them. | 206 // make sure we reach main(), and then copy bottom portion of them. |
| 206 const void* frames[128]; | 207 const void* frames[128]; |
| 207 static_assert(arraysize(frames) >= Backtrace::kMaxFrameCount, | 208 static_assert(arraysize(frames) >= Backtrace::kMaxFrameCount, |
| 208 "not requesting enough frames to fill Backtrace"); | 209 "not requesting enough frames to fill Backtrace"); |
| 209 #if HAVE_TRACE_STACK_FRAME_POINTERS && !defined(OS_NACL) | 210 #if BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) && !defined(OS_NACL) |
| 210 size_t frame_count = debug::TraceStackFramePointers( | 211 size_t frame_count = debug::TraceStackFramePointers( |
| 211 frames, | 212 frames, |
| 212 arraysize(frames), | 213 arraysize(frames), |
| 213 1 /* exclude this function from the trace */ ); | 214 1 /* exclude this function from the trace */ ); |
| 214 #else | 215 #else |
| 215 size_t frame_count = 0; | 216 size_t frame_count = 0; |
| 216 NOTREACHED(); | 217 NOTREACHED(); |
| 217 #endif | 218 #endif |
| 218 | 219 |
| 219 // Copy frames backwards | 220 // Copy frames backwards |
| (...skipping 21 matching lines...) Expand all Loading... |
| 241 ctx->type_name = pseudo_stack_.back().trace_event_category; | 242 ctx->type_name = pseudo_stack_.back().trace_event_category; |
| 242 } else { | 243 } else { |
| 243 ctx->type_name = nullptr; | 244 ctx->type_name = nullptr; |
| 244 } | 245 } |
| 245 | 246 |
| 246 return true; | 247 return true; |
| 247 } | 248 } |
| 248 | 249 |
| 249 } // namespace trace_event | 250 } // namespace trace_event |
| 250 } // namespace base | 251 } // namespace base |
| OLD | NEW |