[lldb] Rename formatv verbose log call, misc log cleanups [NFC] (#186951)
lldb had three preprocessor defines for logging, LLDB_LOG - formatv style argument LLDB_LOGF - printf style argument LLDB_LOGV - formatv style argument, only when verbose enabled If you weren't looking at Log.h and the definition of these three, and wanted to log something with formatv, it was easy to use LLDB_LOGV by accident. We just had a situation where an important log statement wasn't logging and it turned out to be this. This is fragile if you aren't looking at the header directly, so I'd like to make this more explicit. My proposal: LLDB_LOG - formatv style argument LLDB_LOG_VERBOSE - formatv style argument, only when verbose enabled LLDB_LOGF - printf style argument LLDB_LOGF_VERBOSE - printf style argument, only when verbose enabled The new fouth one is to remove several places where we do `if (log && log->GetVerbose()) LLDB_LOGF (...)` in the sources today, and make both styles consistent. This PR implements that change, mechanically changing all LLDB_LOGV's to LLDB_LOG_VERBOSE. It also updates many of the `if (log && log->GetVerbose()) LLDB_LOGF`'s. Some uses of this conditional expression do extra calculations in addition to logging, and so those were left as-is so we're not doing throwaway work when running without verbose logging. There were many instances throughout lldb where callers are still doing `if (log) LLDB_LOG*(...)`, a remnant of when all calls were to the `Log` object's `Printf()` method, and you had to check if your local Log* pointer was non-nullptr before calling the method. I removed those, again keeping ones where work for logging is done in the block of code. The code changes are all mechanical and uninteresting, but the question of whether this naming change is widely agreed on is maybe worth discussing.
This commit is contained in:
1 parent
fb39a5d6af
commit
fb36a54ef6
62 files changed
+590
-764
No files matched your search
@@ -134,16 +134,17 @@ public:
|
||||
|
||||
m_was_already_initialized = true;
|
||||
m_gil_state = gil_state;
|
||||
LLDB_LOGV(GetLog(LLDBLog::Script),
|
||||
"Ensured PyGILState. Previous state = {0}",
|
||||
m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked");
|
||||
LLDB_LOG_VERBOSE(
|
||||
GetLog(LLDBLog::Script), "Ensured PyGILState. Previous state = {0}",
|
||||
m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked");
|
||||
}
|
||||
|
||||
~InitializePythonRAII() {
|
||||
if (m_was_already_initialized) {
|
||||
LLDB_LOGV(GetLog(LLDBLog::Script),
|
||||
"Releasing PyGILState. Returning to state = {0}",
|
||||
m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked");
|
||||
LLDB_LOG_VERBOSE(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.
|
||||
@@ -330,8 +331,9 @@ ScriptInterpreterPythonImpl::Locker::Locker(
|
||||
|
||||
bool ScriptInterpreterPythonImpl::Locker::DoAcquireLock() {
|
||||
m_GILState = PyGILState_Ensure();
|
||||
LLDB_LOGV(GetLog(LLDBLog::Script), "Ensured PyGILState. Previous state = {0}",
|
||||
m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked");
|
||||
LLDB_LOG_VERBOSE(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 +354,9 @@ bool ScriptInterpreterPythonImpl::Locker::DoInitSession(uint16_t on_entry_flags,
|
||||
}
|
||||
|
||||
bool ScriptInterpreterPythonImpl::Locker::DoFreeLock() {
|
||||
LLDB_LOGV(GetLog(LLDBLog::Script),
|
||||
"Releasing PyGILState. Returning to state = {0}",
|
||||
m_GILState == PyGILState_UNLOCKED ? "unlocked" : "locked");
|
||||
LLDB_LOG_VERBOSE(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;
|
||||
|
||||
Reference in new issue
Block a user