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

Unified Diff: base/debug/gdi_debug_util_win.cc

Issue 2452933002: Collect information on the dump when GetDC fails. (Closed)
Patch Set: Created 4 years, 2 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: base/debug/gdi_debug_util_win.cc
diff --git a/base/debug/gdi_debug_util_win.cc b/base/debug/gdi_debug_util_win.cc
index ce339559eadfe57f11d7ceeeb1e2a3e95b3b73f7..7aded1c06b2cf305c2f7f89636e18c62d7951137 100644
--- a/base/debug/gdi_debug_util_win.cc
+++ b/base/debug/gdi_debug_util_win.cc
@@ -59,22 +59,12 @@ void CollectChildGDIUsageAndDie(DWORD parent_pid) {
CHECK(false);
}
-} // namespace
-
-namespace base {
-namespace debug {
-
-void GDIBitmapAllocFailure(BITMAPINFOHEADER* header, HANDLE shared_section) {
+void CollectGDIUsageAndDieWithBitmap(BITMAPINFOHEADER* header,
+ HANDLE shared_section) {
// Make sure parameters are saved in the minidump.
DWORD last_error = GetLastError();
- LONG width = header->biWidth;
- LONG heigth = header->biHeight;
-
base::debug::Alias(&last_error);
- base::debug::Alias(&width);
- base::debug::Alias(&heigth);
- base::debug::Alias(&shared_section);
DWORD num_user_handles = GetGuiResources(GetCurrentProcess(), GR_USEROBJECTS);
@@ -100,24 +90,45 @@ void GDIBitmapAllocFailure(BITMAPINFOHEADER* header, HANDLE shared_section) {
CHECK_LE(pmc.PagefileUsage, kLotsOfMemory);
CHECK_LE(pmc.PrivateUsage, kLotsOfMemory);
- void* small_data = NULL;
+ void* small_data = nullptr;
base::debug::Alias(&small_data);
- if (std::abs(heigth) * width > 100) {
+ if (header && (std::abs(header->biHeight) * header->biWidth > 100)) {
// Huh, that's weird. We don't have crazy handle count, we don't have
// ridiculous memory usage. Try to allocate a small bitmap and see if that
// fails too.
header->biWidth = 5;
header->biHeight = -5;
HBITMAP small_bitmap = CreateDIBSection(
- NULL, reinterpret_cast<BITMAPINFO*>(&header),
+ nullptr, reinterpret_cast<BITMAPINFO*>(&header),
0, &small_data, shared_section, 0);
- CHECK(small_bitmap != NULL);
+ CHECK(small_bitmap != nullptr);
DeleteObject(small_bitmap);
}
+
// Maybe the child processes are the ones leaking GDI or USER resouces.
CollectChildGDIUsageAndDie(GetCurrentProcessId());
}
+} // namespace
+
+namespace base {
+namespace debug {
+
+void CollectGDIUsageAndDie() {
+ CollectGDIUsageAndDieWithBitmap(nullptr, nullptr);
+}
+
+void GDIBitmapAllocFailure(BITMAPINFOHEADER* header, HANDLE shared_section) {
+ LONG width = header->biWidth;
+ LONG height = header->biHeight;
+
+ base::debug::Alias(&width);
+ base::debug::Alias(&height);
+ base::debug::Alias(&shared_section);
+
+ CollectGDIUsageAndDieWithBitmap(header, shared_section);
+}
+
} // namespace debug
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698