1//===-- GDBRemoteCommunicationServerPlatform.h ------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERPLATFORM_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERPLATFORM_H
11
12#include <map>
13#include <mutex>
14#include <optional>
15#include <set>
16
17#include "GDBRemoteCommunicationServerCommon.h"
18#include "lldb/Host/Socket.h"
19
20#include "llvm/Support/Error.h"
21
22namespace lldb_private {
23namespace process_gdb_remote {
24
25class GDBRemoteCommunicationServerPlatform
26 : public GDBRemoteCommunicationServerCommon {
27public:
28 GDBRemoteCommunicationServerPlatform(
29 const Socket::SocketProtocol socket_protocol, uint16_t gdbserver_port);
30
31 ~GDBRemoteCommunicationServerPlatform() override;
32
33 Status LaunchProcess() override;
34
35 void SetInferiorArguments(const lldb_private::Args &args);
36
37 Status LaunchGDBServer(const lldb_private::Args &args, lldb::pid_t &pid,
38 std::string &socket_name, shared_fd_t fd);
39
40 void SetPendingGdbServer(const std::string &socket_name);
41
42protected:
43 const Socket::SocketProtocol m_socket_protocol;
44 std::recursive_mutex m_spawned_pids_mutex;
45 std::set<lldb::pid_t> m_spawned_pids;
46
47 uint16_t m_gdbserver_port;
48 std::optional<std::string> m_pending_gdb_server_socket_name;
49
50 PacketResult Handle_qLaunchGDBServer(StringExtractorGDBRemote &packet);
51
52 PacketResult Handle_qQueryGDBServer(StringExtractorGDBRemote &packet);
53
54 PacketResult Handle_qKillSpawnedProcess(StringExtractorGDBRemote &packet);
55
56 PacketResult Handle_qPathComplete(StringExtractorGDBRemote &packet);
57
58 PacketResult Handle_qProcessInfo(StringExtractorGDBRemote &packet);
59
60 PacketResult Handle_qGetWorkingDir(StringExtractorGDBRemote &packet);
61
62 PacketResult Handle_QSetWorkingDir(StringExtractorGDBRemote &packet);
63
64 PacketResult Handle_qC(StringExtractorGDBRemote &packet);
65
66 PacketResult Handle_jSignalsInfo(StringExtractorGDBRemote &packet);
67
68private:
69 bool KillSpawnedProcess(lldb::pid_t pid);
70 bool SpawnedProcessIsRunning(lldb::pid_t pid);
71 void AddSpawnedProcess(lldb::pid_t pid);
72
73 void DebugserverProcessReaped(lldb::pid_t pid);
74
75 static const FileSpec &GetDomainSocketDir();
76
77 static FileSpec GetDomainSocketPath(const char *prefix);
78
79 GDBRemoteCommunicationServerPlatform(
80 const GDBRemoteCommunicationServerPlatform &) = delete;
81 const GDBRemoteCommunicationServerPlatform &
82 operator=(const GDBRemoteCommunicationServerPlatform &) = delete;
83};
84
85} // namespace process_gdb_remote
86} // namespace lldb_private
87
88#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERPLATFORM_H
89

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h