1*0b57cec5SDimitry Andric //===-- ProcessGDBRemoteLog.cpp -------------------------------------------===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #include "ProcessGDBRemoteLog.h"
10*0b57cec5SDimitry Andric #include "ProcessGDBRemote.h"
11*0b57cec5SDimitry Andric #include "llvm/Support/Threading.h"
12*0b57cec5SDimitry Andric 
13*0b57cec5SDimitry Andric using namespace lldb;
14*0b57cec5SDimitry Andric using namespace lldb_private;
15*0b57cec5SDimitry Andric using namespace lldb_private::process_gdb_remote;
16*0b57cec5SDimitry Andric 
17*0b57cec5SDimitry Andric static constexpr Log::Category g_categories[] = {
18*0b57cec5SDimitry Andric     {{"async"}, {"log asynchronous activity"}, GDBRLog::Async},
19*0b57cec5SDimitry Andric     {{"break"}, {"log breakpoints"}, GDBRLog::Breakpoints},
20*0b57cec5SDimitry Andric     {{"comm"}, {"log communication activity"}, GDBRLog::Comm},
21*0b57cec5SDimitry Andric     {{"packets"}, {"log gdb remote packets"}, GDBRLog::Packets},
22*0b57cec5SDimitry Andric     {{"memory"}, {"log memory reads and writes"}, GDBRLog::Memory},
23*0b57cec5SDimitry Andric     {{"data-short"},
24*0b57cec5SDimitry Andric      {"log memory bytes for memory reads and writes for short transactions "
25*0b57cec5SDimitry Andric       "only"},
26*0b57cec5SDimitry Andric      GDBRLog::MemoryDataShort},
27*0b57cec5SDimitry Andric     {{"data-long"},
28*0b57cec5SDimitry Andric      {"log memory bytes for memory reads and writes for all transactions"},
29*0b57cec5SDimitry Andric      GDBRLog::MemoryDataLong},
30*0b57cec5SDimitry Andric     {{"process"}, {"log process events and activities"}, GDBRLog::Process},
31*0b57cec5SDimitry Andric     {{"step"}, {"log step related activities"}, GDBRLog::Step},
32*0b57cec5SDimitry Andric     {{"thread"}, {"log thread events and activities"}, GDBRLog::Thread},
33*0b57cec5SDimitry Andric     {{"watch"}, {"log watchpoint related activities"}, GDBRLog::Watchpoints},
34*0b57cec5SDimitry Andric };
35*0b57cec5SDimitry Andric 
36*0b57cec5SDimitry Andric static Log::Channel g_channel(g_categories, GDBRLog::Packets);
37*0b57cec5SDimitry Andric 
LogChannelFor()38*0b57cec5SDimitry Andric template <> Log::Channel &lldb_private::LogChannelFor<GDBRLog>() {
39*0b57cec5SDimitry Andric   return g_channel;
40*0b57cec5SDimitry Andric }
41*0b57cec5SDimitry Andric 
Initialize()42*0b57cec5SDimitry Andric void ProcessGDBRemoteLog::Initialize() {
43*0b57cec5SDimitry Andric   static llvm::once_flag g_once_flag;
44   llvm::call_once(g_once_flag, []() {
45     Log::Register("gdb-remote", g_channel);
46   });
47 }
48