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

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

Issue 2927653003: Stability instrumentation: add a Vectored Exception Handler (Closed)
Patch Set: A few comments Created 3 years, 6 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 unified diff | Download patch
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 #include "components/browser_watcher/stability_debugging.h" 5 #include "components/browser_watcher/stability_debugging.h"
6 6
7 #include <windows.h>
8
7 #include "base/debug/activity_tracker.h" 9 #include "base/debug/activity_tracker.h"
10 #include "build/build_config.h"
8 11
9 namespace browser_watcher { 12 namespace browser_watcher {
10 13
14 namespace {
15
16 // A registered vecotred exception handler.
Sigurður Ásgeirsson 2017/06/07 17:43:25 speling [sic]
manzagop (departed) 2017/06/08 22:46:38 Done.
17 void* g_veh_handler = nullptr;
18
19 uintptr_t GetProgramCounter(const CONTEXT& context) {
20 #if defined(ARCH_CPU_X86)
21 return context.Eip;
22 #elif defined(ARCH_CPU_X86_64)
23 return context.Rip;
24 #endif
25 }
26
27 LONG CALLBACK VectoredExceptionHandler(PEXCEPTION_POINTERS exception_pointers) {
Sigurður Ásgeirsson 2017/06/07 17:43:25 I think we shy away from the Hungarian notation PF
manzagop (departed) 2017/06/08 22:46:38 Done.
28 base::debug::GlobalActivityTracker* tracker =
29 base::debug::GlobalActivityTracker::Get();
Sigurður Ásgeirsson 2017/06/07 17:43:25 QQ: is this a straight-up accessor, or can this ca
manzagop (departed) 2017/06/08 22:46:38 This is a straight up accessor. ACK.
30 if (tracker) {
31 EXCEPTION_RECORD* record = exception_pointers->ExceptionRecord;
32 uintptr_t pc = GetProgramCounter(*exception_pointers->ContextRecord);
33 tracker->RecordException(reinterpret_cast<void*>(pc),
34 record->ExceptionAddress, record->ExceptionCode);
35 }
36
37 return EXCEPTION_CONTINUE_SEARCH; // Continue to the next handler.
38 }
39
40 } // namespace
41
11 void SetStabilityDataBool(base::StringPiece name, bool value) { 42 void SetStabilityDataBool(base::StringPiece name, bool value) {
12 base::debug::GlobalActivityTracker* global_tracker = 43 base::debug::GlobalActivityTracker* global_tracker =
13 base::debug::GlobalActivityTracker::Get(); 44 base::debug::GlobalActivityTracker::Get();
14 if (!global_tracker) 45 if (!global_tracker)
15 return; // Activity tracking isn't enabled. 46 return; // Activity tracking isn't enabled.
16 47
17 global_tracker->process_data().SetBool(name, value); 48 global_tracker->process_data().SetBool(name, value);
18 } 49 }
19 50
20 void SetStabilityDataInt(base::StringPiece name, int64_t value) { 51 void SetStabilityDataInt(base::StringPiece name, int64_t value) {
21 base::debug::GlobalActivityTracker* global_tracker = 52 base::debug::GlobalActivityTracker* global_tracker =
22 base::debug::GlobalActivityTracker::Get(); 53 base::debug::GlobalActivityTracker::Get();
23 if (!global_tracker) 54 if (!global_tracker)
24 return; // Activity tracking isn't enabled. 55 return; // Activity tracking isn't enabled.
25 56
26 global_tracker->process_data().SetInt(name, value); 57 global_tracker->process_data().SetInt(name, value);
27 } 58 }
28 59
60 void RegisterStabilityVEH() {
61 DCHECK(!g_veh_handler);
62 // Register a vectored exception handler and request it be first. Note that
63 // subsequent registrations may also request to be first, in which case this
64 // one will be bumped.
65 // TODO(manzagop): Depending on observations, it may be necessary to
66 // consider refreshing the registration, either periodically or at opportune
67 // (e.g. risky) times.
68 // DO NOT SUBMIT: figure out when to ::RemoveVectoredExceptionHandler.
Sigurður Ásgeirsson 2017/06/07 17:43:25 pro tip, there really isn't a good time to RemoveV
manzagop (departed) 2017/06/08 22:46:38 Does this look ok?
Sigurður Ásgeirsson 2017/06/09 13:55:15 looks good to me.
manzagop (departed) 2017/06/09 21:27:35 Acknowledged.
69 g_veh_handler = ::AddVectoredExceptionHandler(1, &VectoredExceptionHandler);
70 }
71
29 } // namespace browser_watcher 72 } // namespace browser_watcher
OLDNEW
« no previous file with comments | « components/browser_watcher/stability_debugging.h ('k') | components/browser_watcher/stability_report.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698