summaryrefslogtreecommitdiffstats
path: root/base/linux_util.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 /base/linux_util.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 'base/linux_util.cc')
-rw-r--r--base/linux_util.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/base/linux_util.cc b/base/linux_util.cc
index b8c78e4..246c95c 100644
--- a/base/linux_util.cc
+++ b/base/linux_util.cc
@@ -126,9 +126,12 @@ bool ProcPathGetInode(ino_t* inode_out, const char* path, bool log = false) {
namespace base {
+// Account for the terminating null character.
+static const int kDistroSize = 128 + 1;
+
// We use this static string to hold the Linux distro info. If we
// crash, the crash handler code will send this in the crash dump.
-std::string linux_distro =
+char g_linux_distro[kDistroSize] =
#if defined(OS_CHROMEOS)
"CrOS";
#else // if defined(OS_LINUX)
@@ -137,7 +140,7 @@ std::string linux_distro =
std::string GetLinuxDistro() {
#if defined(OS_CHROMEOS)
- return linux_distro;
+ return g_linux_distro;
#elif defined(OS_LINUX)
LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::Get();
LinuxDistroState state = distro_state_singleton->State();
@@ -154,25 +157,30 @@ std::string GetLinuxDistro() {
// lsb_release -d should return: Description:<tab>Distro Info
static const std::string field = "Description:\t";
if (output.compare(0, field.length(), field) == 0) {
- linux_distro = output.substr(field.length());
- TrimWhitespaceASCII(linux_distro, TRIM_ALL, &linux_distro);
+ SetLinuxDistro(output.substr(field.length()));
}
}
distro_state_singleton->CheckFinished();
- return linux_distro;
+ return g_linux_distro;
} else if (STATE_CHECK_STARTED == state) {
// If the distro check above is in progress in some other thread, we're
// not going to wait for the results.
return "Unknown";
} else {
// In STATE_CHECK_FINISHED, no more writing to |linux_distro|.
- return linux_distro;
+ return g_linux_distro;
}
#else
NOTIMPLEMENTED();
#endif
}
+void SetLinuxDistro(const std::string& distro) {
+ std::string trimmed_distro;
+ TrimWhitespaceASCII(distro, TRIM_ALL, &trimmed_distro);
+ base::strlcpy(g_linux_distro, trimmed_distro.c_str(), kDistroSize);
+}
+
bool FileDescriptorGetInode(ino_t* inode_out, int fd) {
DCHECK(inode_out);