Commit 3f791214 authored by Charlie Andrews's avatar Charlie Andrews Committed by Commit Bot

Create stub for ThreadDelegateAndroid

This class will contain the Android-specific thread and stack
manipulation code. It's interface is likely to change in the near future
when wittman@ resolves https://crbug.com/988579, adding support for
signal-based thread suspension.

None of this code will be run because Android support is still disabled
within stack_sampling_configuration.cc.

TBR=gab@chromium.org
R=wittman@chromium.org

Bug: 988574
Change-Id: Idf8b75998ea12b554d54729bf33f9d7a91b20b01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1723024Reviewed-by: default avatarCharlie Andrews <charliea@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Commit-Queue: Charlie Andrews <charliea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682025}
parent fa7e58b5
......@@ -630,6 +630,8 @@ jumbo_component("base") {
"profiler/stack_sampling_profiler.cc",
"profiler/stack_sampling_profiler.h",
"profiler/thread_delegate.h",
"profiler/thread_delegate_android.cc",
"profiler/thread_delegate_android.h",
"profiler/thread_delegate_mac.cc",
"profiler/thread_delegate_mac.h",
"profiler/thread_delegate_win.cc",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/profiler/thread_delegate_android.h"
// IMPORTANT NOTE: Some functions within this implementation are invoked while
// the target thread is suspended so it must not do any allocation from the
// heap, including indirectly via use of DCHECK/CHECK or other logging
// statements. Otherwise this code can deadlock on heap locks acquired by the
// target thread before it was suspended. These functions are commented with "NO
// HEAP ALLOCATIONS".
namespace base {
// ScopedSuspendThread --------------------------------------------------------
bool ThreadDelegateAndroid::ScopedSuspendThread::WasSuccessful() const {
return false;
}
// ThreadDelegateAndroid ------------------------------------------------------
std::unique_ptr<ThreadDelegate::ScopedSuspendThread>
ThreadDelegateAndroid::CreateScopedSuspendThread() {
return std::make_unique<ScopedSuspendThread>();
}
// NO HEAP ALLOCATIONS.
bool ThreadDelegateAndroid::GetThreadContext(RegisterContext* thread_context) {
return false;
}
// NO HEAP ALLOCATIONS.
uintptr_t ThreadDelegateAndroid::GetStackBaseAddress() const {
// It's okay for the stub to return zero here: GetStackBaseAddress() if
// ScopedSuspendThread fails, which it always will in the stub.
return 0;
}
// NO HEAP ALLOCATIONS.
bool ThreadDelegateAndroid::CanCopyStack(uintptr_t stack_pointer) {
return false;
}
std::vector<uintptr_t*> ThreadDelegateAndroid::GetRegistersToRewrite(
RegisterContext* thread_context) {
return {};
}
} // namespace base
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_PROFILER_THREAD_DELEGATE_ANDROID_H_
#define BASE_PROFILER_THREAD_DELEGATE_ANDROID_H_
#include "base/base_export.h"
#include "base/profiler/thread_delegate.h"
namespace base {
// Platform- and thread-specific implementation in support of stack sampling on
// Android.
//
// TODO(charliea): Implement this class.
class BASE_EXPORT ThreadDelegateAndroid : public ThreadDelegate {
public:
class ScopedSuspendThread : public ThreadDelegate::ScopedSuspendThread {
public:
ScopedSuspendThread() = default;
~ScopedSuspendThread() override = default;
ScopedSuspendThread(const ScopedSuspendThread&) = delete;
ScopedSuspendThread& operator=(const ScopedSuspendThread&) = delete;
bool WasSuccessful() const override;
};
ThreadDelegateAndroid() = default;
~ThreadDelegateAndroid() override = default;
ThreadDelegateAndroid(const ThreadDelegateAndroid&) = delete;
ThreadDelegateAndroid& operator=(const ThreadDelegateAndroid&) = delete;
// ThreadDelegate
std::unique_ptr<ThreadDelegate::ScopedSuspendThread>
CreateScopedSuspendThread() override;
bool GetThreadContext(RegisterContext* thread_context) override;
uintptr_t GetStackBaseAddress() const override;
bool CanCopyStack(uintptr_t stack_pointer) override;
std::vector<uintptr_t*> GetRegistersToRewrite(
RegisterContext* thread_context) override;
};
} // namespace base
#endif // BASE_PROFILER_THREAD_DELEGATE_ANDROID_H_
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