Add product name and version to crash_reporter.cfg (issue #1995)

This commit is contained in:
Marshall Greenblatt 2017-01-12 11:44:35 -05:00
parent f7cc01059b
commit 650a49b0a7
7 changed files with 135 additions and 20 deletions

View File

@ -55,6 +55,8 @@ extern "C" {
// # Comments start with a hash character and must be on their own line.
//
// [Config]
// ProductName=<Value of the "prod" crash key; defaults to "cef">
// ProductVersion=<Value of the "ver" crash key; defaults to the CEF version>
// AppName=<Windows only; App-specific folder name component for storing crash
// information; default to "CEF">
// ExternalHandler=<Windows only; Name of the external handler exe to use
@ -74,6 +76,11 @@ extern "C" {
//
// Config section:
//
// If "ProductName" and/or "ProductVersion" are set then the specified values
// will be included in the crash dump metadata. On macOS if these values are set
// to NULL then they will be retrieved from the Info.plist file using the
// "CFBundleName" and "CFBundleShortVersionString" keys respectively.
//
// If "AppName" is set on Windows then crash report information (metrics,
// database and dumps) will be stored locally on disk under the
// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other

View File

@ -48,6 +48,8 @@
// # Comments start with a hash character and must be on their own line.
//
// [Config]
// ProductName=<Value of the "prod" crash key; defaults to "cef">
// ProductVersion=<Value of the "ver" crash key; defaults to the CEF version>
// AppName=<Windows only; App-specific folder name component for storing crash
// information; default to "CEF">
// ExternalHandler=<Windows only; Name of the external handler exe to use
@ -67,6 +69,11 @@
//
// Config section:
//
// If "ProductName" and/or "ProductVersion" are set then the specified values
// will be included in the crash dump metadata. On macOS if these values are set
// to empty then they will be retrieved from the Info.plist file using the
// "CFBundleName" and "CFBundleShortVersionString" keys respectively.
//
// If "AppName" is set on Windows then crash report information (metrics,
// database and dumps) will be stored locally on disk under the
// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other

View File

@ -23,8 +23,6 @@
#if defined(OS_MACOSX)
#include "base/mac/foundation_util.h"
#else
#include "include/cef_version.h"
#endif
#if defined(OS_POSIX)
@ -347,13 +345,17 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
base::TrimString(name_str, base::kWhitespaceASCII, &name_str);
std::string val_str = str.substr(div + 1);
base::TrimString(val_str, base::kWhitespaceASCII, &val_str);
if (name_str.empty() || val_str.empty())
if (name_str.empty())
continue;
if (current_section == kConfigSection) {
if (name_str == "ServerURL") {
if (val_str.find("http://") == 0 || val_str.find("https://") == 0)
server_url_ = val_str;
} else if (name_str == "ProductName") {
product_name_ = val_str;
} else if (name_str == "ProductVersion") {
product_version_ = val_str;
} else if (name_str == "RateLimitEnabled") {
rate_limit_ = (base::EqualsCaseInsensitiveASCII(val_str, "true") ||
val_str == "1");
@ -375,8 +377,10 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
}
#if defined(OS_WIN)
else if (name_str == "ExternalHandler") {
external_handler_ = sanitizePath(name_str);
if (!val_str.empty())
external_handler_ = sanitizePath(val_str);
} else if (name_str == "AppName") {
if (!val_str.empty())
app_name_ = sanitizePathComponent(val_str);
}
#endif
@ -466,8 +470,8 @@ void CefCrashReporterClient::GetProductNameAndVersion(
base::string16* version,
base::string16* special_build,
base::string16* channel_name) {
*product_name = base::ASCIIToUTF16("cef");
*version = base::ASCIIToUTF16(CEF_VERSION);
*product_name = base::ASCIIToUTF16(product_name_);
*version = base::ASCIIToUTF16(product_version_);
*special_build = base::string16();
*channel_name = base::string16();
}
@ -490,15 +494,15 @@ bool CefCrashReporterClient::GetCrashMetricsLocation(
#elif defined(OS_POSIX)
#if !defined(OS_MACOSX)
void CefCrashReporterClient::GetProductNameAndVersion(
const char** product_name,
const char** version) {
*product_name = "cef";
*version = CEF_VERSION;
*product_name = product_name_.c_str();
*version = product_version_.c_str();
}
#if !defined(OS_MACOSX)
base::FilePath CefCrashReporterClient::GetReporterLogFilename() {
return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
}

View File

@ -8,6 +8,8 @@
#include <vector>
#include <string>
#include "include/cef_version.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "components/crash/content/app/crash_reporter_client.h"
@ -45,9 +47,9 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
bool GetCrashDumpLocation(base::string16* crash_dir) override;
bool GetCrashMetricsLocation(base::string16* metrics_dir) override;
#elif defined(OS_POSIX)
#if !defined(OS_MACOSX)
void GetProductNameAndVersion(const char** product_name,
const char** version) override;
#if !defined(OS_MACOSX)
base::FilePath GetReporterLogFilename() override;
bool EnableBreakpadForProcess(const std::string& process_type) override;
#endif
@ -99,6 +101,9 @@ private:
int max_db_size_ = 20;
int max_db_age_ = 5;
std::string product_name_ = "cef";
std::string product_version_ = CEF_VERSION;
#if defined(OS_WIN)
std::string app_name_ = "CEF";
std::string external_handler_;

View File

@ -340,10 +340,32 @@ index 3316fa0..df90dbd 100644
const char kWebViewSingleProcessType[] = "webview";
diff --git components/crash/content/app/crash_reporter_client.cc components/crash/content/app/crash_reporter_client.cc
index 3dfbd99..cb99c1e 100644
index 3dfbd99..80e5b66 100644
--- components/crash/content/app/crash_reporter_client.cc
+++ components/crash/content/app/crash_reporter_client.cc
@@ -141,6 +141,26 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
@@ -88,11 +88,12 @@ int CrashReporterClient::GetResultCodeRespawnFailed() {
}
#endif
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
+#if defined(OS_POSIX) && !defined(OS_IOS)
void CrashReporterClient::GetProductNameAndVersion(const char** product_name,
const char** version) {
}
+#if !defined(OS_MACOSX)
base::FilePath CrashReporterClient::GetReporterLogFilename() {
return base::FilePath();
}
@@ -101,6 +102,7 @@ bool CrashReporterClient::HandleCrashDump(const char* crashdump_filename) {
return false;
}
#endif
+#endif
#if defined(OS_WIN)
bool CrashReporterClient::GetCrashDumpLocation(base::string16* crash_dir) {
@@ -141,6 +143,26 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
}
#endif
@ -370,7 +392,7 @@ index 3dfbd99..cb99c1e 100644
#if defined(OS_ANDROID)
int CrashReporterClient::GetAndroidMinidumpDescriptor() {
return 0;
@@ -165,9 +185,4 @@ bool CrashReporterClient::ShouldEnableBreakpadMicrodumps() {
@@ -165,9 +187,4 @@ bool CrashReporterClient::ShouldEnableBreakpadMicrodumps() {
}
#endif
@ -381,7 +403,7 @@ index 3dfbd99..cb99c1e 100644
-
} // namespace crash_reporter
diff --git components/crash/content/app/crash_reporter_client.h components/crash/content/app/crash_reporter_client.h
index 25ae505..349ee49 100644
index 25ae505..d923b39 100644
--- components/crash/content/app/crash_reporter_client.h
+++ components/crash/content/app/crash_reporter_client.h
@@ -8,6 +8,7 @@
@ -392,7 +414,30 @@ index 25ae505..349ee49 100644
#include "base/strings/string16.h"
#include "build/build_config.h"
@@ -176,6 +177,17 @@ class CrashReporterClient {
@@ -104,12 +105,13 @@ class CrashReporterClient {
virtual int GetResultCodeRespawnFailed();
#endif
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
+#if defined(OS_POSIX) && !defined(OS_IOS)
// Returns a textual description of the product type and version to include
// in the crash report. Neither out parameter should be set to NULL.
virtual void GetProductNameAndVersion(const char** product_name,
const char** version);
+#if !defined(OS_MACOSX)
virtual base::FilePath GetReporterLogFilename();
// Custom crash minidump handler after the minidump is generated.
@@ -119,6 +121,7 @@ class CrashReporterClient {
// libc nor allocate memory normally.
virtual bool HandleCrashDump(const char* crashdump_filename);
#endif
+#endif
// The location where minidump files should be written. Returns true if
// |crash_dir| was set. Windows has to use base::string16 because this code
@@ -176,6 +179,17 @@ class CrashReporterClient {
// Returns true if breakpad should run in the given process type.
virtual bool EnableBreakpadForProcess(const std::string& process_type);
@ -411,7 +456,7 @@ index 25ae505..349ee49 100644
} // namespace crash_reporter
diff --git components/crash/content/app/crashpad_mac.mm components/crash/content/app/crashpad_mac.mm
index 7df66ea..f841aea 100644
index 7df66ea..1e24110 100644
--- components/crash/content/app/crashpad_mac.mm
+++ components/crash/content/app/crashpad_mac.mm
@@ -16,11 +16,14 @@
@ -443,7 +488,7 @@ index 7df66ea..f841aea 100644
// Is there a way to recover if this fails?
CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
@@ -54,7 +58,7 @@
@@ -54,16 +58,27 @@
// crash server won't have symbols for any other build types.
std::string url = "https://clients2.google.com/cr/report";
#else
@ -452,7 +497,50 @@ index 7df66ea..f841aea 100644
#endif
std::map<std::string, std::string> process_annotations;
@@ -90,6 +94,12 @@
+ const char* product_name = "";
+ const char* product_version = "";
+ crash_reporter_client->GetProductNameAndVersion(&product_name,
+ &product_version);
+
NSBundle* outer_bundle = base::mac::OuterBundle();
- NSString* product = base::mac::ObjCCast<NSString>([outer_bundle
- objectForInfoDictionaryKey:base::mac::CFToNSCast(kCFBundleNameKey)]);
- process_annotations["prod"] =
- base::SysNSStringToUTF8(product).append("_Mac");
+
+ if (strlen(product_name) == 0) {
+ NSString* product = base::mac::ObjCCast<NSString>([outer_bundle
+ objectForInfoDictionaryKey:base::mac::CFToNSCast(
+ kCFBundleNameKey)]);
+ process_annotations["prod"] =
+ base::SysNSStringToUTF8(product).append("_Mac");
+ } else {
+ process_annotations["prod"] = product_name;
+ }
#if defined(GOOGLE_CHROME_BUILD)
NSString* channel = base::mac::ObjCCast<NSString>(
@@ -73,10 +88,14 @@
}
#endif
- NSString* version =
- base::mac::ObjCCast<NSString>([base::mac::FrameworkBundle()
- objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
- process_annotations["ver"] = base::SysNSStringToUTF8(version);
+ if (strlen(product_version) == 0) {
+ NSString* version =
+ base::mac::ObjCCast<NSString>([base::mac::FrameworkBundle()
+ objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
+ process_annotations["ver"] = base::SysNSStringToUTF8(version);
+ } else {
+ process_annotations["ver"] = product_version;
+ }
process_annotations["plat"] = std::string("OS X");
@@ -90,6 +109,12 @@
"--reset-own-crash-exception-port-to-system-default");
}

View File

@ -16,6 +16,8 @@
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@ -16,6 +16,8 @@
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>LSFileQuarantineEnabled</key>