Skip to content

Commit 8f77fa7

Browse files
committed
[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.
1 parent 5a80274 commit 8f77fa7

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ struct InitializePythonRAII {
145145
m_was_already_initialized = true;
146146
m_gil_state = PyGILState_Ensure();
147147
LLDB_LOGV(GetLog(LLDBLog::Script),
148-
"Ensured PyGILState. Previous state = {0}locked\n",
149-
m_gil_state == PyGILState_UNLOCKED ? "un" : "");
148+
"Ensured PyGILState. Previous state = {0}",
149+
m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked");
150150
}
151151

152152
~InitializePythonRAII() {
153153
if (m_was_already_initialized) {
154-
Log *log = GetLog(LLDBLog::Script);
155-
LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked",
156-
m_gil_state == PyGILState_UNLOCKED ? "un" : "");
154+
LLDB_LOGV(GetLog(LLDBLog::Script),
155+
"Releasing PyGILState. Returning to state = {0}",
156+
m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked");
157157
PyGILState_Release(m_gil_state);
158158
} else {
159159
// We initialized the threads in this function, just unlock the GIL.
@@ -328,10 +328,9 @@ ScriptInterpreterPythonImpl::Locker::Locker(
328328
}
329329

330330
bool ScriptInterpreterPythonImpl::Locker::DoAcquireLock() {
331-
Log *log = GetLog(LLDBLog::Script);
332331
m_GILState = PyGILState_Ensure();
333-
LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked",
334-
m_GILState == PyGILState_UNLOCKED ? "un" : "");
332+
LLDB_LOGV(GetLog(LLDBLog::Script), "Ensured PyGILState. Previous state = {0}",
333+
m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked");
335334

336335
// we need to save the thread state when we first start the command because
337336
// 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,
352351
}
353352

354353
bool ScriptInterpreterPythonImpl::Locker::DoFreeLock() {
355-
Log *log = GetLog(LLDBLog::Script);
356-
LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked",
357-
m_GILState == PyGILState_UNLOCKED ? "un" : "");
354+
LLDB_LOGV(GetLog(LLDBLog::Script),
355+
"Releasing PyGILState. Returning to state = {0}",
356+
m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked");
358357
PyGILState_Release(m_GILState);
359358
m_python_interpreter->DecrementLockCount();
360359
return true;

0 commit comments

Comments
 (0)