mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-27 23:14:24 +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 {
|
||||
|
||||
struct ClientInfo {
|
||||
int exception_type;
|
||||
int exception_code;
|
||||
int exception_subcode;
|
||||
class ClientInfo {
|
||||
public:
|
||||
explicit ClientInfo(pid_t pid) : pid_(pid) {}
|
||||
|
||||
pid_t pid() const { return pid_; }
|
||||
|
||||
private:
|
||||
pid_t pid_;
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#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 "common/mac/MachIPC.h"
|
||||
|
||||
@ -50,7 +49,7 @@ bool CrashGenerationClient::RequestDumpForException(
|
||||
message.AddDescriptor(mach_thread_self()); // handler thread
|
||||
message.AddDescriptor(acknowledge_port.GetPort()); // message receive port
|
||||
|
||||
ClientInfo info;
|
||||
ExceptionInfo info;
|
||||
info.exception_type = exception_type;
|
||||
info.exception_code = exception_code;
|
||||
info.exception_subcode = exception_subcode;
|
||||
|
@ -98,12 +98,15 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
||||
if (result == KERN_SUCCESS) {
|
||||
switch (message.GetMessageID()) {
|
||||
case kDumpRequestMessage: {
|
||||
ClientInfo &info = (ClientInfo &)*message.GetData();
|
||||
ExceptionInfo &info = (ExceptionInfo &)*message.GetData();
|
||||
|
||||
mach_port_t remote_task = message.GetTranslatedPort(0);
|
||||
mach_port_t crashing_thread = message.GetTranslatedPort(1);
|
||||
mach_port_t handler_thread = message.GetTranslatedPort(2);
|
||||
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;
|
||||
std::string dump_path;
|
||||
@ -125,12 +128,12 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
||||
}
|
||||
|
||||
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,
|
||||
// perhaps with a callback so users of the server can read the data
|
||||
// themselves?
|
||||
// perhaps with a callback so users of the server can read the data
|
||||
// themselves?
|
||||
|
||||
if (ack_port != MACH_PORT_DEAD && ack_port != MACH_PORT_NULL) {
|
||||
MachPortSender sender(ack_port);
|
||||
@ -141,7 +144,7 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
||||
}
|
||||
|
||||
if (exit_callback_) {
|
||||
exit_callback_(exit_context_, info);
|
||||
exit_callback_(exit_context_, client);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -149,7 +152,6 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
||||
return false;
|
||||
}
|
||||
} else { // result != KERN_SUCCESS
|
||||
mach_error("WaitForMessage", result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -45,6 +45,13 @@ enum {
|
||||
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 {
|
||||
public:
|
||||
// WARNING: callbacks may be invoked on a different thread
|
||||
|
@ -60,6 +60,8 @@ public:
|
||||
char mach_port_name[128];
|
||||
// Filename of the last dump that was generated
|
||||
string last_dump_name;
|
||||
// PID of the child process
|
||||
pid_t child_pid;
|
||||
// A temp dir
|
||||
AutoTempDir temp_dir;
|
||||
// Counter just to ensure that we don't hit the same port again
|
||||
@ -69,6 +71,7 @@ public:
|
||||
sprintf(mach_port_name,
|
||||
"com.google.breakpad.ServerTest.%d.%d", getpid(),
|
||||
CrashGenerationServerTest::i++);
|
||||
child_pid = (pid_t)-1;
|
||||
}
|
||||
};
|
||||
int CrashGenerationServerTest::i = 0;
|
||||
@ -127,6 +130,7 @@ void dumpCallback(void *context, const ClientInfo &client_info,
|
||||
reinterpret_cast<CrashGenerationServerTest*>(context);
|
||||
if (!file_path.empty())
|
||||
self->last_dump_name = file_path;
|
||||
self->child_pid = client_info.pid();
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +174,9 @@ TEST_F(CrashGenerationServerTest, testRequestDump) {
|
||||
ASSERT_FALSE(last_dump_name.empty());
|
||||
struct stat 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() {
|
||||
|
Loading…
Reference in New Issue
Block a user