OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_DEBUG_STACK_TRACE_H_ | 5 #ifndef BASE_DEBUG_STACK_TRACE_H_ |
6 #define BASE_DEBUG_STACK_TRACE_H_ | 6 #define BASE_DEBUG_STACK_TRACE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 | 10 |
11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
15 struct _EXCEPTION_POINTERS; | 15 struct _EXCEPTION_POINTERS; |
16 #endif | 16 #endif |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 namespace debug { | 19 namespace debug { |
20 | 20 |
21 // A stacktrace can be helpful in debugging. For example, you can include a | 21 // A stacktrace can be helpful in debugging. For example, you can include a |
22 // stacktrace member in a object (probably around #ifndef NDEBUG) so that you | 22 // stacktrace member in a object (probably around #ifndef NDEBUG) so that you |
23 // can later see where the given object was created from. | 23 // can later see where the given object was created from. |
24 class BASE_EXPORT StackTrace { | 24 class BASE_EXPORT StackTrace { |
25 public: | 25 public: |
26 // Creates a stacktrace from the current location. | 26 // Creates a stacktrace from the current location. |
27 StackTrace(); | 27 StackTrace(); |
28 | 28 |
29 // Creates a stacktrace from an existing buffer gotten elsewhere. | |
30 // Useful for sharing PrintBacktrace(). | |
31 StackTrace(const void* const* trace, int count); | |
Mark Mentovai
2011/08/27 00:29:02
Since this is part of the public interface now, yo
Scott Hess - ex-Googler
2011/08/27 05:15:40
OK, I'll document it as accepting an array of inst
| |
32 | |
29 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
30 // Creates a stacktrace for an exception. | 34 // Creates a stacktrace for an exception. |
31 // Note: this function will throw an import not found (StackWalk64) exception | 35 // Note: this function will throw an import not found (StackWalk64) exception |
32 // on system without dbghelp 5.1. | 36 // on system without dbghelp 5.1. |
33 StackTrace(_EXCEPTION_POINTERS* exception_pointers); | 37 StackTrace(_EXCEPTION_POINTERS* exception_pointers); |
34 #endif | 38 #endif |
35 | 39 |
36 // Copying and assignment are allowed with the default functions. | 40 // Copying and assignment are allowed with the default functions. |
37 | 41 |
38 ~StackTrace(); | 42 ~StackTrace(); |
(...skipping 16 matching lines...) Expand all Loading... | |
55 static const int kMaxTraces = 62; | 59 static const int kMaxTraces = 62; |
56 | 60 |
57 void* trace_[kMaxTraces]; | 61 void* trace_[kMaxTraces]; |
58 int count_; | 62 int count_; |
59 }; | 63 }; |
60 | 64 |
61 } // namespace debug | 65 } // namespace debug |
62 } // namespace base | 66 } // namespace base |
63 | 67 |
64 #endif // BASE_DEBUG_STACK_TRACE_H_ | 68 #endif // BASE_DEBUG_STACK_TRACE_H_ |
OLD | NEW |