OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/crash/content/app/crashpad.h" | 5 #include "components/crash/content/app/crashpad.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 std::map<std::string, std::string> process_annotations; | 60 std::map<std::string, std::string> process_annotations; |
61 | 61 |
62 NSBundle* outer_bundle = base::mac::OuterBundle(); | 62 NSBundle* outer_bundle = base::mac::OuterBundle(); |
63 NSString* product = base::mac::ObjCCast<NSString>([outer_bundle | 63 NSString* product = base::mac::ObjCCast<NSString>([outer_bundle |
64 objectForInfoDictionaryKey:base::mac::CFToNSCast(kCFBundleNameKey)]); | 64 objectForInfoDictionaryKey:base::mac::CFToNSCast(kCFBundleNameKey)]); |
65 process_annotations["prod"] = | 65 process_annotations["prod"] = |
66 base::SysNSStringToUTF8(product).append("_Mac"); | 66 base::SysNSStringToUTF8(product).append("_Mac"); |
67 | 67 |
68 #if defined(GOOGLE_CHROME_BUILD) | 68 #if defined(GOOGLE_CHROME_BUILD) |
| 69 // Empty means stable. |
| 70 const bool allow_empty_channel = true; |
| 71 #else |
| 72 const bool allow_empty_channel = false; |
| 73 #endif |
69 NSString* channel = base::mac::ObjCCast<NSString>( | 74 NSString* channel = base::mac::ObjCCast<NSString>( |
70 [outer_bundle objectForInfoDictionaryKey:@"KSChannelID"]); | 75 [outer_bundle objectForInfoDictionaryKey:@"KSChannelID"]); |
71 if (channel) { | 76 if (channel) { |
72 process_annotations["channel"] = base::SysNSStringToUTF8(channel); | 77 process_annotations["channel"] = base::SysNSStringToUTF8(channel); |
| 78 } else if (allow_empty_channel) { |
| 79 process_annotations["channel"] = ""; |
73 } | 80 } |
74 #endif | |
75 | 81 |
76 NSString* version = | 82 NSString* version = |
77 base::mac::ObjCCast<NSString>([base::mac::FrameworkBundle() | 83 base::mac::ObjCCast<NSString>([base::mac::FrameworkBundle() |
78 objectForInfoDictionaryKey:@"CFBundleShortVersionString"]); | 84 objectForInfoDictionaryKey:@"CFBundleShortVersionString"]); |
79 process_annotations["ver"] = base::SysNSStringToUTF8(version); | 85 process_annotations["ver"] = base::SysNSStringToUTF8(version); |
80 | 86 |
81 process_annotations["plat"] = std::string("OS X"); | 87 process_annotations["plat"] = std::string("OS X"); |
82 | 88 |
83 std::vector<std::string> arguments; | 89 std::vector<std::string> arguments; |
| 90 |
| 91 if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) { |
| 92 arguments.push_back("--monitor-self"); |
| 93 } |
| 94 |
| 95 // Set up --monitor-self-annotation even in the absence of --monitor-self |
| 96 // so that minidumps produced by Crashpad's generate_dump tool will |
| 97 // contain these annotations. |
| 98 arguments.push_back("--monitor-self-annotation=ptype=crashpad-handler"); |
| 99 |
84 if (!browser_process) { | 100 if (!browser_process) { |
85 // If this is an initial client that's not the browser process, it's | 101 // If this is an initial client that's not the browser process, it's |
86 // important that the new Crashpad handler also not be connected to any | 102 // important that the new Crashpad handler also not be connected to any |
87 // existing handler. This argument tells the new Crashpad handler to | 103 // existing handler. This argument tells the new Crashpad handler to |
88 // sever this connection. | 104 // sever this connection. |
89 arguments.push_back( | 105 arguments.push_back( |
90 "--reset-own-crash-exception-port-to-system-default"); | 106 "--reset-own-crash-exception-port-to-system-default"); |
91 } | 107 } |
92 | 108 |
93 bool result = GetCrashpadClient().StartHandler( | 109 bool result = GetCrashpadClient().StartHandler( |
94 handler_path, database_path, metrics_path, url, process_annotations, | 110 handler_path, database_path, metrics_path, url, process_annotations, |
95 arguments, true, false); | 111 arguments, true, false); |
96 | 112 |
97 // If this is an initial client that's not the browser process, it's | 113 // If this is an initial client that's not the browser process, it's |
98 // important to sever the connection to any existing handler. If | 114 // important to sever the connection to any existing handler. If |
99 // StartHandler() failed, call UseSystemDefaultHandler() to drop the link | 115 // StartHandler() failed, call UseSystemDefaultHandler() to drop the link |
100 // to the existing handler. | 116 // to the existing handler. |
101 if (!result && !browser_process) { | 117 if (!result && !browser_process) { |
102 crashpad::CrashpadClient::UseSystemDefaultHandler(); | 118 crashpad::CrashpadClient::UseSystemDefaultHandler(); |
103 } | 119 } |
104 } // @autoreleasepool | 120 } // @autoreleasepool |
105 } | 121 } |
106 | 122 |
107 return database_path; | 123 return database_path; |
108 } | 124 } |
109 | 125 |
110 } // namespace internal | 126 } // namespace internal |
111 } // namespace crash_reporter | 127 } // namespace crash_reporter |
OLD | NEW |