summaryrefslogtreecommitdiffstats
path: root/chrome/app/breakpad_linux.cc
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 08:55:22 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 08:55:22 +0000
commit6dde9d7f2a99851b0f84671832f072799dd3f8d5 (patch)
tree133dc5f7a37c0c1bf0e65f3ab32ef081a3c3f293 /chrome/app/breakpad_linux.cc
parent31de519d7a62e532c2bdded403a451c9f3f972da (diff)
downloadchromium_src-6dde9d7f2a99851b0f84671832f072799dd3f8d5.zip
chromium_src-6dde9d7f2a99851b0f84671832f072799dd3f8d5.tar.gz
chromium_src-6dde9d7f2a99851b0f84671832f072799dd3f8d5.tar.bz2
Make crash reporting client_id accessible through child_process_logging.
On Mac and Linux, keep the client id in a global variable kept by the child_process_logging implementations. This allows to read it in a thread safe fashion when starting a child process. Also replace std::string with statically allocated buffers for the various items we add to the crash reports. This allows to properly handle crashes upon shutdown (std::string would run its destructor, invalidating the memory). BUG=53231 TEST=Crash reporting should still work Review URL: http://codereview.chromium.org/3186028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/breakpad_linux.cc')
-rw-r--r--chrome/app/breakpad_linux.cc52
1 files changed, 17 insertions, 35 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index 795f3f0..4d32ac5 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -22,6 +22,7 @@
#include "base/eintr_wrapper.h"
#include "base/file_path.h"
#include "base/global_descriptors_posix.h"
+#include "base/linux_util.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "breakpad/src/client/linux/handler/exception_handler.h"
@@ -29,12 +30,12 @@
#include "breakpad/src/common/linux/linux_libc_support.h"
#include "breakpad/src/common/linux/linux_syscall_support.h"
#include "breakpad/src/common/linux/memory.h"
+#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_descriptors.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info_posix.h"
#include "chrome/common/env_vars.h"
-#include "chrome/installer/util/google_update_settings.h"
// Some versions of gcc are prone to warn about unused return values. In cases
// where we either a) know the call cannot fail, or b) there is nothing we
@@ -579,19 +580,6 @@ pid_t HandleCrashDump(const BreakpadInfo& info) {
return child;
}
-// This is defined in chrome/browser/google_update_settings_posix.cc, it's the
-// static string containing the user's unique GUID. We send this in the crash
-// report.
-namespace google_update {
-extern std::string posix_guid;
-}
-
-// This is defined in base/linux_util.cc, it's the static string containing the
-// user's distro info. We send this in the crash report.
-namespace base {
-extern std::string linux_distro;
-}
-
static bool CrashDone(const char* dump_path,
const char* minidump_id,
const bool upload,
@@ -619,10 +607,10 @@ static bool CrashDone(const char* dump_path,
info.process_type_length = 7;
info.crash_url = NULL;
info.crash_url_length = 0;
- info.guid = google_update::posix_guid.data();
- info.guid_length = google_update::posix_guid.length();
- info.distro = base::linux_distro.data();
- info.distro_length = base::linux_distro.length();
+ info.guid = child_process_logging::g_client_id;
+ info.guid_length = my_strlen(child_process_logging::g_client_id);
+ info.distro = base::g_linux_distro;
+ info.distro_length = my_strlen(base::g_linux_distro);
info.upload = upload;
HandleCrashDump(info);
@@ -659,13 +647,6 @@ void EnableCrashDumping(const bool unattended) {
}
}
-// This is defined in chrome/common/child_process_logging_linux.cc, it's the
-// static string containing the current active URL. We send this in the crash
-// report.
-namespace child_process_logging {
-extern std::string active_url;
-}
-
// Currently Non-Browser = Renderer and Plugins
static bool
NonBrowserCrashHandler(const void* crash_context, size_t crash_context_size,
@@ -680,15 +661,16 @@ NonBrowserCrashHandler(const void* crash_context, size_t crash_context_size,
char guid[kGuidSize + 1] = {0};
char crash_url[kMaxActiveURLSize + 1] = {0};
char distro[kDistroSize + 1] = {0};
- const size_t guid_len = std::min(google_update::posix_guid.size(),
- kGuidSize);
+ const size_t guid_len =
+ std::min(my_strlen(child_process_logging::g_client_id), kGuidSize);
const size_t crash_url_len =
- std::min(child_process_logging::active_url.size(), kMaxActiveURLSize);
+ std::min(my_strlen(child_process_logging::g_active_url),
+ kMaxActiveURLSize);
const size_t distro_len =
- std::min(base::linux_distro.size(), kDistroSize);
- memcpy(guid, google_update::posix_guid.data(), guid_len);
- memcpy(crash_url, child_process_logging::active_url.data(), crash_url_len);
- memcpy(distro, base::linux_distro.data(), distro_len);
+ std::min(my_strlen(base::g_linux_distro), kDistroSize);
+ memcpy(guid, child_process_logging::g_client_id, guid_len);
+ memcpy(crash_url, child_process_logging::g_active_url, crash_url_len);
+ memcpy(distro, base::g_linux_distro, distro_len);
char b; // Dummy variable for sys_read below.
const char* b_addr = &b; // Get the address of |b| so we can create the
@@ -776,10 +758,10 @@ void InitCrashReporter() {
parsed_command_line.GetSwitchValueASCII(switches::kEnableCrashReporter);
size_t separator = switch_value.find(",");
if (separator != std::string::npos) {
- google_update::posix_guid = switch_value.substr(0, separator);
- base::linux_distro = switch_value.substr(separator + 1);
+ child_process_logging::SetClientId(switch_value.substr(0, separator));
+ base::SetLinuxDistro(switch_value.substr(separator + 1));
} else {
- google_update::posix_guid = switch_value;
+ child_process_logging::SetClientId(switch_value);
}
EnableNonBrowserCrashDumping();
}