OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // Handle a specific user space crash. | 141 // Handle a specific user space crash. |
142 CHECK(!FLAGS_user.empty()) << "--user= must be set"; | 142 CHECK(!FLAGS_user.empty()) << "--user= must be set"; |
143 | 143 |
144 // Make it possible to test what happens when we crash while | 144 // Make it possible to test what happens when we crash while |
145 // handling a crash. | 145 // handling a crash. |
146 if (FLAGS_crash_test) { | 146 if (FLAGS_crash_test) { |
147 *(char *)0 = 0; | 147 *(char *)0 = 0; |
148 return 0; | 148 return 0; |
149 } | 149 } |
150 | 150 |
| 151 // Accumulate logs to help in diagnosing failures during user collection. |
| 152 s_system_log.set_accumulating(true); |
151 // Handle the crash, get the name of the process from procfs. | 153 // Handle the crash, get the name of the process from procfs. |
152 if (!user_collector->HandleCrash(FLAGS_user, NULL)) { | 154 bool handled = user_collector->HandleCrash(FLAGS_user, NULL); |
| 155 s_system_log.set_accumulating(false); |
| 156 if (!handled) |
153 return 1; | 157 return 1; |
154 } | |
155 return 0; | 158 return 0; |
156 } | 159 } |
157 | 160 |
158 // Interactive/diagnostics mode for generating kernel crash signatures. | 161 // Interactive/diagnostics mode for generating kernel crash signatures. |
159 static int GenerateKernelSignature(KernelCollector *kernel_collector) { | 162 static int GenerateKernelSignature(KernelCollector *kernel_collector) { |
160 std::string kcrash_contents; | 163 std::string kcrash_contents; |
161 std::string signature; | 164 std::string signature; |
162 if (!file_util::ReadFileToString(FilePath(FLAGS_generate_kernel_signature), | 165 if (!file_util::ReadFileToString(FilePath(FLAGS_generate_kernel_signature), |
163 &kcrash_contents)) { | 166 &kcrash_contents)) { |
164 fprintf(stderr, "Could not read file.\n"); | 167 fprintf(stderr, "Could not read file.\n"); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 user_collector.Disable(); | 215 user_collector.Disable(); |
213 return 0; | 216 return 0; |
214 } | 217 } |
215 | 218 |
216 if (!FLAGS_generate_kernel_signature.empty()) { | 219 if (!FLAGS_generate_kernel_signature.empty()) { |
217 return GenerateKernelSignature(&kernel_collector); | 220 return GenerateKernelSignature(&kernel_collector); |
218 } | 221 } |
219 | 222 |
220 return HandleUserCrash(&user_collector); | 223 return HandleUserCrash(&user_collector); |
221 } | 224 } |
OLD | NEW |