aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2022-01-17 15:56:11 +0100
committerPavel Labath <pavel@labath.sk>2022-01-25 12:13:49 +0100
commit0f08db66db93b42ff26caca2159bd548436184ae (patch)
tree39305677b1531edadd18c390a4b0062fc5621c76 /lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
parent7cb452bfde1086f7bcddfd6de5594ebcb4c11bf5 (diff)
downloadllvm-0f08db66db93b42ff26caca2159bd548436184ae.zip
llvm-0f08db66db93b42ff26caca2159bd548436184ae.tar.gz
llvm-0f08db66db93b42ff26caca2159bd548436184ae.tar.bz2
[lldb] Make logging machinery type-safe
This patch makes use of c++ type checking and scoped enums to make logging statements shorter and harder to misuse. Defines like LIBLLDB_LOG_PROCESS are replaces with LLDBLog::Process. Because it now carries type information we do not need to worry about matching a specific enum value with the right getter function -- the compiler will now do that for us. The main entry point for the logging machinery becomes the GetLog (template) function, which will obtain the correct Log object based on the enum type. It achieves this through another template function (LogChannelFor<T>), which must be specialized for each type, and should return the appropriate channel object. This patch also removes the ability to log a message if multiple categories are enabled simultaneously as it was unused and confusing. This patch does not actually remove any of the existing interfaces. The defines and log retrieval functions are left around as wrappers around the new interfaces. They will be removed in follow-up patch. Differential Revision: https://reviews.llvm.org/D117490
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 2a9896e..ba73115 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -39,7 +39,7 @@ ThreadGDBRemote::ThreadGDBRemote(Process &process, lldb::tid_t tid)
m_dispatch_queue_t(LLDB_INVALID_ADDRESS), m_queue_kind(eQueueKindUnknown),
m_queue_serial_number(LLDB_INVALID_QUEUE_ID),
m_associated_with_libdispatch_queue(eLazyBoolCalculate) {
- Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
+ Log *log = GetLog(GDBRLog::Thread);
LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this, process.GetID(),
GetID());
// At this point we can clone reg_info for architectures supporting
@@ -54,7 +54,7 @@ ThreadGDBRemote::ThreadGDBRemote(Process &process, lldb::tid_t tid)
ThreadGDBRemote::~ThreadGDBRemote() {
ProcessSP process_sp(GetProcess());
- Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
+ Log *log = GetLog(GDBRLog::Thread);
LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this,
process_sp ? process_sp->GetID() : LLDB_INVALID_PROCESS_ID, GetID());
DestroyThread();
@@ -222,7 +222,7 @@ void ThreadGDBRemote::SetAssociatedWithLibdispatchQueue(
StructuredData::ObjectSP ThreadGDBRemote::FetchThreadExtendedInfo() {
StructuredData::ObjectSP object_sp;
const lldb::user_id_t tid = GetProtocolID();
- Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
+ Log *log = GetLog(GDBRLog::Thread);
LLDB_LOGF(log, "Fetching extended information for thread %4.4" PRIx64, tid);
ProcessSP process_sp(GetProcess());
if (process_sp) {
@@ -236,7 +236,7 @@ StructuredData::ObjectSP ThreadGDBRemote::FetchThreadExtendedInfo() {
void ThreadGDBRemote::WillResume(StateType resume_state) {
int signo = GetResumeSignal();
const lldb::user_id_t tid = GetProtocolID();
- Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
+ Log *log = GetLog(GDBRLog::Thread);
LLDB_LOGF(log, "Resuming thread: %4.4" PRIx64 " with state: %s.", tid,
StateAsCString(resume_state));