1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:35:06 +00:00

Everywhere: Replace a bundle of dbg with dbgln.

These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.

This commit touches some dbg() calls which are enclosed in macros. This
should be fine because with the new constexpr stuff, we ensure that the
stuff actually compiles.
This commit is contained in:
asynts 2021-01-12 22:30:52 +01:00 committed by Andreas Kling
parent adbb8d62d1
commit 94bb544c33
6 changed files with 154 additions and 103 deletions

71
AK/Debug.h Normal file
View file

@ -0,0 +1,71 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
// FIXME: We could generate this file with CMake and configure.
#ifdef PROCESS_DEBUG
constexpr bool debug_process = true;
#else
constexpr bool debug_process = false;
#endif
#ifdef SCHEDULER_DEBUG
constexpr bool debug_scheduler = true;
#else
constexpr bool debug_scheduler = false;
#endif
#ifdef SCHEDULER_RUNNABLE_DEBUG
constexpr bool debug_scheduler_runnable = true;
#else
constexpr bool debug_scheduler_runnable = false;
#endif
#ifdef SHARED_BUFFER_DEBUG
constexpr bool debug_shared_buffer = true;
#else
constexpr bool debug_shared_buffer = false;
#endif
#ifdef THREAD_DEBUG
constexpr bool debug_thread = true;
#else
constexpr bool debug_thread = false;
#endif
#ifdef LOCK_DEBUG
constexpr bool debug_lock = true;
#else
constexpr bool debug_lock = false;
#endif
#ifdef SIGNAL_DEBUG
constexpr bool debug_signal = true;
#else
constexpr bool debug_signal = false;
#endif

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/Demangle.h> #include <AK/Demangle.h>
#include <AK/QuickSort.h> #include <AK/QuickSort.h>
#include <AK/StdLibExtras.h> #include <AK/StdLibExtras.h>
@ -355,9 +356,7 @@ Process::Process(RefPtr<Thread>& first_thread, const String& name, uid_t uid, gi
, m_ppid(ppid) , m_ppid(ppid)
, m_wait_block_condition(*this) , m_wait_block_condition(*this)
{ {
#ifdef PROCESS_DEBUG dbgln<debug_process>("Created new process {}({})", m_name, m_pid.value());
dbg() << "Created new process " << m_name << "(" << m_pid.value() << ")";
#endif
m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr); m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr);
@ -620,9 +619,8 @@ bool Process::dump_perfcore()
void Process::finalize() void Process::finalize()
{ {
ASSERT(Thread::current() == g_finalizer); ASSERT(Thread::current() == g_finalizer);
#ifdef PROCESS_DEBUG
dbg() << "Finalizing process " << *this; dbgln<debug_process>("Finalizing process {}", *this);
#endif
if (is_dumpable()) { if (is_dumpable()) {
if (m_should_dump_core) if (m_should_dump_core)

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/QuickSort.h> #include <AK/QuickSort.h>
#include <AK/ScopeGuard.h> #include <AK/ScopeGuard.h>
#include <AK/TemporaryChange.h> #include <AK/TemporaryChange.h>
@ -131,28 +132,46 @@ bool Scheduler::pick_next()
// no longer want to schedule this thread. We can't wait until // no longer want to schedule this thread. We can't wait until
// Scheduler::enter_current because we don't want to allow it to // Scheduler::enter_current because we don't want to allow it to
// transition back to user mode. // transition back to user mode.
#ifdef SCHEDULER_DEBUG
dbg() << "Scheduler[" << Processor::current().id() << "]: Thread " << *current_thread << " is dying"; if constexpr (debug_scheduler)
#endif dbgln("Scheduler[{}]: Thread {} is dying", Processor::current().id(), *current_thread);
current_thread->set_state(Thread::Dying); current_thread->set_state(Thread::Dying);
} }
#ifdef SCHEDULER_RUNNABLE_DEBUG if constexpr (debug_scheduler_runnable) {
dbg() << "Scheduler[" << Processor::current().id() << "]: Non-runnables:"; dbgln("Scheduler[{}j]: Non-runnables:", Processor::current().id());
Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision { Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision {
if (thread.state() == Thread::Dying) if (thread.state() == Thread::Dying) {
dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip) << " Finalizable: " << thread.is_finalizable(); dbgln(" {:12} {} @ {:04x}:{:08x} Finalizable: {}",
else thread.state_string(),
dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip); thread,
return IterationDecision::Continue; thread.tss().cs,
}); thread.tss().eip,
thread.is_finalizable());
} else {
dbgln(" {:12} {} @ {:04x}:{:08x}",
thread.state_string(),
thread,
thread.tss().cs,
thread.tss().eip);
}
dbg() << "Scheduler[" << Processor::current().id() << "]: Runnables:"; return IterationDecision::Continue;
Scheduler::for_each_runnable([](Thread& thread) -> IterationDecision { });
dbg() << " " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip);
return IterationDecision::Continue; dbgln("Scheduler[{}j]: Runnables:", Processor::current().id());
}); Scheduler::for_each_runnable([](Thread& thread) -> IterationDecision {
#endif dbgln(" {:3}/{:2} {:12} @ {:04x}:{:08x}",
thread.effective_priority(),
thread.priority(),
thread.state_string(),
thread.tss().cs,
thread.tss().eip);
return IterationDecision::Continue;
});
}
Thread* thread_to_schedule = nullptr; Thread* thread_to_schedule = nullptr;
@ -181,9 +200,7 @@ bool Scheduler::pick_next()
// but since we're still holding the scheduler lock we're still in a critical section // but since we're still holding the scheduler lock we're still in a critical section
critical.leave(); critical.leave();
#ifdef SCHEDULER_DEBUG dbgln<debug_scheduler>("Processing pending donate to {} reason={}", *thread_to_schedule, reason);
dbg() << "Processing pending donate to " << *thread_to_schedule << " reason=" << reason;
#endif
return donate_to_and_switch(thread_to_schedule, reason); return donate_to_and_switch(thread_to_schedule, reason);
} }
@ -211,9 +228,12 @@ bool Scheduler::pick_next()
if (!thread_to_schedule) if (!thread_to_schedule)
thread_to_schedule = Processor::current().idle_thread(); thread_to_schedule = Processor::current().idle_thread();
#ifdef SCHEDULER_DEBUG if constexpr (debug_scheduler) {
dbg() << "Scheduler[" << Processor::current().id() << "]: Switch to " << *thread_to_schedule << " @ " << String::format("%04x:%08x", thread_to_schedule->tss().cs, thread_to_schedule->tss().eip); dbgln("Scheduler[{}]: Switch to {} @ {:04x}:{:08x}",
#endif Processor::current().id(),
*thread_to_schedule,
thread_to_schedule->tss().cs, thread_to_schedule->tss().eip);
}
// We need to leave our first critical section before switching context, // We need to leave our first critical section before switching context,
// but since we're still holding the scheduler lock we're still in a critical section // but since we're still holding the scheduler lock we're still in a critical section
@ -234,9 +254,7 @@ bool Scheduler::yield()
scheduler_data.m_pending_donate_reason = nullptr; scheduler_data.m_pending_donate_reason = nullptr;
auto current_thread = Thread::current(); auto current_thread = Thread::current();
#ifdef SCHEDULER_DEBUG dbgln<debug_scheduler>("Scheduler[{}]: yielding thread {} in_irq={}", proc.id(), *current_thread, proc.in_irq());
dbg() << "Scheduler[" << proc.id() << "]: yielding thread " << *current_thread << " in_irq: " << proc.in_irq();
#endif
ASSERT(current_thread != nullptr); ASSERT(current_thread != nullptr);
if (proc.in_irq() || proc.in_critical()) { if (proc.in_irq() || proc.in_critical()) {
// If we're handling an IRQ we can't switch context, or we're in // If we're handling an IRQ we can't switch context, or we're in
@ -248,9 +266,9 @@ bool Scheduler::yield()
if (!Scheduler::pick_next()) if (!Scheduler::pick_next())
return false; return false;
#ifdef SCHEDULER_DEBUG
dbg() << "Scheduler[" << Processor::current().id() << "]: yield returns to thread " << *current_thread << " in_irq: " << Processor::current().in_irq(); if constexpr (debug_scheduler)
#endif dbgln("Scheduler[{}]: yield returns to thread {} in_irq={}", Processor::current().id(), *current_thread, Processor::current().in_irq());
return true; return true;
} }
@ -266,9 +284,7 @@ bool Scheduler::donate_to_and_switch(Thread* beneficiary, [[maybe_unused]] const
return Scheduler::yield(); return Scheduler::yield();
unsigned ticks_to_donate = min(ticks_left - 1, time_slice_for(*beneficiary)); unsigned ticks_to_donate = min(ticks_left - 1, time_slice_for(*beneficiary));
#ifdef SCHEDULER_DEBUG dbgln<debug_scheduler>("Scheduler[{}]: Donating {} ticks to {}, reason={}", proc.id(), ticks_to_donate, *beneficiary, reason);
dbg() << "Scheduler[" << proc.id() << "]: Donating " << ticks_to_donate << " ticks to " << *beneficiary << ", reason=" << reason;
#endif
beneficiary->set_ticks_left(ticks_to_donate); beneficiary->set_ticks_left(ticks_to_donate);
return Scheduler::context_switch(beneficiary); return Scheduler::context_switch(beneficiary);

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/Singleton.h> #include <AK/Singleton.h>
#include <Kernel/Process.h> #include <Kernel/Process.h>
#include <Kernel/SharedBuffer.h> #include <Kernel/SharedBuffer.h>
@ -155,13 +156,9 @@ void SharedBuffer::deref_for_process(Process& process)
ASSERT(m_total_refs > 0); ASSERT(m_total_refs > 0);
m_total_refs--; m_total_refs--;
if (ref.count == 0) { if (ref.count == 0) {
#ifdef SHARED_BUFFER_DEBUG dbgln<debug_shared_buffer>("Releasing shared buffer reference on {} of size {} by PID {}", m_shbuf_id, size(), process.pid().value());
dbg() << "Releasing shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid().value();
#endif
process.deallocate_region(*ref.region.unsafe_ptr()); // TODO: Region needs to be RefCounted! process.deallocate_region(*ref.region.unsafe_ptr()); // TODO: Region needs to be RefCounted!
#ifdef SHARED_BUFFER_DEBUG dbgln<debug_shared_buffer>("Released shared buffer reference on {} of size {} by PID {}", m_shbuf_id, size(), process.pid().value());
dbg() << "Released shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid().value();
#endif
sanity_check("deref_for_process"); sanity_check("deref_for_process");
destroy_if_unused(); destroy_if_unused();
return; return;
@ -179,15 +176,11 @@ bool SharedBuffer::disown(ProcessID pid)
for (size_t i = 0; i < m_refs.size(); ++i) { for (size_t i = 0; i < m_refs.size(); ++i) {
auto& ref = m_refs[i]; auto& ref = m_refs[i];
if (ref.pid == pid) { if (ref.pid == pid) {
#ifdef SHARED_BUFFER_DEBUG dbgln<debug_shared_buffer>("Disowning shared buffer {} of size {} by PID {}", m_shbuf_id, size(), pid.value());
dbg() << "Disowning shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid.value();
#endif
ASSERT(m_total_refs >= ref.count); ASSERT(m_total_refs >= ref.count);
m_total_refs -= ref.count; m_total_refs -= ref.count;
m_refs.unstable_take(i); m_refs.unstable_take(i);
#ifdef SHARED_BUFFER_DEBUG dbgln<debug_shared_buffer>("Disowned shared buffer {} of size {} by PID {}", m_shbuf_id, size(), pid.value());
dbg() << "Disowned shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid.value();
#endif
destroy_if_unused(); destroy_if_unused();
break; break;
} }
@ -201,9 +194,7 @@ void SharedBuffer::destroy_if_unused()
LOCKER(shared_buffers().lock()); LOCKER(shared_buffers().lock());
sanity_check("destroy_if_unused"); sanity_check("destroy_if_unused");
if (m_total_refs == 0) { if (m_total_refs == 0) {
#ifdef SHARED_BUFFER_DEBUG dbgln<debug_shared_buffer>("Destroying unused SharedBuffer({}) id={}", this, m_shbuf_id);
dbg() << "Destroying unused SharedBuffer{" << this << "} id: " << m_shbuf_id;
#endif
auto count_before = shared_buffers().resource().size(); auto count_before = shared_buffers().resource().size();
shared_buffers().resource().remove(m_shbuf_id); shared_buffers().resource().remove(m_shbuf_id);
ASSERT(count_before != shared_buffers().resource().size()); ASSERT(count_before != shared_buffers().resource().size());

View file

@ -26,6 +26,7 @@
#pragma once #pragma once
#include <AK/Debug.h>
#include <AK/OwnPtr.h> #include <AK/OwnPtr.h>
#include <AK/WeakPtr.h> #include <AK/WeakPtr.h>
#include <Kernel/VM/AnonymousVMObject.h> #include <Kernel/VM/AnonymousVMObject.h>
@ -52,16 +53,12 @@ public:
: m_shbuf_id(id) : m_shbuf_id(id)
, m_vmobject(move(vmobject)) , m_vmobject(move(vmobject))
{ {
#ifdef SHARED_BUFFER_DEBUG dbgln<debug_shared_buffer>("Created shared buffer {} of size {}", m_shbuf_id, size());
dbg() << "Created shared buffer " << m_shbuf_id << " of size " << m_vmobject->size();
#endif
} }
~SharedBuffer() ~SharedBuffer()
{ {
#ifdef SHARED_BUFFER_DEBUG dbgln<debug_shared_buffer>("Destroyed shared buffer {} of size {}", m_shbuf_id, size());
dbg() << "Destroyed shared buffer " << m_shbuf_id << " of size " << size();
#endif
} }
void sanity_check(const char* what); void sanity_check(const char* what);

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/Demangle.h> #include <AK/Demangle.h>
#include <AK/ScopeGuard.h> #include <AK/ScopeGuard.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
@ -61,9 +62,8 @@ Thread::Thread(NonnullRefPtr<Process> process)
} else { } else {
m_tid = Process::allocate_pid().value(); m_tid = Process::allocate_pid().value();
} }
#ifdef THREAD_DEBUG if constexpr (debug_thread)
dbg() << "Created new thread " << m_process->name() << "(" << m_process->pid().value() << ":" << m_tid.value() << ")"; dbgln("Created new thread {}({}:{})", m_process->name(), m_process->pid().value(), m_tid.value());
#endif
set_default_signal_dispositions(); set_default_signal_dispositions();
m_fpu_state = (FPUState*)kmalloc_aligned<16>(sizeof(FPUState)); m_fpu_state = (FPUState*)kmalloc_aligned<16>(sizeof(FPUState));
reset_fpu_state(); reset_fpu_state();
@ -182,9 +182,7 @@ void Thread::unblock(u8 signal)
void Thread::set_should_die() void Thread::set_should_die()
{ {
if (m_should_die) { if (m_should_die) {
#ifdef THREAD_DEBUG dbgln("{} Should already die", *this);
dbg() << *this << " Should already die";
#endif
return; return;
} }
ScopedCritical critical; ScopedCritical critical;
@ -369,9 +367,7 @@ void Thread::finalize()
{ {
ScopedSpinLock lock(g_scheduler_lock); ScopedSpinLock lock(g_scheduler_lock);
#ifdef THREAD_DEBUG dbgln<debug_thread>("Finalizing thread {}", *this);
dbg() << "Finalizing thread " << *this;
#endif
set_state(Thread::State::Dead); set_state(Thread::State::Dead);
m_join_condition.thread_finalizing(); m_join_condition.thread_finalizing();
} }
@ -475,18 +471,16 @@ void Thread::send_signal(u8 signal, [[maybe_unused]] Process* sender)
// FIXME: Figure out what to do for masked signals. Should we also ignore them here? // FIXME: Figure out what to do for masked signals. Should we also ignore them here?
if (should_ignore_signal(signal)) { if (should_ignore_signal(signal)) {
#ifdef SIGNAL_DEBUG dbgln<debug_signal>("Signal {} was ignored by {}", signal, process());
dbg() << "Signal " << signal << " was ignored by " << process();
#endif
return; return;
} }
#ifdef SIGNAL_DEBUG if constexpr (debug_signal) {
if (sender) if (sender)
dbg() << "Signal: " << *sender << " sent " << signal << " to " << process(); dbgln("Signal: {} sent {} to {}", *sender, signal, process());
else else
dbg() << "Signal: Kernel sent " << signal << " to " << process(); dbgln("Signal: Kernel send {} to {}", signal, process());
#endif }
m_pending_signals |= 1 << (signal - 1); m_pending_signals |= 1 << (signal - 1);
m_have_any_unmasked_pending_signals.store(pending_signals_for_state() & ~m_signal_mask, AK::memory_order_release); m_have_any_unmasked_pending_signals.store(pending_signals_for_state() & ~m_signal_mask, AK::memory_order_release);
@ -494,16 +488,12 @@ void Thread::send_signal(u8 signal, [[maybe_unused]] Process* sender)
if (m_state == Stopped) { if (m_state == Stopped) {
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
if (pending_signals_for_state()) { if (pending_signals_for_state()) {
#ifdef SIGNAL_DEBUG dbgln<debug_signal>("Signal: Resuming stopped {} to deliver signal {}", *this, signal);
dbg() << "Signal: Resuming stopped " << *this << " to deliver signal " << signal;
#endif
resume_from_stopped(); resume_from_stopped();
} }
} else { } else {
ScopedSpinLock block_lock(m_block_lock); ScopedSpinLock block_lock(m_block_lock);
#ifdef SIGNAL_DEBUG dbgln<debug_signal>("Signal: Unblocking {} to deliver signal {}", *this, signal);
dbg() << "Signal: Unblocking " << *this << " to deliver signal " << signal;
#endif
unblock(signal); unblock(signal);
} }
} }
@ -728,26 +718,20 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
auto& process = this->process(); auto& process = this->process();
auto tracer = process.tracer(); auto tracer = process.tracer();
if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) { if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) {
#ifdef SIGNAL_DEBUG dbgln<debug_signal>("signal: signal {} sopping thread {}", signal, *this);
dbg() << "signal: signal " << signal << " stopping thread " << *this;
#endif
set_state(State::Stopped, signal); set_state(State::Stopped, signal);
return DispatchSignalResult::Yield; return DispatchSignalResult::Yield;
} }
if (signal == SIGCONT) { if (signal == SIGCONT) {
#ifdef SIGNAL_DEBUG dbgln("signal: SIGCONT resuming {}", *this);
dbg() << "signal: SIGCONT resuming " << *this;
#endif
} else { } else {
if (tracer) { if (tracer) {
// when a thread is traced, it should be stopped whenever it receives a signal // when a thread is traced, it should be stopped whenever it receives a signal
// the tracer is notified of this by using waitpid() // the tracer is notified of this by using waitpid()
// only "pending signals" from the tracer are sent to the tracee // only "pending signals" from the tracer are sent to the tracee
if (!tracer->has_pending_signal(signal)) { if (!tracer->has_pending_signal(signal)) {
#ifdef SIGNAL_DEBUG dbgln("signal: {} stopping {} for tracer", signal, *this);
dbg() << "signal: " << signal << " stopping " << *this << " for tracer";
#endif
set_state(Stopped, signal); set_state(Stopped, signal);
return DispatchSignalResult::Yield; return DispatchSignalResult::Yield;
} }
@ -897,15 +881,13 @@ void Thread::set_state(State new_state, u8 stop_signal)
if (previous_state == Invalid) { if (previous_state == Invalid) {
// If we were *just* created, we may have already pending signals // If we were *just* created, we may have already pending signals
if (has_unmasked_pending_signals()) { if (has_unmasked_pending_signals()) {
dbgln("Dispatch pending signals to new thread {}", *this); dbgln<debug_thread>("Dispatch pending signals to new thread {}", *this);
dispatch_one_pending_signal(); dispatch_one_pending_signal();
} }
} }
m_state = new_state; m_state = new_state;
#ifdef THREAD_DEBUG dbgln<debug_thread>("Set thread {} state to {}", *this, state_string());
dbg() << "Set Thread " << *this << " state to " << state_string();
#endif
} }
if (m_process->pid() != 0) { if (m_process->pid() != 0) {
@ -920,9 +902,7 @@ void Thread::set_state(State new_state, u8 stop_signal)
process.for_each_thread([&](auto& thread) { process.for_each_thread([&](auto& thread) {
if (&thread == this || !thread.is_stopped()) if (&thread == this || !thread.is_stopped())
return IterationDecision::Continue; return IterationDecision::Continue;
#ifdef THREAD_DEBUG dbgln<debug_thread>("Resuming peer thread {}", thread);
dbg() << "Resuming peer thread " << thread;
#endif
thread.resume_from_stopped(); thread.resume_from_stopped();
return IterationDecision::Continue; return IterationDecision::Continue;
}); });
@ -938,9 +918,7 @@ void Thread::set_state(State new_state, u8 stop_signal)
process.for_each_thread([&](auto& thread) { process.for_each_thread([&](auto& thread) {
if (&thread == this || thread.is_stopped()) if (&thread == this || thread.is_stopped())
return IterationDecision::Continue; return IterationDecision::Continue;
#ifdef THREAD_DEBUG dbgln<debug_thread>("Stopping peer thread {}", thread);
dbg() << "Stopping peer thread " << thread;
#endif
thread.set_state(Stopped, stop_signal); thread.set_state(Stopped, stop_signal);
return IterationDecision::Continue; return IterationDecision::Continue;
}); });