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 #include <string> |
10 | 11 |
11 #include "base/base_export.h" | 12 #include "base/base_export.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 | 14 |
14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
15 struct _EXCEPTION_POINTERS; | 16 struct _EXCEPTION_POINTERS; |
16 #endif | 17 #endif |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 namespace debug { | 20 namespace debug { |
(...skipping 25 matching lines...) Expand all Loading... |
45 // Gets an array of instruction pointer values. |*count| will be set to the | 46 // Gets an array of instruction pointer values. |*count| will be set to the |
46 // number of elements in the returned array. | 47 // number of elements in the returned array. |
47 const void* const* Addresses(size_t* count) const; | 48 const void* const* Addresses(size_t* count) const; |
48 | 49 |
49 // Prints a backtrace to stderr | 50 // Prints a backtrace to stderr |
50 void PrintBacktrace() const; | 51 void PrintBacktrace() const; |
51 | 52 |
52 // Resolves backtrace to symbols and write to stream. | 53 // Resolves backtrace to symbols and write to stream. |
53 void OutputToStream(std::ostream* os) const; | 54 void OutputToStream(std::ostream* os) const; |
54 | 55 |
| 56 // Resolves backtrace to symbols and returns as string. |
| 57 std::string ToString() const; |
| 58 |
55 private: | 59 private: |
56 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, | 60 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, |
57 // the sum of FramesToSkip and FramesToCapture must be less than 63, | 61 // the sum of FramesToSkip and FramesToCapture must be less than 63, |
58 // so set it to 62. Even if on POSIX it could be a larger value, it usually | 62 // so set it to 62. Even if on POSIX it could be a larger value, it usually |
59 // doesn't give much more information. | 63 // doesn't give much more information. |
60 static const int kMaxTraces = 62; | 64 static const int kMaxTraces = 62; |
61 | 65 |
62 void* trace_[kMaxTraces]; | 66 void* trace_[kMaxTraces]; |
63 int count_; | 67 int count_; |
64 }; | 68 }; |
65 | 69 |
66 } // namespace debug | 70 } // namespace debug |
67 } // namespace base | 71 } // namespace base |
68 | 72 |
69 #endif // BASE_DEBUG_STACK_TRACE_H_ | 73 #endif // BASE_DEBUG_STACK_TRACE_H_ |
OLD | NEW |