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

Unified Diff: snapshot/win/process_reader_win.cc

Issue 1119393003: win: Add support for CPUTimes and StartTime to snapshot (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@generate-dump
Patch Set: Created 5 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: snapshot/win/process_reader_win.cc
diff --git a/snapshot/win/process_reader_win.cc b/snapshot/win/process_reader_win.cc
index c0a3c56b454207a1b4669a3e2de9ae0ddba8a429..f08822eb7607f0f61bf095152a3b0c42f876b723 100644
--- a/snapshot/win/process_reader_win.cc
+++ b/snapshot/win/process_reader_win.cc
@@ -15,9 +15,19 @@
#include "snapshot/win/process_reader_win.h"
#include "base/numerics/safe_conversions.h"
+#include "util/win/time.h"
namespace crashpad {
+namespace {
+
+void TimerClear(timeval* tv) {
Mark Mentovai 2015/05/04 21:29:23 Do this in compat if it’s needed elsewhere, or jus
scottmg 2015/05/05 16:45:48 Done.
+ tv->tv_sec = 0;
+ tv->tv_usec = 0;
+}
+
+} // namespace
+
ProcessReaderWin::ProcessReaderWin()
: process_(INVALID_HANDLE_VALUE),
process_info_(),
@@ -54,6 +64,31 @@ bool ProcessReaderWin::ReadMemory(WinVMAddress at,
return true;
}
+bool ProcessReaderWin::StartTime(timeval* start_time) const {
+ FILETIME creation, exit, kernel, user;
+ if (!GetProcessTimes(process_, &creation, &exit, &kernel, &user)) {
+ PLOG(ERROR) << "GetProcessTimes";
+ TimerClear(start_time);
+ return false;
+ }
+ *start_time = FiletimeToTimevalEpoch(creation);
+ return true;
+}
+
+bool ProcessReaderWin::CPUTimes(timeval* user_time,
+ timeval* system_time) const {
+ FILETIME creation, exit, kernel, user;
+ if (!GetProcessTimes(process_, &creation, &exit, &kernel, &user)) {
+ PLOG(ERROR) << "GetProcessTimes";
+ TimerClear(user_time);
+ TimerClear(system_time);
+ return false;
+ }
+ *user_time = FiletimeToTimevalAmount(user);
+ *system_time = FiletimeToTimevalAmount(kernel);
+ return true;
+}
+
const std::vector<ProcessInfo::Module>& ProcessReaderWin::Modules() {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);

Powered by Google App Engine
This is Rietveld 408576698