xref: /src/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp (revision 04eeddc0aa8e0a417a16eaf9d7d095207f4a8623)
1cfca06d7SDimitry Andric //===-- ProcessGDBRemoteLog.cpp -------------------------------------------===//
2f034231aSEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f034231aSEd Maste //
7f034231aSEd Maste //===----------------------------------------------------------------------===//
8f034231aSEd Maste 
9f034231aSEd Maste #include "ProcessGDBRemoteLog.h"
10f034231aSEd Maste #include "ProcessGDBRemote.h"
1174a628f7SDimitry Andric #include "llvm/Support/Threading.h"
12f034231aSEd Maste 
13f034231aSEd Maste using namespace lldb;
14f034231aSEd Maste using namespace lldb_private;
155e95aa85SEd Maste using namespace lldb_private::process_gdb_remote;
16f034231aSEd Maste 
1774a628f7SDimitry Andric static constexpr Log::Category g_categories[] = {
186f8fc217SDimitry Andric     {{"async"}, {"log asynchronous activity"}, GDBRLog::Async},
196f8fc217SDimitry Andric     {{"break"}, {"log breakpoints"}, GDBRLog::Breakpoints},
206f8fc217SDimitry Andric     {{"comm"}, {"log communication activity"}, GDBRLog::Comm},
216f8fc217SDimitry Andric     {{"packets"}, {"log gdb remote packets"}, GDBRLog::Packets},
226f8fc217SDimitry Andric     {{"memory"}, {"log memory reads and writes"}, GDBRLog::Memory},
2374a628f7SDimitry Andric     {{"data-short"},
2474a628f7SDimitry Andric      {"log memory bytes for memory reads and writes for short transactions "
2574a628f7SDimitry Andric       "only"},
266f8fc217SDimitry Andric      GDBRLog::MemoryDataShort},
2774a628f7SDimitry Andric     {{"data-long"},
2874a628f7SDimitry Andric      {"log memory bytes for memory reads and writes for all transactions"},
296f8fc217SDimitry Andric      GDBRLog::MemoryDataLong},
306f8fc217SDimitry Andric     {{"process"}, {"log process events and activities"}, GDBRLog::Process},
316f8fc217SDimitry Andric     {{"step"}, {"log step related activities"}, GDBRLog::Step},
326f8fc217SDimitry Andric     {{"thread"}, {"log thread events and activities"}, GDBRLog::Thread},
336f8fc217SDimitry Andric     {{"watch"}, {"log watchpoint related activities"}, GDBRLog::Watchpoints},
3474a628f7SDimitry Andric };
3574a628f7SDimitry Andric 
366f8fc217SDimitry Andric static Log::Channel g_channel(g_categories, GDBRLog::Packets);
376f8fc217SDimitry Andric 
LogChannelFor()386f8fc217SDimitry Andric template <> Log::Channel &lldb_private::LogChannelFor<GDBRLog>() {
396f8fc217SDimitry Andric   return g_channel;
406f8fc217SDimitry Andric }
41f034231aSEd Maste 
Initialize()4214f1b3e8SDimitry Andric void ProcessGDBRemoteLog::Initialize() {
4374a628f7SDimitry Andric   static llvm::once_flag g_once_flag;
4474a628f7SDimitry Andric   llvm::call_once(g_once_flag, []() {
4574a628f7SDimitry Andric     Log::Register("gdb-remote", g_channel);
465e95aa85SEd Maste   });
475e95aa85SEd Maste }
48