Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: base/debug/stack_trace.h

Issue 1446363003: Deleted OS_WIN and all Windows specific files from base. (Closed) Base URL: https://github.com/domokit/mojo.git@base_tests
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/debug/profiler.cc ('k') | base/debug/stack_trace_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
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_POSIX) 14 #if defined(OS_POSIX)
15 #include <unistd.h> 15 #include <unistd.h>
16 #endif 16 #endif
17 17
18 #if defined(OS_WIN)
19 struct _EXCEPTION_POINTERS;
20 struct _CONTEXT;
21 #endif
22
23 namespace base { 18 namespace base {
24 namespace debug { 19 namespace debug {
25 20
26 // Enables stack dump to console output on exception and signals. 21 // Enables stack dump to console output on exception and signals.
27 // When enabled, the process will quit immediately. This is meant to be used in 22 // When enabled, the process will quit immediately. This is meant to be used in
28 // unit_tests only! This is not thread-safe: only call from main thread. 23 // unit_tests only! This is not thread-safe: only call from main thread.
29 BASE_EXPORT bool EnableInProcessStackDumping(); 24 BASE_EXPORT bool EnableInProcessStackDumping();
30 25
31 // A different version of EnableInProcessStackDumping that also works for 26 // A different version of EnableInProcessStackDumping that also works for
32 // sandboxed processes. For more details take a look at the description 27 // sandboxed processes. For more details take a look at the description
(...skipping 10 matching lines...) Expand all
43 class BASE_EXPORT StackTrace { 38 class BASE_EXPORT StackTrace {
44 public: 39 public:
45 // Creates a stacktrace from the current location. 40 // Creates a stacktrace from the current location.
46 StackTrace(); 41 StackTrace();
47 42
48 // Creates a stacktrace from an existing array of instruction 43 // Creates a stacktrace from an existing array of instruction
49 // pointers (such as returned by Addresses()). |count| will be 44 // pointers (such as returned by Addresses()). |count| will be
50 // trimmed to |kMaxTraces|. 45 // trimmed to |kMaxTraces|.
51 StackTrace(const void* const* trace, size_t count); 46 StackTrace(const void* const* trace, size_t count);
52 47
53 #if defined(OS_WIN)
54 // Creates a stacktrace for an exception.
55 // Note: this function will throw an import not found (StackWalk64) exception
56 // on system without dbghelp 5.1.
57 StackTrace(const _EXCEPTION_POINTERS* exception_pointers);
58 StackTrace(const _CONTEXT* context);
59 #endif
60
61 // Copying and assignment are allowed with the default functions. 48 // Copying and assignment are allowed with the default functions.
62 49
63 ~StackTrace(); 50 ~StackTrace();
64 51
65 // Gets an array of instruction pointer values. |*count| will be set to the 52 // Gets an array of instruction pointer values. |*count| will be set to the
66 // number of elements in the returned array. 53 // number of elements in the returned array.
67 const void* const* Addresses(size_t* count) const; 54 const void* const* Addresses(size_t* count) const;
68 55
69 // Prints the stack trace to stderr. 56 // Prints the stack trace to stderr.
70 void Print() const; 57 void Print() const;
71 58
72 #if !defined(__UCLIBC__) 59 #if !defined(__UCLIBC__)
73 // Resolves backtrace to symbols and write to stream. 60 // Resolves backtrace to symbols and write to stream.
74 void OutputToStream(std::ostream* os) const; 61 void OutputToStream(std::ostream* os) const;
75 #endif 62 #endif
76 63
77 // Resolves backtrace to symbols and returns as string. 64 // Resolves backtrace to symbols and returns as string.
78 std::string ToString() const; 65 std::string ToString() const;
79 66
80 private: 67 private:
81 #if defined(OS_WIN)
82 void InitTrace(_CONTEXT* context_record);
83 #endif
84
85 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, 68 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx,
86 // the sum of FramesToSkip and FramesToCapture must be less than 63, 69 // the sum of FramesToSkip and FramesToCapture must be less than 63,
87 // so set it to 62. Even if on POSIX it could be a larger value, it usually 70 // so set it to 62. Even if on POSIX it could be a larger value, it usually
88 // doesn't give much more information. 71 // doesn't give much more information.
89 static const int kMaxTraces = 62; 72 static const int kMaxTraces = 62;
90 73
91 void* trace_[kMaxTraces]; 74 void* trace_[kMaxTraces];
92 75
93 // The number of valid frames in |trace_|. 76 // The number of valid frames in |trace_|.
94 size_t count_; 77 size_t count_;
(...skipping 14 matching lines...) Expand all
109 int base, 92 int base,
110 size_t padding); 93 size_t padding);
111 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) 94 #endif // defined(OS_POSIX) && !defined(OS_ANDROID)
112 95
113 } // namespace internal 96 } // namespace internal
114 97
115 } // namespace debug 98 } // namespace debug
116 } // namespace base 99 } // namespace base
117 100
118 #endif // BASE_DEBUG_STACK_TRACE_H_ 101 #endif // BASE_DEBUG_STACK_TRACE_H_
OLDNEW
« no previous file with comments | « base/debug/profiler.cc ('k') | base/debug/stack_trace_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698