OLD | NEW |
1 | 1 |
2 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 // crash_report.cc : Implementation crash reporting. | 6 // crash_report.cc : Implementation crash reporting. |
7 #include "chrome_frame/crash_reporting/crash_report.h" | 7 #include "chrome_frame/crash_reporting/crash_report.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | |
11 #include "breakpad/src/client/windows/handler/exception_handler.h" | 10 #include "breakpad/src/client/windows/handler/exception_handler.h" |
12 #include "chrome_frame/crash_reporting/vectored_handler.h" | 11 #include "chrome_frame/crash_reporting/vectored_handler.h" |
13 #include "chrome_frame/crash_reporting/vectored_handler-impl.h" | |
14 | 12 |
15 namespace { | |
16 // TODO(joshia): factor out common code with chrome used for crash reporting | 13 // TODO(joshia): factor out common code with chrome used for crash reporting |
17 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | 14 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
18 | |
19 google_breakpad::ExceptionHandler* g_breakpad = NULL; | 15 google_breakpad::ExceptionHandler* g_breakpad = NULL; |
20 | 16 |
21 __declspec(naked) | 17 Win32VEHTraits::CodeBlock Win32VEHTraits::IgnoreExceptions[kIgnoreEntries] = { |
22 static EXCEPTION_REGISTRATION_RECORD* InternalRtlpGetExceptionList() { | 18 { "kernel32.dll", "IsBadReadPtr", 0, 100, NULL }, |
23 __asm { | 19 { "kernel32.dll", "IsBadWritePtr", 0, 100, NULL }, |
24 mov eax, fs:0 | 20 { "kernel32.dll", "IsBadStringPtrA", 0, 100, NULL }, |
25 ret | 21 { "kernel32.dll", "IsBadStringPtrW", 0, 100, NULL }, |
26 } | |
27 } | |
28 } // end of namespace | |
29 | |
30 // Class which methods simply forwards to Win32 API and uses breakpad to write | |
31 // a minidump. Used as template (external interface) of VectoredHandlerT<E>. | |
32 class Win32VEHTraits : public VEHTraitsBase { | |
33 public: | |
34 static inline void* Register(PVECTORED_EXCEPTION_HANDLER func, | |
35 const void* module_start, const void* module_end) { | |
36 VEHTraitsBase::SetModule(module_start, module_end); | |
37 return ::AddVectoredExceptionHandler(1, func); | |
38 } | |
39 | |
40 static inline ULONG Unregister(void* handle) { | |
41 return ::RemoveVectoredExceptionHandler(handle); | |
42 } | |
43 | |
44 static inline bool WriteDump(EXCEPTION_POINTERS* p) { | |
45 return g_breakpad->WriteMinidumpForException(p); | |
46 } | |
47 | |
48 static inline EXCEPTION_REGISTRATION_RECORD* RtlpGetExceptionList() { | |
49 return InternalRtlpGetExceptionList(); | |
50 } | |
51 | |
52 static inline WORD RtlCaptureStackBackTrace(DWORD FramesToSkip, | |
53 DWORD FramesToCapture, void** BackTrace, DWORD* BackTraceHash) { | |
54 return ::RtlCaptureStackBackTrace(FramesToSkip, FramesToCapture, | |
55 BackTrace, BackTraceHash); | |
56 } | |
57 }; | 22 }; |
58 | 23 |
59 extern "C" IMAGE_DOS_HEADER __ImageBase; | |
60 | |
61 std::wstring GetCrashServerPipeName(const std::wstring& user_sid) { | 24 std::wstring GetCrashServerPipeName(const std::wstring& user_sid) { |
62 std::wstring pipe_name = kGoogleUpdatePipeName; | 25 std::wstring pipe_name = kGoogleUpdatePipeName; |
63 pipe_name += user_sid; | 26 pipe_name += user_sid; |
64 return pipe_name; | 27 return pipe_name; |
65 } | 28 } |
66 | 29 |
67 bool InitializeVectoredCrashReportingWithPipeName( | 30 bool InitializeVectoredCrashReportingWithPipeName( |
68 bool full_dump, | 31 bool full_dump, |
69 const wchar_t* pipe_name, | 32 const wchar_t* pipe_name, |
70 const std::wstring& dump_path, | 33 const std::wstring& dump_path, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 dump_path, | 74 dump_path, |
112 client_info); | 75 client_info); |
113 } | 76 } |
114 | 77 |
115 bool ShutdownVectoredCrashReporting() { | 78 bool ShutdownVectoredCrashReporting() { |
116 VectoredHandler::Unregister(); | 79 VectoredHandler::Unregister(); |
117 delete g_breakpad; | 80 delete g_breakpad; |
118 g_breakpad = NULL; | 81 g_breakpad = NULL; |
119 return true; | 82 return true; |
120 } | 83 } |
OLD | NEW |