mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +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 is contained in:
parent
fb8d3635d9
commit
ea7b7d8ceb
10 changed files with 99 additions and 74 deletions
|
@ -24,14 +24,12 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Lock.h>
|
||||
#include <Kernel/Thread.h>
|
||||
|
||||
//#define LOCK_TRACE_DEBUG
|
||||
//#define LOCK_RESTORE_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
#ifdef LOCK_DEBUG
|
||||
|
@ -58,9 +56,7 @@ void Lock::lock(Mode mode)
|
|||
Mode current_mode = m_mode;
|
||||
switch (current_mode) {
|
||||
case Mode::Unlocked: {
|
||||
#ifdef LOCK_TRACE_DEBUG
|
||||
dbg() << "Lock::lock @ " << this << ": acquire " << mode_to_string(mode) << ", currently unlocked";
|
||||
#endif
|
||||
dbgln<debug_lock_trace>("Lock::lock @ {}: acquire {}, currently unlocked", this, mode_to_string(mode));
|
||||
m_mode = mode;
|
||||
ASSERT(!m_holder);
|
||||
ASSERT(m_shared_holders.is_empty());
|
||||
|
@ -83,12 +79,14 @@ void Lock::lock(Mode mode)
|
|||
if (m_holder != current_thread)
|
||||
break;
|
||||
ASSERT(m_shared_holders.is_empty());
|
||||
#ifdef LOCK_TRACE_DEBUG
|
||||
if (mode == Mode::Exclusive)
|
||||
dbg() << "Lock::lock @ " << this << ": acquire " << mode_to_string(mode) << ", currently exclusive, holding: " << m_times_locked;
|
||||
else
|
||||
dbg() << "Lock::lock @ " << this << ": acquire exclusive (requested " << mode_to_string(mode) << "), currently exclusive, holding " << m_times_locked;
|
||||
#endif
|
||||
|
||||
if constexpr (debug_lock_trace) {
|
||||
if (mode == Mode::Exclusive)
|
||||
dbgln("Lock::lock @ {}: acquire {}, currently exclusive, holding: {}", this, mode_to_string(mode), m_times_locked);
|
||||
else
|
||||
dbgln("Lock::lock @ {}: acquire exclusive (requested {}), currently exclusive, holding: {}", this, mode_to_string(mode), m_times_locked);
|
||||
}
|
||||
|
||||
ASSERT(mode == Mode::Exclusive || mode == Mode::Shared);
|
||||
ASSERT(m_times_locked > 0);
|
||||
m_times_locked++;
|
||||
|
@ -102,9 +100,9 @@ void Lock::lock(Mode mode)
|
|||
ASSERT(!m_holder);
|
||||
if (mode != Mode::Shared)
|
||||
break;
|
||||
#ifdef LOCK_TRACE_DEBUG
|
||||
dbg() << "Lock::lock @ " << this << ": acquire " << mode_to_string(mode) << ", currently shared, locks held: " << m_times_locked;
|
||||
#endif
|
||||
|
||||
dbgln<debug_lock_trace>("Lock::lock @ {}: acquire {}, currently shared, locks held {}", this, mode_to_string(mode), m_times_locked);
|
||||
|
||||
ASSERT(m_times_locked > 0);
|
||||
m_times_locked++;
|
||||
ASSERT(!m_shared_holders.is_empty());
|
||||
|
@ -141,12 +139,13 @@ void Lock::unlock()
|
|||
for (;;) {
|
||||
if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) {
|
||||
Mode current_mode = m_mode;
|
||||
#ifdef LOCK_TRACE_DEBUG
|
||||
if (current_mode == Mode::Shared)
|
||||
dbg() << "Lock::unlock @ " << this << ": release " << mode_to_string(current_mode) << ", locks held: " << m_times_locked;
|
||||
else
|
||||
dbg() << "Lock::unlock @ " << this << ": release " << mode_to_string(current_mode) << ", holding: " << m_times_locked;
|
||||
#endif
|
||||
if constexpr (debug_lock_trace) {
|
||||
if (current_mode == Mode::Shared)
|
||||
dbgln("Lock::unlock @ {}: release {}, locks held: {}", this, mode_to_string(current_mode), m_times_locked);
|
||||
else
|
||||
dbgln("Lock::unlock @ {}: release {}, holding: {}", this, mode_to_string(current_mode), m_times_locked);
|
||||
}
|
||||
|
||||
ASSERT(current_mode != Mode::Unlocked);
|
||||
|
||||
ASSERT(m_times_locked > 0);
|
||||
|
@ -211,9 +210,9 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
|
|||
lock_count_to_restore = 0;
|
||||
return Mode::Unlocked;
|
||||
}
|
||||
#ifdef LOCK_RESTORE_DEBUG
|
||||
dbg() << "Lock::force_unlock_if_locked @ " << this << ": unlocking exclusive with lock count: " << m_times_locked;
|
||||
#endif
|
||||
|
||||
dbgln<debug_lock_restore>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
|
||||
|
||||
m_holder = nullptr;
|
||||
ASSERT(m_times_locked > 0);
|
||||
lock_count_to_restore = m_times_locked;
|
||||
|
@ -234,9 +233,10 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
|
|||
lock_count_to_restore = 0;
|
||||
return Mode::Unlocked;
|
||||
}
|
||||
#ifdef LOCK_RESTORE_DEBUG
|
||||
dbg() << "Lock::force_unlock_if_locked @ " << this << ": unlocking exclusive with lock count: " << it->value << ", total locks: " << m_times_locked;
|
||||
#endif
|
||||
|
||||
dbgln<debug_lock_restore>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}",
|
||||
this, it->value, m_times_locked);
|
||||
|
||||
ASSERT(it->value > 0);
|
||||
lock_count_to_restore = it->value;
|
||||
ASSERT(lock_count_to_restore > 0);
|
||||
|
@ -292,9 +292,9 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
|
|||
auto expected_mode = Mode::Unlocked;
|
||||
if (!m_mode.compare_exchange_strong(expected_mode, Mode::Exclusive))
|
||||
break;
|
||||
#ifdef LOCK_RESTORE_DEBUG
|
||||
dbg() << "Lock::restore_lock @ " << this << ": restoring " << mode_to_string(mode) << " with lock count " << lock_count << ", was unlocked";
|
||||
#endif
|
||||
|
||||
dbgln<debug_lock_restore>("Lock::restore_lock @ {}: restoring {} with lock count {}, was unlocked", this, mode_to_string(mode), lock_count);
|
||||
|
||||
ASSERT(m_times_locked == 0);
|
||||
m_times_locked = lock_count;
|
||||
ASSERT(!m_holder);
|
||||
|
@ -310,9 +310,10 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
|
|||
auto expected_mode = Mode::Unlocked;
|
||||
if (!m_mode.compare_exchange_strong(expected_mode, Mode::Shared) && expected_mode != Mode::Shared)
|
||||
break;
|
||||
#ifdef LOCK_RESTORE_DEBUG
|
||||
dbg() << "Lock::restore_lock @ " << this << ": restoring " << mode_to_string(mode) << " with lock count " << lock_count << ", was " << mode_to_string(expected_mode);
|
||||
#endif
|
||||
|
||||
dbgln<debug_lock_restore>("Lock::restore_lock @ {}: restoring {} with lock count {}, was {}",
|
||||
this, mode_to_string(mode), lock_count, mode_to_string(expected_mode));
|
||||
|
||||
ASSERT(expected_mode == Mode::Shared || m_times_locked == 0);
|
||||
m_times_locked += lock_count;
|
||||
ASSERT(!m_holder);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue