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

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

Issue 1387913002: Copy the register context before calling StackWalk64 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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 | « no previous file | base/debug/stack_trace_win.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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Creates a stacktrace from an existing array of instruction 45 // Creates a stacktrace from an existing array of instruction
46 // pointers (such as returned by Addresses()). |count| will be 46 // pointers (such as returned by Addresses()). |count| will be
47 // trimmed to |kMaxTraces|. 47 // trimmed to |kMaxTraces|.
48 StackTrace(const void* const* trace, size_t count); 48 StackTrace(const void* const* trace, size_t count);
49 49
50 #if defined(OS_WIN) 50 #if defined(OS_WIN)
51 // Creates a stacktrace for an exception. 51 // Creates a stacktrace for an exception.
52 // Note: this function will throw an import not found (StackWalk64) exception 52 // Note: this function will throw an import not found (StackWalk64) exception
53 // on system without dbghelp 5.1. 53 // on system without dbghelp 5.1.
54 StackTrace(_EXCEPTION_POINTERS* exception_pointers); 54 StackTrace(_EXCEPTION_POINTERS* exception_pointers);
55 StackTrace(_CONTEXT* context); 55 StackTrace(const _CONTEXT* context);
56 #endif 56 #endif
57 57
58 // Copying and assignment are allowed with the default functions. 58 // Copying and assignment are allowed with the default functions.
59 59
60 ~StackTrace(); 60 ~StackTrace();
61 61
62 // Gets an array of instruction pointer values. |*count| will be set to the 62 // Gets an array of instruction pointer values. |*count| will be set to the
63 // number of elements in the returned array. 63 // number of elements in the returned array.
64 const void* const* Addresses(size_t* count) const; 64 const void* const* Addresses(size_t* count) const;
65 65
66 // Prints the stack trace to stderr. 66 // Prints the stack trace to stderr.
67 void Print() const; 67 void Print() const;
68 68
69 #if !defined(__UCLIBC__) 69 #if !defined(__UCLIBC__)
70 // Resolves backtrace to symbols and write to stream. 70 // Resolves backtrace to symbols and write to stream.
71 void OutputToStream(std::ostream* os) const; 71 void OutputToStream(std::ostream* os) const;
72 #endif 72 #endif
73 73
74 // Resolves backtrace to symbols and returns as string. 74 // Resolves backtrace to symbols and returns as string.
75 std::string ToString() const; 75 std::string ToString() const;
76 76
77 private: 77 private:
78 #if defined(OS_WIN) 78 #if defined(OS_WIN)
79 void InitTrace(_CONTEXT* context_record); 79 void InitTrace(const _CONTEXT* context_record);
80 #endif 80 #endif
81 81
82 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, 82 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx,
83 // the sum of FramesToSkip and FramesToCapture must be less than 63, 83 // the sum of FramesToSkip and FramesToCapture must be less than 63,
84 // so set it to 62. Even if on POSIX it could be a larger value, it usually 84 // so set it to 62. Even if on POSIX it could be a larger value, it usually
85 // doesn't give much more information. 85 // doesn't give much more information.
86 static const int kMaxTraces = 62; 86 static const int kMaxTraces = 62;
87 87
88 void* trace_[kMaxTraces]; 88 void* trace_[kMaxTraces];
89 89
(...skipping 16 matching lines...) Expand all
106 int base, 106 int base,
107 size_t padding); 107 size_t padding);
108 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) 108 #endif // defined(OS_POSIX) && !defined(OS_ANDROID)
109 109
110 } // namespace internal 110 } // namespace internal
111 111
112 } // namespace debug 112 } // namespace debug
113 } // namespace base 113 } // namespace base
114 114
115 #endif // BASE_DEBUG_STACK_TRACE_H_ 115 #endif // BASE_DEBUG_STACK_TRACE_H_
OLDNEW
« no previous file with comments | « no previous file | base/debug/stack_trace_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698