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 // 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 | 8 |
9 #include <dbghelp.h> | 9 #include <dbghelp.h> |
10 | 10 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 fprintf(out, "id: %u, data: %d\n", activity.generic_id(), | 133 fprintf(out, "id: %u, data: %d\n", activity.generic_id(), |
134 activity.generic_data()); | 134 activity.generic_data()); |
135 break; | 135 break; |
136 } | 136 } |
137 | 137 |
138 PrintUserData(out, indent_level + 1, activity.user_data()); | 138 PrintUserData(out, indent_level + 1, activity.user_data()); |
139 } | 139 } |
140 | 140 |
141 void PrintProcessState(FILE* out, | 141 void PrintProcessState(FILE* out, |
142 const browser_watcher::ProcessState& process) { | 142 const browser_watcher::ProcessState& process) { |
143 fprintf(out, "Process %lld (%d threads)\n", process.process_id(), | 143 std::string process_type; |
144 process.threads_size()); | 144 switch (process.process_type()) { |
| 145 case browser_watcher::ProcessState::UNKNOWN_PROCESS: |
| 146 process_type = "unknown type"; |
| 147 break; |
| 148 case browser_watcher::ProcessState::BROWSER_PROCESS: |
| 149 process_type = "browser"; |
| 150 break; |
| 151 case browser_watcher::ProcessState::WATCHER_PROCESS: |
| 152 process_type = "watcher"; |
| 153 break; |
| 154 default: |
| 155 base::SStringPrintf(&process_type, "process type %d", |
| 156 process.process_type()); |
| 157 break; |
| 158 } |
| 159 |
| 160 fprintf(out, "Process %lld (%s, %d threads)\n", process.process_id(), |
| 161 process_type.c_str(), process.threads_size()); |
145 | 162 |
146 if (process.has_memory_state() && | 163 if (process.has_memory_state() && |
147 process.memory_state().has_windows_memory()) { | 164 process.memory_state().has_windows_memory()) { |
148 const auto& windows_memory = process.memory_state().windows_memory(); | 165 const auto& windows_memory = process.memory_state().windows_memory(); |
149 if (windows_memory.has_process_private_usage()) { | 166 if (windows_memory.has_process_private_usage()) { |
150 fprintf(out, "process_private_usage: %u pages\n", | 167 fprintf(out, "process_private_usage: %u pages\n", |
151 windows_memory.process_private_usage()); | 168 windows_memory.process_private_usage()); |
152 } | 169 } |
153 if (windows_memory.has_process_peak_workingset_size()) { | 170 if (windows_memory.has_process_peak_workingset_size()) { |
154 fprintf(out, "process_peak_workingset_size: %u pages\n", | 171 fprintf(out, "process_peak_workingset_size: %u pages\n", |
155 windows_memory.process_peak_workingset_size()); | 172 windows_memory.process_peak_workingset_size()); |
156 } | 173 } |
157 if (windows_memory.has_process_peak_pagefile_usage()) { | 174 if (windows_memory.has_process_peak_pagefile_usage()) { |
158 fprintf(out, "process_peak_pagefile_usage: %u pages\n", | 175 fprintf(out, "process_peak_pagefile_usage: %u pages\n", |
159 windows_memory.process_peak_pagefile_usage()); | 176 windows_memory.process_peak_pagefile_usage()); |
160 } | 177 } |
161 if (windows_memory.has_process_allocation_attempt()) { | 178 if (windows_memory.has_process_allocation_attempt()) { |
162 fprintf(out, "process_allocation_attempt: %u bytes\n", | 179 fprintf(out, "process_allocation_attempt: %u bytes\n", |
163 windows_memory.process_allocation_attempt()); | 180 windows_memory.process_allocation_attempt()); |
164 } | 181 } |
165 } | 182 } |
| 183 |
166 for (const browser_watcher::ThreadState& thread : process.threads()) { | 184 for (const browser_watcher::ThreadState& thread : process.threads()) { |
167 fprintf(out, "Thread %lld (%s) : %d activities\n", thread.thread_id(), | 185 fprintf(out, "Thread %lld (%s) : %d activities\n", thread.thread_id(), |
168 thread.thread_name().c_str(), thread.activity_count()); | 186 thread.thread_name().c_str(), thread.activity_count()); |
169 for (const browser_watcher::Activity& activity : thread.activities()) | 187 for (const browser_watcher::Activity& activity : thread.activities()) |
170 PrintActivity(out, 1, activity); | 188 PrintActivity(out, 1, activity); |
171 } | 189 } |
| 190 |
| 191 PrintUserData(out, 1, process.data()); |
172 } | 192 } |
173 | 193 |
174 // TODO(manzagop): flesh out as StabilityReport gets fleshed out. | 194 // TODO(manzagop): flesh out as StabilityReport gets fleshed out. |
175 void PrintReport(FILE* out, const browser_watcher::StabilityReport& report) { | 195 void PrintReport(FILE* out, const browser_watcher::StabilityReport& report) { |
176 if (report.has_system_memory_state() && | 196 if (report.has_system_memory_state() && |
177 report.system_memory_state().has_windows_memory()) { | 197 report.system_memory_state().has_windows_memory()) { |
178 const auto& windows_memory = report.system_memory_state().windows_memory(); | 198 const auto& windows_memory = report.system_memory_state().windows_memory(); |
179 | 199 |
180 if (windows_memory.has_system_commit_limit()) { | 200 if (windows_memory.has_system_commit_limit()) { |
181 fprintf(out, "system_commit_limit: %u pages\n", | 201 fprintf(out, "system_commit_limit: %u pages\n", |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 PrintReport(stdout, report); | 279 PrintReport(stdout, report); |
260 | 280 |
261 return 0; | 281 return 0; |
262 } | 282 } |
263 | 283 |
264 } // namespace | 284 } // namespace |
265 | 285 |
266 int main(int argc, char** argv) { | 286 int main(int argc, char** argv) { |
267 return Main(argc, argv); | 287 return Main(argc, argv); |
268 } | 288 } |
OLD | NEW |