Everywhere: Deprecate dbg().
This commit is contained in:
parent
d7345cf560
commit
1c1e577a5e
Notes:
sideshowbarker
2024-07-18 22:55:34 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/1c1e577a5ef Pull-request: https://github.com/SerenityOS/serenity/pull/5068
5 changed files with 51 additions and 48 deletions
12
AK/Debug.h
12
AK/Debug.h
|
@ -573,3 +573,15 @@ constexpr bool debug_lock_restore = true;
|
|||
#else
|
||||
constexpr bool debug_lock_restore = false;
|
||||
#endif
|
||||
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
constexpr bool debug_futex_queue = true;
|
||||
#else
|
||||
constexpr bool debug_futex_queue = false;
|
||||
#endif
|
||||
|
||||
#ifdef FUTEX_DEBUG
|
||||
constexpr bool debug_futex = true;
|
||||
#else
|
||||
constexpr bool debug_futex = false;
|
||||
#endif
|
||||
|
|
|
@ -149,7 +149,10 @@ KernelLogStream klog()
|
|||
#else
|
||||
DebugLogStream klog()
|
||||
{
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
return dbg();
|
||||
# pragma GCC diagnostic pop
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ inline const LogStream& operator<<(const LogStream& stream, bool value)
|
|||
return stream << (value ? "true" : "false");
|
||||
}
|
||||
|
||||
DebugLogStream dbg();
|
||||
[[deprecated("Plase use dbgln in AK/Format.h instead.")]] DebugLogStream dbg();
|
||||
|
||||
#ifdef KERNEL
|
||||
KernelLogStream klog();
|
||||
|
|
|
@ -24,11 +24,10 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/FutexQueue.h>
|
||||
#include <Kernel/Thread.h>
|
||||
|
||||
//#define FUTEXQUEUE_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
bool FutexQueue::should_add_blocker(Thread::Blocker& b, void* data)
|
||||
|
@ -36,9 +35,9 @@ bool FutexQueue::should_add_blocker(Thread::Blocker& b, void* data)
|
|||
ASSERT(data != nullptr); // Thread that is requesting to be blocked
|
||||
ASSERT(m_lock.is_locked());
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": should block thread " << *static_cast<Thread*>(data);
|
||||
#endif
|
||||
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: should block thread {}", this, *static_cast<Thread*>(data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -46,17 +45,16 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
|
|||
{
|
||||
is_empty_target = false;
|
||||
ScopedSpinLock lock(m_lock);
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue(" << wake_count << ", " << requeue_count << ")";
|
||||
#endif
|
||||
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue({}, {})", this, wake_count, requeue_count);
|
||||
|
||||
u32 did_wake = 0, did_requeue = 0;
|
||||
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
|
||||
ASSERT(data);
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue unblocking " << *static_cast<Thread*>(data);
|
||||
#endif
|
||||
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue unblocking {}", this, *static_cast<Thread*>(data));
|
||||
ASSERT(did_wake < wake_count);
|
||||
if (blocker.unblock()) {
|
||||
if (++did_wake >= wake_count)
|
||||
|
@ -70,9 +68,8 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
|
|||
auto blockers_to_requeue = do_take_blockers(requeue_count);
|
||||
if (!blockers_to_requeue.is_empty()) {
|
||||
if (auto* target_futex_queue = get_target_queue()) {
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue requeueing " << blockers_to_requeue.size() << " blockers to " << target_futex_queue;
|
||||
#endif
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue requeueing {} blockers to {}", this, blockers_to_requeue.size(), target_futex_queue);
|
||||
|
||||
// While still holding m_lock, notify each blocker
|
||||
for (auto& info : blockers_to_requeue) {
|
||||
ASSERT(info.blocker->blocker_type() == Thread::Blocker::Type::Futex);
|
||||
|
@ -94,9 +91,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
|
|||
target_futex_queue->do_append_blockers(move(blockers_to_requeue));
|
||||
is_empty_target = target_futex_queue->is_empty_locked();
|
||||
} else {
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue could not get target queue to requeueing " << blockers_to_requeue.size() << " blockers";
|
||||
#endif
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue could not get target queue to requeue {} blockers", this, blockers_to_requeue.size());
|
||||
do_append_blockers(move(blockers_to_requeue));
|
||||
}
|
||||
}
|
||||
|
@ -109,17 +104,14 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
|
|||
if (wake_count == 0)
|
||||
return 0; // should we assert instead?
|
||||
ScopedSpinLock lock(m_lock);
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_n(" << wake_count << ")";
|
||||
#endif
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n({})", this, wake_count);
|
||||
u32 did_wake = 0;
|
||||
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
|
||||
ASSERT(data);
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_n unblocking " << *static_cast<Thread*>(data);
|
||||
#endif
|
||||
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n unblocking {}", this, *static_cast<Thread*>(data));
|
||||
ASSERT(did_wake < wake_count);
|
||||
if (bitset.has_value() ? blocker.unblock_bitset(bitset.value()) : blocker.unblock()) {
|
||||
if (++did_wake >= wake_count)
|
||||
|
@ -135,17 +127,13 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
|
|||
u32 FutexQueue::wake_all(bool& is_empty)
|
||||
{
|
||||
ScopedSpinLock lock(m_lock);
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_all";
|
||||
#endif
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all", this);
|
||||
u32 did_wake = 0;
|
||||
do_unblock([&](Thread::Blocker& b, void* data, bool&) {
|
||||
ASSERT(data);
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
||||
#ifdef FUTEXQUEUE_DEBUG
|
||||
dbg() << "FutexQueue @ " << this << ": wake_all unblocking " << *static_cast<Thread*>(data);
|
||||
#endif
|
||||
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all unblocking", this, *static_cast<Thread*>(data));
|
||||
if (blocker.unblock(true)) {
|
||||
did_wake++;
|
||||
return true;
|
||||
|
|
|
@ -24,13 +24,12 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/Time.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
||||
//#define FUTEX_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static SpinLock<u8> g_global_futex_lock;
|
||||
|
@ -40,9 +39,10 @@ FutexQueue::FutexQueue(FlatPtr user_address_or_offset, VMObject* vmobject)
|
|||
: m_user_address_or_offset(user_address_or_offset)
|
||||
, m_is_global(vmobject != nullptr)
|
||||
{
|
||||
#ifdef FUTEX_DEBUG
|
||||
dbg() << "Futex @ " << this << (m_is_global ? " (global)" : "(local)");
|
||||
#endif
|
||||
dbgln<debug_futex>("Futex @ {}{}",
|
||||
this,
|
||||
m_is_global ? " (global)" : " (local)");
|
||||
|
||||
if (m_is_global) {
|
||||
// Only register for global futexes
|
||||
m_vmobject = vmobject->make_weak_ptr();
|
||||
|
@ -56,9 +56,9 @@ FutexQueue::~FutexQueue()
|
|||
if (auto vmobject = m_vmobject.strong_ref())
|
||||
vmobject->unregister_on_deleted_handler(*this);
|
||||
}
|
||||
#ifdef FUTEX_DEBUG
|
||||
dbg() << "~Futex @ " << this << (m_is_global ? " (global)" : "(local)");
|
||||
#endif
|
||||
dbgln<debug_futex>("~Futex @ {}{}",
|
||||
this,
|
||||
m_is_global ? " (global)" : " (local)");
|
||||
}
|
||||
|
||||
void FutexQueue::vmobject_deleted(VMObject& vmobject)
|
||||
|
@ -68,9 +68,9 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
|
|||
// to make sure we have at last a reference until we're done
|
||||
NonnullRefPtr<FutexQueue> own_ref(*this);
|
||||
|
||||
#ifdef FUTEX_DEBUG
|
||||
dbg() << "Futex::vmobject_deleted @ " << this << (m_is_global ? " (global)" : "(local)");
|
||||
#endif
|
||||
dbgln<debug_futex>("Futex::vmobject_deleted @ {}{}",
|
||||
this,
|
||||
m_is_global ? " (global)" : " (local)");
|
||||
|
||||
// Because this is called from the VMObject's destructor, getting a
|
||||
// strong_ref in this function is unsafe!
|
||||
|
@ -83,12 +83,12 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
|
|||
|
||||
bool did_wake_all;
|
||||
auto wake_count = wake_all(did_wake_all);
|
||||
#ifdef FUTEX_DEBUG
|
||||
if (wake_count > 0)
|
||||
dbg() << "Futex: @ " << this << " unblocked " << wake_count << " waiters due to vmobject free";
|
||||
#else
|
||||
(void)wake_count;
|
||||
#endif
|
||||
|
||||
if constexpr (debug_futex) {
|
||||
if (wake_count > 0)
|
||||
dbgln("Futex @ {} unblocked {} waiters due to vmobject free", this, wake_count);
|
||||
}
|
||||
|
||||
ASSERT(did_wake_all); // No one should be left behind...
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ int Process::sys$futex(Userspace<const Syscall::SC_futex_params*> user_params)
|
|||
if (!user_value.has_value())
|
||||
return -EFAULT;
|
||||
if (user_value.value() != params.val) {
|
||||
dbg() << "futex wait: EAGAIN. user value: " << (void*)user_value.value() << " @ " << (void*)params.userspace_address << " != val: " << params.val;
|
||||
dbgln("futex wait: EAGAIN. user value: {:p} @ {:p} != val: {}", user_value.value(), params.userspace_address, params.val);
|
||||
return -EAGAIN;
|
||||
}
|
||||
atomic_thread_fence(AK::MemoryOrder::memory_order_acquire);
|
||||
|
|
Loading…
Add table
Reference in a new issue