Commit a3833d9f authored by Xi Cheng's avatar Xi Cheng Committed by Commit Bot

Format stack_sampling_profiler_unittest.cc

Bug: 851163
Change-Id: I852e1c1bcab17d250ddd5dcb7f69ca7d81d0ccdc
Reviewed-on: https://chromium-review.googlesource.com/1122964Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Reviewed-by: default avatarXi Cheng <chengx@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571941}
parent 318d6767
...@@ -93,8 +93,9 @@ struct StackConfiguration { ...@@ -93,8 +93,9 @@ struct StackConfiguration {
// Signature for a target function that is expected to appear in the stack. See // Signature for a target function that is expected to appear in the stack. See
// SignalAndWaitUntilSignaled() below. The return value should be a program // SignalAndWaitUntilSignaled() below. The return value should be a program
// counter pointer near the end of the function. // counter pointer near the end of the function.
using TargetFunction = const void*(*)(WaitableEvent*, WaitableEvent*, using TargetFunction = const void* (*)(WaitableEvent*,
const StackConfiguration*); WaitableEvent*,
const StackConfiguration*);
// A thread to target for profiling, whose stack is guaranteed to contain // A thread to target for profiling, whose stack is guaranteed to contain
// SignalAndWaitUntilSignaled() when coordinated with the main thread. // SignalAndWaitUntilSignaled() when coordinated with the main thread.
...@@ -150,7 +151,7 @@ class TargetThread : public PlatformThread::Delegate { ...@@ -150,7 +151,7 @@ class TargetThread : public PlatformThread::Delegate {
}; };
// Callback function to be provided when calling through the other library. // Callback function to be provided when calling through the other library.
static void OtherLibraryCallback(void *arg); static void OtherLibraryCallback(void* arg);
// Returns the current program counter, or a value very close to it. // Returns the current program counter, or a value very close to it.
static const void* GetProgramCounter(); static const void* GetProgramCounter();
...@@ -238,18 +239,15 @@ NOINLINE const void* TargetThread::CallThroughOtherLibrary( ...@@ -238,18 +239,15 @@ NOINLINE const void* TargetThread::CallThroughOtherLibrary(
const StackConfiguration* stack_config) { const StackConfiguration* stack_config) {
if (stack_config) { if (stack_config) {
// A function whose arguments are a function accepting void*, and a void*. // A function whose arguments are a function accepting void*, and a void*.
using InvokeCallbackFunction = void(*)(void (*)(void*), void*); using InvokeCallbackFunction = void (*)(void (*)(void*), void*);
EXPECT_TRUE(stack_config->library); EXPECT_TRUE(stack_config->library);
InvokeCallbackFunction function = reinterpret_cast<InvokeCallbackFunction>( InvokeCallbackFunction function = reinterpret_cast<InvokeCallbackFunction>(
GetFunctionPointerFromNativeLibrary(stack_config->library, GetFunctionPointerFromNativeLibrary(stack_config->library,
"InvokeCallbackFunction")); "InvokeCallbackFunction"));
EXPECT_TRUE(function); EXPECT_TRUE(function);
TargetFunctionArgs args = { TargetFunctionArgs args = {thread_started_event, finish_event,
thread_started_event, stack_config};
finish_event,
stack_config
};
(*function)(&OtherLibraryCallback, &args); (*function)(&OtherLibraryCallback, &args);
} }
...@@ -259,7 +257,7 @@ NOINLINE const void* TargetThread::CallThroughOtherLibrary( ...@@ -259,7 +257,7 @@ NOINLINE const void* TargetThread::CallThroughOtherLibrary(
} }
// static // static
void TargetThread::OtherLibraryCallback(void *arg) { void TargetThread::OtherLibraryCallback(void* arg) {
const TargetFunctionArgs* args = static_cast<TargetFunctionArgs*>(arg); const TargetFunctionArgs* args = static_cast<TargetFunctionArgs*>(arg);
SignalAndWaitUntilSignaled(args->thread_started_event, args->finish_event, SignalAndWaitUntilSignaled(args->thread_started_event, args->finish_event,
args->stack_config); args->stack_config);
...@@ -311,7 +309,7 @@ void SynchronousUnloadNativeLibrary(NativeLibrary library) { ...@@ -311,7 +309,7 @@ void SynchronousUnloadNativeLibrary(NativeLibrary library) {
HMODULE module_handle; HMODULE module_handle;
// Keep trying to get the module handle until the call fails. // Keep trying to get the module handle until the call fails.
while (::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | while (::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCTSTR>(module_base_address), reinterpret_cast<LPCTSTR>(module_base_address),
&module_handle) || &module_handle) ||
::GetLastError() != ERROR_MOD_NOT_FOUND) { ::GetLastError() != ERROR_MOD_NOT_FOUND) {
...@@ -491,7 +489,9 @@ std::string FormatSampleForDiagnosticOutput( ...@@ -491,7 +489,9 @@ std::string FormatSampleForDiagnosticOutput(
// Returns a duration that is longer than the test timeout. We would use // Returns a duration that is longer than the test timeout. We would use
// TimeDelta::Max() but https://crbug.com/465948. // TimeDelta::Max() but https://crbug.com/465948.
TimeDelta AVeryLongTimeDelta() { return TimeDelta::FromDays(1); } TimeDelta AVeryLongTimeDelta() {
return TimeDelta::FromDays(1);
}
// Tests the scenario where the library is unloaded after copying the stack, but // Tests the scenario where the library is unloaded after copying the stack, but
// before walking it. If |wait_until_unloaded| is true, ensures that the // before walking it. If |wait_until_unloaded| is true, ensures that the
...@@ -527,8 +527,7 @@ void TestLibraryUnload(bool wait_until_unloaded) { ...@@ -527,8 +527,7 @@ void TestLibraryUnload(bool wait_until_unloaded) {
NativeLibrary other_library = LoadOtherLibrary(); NativeLibrary other_library = LoadOtherLibrary();
TargetThread target_thread(StackConfiguration( TargetThread target_thread(StackConfiguration(
StackConfiguration::WITH_OTHER_LIBRARY, StackConfiguration::WITH_OTHER_LIBRARY, other_library));
other_library));
PlatformThreadHandle target_thread_handle; PlatformThreadHandle target_thread_handle;
EXPECT_TRUE(PlatformThread::Create(0, &target_thread, &target_thread_handle)); EXPECT_TRUE(PlatformThread::Create(0, &target_thread, &target_thread_handle));
......
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