OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 while ((opt = getopt_long(argc, argv, "+a:h:", long_options, nullptr)) != | 108 while ((opt = getopt_long(argc, argv, "+a:h:", long_options, nullptr)) != |
109 -1) { | 109 -1) { |
110 switch (opt) { | 110 switch (opt) { |
111 case kOptionHandler: { | 111 case kOptionHandler: { |
112 options.handler = optarg; | 112 options.handler = optarg; |
113 break; | 113 break; |
114 } | 114 } |
115 case kOptionAnnotation: { | 115 case kOptionAnnotation: { |
116 std::string key; | 116 std::string key; |
117 std::string value; | 117 std::string value; |
118 if (!SplitString(optarg, '=', &key, &value)) { | 118 if (!SplitStringFirst(optarg, '=', &key, &value)) { |
119 ToolSupport::UsageHint(me, "--annotation requires KEY=VALUE"); | 119 ToolSupport::UsageHint(me, "--annotation requires KEY=VALUE"); |
120 return EXIT_FAILURE; | 120 return EXIT_FAILURE; |
121 } | 121 } |
122 std::string old_value; | 122 std::string old_value; |
123 if (!MapInsertOrReplace(&options.annotations, key, value, &old_value)) { | 123 if (!MapInsertOrReplace(&options.annotations, key, value, &old_value)) { |
124 LOG(WARNING) << "duplicate key " << key << ", discarding value " | 124 LOG(WARNING) << "duplicate key " << key << ", discarding value " |
125 << old_value; | 125 << old_value; |
126 } | 126 } |
127 break; | 127 break; |
128 } | 128 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 // Start the handler process and direct exceptions to it. | 163 // Start the handler process and direct exceptions to it. |
164 CrashpadClient crashpad_client; | 164 CrashpadClient crashpad_client; |
165 if (!crashpad_client.StartHandler(base::FilePath(options.handler), | 165 if (!crashpad_client.StartHandler(base::FilePath(options.handler), |
166 base::FilePath(options.database), | 166 base::FilePath(options.database), |
167 base::FilePath(), | 167 base::FilePath(), |
168 options.url, | 168 options.url, |
169 options.annotations, | 169 options.annotations, |
170 options.arguments, | 170 options.arguments, |
| 171 false, |
171 false)) { | 172 false)) { |
172 return kExitFailure; | 173 return kExitFailure; |
173 } | 174 } |
174 | 175 |
175 if (!crashpad_client.UseHandler()) { | |
176 return kExitFailure; | |
177 } | |
178 | |
179 // Using the remaining arguments, start a new program with the new exception | 176 // Using the remaining arguments, start a new program with the new exception |
180 // port in effect. | 177 // port in effect. |
181 execvp(argv[0], argv); | 178 execvp(argv[0], argv); |
182 PLOG(ERROR) << "execvp " << argv[0]; | 179 PLOG(ERROR) << "execvp " << argv[0]; |
183 return errno == ENOENT ? kExitExecENOENT : kExitExecFailure; | 180 return errno == ENOENT ? kExitExecENOENT : kExitExecFailure; |
184 } | 181 } |
185 | 182 |
186 } // namespace | 183 } // namespace |
187 } // namespace crashpad | 184 } // namespace crashpad |
188 | 185 |
189 int main(int argc, char* argv[]) { | 186 int main(int argc, char* argv[]) { |
190 return crashpad::RunWithCrashpadMain(argc, argv); | 187 return crashpad::RunWithCrashpadMain(argc, argv); |
191 } | 188 } |
OLD | NEW |