diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp index 803e5842cd7de..8364ffeef46fa 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp @@ -40,7 +40,7 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse( ContinueDelegate &delegate, const UnixSignals &signals, llvm::StringRef payload, std::chrono::seconds interrupt_timeout, StringExtractorGDBRemote &response) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); response.Clear(); { @@ -184,8 +184,7 @@ GDBRemoteClientBase::SendPacketAndWaitForResponse( std::chrono::seconds interrupt_timeout) { Lock lock(*this, interrupt_timeout); if (!lock) { - if (Log *log = - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)) + if (Log *log = GetLog(GDBRLog::Process)) LLDB_LOGF(log, "GDBRemoteClientBase::%s failed to get mutex, not sending " "packet '%.*s'", @@ -203,8 +202,7 @@ GDBRemoteClientBase::SendPacketAndReceiveResponseWithOutputSupport( llvm::function_ref output_callback) { Lock lock(*this, interrupt_timeout); if (!lock) { - if (Log *log = - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)) + if (Log *log = GetLog(GDBRLog::Process)) LLDB_LOGF(log, "GDBRemoteClientBase::%s failed to get mutex, not sending " "packet '%.*s'", @@ -237,7 +235,7 @@ GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock( if (response.ValidateResponse()) return packet_result; // Response says it wasn't valid - Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS); + Log *log = GetLog(GDBRLog::Packets); LLDB_LOGF( log, "error: packet with payload \"%.*s\" got invalid response \"%s\": %s", @@ -311,7 +309,7 @@ void GDBRemoteClientBase::ContinueLock::unlock() { GDBRemoteClientBase::ContinueLock::LockResult GDBRemoteClientBase::ContinueLock::lock() { - Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "GDBRemoteClientBase::ContinueLock::%s() resuming with %s", __FUNCTION__, m_comm.m_continue_packet.c_str()); @@ -349,7 +347,7 @@ GDBRemoteClientBase::Lock::Lock(GDBRemoteClientBase &comm, } void GDBRemoteClientBase::Lock::SyncWithContinueThread() { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); std::unique_lock lock(m_comm.m_mutex); if (m_comm.m_is_running && m_interrupt_timeout == std::chrono::seconds(0)) return; // We were asked to avoid interrupting the sender. Lock is not diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 25ae08838bf86..38d9e400978d2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -93,7 +93,7 @@ char GDBRemoteCommunication::CalculcateChecksum(llvm::StringRef payload) { } size_t GDBRemoteCommunication::SendAck() { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); ConnectionStatus status = eConnectionStatusSuccess; char ch = '+'; const size_t bytes_written = WriteAll(&ch, 1, status, nullptr); @@ -103,7 +103,7 @@ size_t GDBRemoteCommunication::SendAck() { } size_t GDBRemoteCommunication::SendNack() { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); ConnectionStatus status = eConnectionStatusSuccess; char ch = '-'; const size_t bytes_written = WriteAll(&ch, 1, status, nullptr); @@ -128,7 +128,7 @@ GDBRemoteCommunication::PacketResult GDBRemoteCommunication::SendRawPacketNoLock(llvm::StringRef packet, bool skip_ack) { if (IsConnected()) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); ConnectionStatus status = eConnectionStatusSuccess; const char *packet_data = packet.data(); const size_t packet_length = packet.size(); @@ -222,7 +222,7 @@ GDBRemoteCommunication::ReadPacket(StringExtractorGDBRemote &response, bool sync_on_timeout) { using ResponseType = StringExtractorGDBRemote::ResponseType; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); for (;;) { PacketResult result = WaitForPacketNoLock(response, timeout, sync_on_timeout); @@ -241,7 +241,7 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet, uint8_t buffer[8192]; Status error; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); // Check for a packet from our cache first without trying any reading... if (CheckForPacket(nullptr, 0, packet) != PacketType::Invalid) @@ -382,7 +382,7 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet, } bool GDBRemoteCommunication::DecompressPacket() { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); if (!CompressionIsEnabled()) return true; @@ -616,7 +616,7 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, // Put the packet data into the buffer in a thread safe fashion std::lock_guard guard(m_bytes_mutex); - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); if (src && src_len > 0) { if (log && log->GetVerbose()) { @@ -881,7 +881,7 @@ GDBRemoteCommunication::ListenThread(lldb::thread_arg_t arg) { Status GDBRemoteCommunication::StartDebugserverProcess( const char *url, Platform *platform, ProcessLaunchInfo &launch_info, uint16_t *port, const Args *inferior_args, int pass_comm_fd) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")", __FUNCTION__, url ? url : "", port ? *port : uint16_t(0)); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index f6526d03863bb..91b9151328a82 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -399,8 +399,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { packet_response.GetHexMaxU64(/*little_endian=*/false, UINT64_MAX); if (m_max_packet_size == 0) { m_max_packet_size = UINT64_MAX; // Must have been a garbled response - Log *log( - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log(GetLog(GDBRLog::Process)); LLDB_LOGF(log, "Garbled PacketSize spec in qSupported response"); } } @@ -485,8 +484,7 @@ GDBRemoteCommunicationClient::SendThreadSpecificPacketAndWaitForResponse( StringExtractorGDBRemote &response) { Lock lock(*this); if (!lock) { - if (Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet( - GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)) + if (Log *log = GetLog(GDBRLog::Process | GDBRLog::Packets)) LLDB_LOGF(log, "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex " "for %s packet.", @@ -622,7 +620,7 @@ DataBufferSP GDBRemoteCommunicationClient::ReadMemoryTags(lldb::addr_t addr, packet.Printf("qMemTags:%" PRIx64 ",%zx:%" PRIx32, addr, len, type); StringExtractorGDBRemote response; - Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_MEMORY); + Log *log = GetLog(GDBRLog::Memory); if (SendPacketAndWaitForResponse(packet.GetString(), response) != PacketResult::Success || @@ -1200,7 +1198,7 @@ static void ParseOSType(llvm::StringRef value, std::string &os_name, } bool GDBRemoteCommunicationClient::GetHostInfo(bool force) { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); if (force || m_qHostInfo_is_valid == eLazyBoolCalculate) { // host info computation can require DNS traffic and shelling out to external processes. @@ -2110,8 +2108,7 @@ bool GDBRemoteCommunicationClient::GetProcessInfo( } bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS | - GDBR_LOG_PACKETS)); + Log *log(GetLog(GDBRLog::Process | GDBRLog::Packets)); if (allow_lazy) { if (m_qProcessInfo_is_valid == eLazyBoolYes) @@ -2887,8 +2884,7 @@ GDBRemoteCommunicationClient::GetCurrentProcessAndThreadIDs( ids.emplace_back(1, 1); } } else { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS | - GDBR_LOG_PACKETS)); + Log *log(GetLog(GDBRLog::Process | GDBRLog::Packets)); LLDB_LOG(log, "error: failed to get packet sequence mutex, not sending " "packet 'qfThreadInfo'"); sequence_mutex_unavailable = true; @@ -3557,7 +3553,7 @@ bool GDBRemoteCommunicationClient::SyncThreadState(lldb::tid_t tid) { llvm::Expected GDBRemoteCommunicationClient::SendTraceSupported(std::chrono::seconds timeout) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); StreamGDBRemote escaped_packet; escaped_packet.PutCString("jLLDBTraceSupported"); @@ -3583,7 +3579,7 @@ GDBRemoteCommunicationClient::SendTraceSupported(std::chrono::seconds timeout) { llvm::Error GDBRemoteCommunicationClient::SendTraceStop(const TraceStopRequest &request, std::chrono::seconds timeout) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); StreamGDBRemote escaped_packet; escaped_packet.PutCString("jLLDBTraceStop:"); @@ -3618,7 +3614,7 @@ GDBRemoteCommunicationClient::SendTraceStop(const TraceStopRequest &request, llvm::Error GDBRemoteCommunicationClient::SendTraceStart(const llvm::json::Value ¶ms, std::chrono::seconds timeout) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); StreamGDBRemote escaped_packet; escaped_packet.PutCString("jLLDBTraceStart:"); @@ -3653,7 +3649,7 @@ GDBRemoteCommunicationClient::SendTraceStart(const llvm::json::Value ¶ms, llvm::Expected GDBRemoteCommunicationClient::SendTraceGetState(llvm::StringRef type, std::chrono::seconds timeout) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); StreamGDBRemote escaped_packet; escaped_packet.PutCString("jLLDBTraceGetState:"); @@ -3687,7 +3683,7 @@ GDBRemoteCommunicationClient::SendTraceGetState(llvm::StringRef type, llvm::Expected> GDBRemoteCommunicationClient::SendTraceGetBinaryData( const TraceGetBinaryDataRequest &request, std::chrono::seconds timeout) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); StreamGDBRemote escaped_packet; escaped_packet.PutCString("jLLDBTraceGetBinaryData:"); @@ -4132,8 +4128,7 @@ void GDBRemoteCommunicationClient::ServeSymbolLookups( // our symbol lookup failed so we must abort return; - } else if (Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet( - GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)) { + } else if (Log *log = GetLog(GDBRLog::Process | GDBRLog::Packets)) { LLDB_LOGF(log, "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex.", __FUNCTION__); @@ -4147,7 +4142,7 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() { // Query the server for the array of supported asynchronous JSON packets. m_supported_async_json_packets_is_valid = true; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); // Poll it now. StringExtractorGDBRemote response; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 49d88b72b01bf..7d21b0ff01daf 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -138,7 +138,7 @@ GDBRemoteCommunicationServer::Handle_QErrorStringEnable( GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServer::SendIllFormedResponse( const StringExtractorGDBRemote &failed_packet, const char *message) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); + Log *log = GetLog(GDBRLog::Packets); LLDB_LOGF(log, "GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)", __FUNCTION__, failed_packet.GetStringRef().data(), message ? message : ""); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 9410c9bd83ec4..1b66e8c162817 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -238,8 +238,7 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const RegisterInfo *reg_info) { if (GetRegisterIsValid(reg)) return true; } else { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD | - GDBR_LOG_PACKETS)); + Log *log(GetLog(GDBRLog::Thread | GDBRLog::Packets)); LLDB_LOGF( log, "error: GDBRemoteRegisterContext::ReadRegisterBytes tried " @@ -454,8 +453,7 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info, return success; } } else { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD | - GDBR_LOG_PACKETS)); + Log *log(GetLog(GDBRLog::Thread | GDBRLog::Packets)); if (log) { if (log->GetVerbose()) { StreamString strm; @@ -560,8 +558,7 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues( return true; } else { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD | - GDBR_LOG_PACKETS)); + Log *log(GetLog(GDBRLog::Thread | GDBRLog::Packets)); if (log) { if (log->GetVerbose()) { StreamString strm; @@ -736,8 +733,7 @@ bool GDBRemoteRegisterContext::WriteAllRegisterValues( return num_restored > 0; } } else { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD | - GDBR_LOG_PACKETS)); + Log *log(GetLog(GDBRLog::Thread | GDBRLog::Packets)); if (log) { if (log->GetVerbose()) { StreamString strm; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index d8ad0b4e4e4be..82357cd117d78 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -269,7 +269,7 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, m_gdb_comm.SetPacketRecorder(provider.GetNewPacketRecorder()); } - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_ASYNC)); + Log *log = GetLog(GDBRLog::Async); const uint32_t async_event_mask = eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit; @@ -705,7 +705,7 @@ Status ProcessGDBRemote::WillLaunchOrAttach() { // Process Control Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module, ProcessLaunchInfo &launch_info) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); Status error; LLDB_LOGF(log, "ProcessGDBRemote::%s() entered", __FUNCTION__); @@ -897,7 +897,7 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module, Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) { Status error; // Only connect if we have a valid connect URL - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); if (!connect_url.empty()) { LLDB_LOGF(log, "ProcessGDBRemote::%s Connecting to %s", __FUNCTION__, @@ -958,7 +958,7 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) { } void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); BuildDynamicRegisterInfo(false); // See if the GDB server supports qHostInfo or qProcessInfo packets. Prefer @@ -1094,7 +1094,7 @@ void ProcessGDBRemote::DidLaunch() { Status ProcessGDBRemote::DoAttachToProcessWithID( lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); Status error; LLDB_LOGF(log, "ProcessGDBRemote::%s()", __FUNCTION__); @@ -1203,7 +1203,7 @@ Status ProcessGDBRemote::WillResume() { Status ProcessGDBRemote::DoResume() { Status error; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::Resume()"); ListenerSP listener_sp( @@ -1513,7 +1513,7 @@ bool ProcessGDBRemote::UpdateThreadIDList() { bool ProcessGDBRemote::DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) { // locker will keep a mutex locked until it goes out of scope - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_THREAD)); + Log *log = GetLog(GDBRLog::Thread); LLDB_LOGV(log, "pid = {0}", GetID()); size_t num_thread_ids = m_thread_ids.size(); @@ -1793,8 +1793,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( } } if (watch_id == LLDB_INVALID_WATCH_ID) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet( - GDBR_LOG_WATCHPOINTS)); + Log *log(GetLog(GDBRLog::Watchpoints)); LLDB_LOGF(log, "failed to find watchpoint"); } thread_sp->SetStopInfo(StopInfo::CreateStopReasonWithWatchpointID( @@ -2236,8 +2235,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { } else if (key.compare("library") == 0) { auto error = LoadModules(); if (error) { - Log *log( - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log(GetLog(GDBRLog::Process)); LLDB_LOG_ERROR(log, std::move(error), "Failed to load modules: {0}"); } } else if (key.compare("fork") == 0 || key.compare("vfork") == 0) { @@ -2245,8 +2243,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { StringExtractorGDBRemote thread_id{value}; auto pid_tid = thread_id.GetPidTid(LLDB_INVALID_PROCESS_ID); if (!pid_tid) { - Log *log( - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log(GetLog(GDBRLog::Process)); LLDB_LOG(log, "Invalid PID/TID to fork: {0}", value); pid_tid = {{LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID}}; } @@ -2263,7 +2260,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { } if (stop_pid != LLDB_INVALID_PROCESS_ID && stop_pid != pid) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOG(log, "Received stop for incorrect PID = {0} (inferior PID = {1})", stop_pid, pid); @@ -2350,7 +2347,7 @@ Status ProcessGDBRemote::DoHalt(bool &caused_stop) { Status ProcessGDBRemote::DoDetach(bool keep_stopped) { Status error; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped); error = m_gdb_comm.Detach(keep_stopped); @@ -2379,7 +2376,7 @@ Status ProcessGDBRemote::DoDetach(bool keep_stopped) { Status ProcessGDBRemote::DoDestroy() { Status error; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy()"); // There is a bug in older iOS debugservers where they don't shut down the @@ -2561,7 +2558,7 @@ void ProcessGDBRemote::SetLastStopPacket( const bool did_exec = response.GetStringRef().find(";reason:exec;") != std::string::npos; if (did_exec) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::SetLastStopPacket () - detected exec"); m_thread_list_real.Clear(); @@ -2591,7 +2588,7 @@ addr_t ProcessGDBRemote::GetImageInfoAddress() { if (addr == LLDB_INVALID_ADDRESS) { llvm::Expected list = GetLoadedModuleList(); if (!list) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOG_ERROR(log, list.takeError(), "Failed to read module list: {0}."); } else { addr = list->m_link_map; @@ -3036,7 +3033,7 @@ Status ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) { assert(bp_site != nullptr); // Get logging info - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS)); + Log *log = GetLog(GDBRLog::Breakpoints); user_id_t site_id = bp_site->GetID(); // Get the breakpoint address @@ -3160,7 +3157,7 @@ Status ProcessGDBRemote::DisableBreakpointSite(BreakpointSite *bp_site) { assert(bp_site != nullptr); addr_t addr = bp_site->GetLoadAddress(); user_id_t site_id = bp_site->GetID(); - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS)); + Log *log = GetLog(GDBRLog::Breakpoints); LLDB_LOGF(log, "ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64 ") addr = 0x%8.8" PRIx64, @@ -3225,8 +3222,7 @@ Status ProcessGDBRemote::EnableWatchpoint(Watchpoint *wp, bool notify) { if (wp) { user_id_t watchID = wp->GetID(); addr_t addr = wp->GetLoadAddress(); - Log *log( - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS)); + Log *log(GetLog(GDBRLog::Watchpoints)); LLDB_LOGF(log, "ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64 ")", watchID); if (wp->IsEnabled()) { @@ -3262,8 +3258,7 @@ Status ProcessGDBRemote::DisableWatchpoint(Watchpoint *wp, bool notify) { if (wp) { user_id_t watchID = wp->GetID(); - Log *log( - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS)); + Log *log(GetLog(GDBRLog::Watchpoints)); addr_t addr = wp->GetLoadAddress(); @@ -3311,7 +3306,7 @@ void ProcessGDBRemote::Clear() { Status ProcessGDBRemote::DoSignal(int signo) { Status error; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::DoSignal (signal = %d)", signo); if (!m_gdb_comm.SendAsyncSignal(signo, GetInterruptTimeout())) @@ -3432,7 +3427,7 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver( } if (error.Fail()) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "failed to start debugserver process: %s", error.AsCString()); @@ -3458,7 +3453,7 @@ bool ProcessGDBRemote::MonitorDebugserverProcess( ) { // "debugserver_pid" argument passed in is the process ID for debugserver // that we are tracking... - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); const bool handled = true; LLDB_LOGF(log, @@ -3537,7 +3532,7 @@ void ProcessGDBRemote::DebuggerInitialize(Debugger &debugger) { } bool ProcessGDBRemote::StartAsyncThread() { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::%s ()", __FUNCTION__); @@ -3565,7 +3560,7 @@ bool ProcessGDBRemote::StartAsyncThread() { } void ProcessGDBRemote::StopAsyncThread() { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::%s ()", __FUNCTION__); @@ -3589,7 +3584,7 @@ void ProcessGDBRemote::StopAsyncThread() { thread_result_t ProcessGDBRemote::AsyncThread(void *arg) { ProcessGDBRemote *process = (ProcessGDBRemote *)arg; - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") thread starting...", @@ -3792,7 +3787,7 @@ bool ProcessGDBRemote::NewThreadNotifyBreakpointHit( } Status ProcessGDBRemote::UpdateAutomaticSignalFiltering() { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); LLDB_LOG(log, "Check if need to update ignored signals"); // QPassSignals package is not supported by the server, there is no way we @@ -3896,9 +3891,7 @@ DataExtractor ProcessGDBRemote::GetAuxvData() { buf = std::make_shared(response->c_str(), response->length()); else - LLDB_LOG_ERROR( - ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS), - response.takeError(), "{0}"); + LLDB_LOG_ERROR(GetLog(GDBRLog::Process), response.takeError(), "{0}"); } return DataExtractor(buf, GetByteOrder(), GetAddressByteSize()); } @@ -4086,8 +4079,7 @@ void ProcessGDBRemote::GetMaxMemorySize() { else { // In unlikely scenario that max packet size is less then 70, we will // hope that data being written is small enough to fit. - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet( - GDBR_LOG_COMM | GDBR_LOG_MEMORY)); + Log *log(GetLog(GDBRLog::Comm | GDBRLog::Memory)); if (log) log->Warning("Packet size is too small. " "LLDB may face problems while writing memory"); @@ -4266,8 +4258,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info, SplitCommaSeparatedRegisterNumberString( value, reg_info.invalidate_regs, 0); } else { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet( - GDBR_LOG_PROCESS)); + Log *log(GetLog(GDBRLog::Process)); LLDB_LOGF(log, "ProcessGDBRemote::%s unhandled reg attribute %s = %s", __FUNCTION__, name.data(), value.data()); @@ -4309,8 +4300,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info, } if (reg_info.byte_size == 0) { - Log *log( - ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log(GetLog(GDBRLog::Process)); LLDB_LOGF(log, "ProcessGDBRemote::%s Skipping zero bitsize register %s", __FUNCTION__, reg_info.name.AsCString()); @@ -4982,7 +4972,7 @@ static const char *const s_async_json_packet_prefix = "JSON-async:"; static StructuredData::ObjectSP ParseStructuredDataPacket(llvm::StringRef packet) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); if (!packet.consume_front(s_async_json_packet_prefix)) { if (log) { @@ -5355,7 +5345,7 @@ void ProcessGDBRemote::DidForkSwitchHardwareTraps(bool enable) { } void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); lldb::pid_t parent_pid = m_gdb_comm.GetCurrentProcessID(); // Any valid TID will suffice, thread-relevant actions will set a proper TID @@ -5417,7 +5407,7 @@ void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) { } void ProcessGDBRemote::DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); assert(!m_vfork_in_progress); m_vfork_in_progress = true; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h index 44e390ec8cadb..7303842043930 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h @@ -29,28 +29,9 @@ enum class GDBRLog : Log::MaskType { LLVM_MARK_AS_BITMASK_ENUM(Watchpoints) }; -#define GDBR_LOG_PROCESS ::lldb_private::process_gdb_remote::GDBRLog::Process -#define GDBR_LOG_THREAD ::lldb_private::process_gdb_remote::GDBRLog::Thread -#define GDBR_LOG_PACKETS ::lldb_private::process_gdb_remote::GDBRLog::Packets -#define GDBR_LOG_MEMORY ::lldb_private::process_gdb_remote::GDBRLog::Memory -#define GDBR_LOG_MEMORY_DATA_SHORT \ - ::lldb_private::process_gdb_remote::GDBRLog::MemoryDataShort -#define GDBR_LOG_MEMORY_DATA_LONG \ - ::lldb_private::process_gdb_remote::GDBRLog::MemoryDataLong -#define GDBR_LOG_BREAKPOINTS \ - ::lldb_private::process_gdb_remote::GDBRLog::Breakpoints -#define GDBR_LOG_WATCHPOINTS \ - ::lldb_private::process_gdb_remote::GDBRLog::Watchpoints -#define GDBR_LOG_STEP ::lldb_private::process_gdb_remote::GDBRLog::Step -#define GDBR_LOG_COMM ::lldb_private::process_gdb_remote::GDBRLog::Comm -#define GDBR_LOG_ASYNC ::lldb_private::process_gdb_remote::GDBRLog::Async - class ProcessGDBRemoteLog { public: static void Initialize(); - - static Log *GetLogIfAllCategoriesSet(GDBRLog mask) { return GetLog(mask); } - static Log *GetLogIfAnyCategoryIsSet(GDBRLog mask) { return GetLog(mask); } }; } // namespace process_gdb_remote