Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: components/browser_watcher/dump_postmortem_minidump_main_win.cc

Issue 2521193003: Postmortem dumper: add support for Activity (Closed)
Patch Set: Clang compile Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // A utility for printing the contents of a postmortem stability minidump. 5 // A utility for printing the contents of a postmortem stability minidump.
6 6
7 #include <windows.h> // NOLINT 7 #include <windows.h> // NOLINT
8 #include <dbghelp.h> 8 #include <dbghelp.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 15 matching lines...) Expand all
26 base::FilePath* minidump_path) { 26 base::FilePath* minidump_path) {
27 *minidump_path = cmd->GetSwitchValuePath("minidump"); 27 *minidump_path = cmd->GetSwitchValuePath("minidump");
28 if (minidump_path->empty()) { 28 if (minidump_path->empty()) {
29 LOG(ERROR) << "Missing minidump file.\n"; 29 LOG(ERROR) << "Missing minidump file.\n";
30 LOG(ERROR) << base::StringPrintf(kUsage, cmd->GetProgram().value().c_str()); 30 LOG(ERROR) << base::StringPrintf(kUsage, cmd->GetProgram().value().c_str());
31 return false; 31 return false;
32 } 32 }
33 return true; 33 return true;
34 } 34 }
35 35
36 void Indent(FILE* out, size_t indent_level) {
37 DCHECK(out);
38 for (size_t i = 0; i < indent_level; ++i)
39 fprintf(out, " ");
40 }
41
42 void PrintActivity(FILE* out,
43 size_t indent_level,
44 const browser_watcher::Activity& activity) {
45 DCHECK(out);
46 Indent(out, indent_level);
47 fprintf(out, "Activity\n");
48 Indent(out, indent_level + 1);
49 fprintf(out, "type: %d\n", activity.type());
50 Indent(out, indent_level + 1);
51 fprintf(out, "time: %lld\n", activity.time());
52 switch (activity.type()) {
53 case browser_watcher::Activity::NONE:
54 break;
55 case browser_watcher::Activity::ACT_TASK_RUN:
56 Indent(out, indent_level + 1);
57 fprintf(out, "origin_address: %llx\n", activity.origin_address());
58 fprintf(out, "task_sequence_id: %lld\n", activity.task_sequence_id());
59 break;
60 case browser_watcher::Activity::ACT_LOCK_ACQUIRE:
61 Indent(out, indent_level + 1);
62 fprintf(out, "lock_address: %llx\n", activity.lock_address());
63 break;
64 case browser_watcher::Activity::ACT_EVENT_WAIT:
65 Indent(out, indent_level + 1);
66 fprintf(out, "event_address: %llx\n", activity.event_address());
67 break;
68 case browser_watcher::Activity::ACT_THREAD_JOIN:
69 Indent(out, indent_level + 1);
70 fprintf(out, "thread_id: %lld\n", activity.thread_id());
71 break;
72 case browser_watcher::Activity::ACT_PROCESS_WAIT:
73 Indent(out, indent_level + 1);
74 fprintf(out, "process_id: %lld\n", activity.process_id());
75 break;
76 }
77 }
78
36 void PrintProcessState(FILE* out, 79 void PrintProcessState(FILE* out,
37 const browser_watcher::ProcessState& process) { 80 const browser_watcher::ProcessState& process) {
38 fprintf(out, "%s", "Process:\n"); 81 fprintf(out, "Process %lld (%d threads)\n", process.process_id(),
39 for (int i = 0; i < process.threads_size(); ++i) { 82 process.threads_size());
40 const browser_watcher::ThreadState thread = process.threads(i); 83 for (const browser_watcher::ThreadState& thread : process.threads()) {
41 fprintf(out, "%s\n", thread.thread_name().c_str()); 84 fprintf(out, "Thread %lld (%s) : %d activities\n", thread.thread_id(),
85 thread.thread_name().c_str(), thread.activity_count());
86 for (const browser_watcher::Activity& activity : thread.activities())
87 PrintActivity(out, 1, activity);
42 } 88 }
43 } 89 }
44 90
45 // TODO(manzagop): flesh out as StabilityReport gets fleshed out. 91 // TODO(manzagop): flesh out as StabilityReport gets fleshed out.
46 void PrintReport(FILE* out, const browser_watcher::StabilityReport& report) { 92 void PrintReport(FILE* out, const browser_watcher::StabilityReport& report) {
47 for (int i = 0; i < report.process_states_size(); ++i) { 93 for (int i = 0; i < report.process_states_size(); ++i) {
48 const browser_watcher::ProcessState process = report.process_states(i); 94 const browser_watcher::ProcessState process = report.process_states(i);
49 PrintProcessState(out, process); 95 PrintProcessState(out, process);
50 } 96 }
51 } 97 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 PrintReport(stdout, report); 142 PrintReport(stdout, report);
97 143
98 return 0; 144 return 0;
99 } 145 }
100 146
101 } // namespace 147 } // namespace
102 148
103 int main(int argc, char** argv) { 149 int main(int argc, char** argv) {
104 return Main(argc, argv); 150 return Main(argc, argv);
105 } 151 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698