diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 05:55:51 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 05:55:51 +0000 |
commit | 912c64520e0e9f22bd49e43c7ee102e3b9de66a7 (patch) | |
tree | 7eb719597f880b6687c4c5094f83034529378229 /base/linux_util.cc | |
parent | 48e4c173c27c8b539b0719c96985e50651b80d3b (diff) | |
download | chromium_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/linux_util.cc')
-rw-r--r-- | base/linux_util.cc | 33 |
1 files changed, 32 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 |