summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-17 05:55:51 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-17 05:55:51 +0000
commit912c64520e0e9f22bd49e43c7ee102e3b9de66a7 (patch)
tree7eb719597f880b6687c4c5094f83034529378229 /base
parent48e4c173c27c8b539b0719c96985e50651b80d3b (diff)
downloadchromium_src-912c64520e0e9f22bd49e43c7ee102e3b9de66a7.zip
chromium_src-912c64520e0e9f22bd49e43c7ee102e3b9de66a7.tar.gz
chromium_src-912c64520e0e9f22bd49e43c7ee102e3b9de66a7.tar.bz2
Include output of "lsb_release -d" in crash reports.
/etc/lsb-release does not exist on all distros, and sometimes it does not provide any useful info. Whereas all LSB complaint distros return useful data with the lsb_release command. Review URL: http://codereview.chromium.org/155653 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/linux_util.cc33
-rw-r--r--base/linux_util.h6
2 files changed, 38 insertions, 1 deletions
diff --git a/base/linux_util.cc b/base/linux_util.cc
index a58ee99..604980b 100644
--- a/base/linux_util.cc
+++ b/base/linux_util.cc
@@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "linux_util.h"
+#include "base/linux_util.h"
#include <stdlib.h>
+#include <vector>
+
+#include "base/command_line.h"
+#include "base/process_util.h"
+
namespace base {
uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) {
@@ -28,4 +33,30 @@ uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) {
return new_pixels;
}
+// 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 = "Unknown";
+
+std::string GetLinuxDistro() {
+ static bool checked_distro = false;
+ if (!checked_distro) {
+ std::vector<std::string> argv;
+ argv.push_back("lsb_release");
+ argv.push_back("-d");
+ std::string output;
+ base::GetAppOutput(CommandLine(argv), &output);
+ if (output.length() > 0) {
+ // 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());
+ }
+ // We do this check only once per process. If it fails, there's
+ // little reason to believe it will work if we attempt to run
+ // lsb_release again.
+ checked_distro = true;
+ }
+ return linux_distro;
+}
+
} // namespace base
diff --git a/base/linux_util.h b/base/linux_util.h
index aa418cc..973a2b0 100644
--- a/base/linux_util.h
+++ b/base/linux_util.h
@@ -7,6 +7,8 @@
#include <stdint.h>
+#include <string>
+
namespace base {
// Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
@@ -14,6 +16,10 @@ namespace base {
// it's assumed to be 4 * |width|.
uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
+// Get the Linux Distro if we can, or return "Unknown", similar to
+// GetWinVersion() in base/win_util.h.
+std::string GetLinuxDistro();
+
} // namespace base
#endif // BASE_LINUX_UTIL_H__