summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-26 21:57:52 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-26 21:57:52 +0000
commit19f9aa382283378bb1b6c130511ae6bd873b5453 (patch)
tree42bed7abb4f68653696f7edee653426213036d79
parent85eea1db1d52cd71a4a9004c8a2591c18adfa8a1 (diff)
downloadchromium_src-19f9aa382283378bb1b6c130511ae6bd873b5453.zip
chromium_src-19f9aa382283378bb1b6c130511ae6bd873b5453.tar.gz
chromium_src-19f9aa382283378bb1b6c130511ae6bd873b5453.tar.bz2
[Mac] Put command-line switches into crash keys.
BUG=60991 TEST=Crash dumps show neato crash keys. Review URL: http://codereview.chromium.org/8015021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102813 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/child_process_logging_mac.mm34
1 files changed, 32 insertions, 2 deletions
diff --git a/chrome/common/child_process_logging_mac.mm b/chrome/common/child_process_logging_mac.mm
index dbcf37b..5b0c0d7 100644
--- a/chrome/common/child_process_logging_mac.mm
+++ b/chrome/common/child_process_logging_mac.mm
@@ -6,9 +6,11 @@
#import <Foundation/Foundation.h>
+#include "base/command_line.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/common/gpu/gpu_info.h"
@@ -173,8 +175,36 @@ void SetNumberOfViews(int number_of_views) {
SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue);
}
-void SetCommandLine(const CommandLine*) {
- // TODO: http://crbug.com/60991
+void SetCommandLine(const CommandLine* command_line) {
+ DCHECK(SetCrashKeyValue);
+ DCHECK(ClearCrashKey);
+ DCHECK(command_line);
+ if (!command_line || !SetCrashKeyValue || !ClearCrashKey)
+ return;
+
+ // These should match the corresponding strings in breakpad_win.cc.
+ NSString* const kNumSwitchesKey = @"num-switches";
+ NSString* const kSwitchKeyFormat = @"switch-%d";
+
+ // Note the total number of switches, not including the exec path.
+ const CommandLine::StringVector& argv = command_line->argv();
+ SetCrashKeyValue(kNumSwitchesKey,
+ [NSString stringWithFormat:@"%d", argv.size() - 1]);
+
+ size_t key_i = 0;
+ for (size_t i = 1; i < argv.size() && key_i < kMaxSwitches; ++i) {
+ // TODO(shess): Skip boring switches.
+ NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, key_i];
+ NSString* value = base::SysUTF8ToNSString(argv[i]);
+ SetCrashKeyValue(key, value);
+ key_i++;
+ }
+
+ // Clear out any stale keys.
+ for (; key_i < kMaxSwitches; ++key_i) {
+ NSString* key = [NSString stringWithFormat:kSwitchKeyFormat, key_i];
+ ClearCrashKey(key);
+ }
}
} // namespace child_process_logging