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 #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 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <iosfwd> | 10 #include <iosfwd> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 BASE_EXPORT bool EnableInProcessStackDumping(); | 46 BASE_EXPORT bool EnableInProcessStackDumping(); |
47 | 47 |
48 // A stacktrace can be helpful in debugging. For example, you can include a | 48 // A stacktrace can be helpful in debugging. For example, you can include a |
49 // stacktrace member in a object (probably around #ifndef NDEBUG) so that you | 49 // stacktrace member in a object (probably around #ifndef NDEBUG) so that you |
50 // can later see where the given object was created from. | 50 // can later see where the given object was created from. |
51 class BASE_EXPORT StackTrace { | 51 class BASE_EXPORT StackTrace { |
52 public: | 52 public: |
53 // Creates a stacktrace from the current location. | 53 // Creates a stacktrace from the current location. |
54 StackTrace(); | 54 StackTrace(); |
55 | 55 |
| 56 // Creates a stacktrace from the current location, of up to |count| entries. |
| 57 // |count| will be limited to at most |kMaxTraces|. |
| 58 explicit StackTrace(size_t count); |
| 59 |
56 // Creates a stacktrace from an existing array of instruction | 60 // Creates a stacktrace from an existing array of instruction |
57 // pointers (such as returned by Addresses()). |count| will be | 61 // pointers (such as returned by Addresses()). |count| will be |
58 // trimmed to |kMaxTraces|. | 62 // limited to at most |kMaxTraces|. |
59 StackTrace(const void* const* trace, size_t count); | 63 StackTrace(const void* const* trace, size_t count); |
60 | 64 |
61 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
62 // Creates a stacktrace for an exception. | 66 // Creates a stacktrace for an exception. |
63 // Note: this function will throw an import not found (StackWalk64) exception | 67 // Note: this function will throw an import not found (StackWalk64) exception |
64 // on system without dbghelp 5.1. | 68 // on system without dbghelp 5.1. |
65 StackTrace(_EXCEPTION_POINTERS* exception_pointers); | 69 StackTrace(_EXCEPTION_POINTERS* exception_pointers); |
66 StackTrace(const _CONTEXT* context); | 70 StackTrace(const _CONTEXT* context); |
67 #endif | 71 #endif |
68 | 72 |
69 // Copying and assignment are allowed with the default functions. | 73 // Copying and assignment are allowed with the default functions. |
70 | 74 |
71 ~StackTrace(); | |
72 | |
73 // Gets an array of instruction pointer values. |*count| will be set to the | 75 // Gets an array of instruction pointer values. |*count| will be set to the |
74 // number of elements in the returned array. | 76 // number of elements in the returned array. |
75 const void* const* Addresses(size_t* count) const; | 77 const void* const* Addresses(size_t* count) const; |
76 | 78 |
77 // Prints the stack trace to stderr. | 79 // Prints the stack trace to stderr. |
78 void Print() const; | 80 void Print() const; |
79 | 81 |
80 #if !defined(__UCLIBC__) | 82 #if !defined(__UCLIBC__) |
81 // Resolves backtrace to symbols and write to stream. | 83 // Resolves backtrace to symbols and write to stream. |
82 void OutputToStream(std::ostream* os) const; | 84 void OutputToStream(std::ostream* os) const; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 int base, | 184 int base, |
183 size_t padding); | 185 size_t padding); |
184 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) | 186 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) |
185 | 187 |
186 } // namespace internal | 188 } // namespace internal |
187 | 189 |
188 } // namespace debug | 190 } // namespace debug |
189 } // namespace base | 191 } // namespace base |
190 | 192 |
191 #endif // BASE_DEBUG_STACK_TRACE_H_ | 193 #endif // BASE_DEBUG_STACK_TRACE_H_ |
OLD | NEW |