am 7c262abe: Merge "crash_reporter: Set Version and Product ID"

* commit '7c262abeac08483d039da29b4dec3ed02abe12bf':
  crash_reporter: Set Version and Product ID
This commit is contained in:
Steve Fung 2015-10-01 17:17:03 +00:00 committed by Android Git Automerger
commit 3f43729a36
3 changed files with 14 additions and 16 deletions

View File

@ -117,6 +117,7 @@ LOCAL_MODULE := crash_reporter_tests
LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension)
LOCAL_SHARED_LIBRARIES := libchrome \
libchromeos \
libcutils \
libdbus \
libpcrecpp
LOCAL_SRC_FILES := $(crash_reporter_test_src)

View File

@ -53,9 +53,6 @@ const char kSystemCrashPath[] = "/data/misc/crash_reporter/crash";
const char kUploadVarPrefix[] = "upload_var_";
const char kUploadFilePrefix[] = "upload_file_";
// Key of the lsb-release entry containing the OS version.
const char kLsbVersionKey[] = "CHROMEOS_RELEASE_VERSION";
// Normally this path is not used. Unfortunately, there are a few edge cases
// where we need this. Any process that runs as kDefaultUserName that crashes
// is consider a "user crash". That includes the initial Chrome browser that
@ -387,27 +384,14 @@ void CrashCollector::AddCrashMetaUploadData(const std::string &key,
void CrashCollector::WriteCrashMetaData(const FilePath &meta_path,
const std::string &exec_name,
const std::string &payload_path) {
chromeos::KeyValueStore store;
if (!store.Load(FilePath(lsb_release_))) {
LOG(ERROR) << "Problem parsing " << lsb_release_;
// Even though there was some failure, take as much as we could read.
}
std::string version("unknown");
if (!store.GetString(kLsbVersionKey, &version)) {
LOG(ERROR) << "Unable to read " << kLsbVersionKey << " from "
<< lsb_release_;
}
int64_t payload_size = -1;
base::GetFileSize(FilePath(payload_path), &payload_size);
std::string meta_data = StringPrintf("%sexec_name=%s\n"
"ver=%s\n"
"payload=%s\n"
"payload_size=%" PRId64 "\n"
"done=1\n",
extra_metadata_.c_str(),
exec_name.c_str(),
version.c_str(),
payload_path.c_str(),
payload_size);
// We must use WriteNewFile instead of base::WriteFile as we

View File

@ -55,6 +55,13 @@ static const uid_t kUnknownUid = -1;
const char *UserCollector::kUserId = "Uid:\t";
const char *UserCollector::kGroupId = "Gid:\t";
// The property containing the OS version.
const char kVersionProperty[] = "ro.build.id";
// The property containing the product id.
const char kProductIDProperty[] = "ro.product.product_id";
using base::FilePath;
using base::StringPrintf;
@ -455,6 +462,12 @@ UserCollector::ErrorType UserCollector::ConvertAndEnqueueCrash(
if (GetLogContents(FilePath(log_config_path_), exec, log_path))
AddCrashMetaData("log", log_path.value());
char value[PROPERTY_VALUE_MAX];
property_get(kVersionProperty, value, "undefined");
AddCrashMetaUploadData("ver", value);
property_get(kProductIDProperty, value, "undefined");
AddCrashMetaUploadData("prod", value);
ErrorType error_type =
ConvertCoreToMinidump(pid, container_dir, core_path, minidump_path);
if (error_type != kErrorNone) {