Commit 8b856148 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Fix HandleVerifier trace events for static builds

This CL is fixing the trace events of the HandleVerifier for a
non components build.

For a static build, there are two instances of the HandleVerifier
  1) chrome.exe!HandleVerifier
  2) chrome.dll!HandleVerifier

At chrome startup, chrome.exe!InstallVerifier set a global singleton
which start tracking ScopedHandle objects.

After the initialisation, chrome.dll is loaded. The call of
chrome.dll::InstallVerifier() is fetching the singleton from 1) and is
storing it as a global singleton into chrome.dll. Calls to the
chrome.dll!VerifierTraits::StartTracking() and
chrome.dll!VerifierTraits::StopTracking are forwarded to the
chrome.exe!HandleVerifier instance.

Since TraceLog is also part of base, there is also two instances
in each module. There are two instances of categories array that specify
which categories are enabled but only one is used by chrome tracing.

A trace event executed in chrome.exe will never be enabled. This is
explaining why trace events from chrome.exe!HandleVerifier are not
emitted unless the build is a component build.

To solve this issue, this CL is lifting the trace events before
entering the code that forward the call to chrome.exe. This way trace
events are using the right instance of TraceLog (e.g. chrome.dll).

Bug: 1110507
Change-Id: I61ee1e18b849d32f90d2430759da6d1c8666c854
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324873
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792764}
parent ef3af184
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/win/scoped_handle.h"
#include "base/trace_event/base_tracing.h"
#include "base/win/scoped_handle_verifier.h"
#include "base/win/windows_types.h"
......@@ -13,6 +14,7 @@ using base::win::internal::ScopedHandleVerifier;
// Static.
bool HandleTraits::CloseHandle(HANDLE handle) {
TRACE_EVENT0("base", "HandleTraits::CloseHandle");
return ScopedHandleVerifier::Get()->CloseHandle(handle);
}
......@@ -21,6 +23,7 @@ void VerifierTraits::StartTracking(HANDLE handle,
const void* owner,
const void* pc1,
const void* pc2) {
TRACE_EVENT0("base", "VerifierTraits::StartTracking");
return ScopedHandleVerifier::Get()->StartTracking(handle, owner, pc1, pc2);
}
......@@ -29,6 +32,7 @@ void VerifierTraits::StopTracking(HANDLE handle,
const void* owner,
const void* pc1,
const void* pc2) {
TRACE_EVENT0("base", "VerifierTraits::StopTracking");
return ScopedHandleVerifier::Get()->StopTracking(handle, owner, pc1, pc2);
}
......@@ -37,6 +41,7 @@ void DisableHandleVerifier() {
}
void OnHandleBeingClosed(HANDLE handle) {
TRACE_EVENT0("base", "base::win::OnHandleBeingClosed");
return ScopedHandleVerifier::Get()->OnHandleBeingClosed(handle);
}
......
......@@ -15,7 +15,6 @@
#include "base/debug/alias.h"
#include "base/debug/stack_trace.h"
#include "base/synchronization/lock_impl.h"
#include "base/trace_event/base_tracing.h"
#include "base/win/base_win_buildflags.h"
#include "base/win/current_module.h"
......@@ -216,8 +215,6 @@ NOINLINE void ScopedHandleVerifier::StartTrackingImpl(HANDLE handle,
const void* owner,
const void* pc1,
const void* pc2) {
TRACE_EVENT0("base", "ScopedHandleVerifier::StartTrackingImpl");
// Grab the thread id before the lock.
DWORD thread_id = GetCurrentThreadId();
......@@ -238,8 +235,6 @@ NOINLINE void ScopedHandleVerifier::StopTrackingImpl(HANDLE handle,
const void* owner,
const void* pc1,
const void* pc2) {
TRACE_EVENT0("base", "ScopedHandleVerifier::StopTrackingImpl");
AutoNativeLock lock(*lock_);
HandleMap::iterator i = map_.find(handle);
if (i == map_.end()) {
......@@ -256,7 +251,6 @@ NOINLINE void ScopedHandleVerifier::StopTrackingImpl(HANDLE handle,
}
NOINLINE void ScopedHandleVerifier::OnHandleBeingClosedImpl(HANDLE handle) {
TRACE_EVENT0("base", "ScopedHandleVerifier::OnHandleBeingClosedImpl");
if (closing_.Get())
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment