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

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

Issue 276050: Refactoring of crash reporting code in Chrome Frame ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // crash_report.cc : Implementation crash reporting.
6 #include "chrome_frame/crash_reporting/crash_report.h"
7
8 #include "base/basictypes.h"
9 #include "base/logging.h"
10 #include "breakpad/src/client/windows/handler/exception_handler.h"
11 #include "chrome_frame/crash_reporting/vectored_handler.h"
12 #include "chrome_frame/crash_reporting/vectored_handler-impl.h"
13
14 namespace {
15 // TODO(joshia): factor out common code with chrome used for crash reporting
16 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
17 google_breakpad::ExceptionHandler* g_breakpad = NULL;
18
19 __declspec(naked)
20 static EXCEPTION_REGISTRATION_RECORD* InternalRtlpGetExceptionList() {
21 __asm {
22 mov eax, fs:0
23 ret
24 }
25 }
26 } // end of namespace
27
28 // Class which methods simply forwards to Win32 API and uses breakpad to write
29 // a minidump. Used as template (external interface) of VectoredHandlerT<E>.
30 class Win32VEHTraits : public VEHTraitsBase {
31 public:
32 static inline void* Register(PVECTORED_EXCEPTION_HANDLER func,
33 const void* module_start, const void* module_end) {
34 VEHTraitsBase::SetModule(module_start, module_end);
35 return ::AddVectoredExceptionHandler(1, func);
36 }
37
38 static inline ULONG Unregister(void* handle) {
39 return ::RemoveVectoredExceptionHandler(handle);
40 }
41
42 static inline bool WriteDump(EXCEPTION_POINTERS* p) {
43 return g_breakpad->WriteMinidumpForException(p);
44 }
45
46 static inline EXCEPTION_REGISTRATION_RECORD* RtlpGetExceptionList() {
47 return InternalRtlpGetExceptionList();
48 }
49
50 static inline WORD RtlCaptureStackBackTrace(DWORD FramesToSkip,
51 DWORD FramesToCapture, void** BackTrace, DWORD* BackTraceHash) {
52 return ::RtlCaptureStackBackTrace(FramesToSkip, FramesToCapture,
53 BackTrace, BackTraceHash);
54 }
55 };
56
57 extern "C" IMAGE_DOS_HEADER __ImageBase;
58
59 bool InitializeVectoredCrashReporting(
60 bool full_dump,
61 const wchar_t* user_sid,
62 const std::wstring& dump_path,
63 google_breakpad::CustomClientInfo* client_info) {
64 DCHECK(user_sid);
65 DCHECK(client_info);
66 if (g_breakpad)
67 return true;
68
69 std::wstring pipe_name(kGoogleUpdatePipeName);
70 pipe_name += user_sid;
71
72 if (dump_path.empty()) {
73 return false;
74 }
75
76 MINIDUMP_TYPE dump_type = full_dump ? MiniDumpWithFullMemory : MiniDumpNormal;
77 g_breakpad = new google_breakpad::ExceptionHandler(
78 dump_path, NULL, NULL, NULL,
79 google_breakpad::ExceptionHandler::HANDLER_INVALID_PARAMETER |
80 google_breakpad::ExceptionHandler::HANDLER_PURECALL, dump_type,
81 pipe_name.c_str(), client_info);
82
83 if (g_breakpad) {
84 // Find current module boundaries.
85 const void* start = &__ImageBase;
86 const char* s = reinterpret_cast<const char*>(start);
87 const IMAGE_NT_HEADERS32* nt = reinterpret_cast<const IMAGE_NT_HEADERS32*>
88 (s + __ImageBase.e_lfanew);
89 const void* end = s + nt->OptionalHeader.SizeOfImage;
90 VectoredHandler::Register(start, end);
91 }
92
93 return g_breakpad != NULL;
94 }
95
96 bool ShutdownVectoredCrashReporting() {
97 VectoredHandler::Unregister();
98 delete g_breakpad;
99 g_breakpad = NULL;
100 return true;
101 }
OLDNEW
« no previous file with comments | « chrome_frame/crash_reporting/crash_report.h ('k') | chrome_frame/crash_reporting/crash_reporting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698