| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/stack_trace.h" | 5 #include "base/debug/stack_trace.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 uintptr_t fp = reinterpret_cast<uintptr_t>(fpp) - kStackFrameAdjustment; | 185 uintptr_t fp = reinterpret_cast<uintptr_t>(fpp) - kStackFrameAdjustment; |
| 186 void* prev_parent_fp = reinterpret_cast<void**>(fp)[0]; | 186 void* prev_parent_fp = reinterpret_cast<void**>(fp)[0]; |
| 187 reinterpret_cast<void**>(fp)[0] = parent_fp; | 187 reinterpret_cast<void**>(fp)[0] = parent_fp; |
| 188 return prev_parent_fp; | 188 return prev_parent_fp; |
| 189 } | 189 } |
| 190 | 190 |
| 191 #endif // HAVE_TRACE_STACK_FRAME_POINTERS | 191 #endif // HAVE_TRACE_STACK_FRAME_POINTERS |
| 192 | 192 |
| 193 } // namespace | 193 } // namespace |
| 194 | 194 |
| 195 StackTrace::StackTrace() : StackTrace(arraysize(trace_)) {} |
| 196 |
| 195 StackTrace::StackTrace(const void* const* trace, size_t count) { | 197 StackTrace::StackTrace(const void* const* trace, size_t count) { |
| 196 count = std::min(count, arraysize(trace_)); | 198 count = std::min(count, arraysize(trace_)); |
| 197 if (count) | 199 if (count) |
| 198 memcpy(trace_, trace, count * sizeof(trace_[0])); | 200 memcpy(trace_, trace, count * sizeof(trace_[0])); |
| 199 count_ = count; | 201 count_ = count; |
| 200 } | 202 } |
| 201 | 203 |
| 202 StackTrace::~StackTrace() { | |
| 203 } | |
| 204 | |
| 205 const void *const *StackTrace::Addresses(size_t* count) const { | 204 const void *const *StackTrace::Addresses(size_t* count) const { |
| 206 *count = count_; | 205 *count = count_; |
| 207 if (count_) | 206 if (count_) |
| 208 return trace_; | 207 return trace_; |
| 209 return NULL; | 208 return NULL; |
| 210 } | 209 } |
| 211 | 210 |
| 212 std::string StackTrace::ToString() const { | 211 std::string StackTrace::ToString() const { |
| 213 std::stringstream stream; | 212 std::stringstream stream; |
| 214 #if !defined(__UCLIBC__) | 213 #if !defined(__UCLIBC__) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 ScopedStackFrameLinker::~ScopedStackFrameLinker() { | 264 ScopedStackFrameLinker::~ScopedStackFrameLinker() { |
| 266 void* previous_parent_fp = LinkStackFrames(fp_, original_parent_fp_); | 265 void* previous_parent_fp = LinkStackFrames(fp_, original_parent_fp_); |
| 267 CHECK_EQ(parent_fp_, previous_parent_fp) | 266 CHECK_EQ(parent_fp_, previous_parent_fp) |
| 268 << "Stack frame's parent pointer has changed!"; | 267 << "Stack frame's parent pointer has changed!"; |
| 269 } | 268 } |
| 270 | 269 |
| 271 #endif // HAVE_TRACE_STACK_FRAME_POINTERS | 270 #endif // HAVE_TRACE_STACK_FRAME_POINTERS |
| 272 | 271 |
| 273 } // namespace debug | 272 } // namespace debug |
| 274 } // namespace base | 273 } // namespace base |
| OLD | NEW |