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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/crash_reporting/crash_report.cc
===================================================================
--- chrome_frame/crash_reporting/crash_report.cc (revision 0)
+++ chrome_frame/crash_reporting/crash_report.cc (revision 0)
@@ -0,0 +1,101 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// crash_report.cc : Implementation crash reporting.
+#include "chrome_frame/crash_reporting/crash_report.h"
+
+#include "base/basictypes.h"
+#include "base/logging.h"
+#include "breakpad/src/client/windows/handler/exception_handler.h"
+#include "chrome_frame/crash_reporting/vectored_handler.h"
+#include "chrome_frame/crash_reporting/vectored_handler-impl.h"
+
+namespace {
+// TODO(joshia): factor out common code with chrome used for crash reporting
+const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
+google_breakpad::ExceptionHandler* g_breakpad = NULL;
+
+__declspec(naked)
+static EXCEPTION_REGISTRATION_RECORD* InternalRtlpGetExceptionList() {
+ __asm {
+ mov eax, fs:0
+ ret
+ }
+}
+} // end of namespace
+
+// Class which methods simply forwards to Win32 API and uses breakpad to write
+// a minidump. Used as template (external interface) of VectoredHandlerT<E>.
+class Win32VEHTraits : public VEHTraitsBase {
+ public:
+ static inline void* Register(PVECTORED_EXCEPTION_HANDLER func,
+ const void* module_start, const void* module_end) {
+ VEHTraitsBase::SetModule(module_start, module_end);
+ return ::AddVectoredExceptionHandler(1, func);
+ }
+
+ static inline ULONG Unregister(void* handle) {
+ return ::RemoveVectoredExceptionHandler(handle);
+ }
+
+ static inline bool WriteDump(EXCEPTION_POINTERS* p) {
+ return g_breakpad->WriteMinidumpForException(p);
+ }
+
+ static inline EXCEPTION_REGISTRATION_RECORD* RtlpGetExceptionList() {
+ return InternalRtlpGetExceptionList();
+ }
+
+ static inline WORD RtlCaptureStackBackTrace(DWORD FramesToSkip,
+ DWORD FramesToCapture, void** BackTrace, DWORD* BackTraceHash) {
+ return ::RtlCaptureStackBackTrace(FramesToSkip, FramesToCapture,
+ BackTrace, BackTraceHash);
+ }
+};
+
+extern "C" IMAGE_DOS_HEADER __ImageBase;
+
+bool InitializeVectoredCrashReporting(
+ bool full_dump,
+ const wchar_t* user_sid,
+ const std::wstring& dump_path,
+ google_breakpad::CustomClientInfo* client_info) {
+ DCHECK(user_sid);
+ DCHECK(client_info);
+ if (g_breakpad)
+ return true;
+
+ std::wstring pipe_name(kGoogleUpdatePipeName);
+ pipe_name += user_sid;
+
+ if (dump_path.empty()) {
+ return false;
+ }
+
+ MINIDUMP_TYPE dump_type = full_dump ? MiniDumpWithFullMemory : MiniDumpNormal;
+ g_breakpad = new google_breakpad::ExceptionHandler(
+ dump_path, NULL, NULL, NULL,
+ google_breakpad::ExceptionHandler::HANDLER_INVALID_PARAMETER |
+ google_breakpad::ExceptionHandler::HANDLER_PURECALL, dump_type,
+ pipe_name.c_str(), client_info);
+
+ if (g_breakpad) {
+ // Find current module boundaries.
+ const void* start = &__ImageBase;
+ const char* s = reinterpret_cast<const char*>(start);
+ const IMAGE_NT_HEADERS32* nt = reinterpret_cast<const IMAGE_NT_HEADERS32*>
+ (s + __ImageBase.e_lfanew);
+ const void* end = s + nt->OptionalHeader.SizeOfImage;
+ VectoredHandler::Register(start, end);
+ }
+
+ return g_breakpad != NULL;
+}
+
+bool ShutdownVectoredCrashReporting() {
+ VectoredHandler::Unregister();
+ delete g_breakpad;
+ g_breakpad = NULL;
+ return true;
+}
Property changes on: chrome_frame\crash_reporting\crash_report.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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