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

Side by Side Diff: chrome_frame/crash_reporting/crash_report.h

Issue 557021: Prevent excessive crash reporting due stack overflow (due exception in SEH fi... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // crash_report.h : Declarations for crash reporting. 5 // crash_report.h : Declarations for crash reporting.
6 6
7 #ifndef CHROME_FRAME_CRASH_REPORTING_CRASH_REPORT_H_ 7 #ifndef CHROME_FRAME_CRASH_REPORTING_CRASH_REPORT_H_
8 #define CHROME_FRAME_CRASH_REPORTING_CRASH_REPORT_H_ 8 #define CHROME_FRAME_CRASH_REPORTING_CRASH_REPORT_H_
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "breakpad/src/client/windows/handler/exception_handler.h" 13 #include "breakpad/src/client/windows/handler/exception_handler.h"
14 #include "chrome_frame/crash_reporting/vectored_handler-impl.h"
15 14
16 extern google_breakpad::ExceptionHandler* g_breakpad; 15 extern google_breakpad::ExceptionHandler* g_breakpad;
17 extern "C" IMAGE_DOS_HEADER __ImageBase; 16 extern "C" IMAGE_DOS_HEADER __ImageBase;
18 17
19 bool InitializeVectoredCrashReporting( 18 bool InitializeVectoredCrashReporting(
20 bool full_dump, 19 bool full_dump,
21 const wchar_t* user_sid, 20 const wchar_t* user_sid,
22 const std::wstring& dump_path, 21 const std::wstring& dump_path,
23 google_breakpad::CustomClientInfo* client_info); 22 google_breakpad::CustomClientInfo* client_info);
24 23
25 bool InitializeVectoredCrashReportingWithPipeName( 24 bool InitializeVectoredCrashReportingWithPipeName(
26 bool full_dump, 25 bool full_dump,
27 const wchar_t* pipe_name, 26 const wchar_t* pipe_name,
28 const std::wstring& dump_path, 27 const std::wstring& dump_path,
29 google_breakpad::CustomClientInfo* client_info); 28 google_breakpad::CustomClientInfo* client_info);
30 29
31 bool ShutdownVectoredCrashReporting(); 30 bool ShutdownVectoredCrashReporting();
32 31
33 namespace {
34 __declspec(naked)
35 static EXCEPTION_REGISTRATION_RECORD* InternalRtlpGetExceptionList() {
36 __asm {
37 mov eax, fs:0
38 ret
39 }
40 }
41 } // end of namespace
42
43 // Class which methods simply forwards to Win32 API and uses breakpad to write
44 // a minidump. Used as template (external interface) of VectoredHandlerT<E>.
45 class Win32VEHTraits : public VEHTraitsBase {
46 public:
47 static inline void* Register(PVECTORED_EXCEPTION_HANDLER func,
48 const void* module_start, const void* module_end) {
49 InitializeIgnoredBlocks();
50 VEHTraitsBase::SetModule(module_start, module_end);
51 return ::AddVectoredExceptionHandler(1, func);
52 }
53
54 static inline ULONG Unregister(void* handle) {
55 return ::RemoveVectoredExceptionHandler(handle);
56 }
57
58 static inline bool WriteDump(EXCEPTION_POINTERS* p) {
59 return g_breakpad->WriteMinidumpForException(p);
60 }
61
62 static inline EXCEPTION_REGISTRATION_RECORD* RtlpGetExceptionList() {
63 return InternalRtlpGetExceptionList();
64 }
65
66 static inline WORD RtlCaptureStackBackTrace(DWORD FramesToSkip,
67 DWORD FramesToCapture, void** BackTrace, DWORD* BackTraceHash) {
68 return ::RtlCaptureStackBackTrace(FramesToSkip, FramesToCapture,
69 BackTrace, BackTraceHash);
70 }
71
72 static bool ShouldIgnoreException(const EXCEPTION_POINTERS* exceptionInfo) {
73 const void* address = exceptionInfo->ExceptionRecord->ExceptionAddress;
74 for (int i = 0; i < kIgnoreEntries; i++) {
75 const CodeBlock& code_block = IgnoreExceptions[i];
76 if (code_block.code &&
77 (CodeOffset(code_block.code, code_block.begin_offset) <= address) &&
78 (address < CodeOffset(code_block.code, code_block.end_offset))) {
79 return true;
80 }
81 }
82
83 return false;
84 }
85
86 static inline void InitializeIgnoredBlocks() {
87 // Initialize ignored exception list
88 for (int i = 0; i < kIgnoreEntries; i++) {
89 CodeBlock& code_block = IgnoreExceptions[i];
90 if (!code_block.code) {
91 HMODULE module = GetModuleHandleA(code_block.module);
92 DCHECK(module) << "GetModuleHandle error: " << GetLastError();
93 code_block.code = GetProcAddress(module, code_block.function);
94 DCHECK(code_block.code) << "GetProcAddress error: "<< GetLastError();
95 }
96 }
97 }
98
99 static inline const void* CodeOffset(const void* code, int offset) {
100 return reinterpret_cast<const char*>(code) + offset;
101 }
102
103 private:
104 // Block of code to be ignored for exceptions
105 struct CodeBlock {
106 char* module;
107 char* function;
108 int begin_offset;
109 int end_offset;
110 const void* code;
111 };
112
113 static const int kIgnoreEntries = 4;
114 static CodeBlock IgnoreExceptions[kIgnoreEntries];
115 };
116
117
118 #endif // CHROME_FRAME_CRASH_REPORTING_CRASH_REPORT_H_ 32 #endif // CHROME_FRAME_CRASH_REPORTING_CRASH_REPORT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome_frame/crash_reporting/crash_report.cc » ('j') | chrome_frame/crash_reporting/vectored_handler-impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698