crash_allow_setting_more_options.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Jeremy Apthorp <[email protected]>
  3. Date: Thu, 30 Apr 2020 10:08:06 -0700
  4. Subject: crash: allow setting more options
  5. This allows the client of //components/crash to set upload url,
  6. rate-limiting, compression and global annotations.
  7. This should be upstreamed.
  8. diff --git a/components/crash/core/app/breakpad_linux.cc b/components/crash/core/app/breakpad_linux.cc
  9. index 00009dacdc2b084d7c647ab34c8c8be6decf1a5b..5eb19c8a47467d8df30316bfbd7f3c2f38aea7c0 100644
  10. --- a/components/crash/core/app/breakpad_linux.cc
  11. +++ b/components/crash/core/app/breakpad_linux.cc
  12. @@ -112,6 +112,7 @@ void SetUploadURL(const std::string& url) {
  13. }
  14. #endif
  15. +bool g_is_node = false;
  16. bool g_is_crash_reporter_enabled = false;
  17. uint64_t g_process_start_time = 0;
  18. pid_t g_pid = 0;
  19. diff --git a/components/crash/core/app/crash_reporter_client.cc b/components/crash/core/app/crash_reporter_client.cc
  20. index 89b4bfccd5d3278231726184547378805fb30ed5..9f0cb9d52e2f7fc0c1808500b775bc28b4514d00 100644
  21. --- a/components/crash/core/app/crash_reporter_client.cc
  22. +++ b/components/crash/core/app/crash_reporter_client.cc
  23. @@ -139,6 +139,17 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
  24. return false;
  25. }
  26. +bool CrashReporterClient::GetShouldRateLimit() {
  27. + return true;
  28. +}
  29. +
  30. +bool CrashReporterClient::GetShouldCompressUploads() {
  31. + return true;
  32. +}
  33. +
  34. +void CrashReporterClient::GetProcessSimpleAnnotations(std::map<std::string, std::string>* annotations) {
  35. +}
  36. +
  37. #if defined(OS_ANDROID)
  38. unsigned int CrashReporterClient::GetCrashDumpPercentage() {
  39. return 100;
  40. diff --git a/components/crash/core/app/crash_reporter_client.h b/components/crash/core/app/crash_reporter_client.h
  41. index 39557cce474439238255ecd28030215085db0c81..5b3f980837911c710686ab91a2a81c318334080b 100644
  42. --- a/components/crash/core/app/crash_reporter_client.h
  43. +++ b/components/crash/core/app/crash_reporter_client.h
  44. @@ -5,6 +5,7 @@
  45. #ifndef COMPONENTS_CRASH_CORE_APP_CRASH_REPORTER_CLIENT_H_
  46. #define COMPONENTS_CRASH_CORE_APP_CRASH_REPORTER_CLIENT_H_
  47. +#include <map>
  48. #include <string>
  49. #include "build/build_config.h"
  50. @@ -144,6 +145,19 @@ class CrashReporterClient {
  51. // that case, |breakpad_enabled| is set to the value enforced by policies.
  52. virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled);
  53. + // Returns true if crash uploads should be rate limited. If false, no
  54. + // throttling will be applied for uploads.
  55. + virtual bool GetShouldRateLimit();
  56. +
  57. + // Returns true if crash uploads should be compressed with gzip. If false,
  58. + // reports will be uploaded uncompressed.
  59. + virtual bool GetShouldCompressUploads();
  60. +
  61. + // Allows the client to add or edit global annotations passed to the crashpad
  62. + // handler.
  63. + virtual void GetProcessSimpleAnnotations(
  64. + std::map<std::string, std::string>* annotations);
  65. +
  66. #if defined(OS_ANDROID)
  67. // Used by WebView to sample crashes without generating the unwanted dumps. If
  68. // the returned value is less than 100, crash dumping will be sampled to that
  69. diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
  70. index 2be2fd857bc5f6775e20fc595929d984c7543f8c..0d633410842cc4fcb9f1befe452c4fc0776d3af8 100644
  71. --- a/components/crash/core/app/crashpad_mac.mm
  72. +++ b/components/crash/core/app/crashpad_mac.mm
  73. @@ -86,6 +86,8 @@
  74. } // @autoreleasepool
  75. return process_annotations;
  76. }();
  77. + CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
  78. + crash_reporter_client->GetProcessSimpleAnnotations(&annotations);
  79. return annotations;
  80. }
  81. @@ -156,6 +158,13 @@ void DumpProcessWithoutCrashing(task_t task_port) {
  82. std::vector<std::string> arguments;
  83. + if (!crash_reporter_client->GetShouldRateLimit()) {
  84. + arguments.push_back("--no-rate-limit");
  85. + }
  86. + if (!crash_reporter_client->GetShouldCompressUploads()) {
  87. + arguments.push_back("--no-upload-gzip");
  88. + }
  89. +
  90. if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
  91. arguments.push_back("--monitor-self");
  92. }
  93. diff --git a/components/crash/core/app/crashpad_win.cc b/components/crash/core/app/crashpad_win.cc
  94. index 686be7964d77dbba91a6265d157d05d97d5823fb..3e4585f7ba14650fa8b7e644b026147e0bac5119 100644
  95. --- a/components/crash/core/app/crashpad_win.cc
  96. +++ b/components/crash/core/app/crashpad_win.cc
  97. @@ -89,6 +89,7 @@ base::FilePath PlatformCrashpadInitialization(
  98. std::map<std::string, std::string> process_annotations;
  99. GetPlatformCrashpadAnnotations(&process_annotations);
  100. + crash_reporter_client->GetProcessSimpleAnnotations(&process_annotations);
  101. std::string url = crash_reporter_client->GetUploadUrl();
  102. @@ -127,6 +128,13 @@ base::FilePath PlatformCrashpadInitialization(
  103. std::vector<std::string> arguments(start_arguments);
  104. + if (!crash_reporter_client->GetShouldRateLimit()) {
  105. + arguments.push_back("--no-rate-limit");
  106. + }
  107. + if (!crash_reporter_client->GetShouldCompressUploads()) {
  108. + arguments.push_back("--no-upload-gzip");
  109. + }
  110. +
  111. if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
  112. arguments.push_back("--monitor-self");
  113. for (const std::string& start_argument : start_arguments) {