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

Unified Diff: components/crash/content/app/fallback_crash_handler_win.cc

Issue 2643273002: Grab system and process memory stats into crash keys in fallback handler. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | components/crash/content/app/fallback_crash_handler_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/crash/content/app/fallback_crash_handler_win.cc
diff --git a/components/crash/content/app/fallback_crash_handler_win.cc b/components/crash/content/app/fallback_crash_handler_win.cc
index f96d47a3c3a2b672a68cebb6a132eebfb4920bcd..a554673f6a606f2228480d3f15deba7ed1c949cc 100644
--- a/components/crash/content/app/fallback_crash_handler_win.cc
+++ b/components/crash/content/app/fallback_crash_handler_win.cc
@@ -5,6 +5,7 @@
#include "components/crash/content/app/fallback_crash_handler_win.h"
#include <dbghelp.h>
+#include <psapi.h>
#include <algorithm>
#include <map>
@@ -32,6 +33,40 @@ const FilePosition kInvalidFilePos = static_cast<FilePosition>(-1);
using StringStringMap = std::map<std::string, std::string>;
+void AcquireMemoryMetrics(const base::Process& process,
+ StringStringMap* crash_keys) {
+ // Grab the process private memory.
+ // This is best effort, though really shouldn't ever fail.
+ PROCESS_MEMORY_COUNTERS_EX process_memory = {sizeof(process_memory)};
+ if (GetProcessMemoryInfo(
+ process.Handle(),
+ reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&process_memory),
+ sizeof(process_memory))) {
+ // This is in units of bytes, re-scale to pages for consistency with
+ // system metrics.
+ const uint64_t kPageSize = 4096;
+ crash_keys->insert(std::make_pair(
+ "ProcessPrivateUsage",
+ base::Uint64ToString(process_memory.PrivateUsage / kPageSize)));
+
+ crash_keys->insert(std::make_pair(
+ "ProcessPeakWorkingSetSize",
+ base::Uint64ToString(process_memory.PeakWorkingSetSize / kPageSize)));
+ }
+
+ // Grab system commit memory. Also best effort.
+ PERFORMANCE_INFORMATION perf_info = {sizeof(perf_info)};
+ if (GetPerformanceInfo(&perf_info, sizeof(perf_info))) {
+ // Record the remaining committable memory and the limit. This is in units
+ // of system pages.
+ crash_keys->insert(std::make_pair(
+ "SystemCommitRemaining",
+ base::UintToString(perf_info.CommitLimit - perf_info.CommitTotal)));
+ crash_keys->insert(std::make_pair(
+ "SystemCommitLimit", base::UintToString(perf_info.CommitLimit)));
+ }
+}
+
// This class is a helper to edit minidump files written by MiniDumpWriteDump.
// It assumes the minidump file it operates on has a directory entry pointing to
// a CrashpadInfo entry, which it updates to point to the SimpleDictionary data
@@ -412,6 +447,9 @@ bool FallbackCrashHandler::GenerateCrashDump(const std::string& product,
{"plat", platform},
{"ptype", process_type}};
+ // Add memory metrics relating to system-wide and target process memory usage.
+ AcquireMemoryMetrics(process_, &crash_keys);
+
crashpad::UUID client_id;
crashpad::Settings* settings = database->GetSettings();
if (settings) {
@@ -434,8 +472,8 @@ bool FallbackCrashHandler::GenerateCrashDump(const std::string& product,
return false;
uint32_t minidump_type = MiniDumpWithUnloadedModules |
- MiniDumpWithProcessThreadData |
- MiniDumpWithThreadInfo;
+ MiniDumpWithProcessThreadData |
+ MiniDumpWithThreadInfo;
// Capture more detail for canary and dev channels. The prefix search caters
// for the soon to be outdated "-m" suffixed multi-install channels.
« no previous file with comments | « no previous file | components/crash/content/app/fallback_crash_handler_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698