1//===-- PlatformAndroidRemoteGDBServer.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_PLATFORM_ANDROID_PLATFORMANDROIDREMOTEGDBSERVER_H
10#define LLDB_SOURCE_PLUGINS_PLATFORM_ANDROID_PLATFORMANDROIDREMOTEGDBSERVER_H
11
12#include <map>
13#include <optional>
14#include <utility>
15
16#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
17
18
19#include "AdbClient.h"
20
21namespace lldb_private {
22namespace platform_android {
23
24class PlatformAndroidRemoteGDBServer
25 : public platform_gdb_server::PlatformRemoteGDBServer {
26public:
27 PlatformAndroidRemoteGDBServer() = default;
28
29 ~PlatformAndroidRemoteGDBServer() override;
30
31 Status ConnectRemote(Args &args) override;
32
33 Status DisconnectRemote() override;
34
35 lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
36 llvm::StringRef plugin_name,
37 lldb_private::Debugger &debugger,
38 lldb_private::Target *target,
39 lldb_private::Status &error) override;
40
41protected:
42 std::string m_device_id;
43 std::map<lldb::pid_t, uint16_t> m_port_forwards;
44 std::optional<AdbClient::UnixSocketNamespace> m_socket_namespace;
45
46 bool LaunchGDBServer(lldb::pid_t &pid, std::string &connect_url) override;
47
48 bool KillSpawnedProcess(lldb::pid_t pid) override;
49
50 void DeleteForwardPort(lldb::pid_t pid);
51
52 Status MakeConnectURL(const lldb::pid_t pid, const uint16_t local_port,
53 const uint16_t remote_port,
54 llvm::StringRef remote_socket_name,
55 std::string &connect_url);
56
57private:
58 PlatformAndroidRemoteGDBServer(const PlatformAndroidRemoteGDBServer &) =
59 delete;
60 const PlatformAndroidRemoteGDBServer &
61 operator=(const PlatformAndroidRemoteGDBServer &) = delete;
62};
63
64} // namespace platform_android
65} // namespace lldb_private
66
67#endif // LLDB_SOURCE_PLUGINS_PLATFORM_ANDROID_PLATFORMANDROIDREMOTEGDBSERVER_H
68

source code of lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h