Delete unused ScopedRegisterThreadForDebugging facility

Bug: webrtc:6424
Change-Id: I3564d204e8c886ce53e82426ef1d3896d7f6409d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258021
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36441}
This commit is contained in:
Niels Möller
2022-04-05 09:26:57 +02:00
committed by WebRTC LUCI CQ
parent 96dbc60704
commit e0a92f9a42
9 changed files with 1 additions and 148 deletions

View File

@ -91,19 +91,6 @@ if (is_mac || is_ios) {
}
}
rtc_source_set("thread_registry") {
sources = [ "thread_registry.h" ]
deps = [
"..:rtc_base_approved",
"../synchronization:mutex",
]
if (is_android && !build_with_chromium) {
sources += [ "thread_registry.cc" ]
deps += [ "../../sdk/android:native_api_stacktrace" ]
absl_deps = [ "//third_party/abseil-cpp/absl/base:core_headers" ]
}
}
rtc_source_set("warn_current_thread_is_deadlocked") {
sources = [ "warn_current_thread_is_deadlocked.h" ]
deps = []

View File

@ -1,7 +1,4 @@
specific_include_rules = {
"thread_registry\.cc": [
"+sdk/android/native_api/stacktrace/stacktrace.h",
],
"warn_current_thread_is_deadlocked\.cc": [
"+sdk/android/native_api/stacktrace/stacktrace.h",
],

View File

@ -1,71 +0,0 @@
/*
* Copyright 2019 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/system/thread_registry.h"
#include <map>
#include <utility>
#include "absl/base/attributes.h"
#include "rtc_base/logging.h"
#include "rtc_base/platform_thread_types.h"
#include "rtc_base/synchronization/mutex.h"
#include "sdk/android/native_api/stacktrace/stacktrace.h"
namespace webrtc {
namespace {
struct ThreadData {
const rtc::PlatformThreadId thread_id;
const rtc::Location location;
};
// The map of registered threads, and the lock that protects it. We create the
// map on first use, and never destroy it.
ABSL_CONST_INIT GlobalMutex g_thread_registry_lock(absl::kConstInit);
ABSL_CONST_INIT std::map<const ScopedRegisterThreadForDebugging*, ThreadData>*
g_registered_threads = nullptr;
} // namespace
ScopedRegisterThreadForDebugging::ScopedRegisterThreadForDebugging(
rtc::Location location) {
GlobalMutexLock gls(&g_thread_registry_lock);
if (g_registered_threads == nullptr) {
g_registered_threads =
new std::map<const ScopedRegisterThreadForDebugging*, ThreadData>();
}
const auto result = g_registered_threads->insert(
std::make_pair(this, ThreadData{rtc::CurrentThreadId(), location}));
RTC_DCHECK(result.second); // Insertion succeeded without collisions.
}
ScopedRegisterThreadForDebugging::~ScopedRegisterThreadForDebugging() {
GlobalMutexLock gls(&g_thread_registry_lock);
RTC_DCHECK(g_registered_threads != nullptr);
const int num_erased = g_registered_threads->erase(this);
RTC_DCHECK_EQ(num_erased, 1);
}
void PrintStackTracesOfRegisteredThreads() {
GlobalMutexLock gls(&g_thread_registry_lock);
if (g_registered_threads == nullptr) {
return;
}
for (const auto& e : *g_registered_threads) {
const ThreadData& td = e.second;
RTC_LOG(LS_WARNING) << "Thread " << td.thread_id << " registered at "
<< td.location.ToString() << ":";
RTC_LOG(LS_WARNING) << StackTraceToString(GetStackTrace(td.thread_id));
}
}
} // namespace webrtc

View File

@ -1,46 +0,0 @@
/*
* Copyright 2019 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef RTC_BASE_SYSTEM_THREAD_REGISTRY_H_
#define RTC_BASE_SYSTEM_THREAD_REGISTRY_H_
#include "rtc_base/location.h"
namespace webrtc {
class ScopedRegisterThreadForDebugging {
public:
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
explicit ScopedRegisterThreadForDebugging(rtc::Location location);
~ScopedRegisterThreadForDebugging();
#else
explicit ScopedRegisterThreadForDebugging(rtc::Location) {}
#endif
// Not movable or copyable, because we can't duplicate the resource it owns,
// and it needs a constant address.
ScopedRegisterThreadForDebugging(const ScopedRegisterThreadForDebugging&) =
delete;
ScopedRegisterThreadForDebugging(ScopedRegisterThreadForDebugging&&) = delete;
ScopedRegisterThreadForDebugging& operator=(
const ScopedRegisterThreadForDebugging&) = delete;
ScopedRegisterThreadForDebugging& operator=(
ScopedRegisterThreadForDebugging&&) = delete;
};
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
void PrintStackTracesOfRegisteredThreads();
#else
inline void PrintStackTracesOfRegisteredThreads() {}
#endif
} // namespace webrtc
#endif // RTC_BASE_SYSTEM_THREAD_REGISTRY_H_

View File

@ -796,7 +796,6 @@ if (current_os == "linux" || is_android) {
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:threading",
"../../rtc_base/system:thread_registry",
"../../system_wrappers:field_trial",
]
absl_deps = [

View File

@ -549,15 +549,12 @@ public class PeerConnectionFactory {
/**
* Print the Java stack traces for the critical threads used by PeerConnectionFactory, namely;
* signaling thread, worker thread, and network thread. If printNativeStackTraces is true, also
* attempt to print the C++ stack traces for these (and some other) threads.
* attempt to print the C++ stack traces for these threads.
*/
public void printInternalStackTraces(boolean printNativeStackTraces) {
printStackTrace(signalingThread, printNativeStackTraces);
printStackTrace(workerThread, printNativeStackTraces);
printStackTrace(networkThread, printNativeStackTraces);
if (printNativeStackTraces) {
nativePrintStackTracesOfRegisteredThreads();
}
}
@CalledByNative
@ -618,5 +615,4 @@ public class PeerConnectionFactory {
private static native void nativeInjectLoggable(JNILogging jniLogging, int severity);
private static native void nativeDeleteLoggable();
private static native void nativePrintStackTrace(int tid);
private static native void nativePrintStackTracesOfRegisteredThreads();
}

View File

@ -31,7 +31,6 @@
#include "modules/audio_processing/include/audio_processing.h"
#include "rtc_base/event_tracer.h"
#include "rtc_base/physical_socket_server.h"
#include "rtc_base/system/thread_registry.h"
#include "rtc_base/thread.h"
#include "sdk/android/generated_peerconnection_jni/PeerConnectionFactory_jni.h"
#include "sdk/android/native_api/jni/java_types.h"
@ -547,10 +546,5 @@ static void JNI_PeerConnectionFactory_PrintStackTrace(JNIEnv* env, jint tid) {
RTC_LOG(LS_WARNING) << StackTraceToString(GetStackTrace(tid));
}
static void JNI_PeerConnectionFactory_PrintStackTracesOfRegisteredThreads(
JNIEnv* env) {
PrintStackTracesOfRegisteredThreads();
}
} // namespace jni
} // namespace webrtc

View File

@ -128,7 +128,6 @@ rtc_library("video") {
"../rtc_base/experiments:rtt_mult_experiment",
"../rtc_base/synchronization:mutex",
"../rtc_base/system:no_unique_address",
"../rtc_base/system:thread_registry",
"../rtc_base/task_utils:pending_task_safety_flag",
"../rtc_base/task_utils:repeating_task",
"../rtc_base/task_utils:to_queued_task",
@ -208,7 +207,6 @@ rtc_source_set("video_legacy") {
"../rtc_base/experiments:keyframe_interval_settings_experiment",
"../rtc_base/synchronization:mutex",
"../rtc_base/system:no_unique_address",
"../rtc_base/system:thread_registry",
"../rtc_base/task_utils:to_queued_task",
"../system_wrappers",
"../system_wrappers:field_trial",

View File

@ -54,7 +54,6 @@
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/system/thread_registry.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/task_utils/pending_task_safety_flag.h"
#include "rtc_base/task_utils/to_queued_task.h"