Skip to content

Commit c8fbf80

Browse files
committed
[lldb] Convert Process KDP Log to the new API
1 parent 081cff6 commit c8fbf80

File tree

4 files changed

+15
-30
lines changed

4 files changed

+15
-30
lines changed

lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool CommunicationKDP::SendRequestAndGetReply(
6565
const CommandType command, const PacketStreamType &request_packet,
6666
DataExtractor &reply_packet) {
6767
if (IsRunning()) {
68-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
68+
Log *log = GetLog(KDPLog::Packets);
6969
if (log) {
7070
PacketStreamType log_strm;
7171
DumpPacket(log_strm, request_packet.GetData(), request_packet.GetSize());
@@ -133,7 +133,7 @@ bool CommunicationKDP::SendRequestPacketNoLock(
133133
const char *packet_data = request_packet.GetData();
134134
const size_t packet_size = request_packet.GetSize();
135135

136-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
136+
Log *log = GetLog(KDPLog::Packets);
137137
if (log) {
138138
PacketStreamType log_strm;
139139
DumpPacket(log_strm, packet_data, packet_size);
@@ -178,7 +178,7 @@ size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock(
178178
uint8_t buffer[8192];
179179
Status error;
180180

181-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
181+
Log *log = GetLog(KDPLog::Packets);
182182

183183
// Check for a packet from our cache first without trying any reading...
184184
if (CheckForPacket(NULL, 0, packet))
@@ -231,7 +231,7 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len,
231231
// Put the packet data into the buffer in a thread safe fashion
232232
std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
233233

234-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
234+
Log *log = GetLog(KDPLog::Packets);
235235

236236
if (src && src_len > 0) {
237237
if (log && log->GetVerbose()) {

lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ ProcessKDP::DoAttachToProcessWithName(const char *process_name,
381381
void ProcessKDP::DidAttach(ArchSpec &process_arch) {
382382
Process::DidAttach(process_arch);
383383

384-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
384+
Log *log = GetLog(KDPLog::Process);
385385
LLDB_LOGF(log, "ProcessKDP::DidAttach()");
386386
if (GetID() != LLDB_INVALID_PROCESS_ID) {
387387
GetHostArchitecture(process_arch);
@@ -400,7 +400,7 @@ Status ProcessKDP::WillResume() { return Status(); }
400400

401401
Status ProcessKDP::DoResume() {
402402
Status error;
403-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
403+
Log *log = GetLog(KDPLog::Process);
404404
// Only start the async thread if we try to do any process control
405405
if (!m_async_thread.IsJoinable())
406406
StartAsyncThread();
@@ -492,7 +492,7 @@ lldb::ThreadSP ProcessKDP::GetKernelThread() {
492492
bool ProcessKDP::DoUpdateThreadList(ThreadList &old_thread_list,
493493
ThreadList &new_thread_list) {
494494
// locker will keep a mutex locked until it goes out of scope
495-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_THREAD));
495+
Log *log = GetLog(KDPLog::Thread);
496496
LLDB_LOGV(log, "pid = {0}", GetID());
497497

498498
// Even though there is a CPU mask, it doesn't mean we can see each CPU
@@ -530,7 +530,7 @@ Status ProcessKDP::DoHalt(bool &caused_stop) {
530530

531531
Status ProcessKDP::DoDetach(bool keep_stopped) {
532532
Status error;
533-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
533+
Log *log = GetLog(KDPLog::Process);
534534
LLDB_LOGF(log, "ProcessKDP::DoDetach(keep_stopped = %i)", keep_stopped);
535535

536536
if (m_comm.IsRunning()) {
@@ -715,7 +715,7 @@ void ProcessKDP::DebuggerInitialize(lldb_private::Debugger &debugger) {
715715
}
716716

717717
bool ProcessKDP::StartAsyncThread() {
718-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
718+
Log *log = GetLog(KDPLog::Process);
719719

720720
LLDB_LOGF(log, "ProcessKDP::StartAsyncThread ()");
721721

@@ -725,17 +725,16 @@ bool ProcessKDP::StartAsyncThread() {
725725
llvm::Expected<HostThread> async_thread = ThreadLauncher::LaunchThread(
726726
"<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this);
727727
if (!async_thread) {
728-
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
729-
"failed to launch host thread: {}",
730-
llvm::toString(async_thread.takeError()));
728+
LLDB_LOG_ERROR(GetLog(LLDBLog::Host), async_thread.takeError(),
729+
"failed to launch host thread: {}");
731730
return false;
732731
}
733732
m_async_thread = *async_thread;
734733
return m_async_thread.IsJoinable();
735734
}
736735

737736
void ProcessKDP::StopAsyncThread() {
738-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
737+
Log *log = GetLog(KDPLog::Process);
739738

740739
LLDB_LOGF(log, "ProcessKDP::StopAsyncThread ()");
741740

@@ -751,7 +750,7 @@ void *ProcessKDP::AsyncThread(void *arg) {
751750

752751
const lldb::pid_t pid = process->GetID();
753752

754-
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
753+
Log *log = GetLog(KDPLog::Process);
755754
LLDB_LOGF(log,
756755
"ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64
757756
") thread starting...",

lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,10 @@ enum class KDPLog : Log::MaskType {
2828
Watchpoints = Log::ChannelFlag<10>,
2929
LLVM_MARK_AS_BITMASK_ENUM(Watchpoints)
3030
};
31-
#define KDP_LOG_PROCESS ::lldb_private::KDPLog::Process
32-
#define KDP_LOG_THREAD ::lldb_private::KDPLog::Thread
33-
#define KDP_LOG_PACKETS ::lldb_private::KDPLog::Packets
34-
#define KDP_LOG_MEMORY ::lldb_private::KDPLog::Memory
35-
#define KDP_LOG_MEMORY_DATA_SHORT ::lldb_private::KDPLog::MemoryDataShort
36-
#define KDP_LOG_MEMORY_DATA_LONG ::lldb_private::KDPLog::MemoryDataLong
37-
#define KDP_LOG_BREAKPOINTS ::lldb_private::KDPLog::Breakpoints
38-
#define KDP_LOG_WATCHPOINTS ::lldb_private::KDPLog::Watchpoints
39-
#define KDP_LOG_STEP ::lldb_private::KDPLog::Step
40-
#define KDP_LOG_COMM ::lldb_private::KDPLog::Comm
41-
#define KDP_LOG_ASYNC ::lldb_private::KDPLog::Async
42-
#define KDP_LOG_DEFAULT KDP_LOG_PACKETS
4331

4432
class ProcessKDPLog {
4533
public:
4634
static void Initialize();
47-
48-
static Log *GetLogIfAllCategoriesSet(KDPLog mask) { return GetLog(mask); }
4935
};
5036

5137
template <> Log::Channel &LogChannelFor<KDPLog>();

lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ using namespace lldb_private;
3939
ThreadKDP::ThreadKDP(Process &process, lldb::tid_t tid)
4040
: Thread(process, tid), m_thread_name(), m_dispatch_queue_name(),
4141
m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS) {
42-
Log *log = ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_THREAD);
42+
Log *log = GetLog(KDPLog::Thread);
4343
LLDB_LOG(log, "this = {0}, tid = {1:x}", this, GetID());
4444
}
4545

4646
ThreadKDP::~ThreadKDP() {
47-
Log *log = ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_THREAD);
47+
Log *log = GetLog(KDPLog::Thread);
4848
LLDB_LOG(log, "this = {0}, tid = {1:x}", this, GetID());
4949
DestroyThread();
5050
}

0 commit comments

Comments
 (0)