Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser_watcher/postmortem_report_collector.h" | 5 #include "components/browser_watcher/postmortem_report_collector.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/debug/activity_analyzer.h" | 9 #include "base/debug/activity_analyzer.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 DCHECK_NE(nullptr, report); | 160 DCHECK_NE(nullptr, report); |
| 161 report->reset(); | 161 report->reset(); |
| 162 | 162 |
| 163 // Create a global analyzer. | 163 // Create a global analyzer. |
| 164 std::unique_ptr<GlobalActivityAnalyzer> global_analyzer = | 164 std::unique_ptr<GlobalActivityAnalyzer> global_analyzer = |
| 165 GlobalActivityAnalyzer::CreateWithFile(debug_state_file); | 165 GlobalActivityAnalyzer::CreateWithFile(debug_state_file); |
| 166 if (!global_analyzer) | 166 if (!global_analyzer) |
| 167 return ANALYZER_CREATION_FAILED; | 167 return ANALYZER_CREATION_FAILED; |
| 168 | 168 |
| 169 // Early exit if there is no data. | 169 // Early exit if there is no data. |
| 170 std::vector<std::string> log_messages = global_analyzer->GetLogMessages(); | |
| 170 ThreadActivityAnalyzer* thread_analyzer = global_analyzer->GetFirstAnalyzer(); | 171 ThreadActivityAnalyzer* thread_analyzer = global_analyzer->GetFirstAnalyzer(); |
| 171 if (!thread_analyzer) { | 172 if (log_messages.empty() && !thread_analyzer) { |
|
bcwhite
2016/12/09 00:34:22
It's possible to have log messages even on a clean
manzagop (departed)
2016/12/09 22:41:09
Right: if we stop deleting the file on clean exit,
bcwhite
2016/12/09 23:17:06
log_messages being empty or non-empty doesn't cons
manzagop (departed)
2016/12/12 15:59:32
I've removed the mention of clean exit: this shoul
bcwhite
2016/12/13 13:22:55
So to be clear... You _do_ want to send a report
manzagop (departed)
2016/12/13 14:01:39
That's right: short term we rely on MarkStabilityF
| |
| 172 // No data. This case happens in the case of a clean exit. | 173 // No data. This case happens in the case of a clean exit. |
| 173 return DEBUG_FILE_NO_DATA; | 174 return DEBUG_FILE_NO_DATA; |
| 174 } | 175 } |
| 175 | 176 |
| 176 // Iterate through the thread analyzers, fleshing out the report. | 177 // Create the report, then flesh it out. |
| 177 report->reset(new StabilityReport()); | 178 report->reset(new StabilityReport()); |
| 179 | |
| 180 // Collect log messages. | |
| 181 for (const std::string& message : log_messages) { | |
| 182 (*report)->add_log_messages(message); | |
| 183 } | |
| 184 | |
| 185 // Collect thread activity data. | |
| 178 // Note: a single process is instrumented. | 186 // Note: a single process is instrumented. |
| 179 ProcessState* process_state = (*report)->add_process_states(); | 187 ProcessState* process_state = (*report)->add_process_states(); |
| 180 | |
| 181 for (; thread_analyzer != nullptr; | 188 for (; thread_analyzer != nullptr; |
| 182 thread_analyzer = global_analyzer->GetNextAnalyzer()) { | 189 thread_analyzer = global_analyzer->GetNextAnalyzer()) { |
| 183 // Only valid analyzers are expected per contract of GetFirstAnalyzer / | 190 // Only valid analyzers are expected per contract of GetFirstAnalyzer / |
| 184 // GetNextAnalyzer. | 191 // GetNextAnalyzer. |
| 185 DCHECK(thread_analyzer->IsValid()); | 192 DCHECK(thread_analyzer->IsValid()); |
| 186 | 193 |
| 187 if (!process_state->has_process_id()) { | 194 if (!process_state->has_process_id()) { |
| 188 process_state->set_process_id( | 195 process_state->set_process_id( |
| 189 thread_analyzer->activity_snapshot().process_id); | 196 thread_analyzer->activity_snapshot().process_id); |
| 190 } | 197 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 #if defined(ARCH_CPU_X86) | 262 #if defined(ARCH_CPU_X86) |
| 256 minidump_info.platform = std::string("Win32"); | 263 minidump_info.platform = std::string("Win32"); |
| 257 #elif defined(ARCH_CPU_X86_64) | 264 #elif defined(ARCH_CPU_X86_64) |
| 258 minidump_info.platform = std::string("Win64"); | 265 minidump_info.platform = std::string("Win64"); |
| 259 #endif | 266 #endif |
| 260 | 267 |
| 261 return WritePostmortemDump(minidump_file, report, minidump_info); | 268 return WritePostmortemDump(minidump_file, report, minidump_info); |
| 262 } | 269 } |
| 263 | 270 |
| 264 } // namespace browser_watcher | 271 } // namespace browser_watcher |
| OLD | NEW |