From 9033edcd7bab5a25c748dd1979f51853bbe06f87 Mon Sep 17 00:00:00 2001 From: doshimun Date: Thu, 17 Apr 2008 21:21:48 +0000 Subject: [PATCH] Add one more parameter to the ClientDumpRequestCallback in crash generation server to pass in the path of the dump file if the dump was generated successfully. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@262 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../crash_generation/crash_generation_server.cc | 12 ++++++++---- .../crash_generation/crash_generation_server.h | 5 +++-- .../windows/crash_generation/minidump_generator.cc | 10 +++++++++- .../windows/crash_generation/minidump_generator.h | 7 +++++-- .../crash_generation_app/crash_generation_app.cc | 3 ++- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/client/windows/crash_generation/crash_generation_server.cc b/src/client/windows/crash_generation/crash_generation_server.cc index b49f3774..9be11ee7 100644 --- a/src/client/windows/crash_generation/crash_generation_server.cc +++ b/src/client/windows/crash_generation/crash_generation_server.cc @@ -783,20 +783,23 @@ void CrashGenerationServer::HandleDumpRequest(const ClientInfo& client_info) { // Generate the dump only if it's explicitly requested by the // server application; otherwise the server might want to generate // dump in the callback. + std::wstring dump_path; if (generate_dumps_) { - if (!GenerateDump(client_info)) { + if (!GenerateDump(client_info, &dump_path)) { return; } } if (dump_callback_) { - dump_callback_(dump_context_, &client_info); + std::wstring* ptr_dump_path = (dump_path == L"") ? NULL : &dump_path; + dump_callback_(dump_context_, &client_info, ptr_dump_path); } SetEvent(client_info.dump_generated_handle()); } -bool CrashGenerationServer::GenerateDump(const ClientInfo& client) { +bool CrashGenerationServer::GenerateDump(const ClientInfo& client, + std::wstring* dump_path) { assert(client.pid() != 0); assert(client.process_handle()); @@ -819,7 +822,8 @@ bool CrashGenerationServer::GenerateDump(const ClientInfo& client) { client_ex_info, client.assert_info(), client.dump_type(), - true); + true, + dump_path); } } // namespace google_breakpad diff --git a/src/client/windows/crash_generation/crash_generation_server.h b/src/client/windows/crash_generation/crash_generation_server.h index 4568f111..b67b88de 100644 --- a/src/client/windows/crash_generation/crash_generation_server.h +++ b/src/client/windows/crash_generation/crash_generation_server.h @@ -53,7 +53,8 @@ class CrashGenerationServer { const ClientInfo* client_info); typedef void (*OnClientDumpRequestCallback)(void* context, - const ClientInfo* client_info); + const ClientInfo* client_info, + const std::wstring* file_path); typedef void (*OnClientExitedCallback)(void* context, const ClientInfo* client_info); @@ -189,7 +190,7 @@ class CrashGenerationServer { bool AddClient(ClientInfo* client_info); // Generates dump for the given client. - bool GenerateDump(const ClientInfo& client); + bool GenerateDump(const ClientInfo& client, std::wstring* dump_path); // Sync object for thread-safe access to the shared list of clients. CRITICAL_SECTION clients_sync_; diff --git a/src/client/windows/crash_generation/minidump_generator.cc b/src/client/windows/crash_generation/minidump_generator.cc index 7d3e2f6b..1efd9a73 100644 --- a/src/client/windows/crash_generation/minidump_generator.cc +++ b/src/client/windows/crash_generation/minidump_generator.cc @@ -66,7 +66,8 @@ bool MinidumpGenerator::WriteMinidump(HANDLE process_handle, EXCEPTION_POINTERS* exception_pointers, MDRawAssertionInfo* assert_info, MINIDUMP_TYPE dump_type, - bool is_client_pointers) { + bool is_client_pointers, + wstring* dump_path) { MiniDumpWriteDumpType write_dump = GetWriteDump(); if (!write_dump) { return false; @@ -163,6 +164,13 @@ bool MinidumpGenerator::WriteMinidump(HANDLE process_handle, NULL) != FALSE; CloseHandle(dump_file); + + // Store the path of the dump file in the out parameter if dump generation + // succeeded. + if (result && dump_path) { + *dump_path = dump_file_path; + } + return result; } diff --git a/src/client/windows/crash_generation/minidump_generator.h b/src/client/windows/crash_generation/minidump_generator.h index e343a0ab..8ab6a8f6 100644 --- a/src/client/windows/crash_generation/minidump_generator.h +++ b/src/client/windows/crash_generation/minidump_generator.h @@ -48,7 +48,9 @@ class MinidumpGenerator { ~MinidumpGenerator(); - // Writes the minidump with the given parameters. + // Writes the minidump with the given parameters. Stores the + // dump file path in the dump_path parameter if dump generation + // succeeds. bool WriteMinidump(HANDLE process_handle, DWORD process_id, DWORD thread_id, @@ -56,7 +58,8 @@ class MinidumpGenerator { EXCEPTION_POINTERS* exception_pointers, MDRawAssertionInfo* assert_info, MINIDUMP_TYPE dump_type, - bool is_client_pointers); + bool is_client_pointers, + std::wstring* dump_path); private: // Function pointer type for MiniDumpWriteDump, which is looked up diff --git a/src/client/windows/tests/crash_generation_app/crash_generation_app.cc b/src/client/windows/tests/crash_generation_app/crash_generation_app.cc index 129cdb24..924d734a 100644 --- a/src/client/windows/tests/crash_generation_app/crash_generation_app.cc +++ b/src/client/windows/tests/crash_generation_app/crash_generation_app.cc @@ -197,7 +197,8 @@ static void _cdecl ShowClientConnected(void* context, } static void _cdecl ShowClientCrashed(void* context, - const ClientInfo* client_info) { + const ClientInfo* client_info, + const wstring* dump_path) { TCHAR* line = new TCHAR[kMaximumLineLength]; int result = swprintf_s(line, kMaximumLineLength,