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" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "components/browser_watcher/postmortem_minidump_writer.h" | 16 #include "components/browser_watcher/postmortem_minidump_writer.h" |
17 #include "third_party/crashpad/crashpad/client/settings.h" | 17 #include "third_party/crashpad/crashpad/client/settings.h" |
18 #include "third_party/crashpad/crashpad/util/misc/uuid.h" | 18 #include "third_party/crashpad/crashpad/util/misc/uuid.h" |
19 | 19 |
20 using base::FilePath; | 20 using base::FilePath; |
21 | 21 |
22 namespace browser_watcher { | 22 namespace browser_watcher { |
23 | 23 |
24 using base::debug::ActivitySnapshot; | 24 using ActivitySnapshot = base::debug::ThreadActivityAnalyzer::Snapshot; |
25 using base::debug::GlobalActivityAnalyzer; | 25 using base::debug::GlobalActivityAnalyzer; |
26 using base::debug::ThreadActivityAnalyzer; | 26 using base::debug::ThreadActivityAnalyzer; |
27 using crashpad::CrashReportDatabase; | 27 using crashpad::CrashReportDatabase; |
28 | 28 |
29 PostmortemReportCollector::PostmortemReportCollector( | 29 PostmortemReportCollector::PostmortemReportCollector( |
30 const std::string& product_name, | 30 const std::string& product_name, |
31 const std::string& version_number, | 31 const std::string& version_number, |
32 const std::string& channel_name) | 32 const std::string& channel_name) |
33 : product_name_(product_name), | 33 : product_name_(product_name), |
34 version_number_(version_number), | 34 version_number_(version_number), |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 process_state->process_id()); | 192 process_state->process_id()); |
193 | 193 |
194 ThreadState* thread_state = process_state->add_threads(); | 194 ThreadState* thread_state = process_state->add_threads(); |
195 CollectThread(thread_analyzer->activity_snapshot(), thread_state); | 195 CollectThread(thread_analyzer->activity_snapshot(), thread_state); |
196 } | 196 } |
197 | 197 |
198 return SUCCESS; | 198 return SUCCESS; |
199 } | 199 } |
200 | 200 |
201 void PostmortemReportCollector::CollectThread( | 201 void PostmortemReportCollector::CollectThread( |
202 const base::debug::ActivitySnapshot& snapshot, | 202 const base::debug::ThreadActivityAnalyzer::Snapshot& snapshot, |
203 ThreadState* thread_state) { | 203 ThreadState* thread_state) { |
204 DCHECK(thread_state); | 204 DCHECK(thread_state); |
205 | 205 |
206 thread_state->set_thread_name(snapshot.thread_name); | 206 thread_state->set_thread_name(snapshot.thread_name); |
207 thread_state->set_thread_id(snapshot.thread_id); | 207 thread_state->set_thread_id(snapshot.thread_id); |
208 thread_state->set_activity_count(snapshot.activity_stack_depth); | 208 thread_state->set_activity_count(snapshot.activity_stack_depth); |
209 | 209 |
210 for (const base::debug::Activity& recorded : snapshot.activity_stack) { | 210 for (const base::debug::Activity& recorded : snapshot.activity_stack) { |
211 Activity* collected = thread_state->add_activities(); | 211 Activity* collected = thread_state->add_activities(); |
212 switch (recorded.activity_type) { | 212 switch (recorded.activity_type) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 #if defined(ARCH_CPU_X86) | 255 #if defined(ARCH_CPU_X86) |
256 minidump_info.platform = std::string("Win32"); | 256 minidump_info.platform = std::string("Win32"); |
257 #elif defined(ARCH_CPU_X86_64) | 257 #elif defined(ARCH_CPU_X86_64) |
258 minidump_info.platform = std::string("Win64"); | 258 minidump_info.platform = std::string("Win64"); |
259 #endif | 259 #endif |
260 | 260 |
261 return WritePostmortemDump(minidump_file, report, minidump_info); | 261 return WritePostmortemDump(minidump_file, report, minidump_info); |
262 } | 262 } |
263 | 263 |
264 } // namespace browser_watcher | 264 } // namespace browser_watcher |
OLD | NEW |