mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-30 23:54:15 +01:00
Change ClientInfo into a class to match other platforms, rename the current ClientInfo to ExceptionInfo
R=mark at http://breakpad.appspot.com/156001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@651 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
a599ae80aa
commit
14889c340f
@ -32,10 +32,14 @@
|
|||||||
|
|
||||||
namespace google_breakpad {
|
namespace google_breakpad {
|
||||||
|
|
||||||
struct ClientInfo {
|
class ClientInfo {
|
||||||
int exception_type;
|
public:
|
||||||
int exception_code;
|
explicit ClientInfo(pid_t pid) : pid_(pid) {}
|
||||||
int exception_subcode;
|
|
||||||
|
pid_t pid() const { return pid_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
pid_t pid_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace google_breakpad
|
} // namespace google_breakpad
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#include "client/mac/crash_generation/crash_generation_client.h"
|
#include "client/mac/crash_generation/crash_generation_client.h"
|
||||||
|
|
||||||
#include "client/mac/crash_generation/client_info.h"
|
|
||||||
#include "client/mac/crash_generation/crash_generation_server.h"
|
#include "client/mac/crash_generation/crash_generation_server.h"
|
||||||
#include "common/mac/MachIPC.h"
|
#include "common/mac/MachIPC.h"
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ bool CrashGenerationClient::RequestDumpForException(
|
|||||||
message.AddDescriptor(mach_thread_self()); // handler thread
|
message.AddDescriptor(mach_thread_self()); // handler thread
|
||||||
message.AddDescriptor(acknowledge_port.GetPort()); // message receive port
|
message.AddDescriptor(acknowledge_port.GetPort()); // message receive port
|
||||||
|
|
||||||
ClientInfo info;
|
ExceptionInfo info;
|
||||||
info.exception_type = exception_type;
|
info.exception_type = exception_type;
|
||||||
info.exception_code = exception_code;
|
info.exception_code = exception_code;
|
||||||
info.exception_subcode = exception_subcode;
|
info.exception_subcode = exception_subcode;
|
||||||
|
@ -98,12 +98,15 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
|||||||
if (result == KERN_SUCCESS) {
|
if (result == KERN_SUCCESS) {
|
||||||
switch (message.GetMessageID()) {
|
switch (message.GetMessageID()) {
|
||||||
case kDumpRequestMessage: {
|
case kDumpRequestMessage: {
|
||||||
ClientInfo &info = (ClientInfo &)*message.GetData();
|
ExceptionInfo &info = (ExceptionInfo &)*message.GetData();
|
||||||
|
|
||||||
mach_port_t remote_task = message.GetTranslatedPort(0);
|
mach_port_t remote_task = message.GetTranslatedPort(0);
|
||||||
mach_port_t crashing_thread = message.GetTranslatedPort(1);
|
mach_port_t crashing_thread = message.GetTranslatedPort(1);
|
||||||
mach_port_t handler_thread = message.GetTranslatedPort(2);
|
mach_port_t handler_thread = message.GetTranslatedPort(2);
|
||||||
mach_port_t ack_port = message.GetTranslatedPort(3);
|
mach_port_t ack_port = message.GetTranslatedPort(3);
|
||||||
|
pid_t remote_pid = -1;
|
||||||
|
pid_for_task(remote_task, &remote_pid);
|
||||||
|
ClientInfo client(remote_pid);
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
std::string dump_path;
|
std::string dump_path;
|
||||||
@ -125,12 +128,12 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result && dump_callback_) {
|
if (result && dump_callback_) {
|
||||||
dump_callback_(dump_context_, info, dump_path);
|
dump_callback_(dump_context_, client, dump_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ted): support a way for the client to send additional data,
|
// TODO(ted): support a way for the client to send additional data,
|
||||||
// perhaps with a callback so users of the server can read the data
|
// perhaps with a callback so users of the server can read the data
|
||||||
// themselves?
|
// themselves?
|
||||||
|
|
||||||
if (ack_port != MACH_PORT_DEAD && ack_port != MACH_PORT_NULL) {
|
if (ack_port != MACH_PORT_DEAD && ack_port != MACH_PORT_NULL) {
|
||||||
MachPortSender sender(ack_port);
|
MachPortSender sender(ack_port);
|
||||||
@ -141,7 +144,7 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (exit_callback_) {
|
if (exit_callback_) {
|
||||||
exit_callback_(exit_context_, info);
|
exit_callback_(exit_context_, client);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -149,7 +152,6 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else { // result != KERN_SUCCESS
|
} else { // result != KERN_SUCCESS
|
||||||
mach_error("WaitForMessage", result);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -45,6 +45,13 @@ enum {
|
|||||||
kQuitMessage = 3
|
kQuitMessage = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Exception details sent by the client when requesting a dump.
|
||||||
|
struct ExceptionInfo {
|
||||||
|
int exception_type;
|
||||||
|
int exception_code;
|
||||||
|
int exception_subcode;
|
||||||
|
};
|
||||||
|
|
||||||
class CrashGenerationServer {
|
class CrashGenerationServer {
|
||||||
public:
|
public:
|
||||||
// WARNING: callbacks may be invoked on a different thread
|
// WARNING: callbacks may be invoked on a different thread
|
||||||
|
@ -60,6 +60,8 @@ public:
|
|||||||
char mach_port_name[128];
|
char mach_port_name[128];
|
||||||
// Filename of the last dump that was generated
|
// Filename of the last dump that was generated
|
||||||
string last_dump_name;
|
string last_dump_name;
|
||||||
|
// PID of the child process
|
||||||
|
pid_t child_pid;
|
||||||
// A temp dir
|
// A temp dir
|
||||||
AutoTempDir temp_dir;
|
AutoTempDir temp_dir;
|
||||||
// Counter just to ensure that we don't hit the same port again
|
// Counter just to ensure that we don't hit the same port again
|
||||||
@ -69,6 +71,7 @@ public:
|
|||||||
sprintf(mach_port_name,
|
sprintf(mach_port_name,
|
||||||
"com.google.breakpad.ServerTest.%d.%d", getpid(),
|
"com.google.breakpad.ServerTest.%d.%d", getpid(),
|
||||||
CrashGenerationServerTest::i++);
|
CrashGenerationServerTest::i++);
|
||||||
|
child_pid = (pid_t)-1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int CrashGenerationServerTest::i = 0;
|
int CrashGenerationServerTest::i = 0;
|
||||||
@ -127,6 +130,7 @@ void dumpCallback(void *context, const ClientInfo &client_info,
|
|||||||
reinterpret_cast<CrashGenerationServerTest*>(context);
|
reinterpret_cast<CrashGenerationServerTest*>(context);
|
||||||
if (!file_path.empty())
|
if (!file_path.empty())
|
||||||
self->last_dump_name = file_path;
|
self->last_dump_name = file_path;
|
||||||
|
self->child_pid = client_info.pid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +175,8 @@ TEST_F(CrashGenerationServerTest, testRequestDump) {
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
EXPECT_EQ(0, stat(last_dump_name.c_str(), &st));
|
EXPECT_EQ(0, stat(last_dump_name.c_str(), &st));
|
||||||
EXPECT_LT(0, st.st_size);
|
EXPECT_LT(0, st.st_size);
|
||||||
|
// check client's PID
|
||||||
|
ASSERT_EQ(pid, child_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Crasher() {
|
static void Crasher() {
|
||||||
|
Loading…
Reference in New Issue
Block a user