From 8f77fa7026de9f544778063fd9fe900d0804b863 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 4 Aug 2025 09:35:36 -0700 Subject: [lldb] Simplify Python Locker log messages (NFC) Eliminate the `log` variable by inlining the GetLog call and use "locked" and "unlocked" directly, as requested by Ismail in #151780. --- .../Python/ScriptInterpreterPython.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index fc4df81..adc172c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -145,15 +145,15 @@ public: m_was_already_initialized = true; m_gil_state = PyGILState_Ensure(); LLDB_LOGV(GetLog(LLDBLog::Script), - "Ensured PyGILState. Previous state = {0}locked\n", - m_gil_state == PyGILState_UNLOCKED ? "un" : ""); + "Ensured PyGILState. Previous state = {0}", + m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked"); } ~InitializePythonRAII() { if (m_was_already_initialized) { - Log *log = GetLog(LLDBLog::Script); - LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked", - m_gil_state == PyGILState_UNLOCKED ? "un" : ""); + LLDB_LOGV(GetLog(LLDBLog::Script), + "Releasing PyGILState. Returning to state = {0}", + m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked"); PyGILState_Release(m_gil_state); } else { // We initialized the threads in this function, just unlock the GIL. @@ -328,10 +328,9 @@ ScriptInterpreterPythonImpl::Locker::Locker( } bool ScriptInterpreterPythonImpl::Locker::DoAcquireLock() { - Log *log = GetLog(LLDBLog::Script); m_GILState = PyGILState_Ensure(); - LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked", - m_GILState == PyGILState_UNLOCKED ? "un" : ""); + LLDB_LOGV(GetLog(LLDBLog::Script), "Ensured PyGILState. Previous state = {0}", + m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked"); // we need to save the thread state when we first start the command because // we might decide to interrupt it while some action is taking place outside @@ -352,9 +351,9 @@ bool ScriptInterpreterPythonImpl::Locker::DoInitSession(uint16_t on_entry_flags, } bool ScriptInterpreterPythonImpl::Locker::DoFreeLock() { - Log *log = GetLog(LLDBLog::Script); - LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked", - m_GILState == PyGILState_UNLOCKED ? "un" : ""); + LLDB_LOGV(GetLog(LLDBLog::Script), + "Releasing PyGILState. Returning to state = {0}", + m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked"); PyGILState_Release(m_GILState); m_python_interpreter->DecrementLockCount(); return true; -- cgit v1.1