diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-10-24 01:08:35 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-10-24 01:08:35 +0000 |
commit | edb35d95d1ffa14fca9dfdb97d30cc0f834155ba (patch) | |
tree | 87d69039114a4172df389d8ef385c1986c1e8567 /lldb/source/Plugins/Process/gdb-remote | |
parent | 284350e5405ce0d164e9fe35c5b3a95316569763 (diff) | |
download | bcm5719-llvm-edb35d95d1ffa14fca9dfdb97d30cc0f834155ba.tar.gz bcm5719-llvm-edb35d95d1ffa14fca9dfdb97d30cc0f834155ba.zip |
Fix Clang-tidy modernize-use-override warnings in some files in source/Plugins; other minor fixes.
llvm-svn: 251167
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
9 files changed, 177 insertions, 270 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index dee3528463f..ccc8ef1b247 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -12,9 +12,9 @@ // C Includes // C++ Includes -#include <list> #include <string> #include <queue> +#include <vector> // Other libraries and framework includes // Project includes @@ -94,14 +94,10 @@ public: uint32_t m_saved_timeout; }; - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ GDBRemoteCommunication(const char *comm_name, const char *listener_name); - virtual - ~GDBRemoteCommunication(); + ~GDBRemoteCommunication() override; PacketResult GetAck (); @@ -117,12 +113,13 @@ public: size_t payload_length); bool - GetSequenceMutex (Mutex::Locker& locker, const char *failure_message = NULL); + GetSequenceMutex(Mutex::Locker& locker, const char *failure_message = nullptr); PacketType CheckForPacket (const uint8_t *src, size_t src_len, StringExtractorGDBRemote &packet); + bool IsRunning() const { @@ -162,21 +159,21 @@ public: { return m_packet_timeout * TimeValue::MicroSecPerSec; } + //------------------------------------------------------------------ // Start a debugserver instance on the current host using the // supplied connection URL. //------------------------------------------------------------------ Error - StartDebugserverProcess (const char *url, - Platform *platform, // If non NULL, then check with the platform for the GDB server binary if it can't be located - ProcessLaunchInfo &launch_info, - uint16_t *port); + StartDebugserverProcess(const char *url, + Platform *platform, // If non nullptr, then check with the platform for the GDB server binary if it can't be located + ProcessLaunchInfo &launch_info, + uint16_t *port); void DumpHistory(Stream &strm); protected: - class History { public: @@ -223,6 +220,7 @@ protected: AddPacket (char packet_char, PacketType type, uint32_t bytes_transmitted); + void AddPacket (const std::string &src, uint32_t src_len, @@ -241,7 +239,7 @@ protected: return m_dumped_to_log; } -protected: + protected: uint32_t GetFirstSavedPacketIndex () const { @@ -275,13 +273,30 @@ protected: return i % m_packets.size(); } - std::vector<Entry> m_packets; uint32_t m_curr_idx; uint32_t m_total_packet_count; mutable bool m_dumped_to_log; }; + uint32_t m_packet_timeout; + uint32_t m_echo_number; + LazyBool m_supports_qEcho; +#ifdef ENABLE_MUTEX_ERROR_CHECKING + TrackingMutex m_sequence_mutex; +#else + Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time +#endif + Predicate<bool> m_public_is_running; + Predicate<bool> m_private_is_running; + History m_history; + bool m_send_acks; + bool m_is_platform; // Set to true if this class represents a platform, + // false if this class represents a debug session for + // a single process + + CompressionType m_compression_type; + PacketResult SendPacket (const char *payload, size_t payload_length); @@ -321,27 +336,6 @@ protected: bool DecompressPacket (); - //------------------------------------------------------------------ - // Classes that inherit from GDBRemoteCommunication can see and modify these - //------------------------------------------------------------------ - uint32_t m_packet_timeout; - uint32_t m_echo_number; - LazyBool m_supports_qEcho; -#ifdef ENABLE_MUTEX_ERROR_CHECKING - TrackingMutex m_sequence_mutex; -#else - Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time -#endif - Predicate<bool> m_public_is_running; - Predicate<bool> m_private_is_running; - History m_history; - bool m_send_acks; - bool m_is_platform; // Set to true if this class represents a platform, - // false if this class represents a debug session for - // a single process - - CompressionType m_compression_type; - Error StartListenThread (const char *hostname = "127.0.0.1", uint16_t port = 0); @@ -361,10 +355,12 @@ protected: // This method is defined as part of communication.h // when the read thread gets any bytes it will pass them on to this function - virtual void AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast, lldb::ConnectionStatus status); + void AppendBytesToCache(const uint8_t * bytes, + size_t len, + bool broadcast, + lldb::ConnectionStatus status) override; private: - std::queue<StringExtractorGDBRemote> m_packet_queue; // The packet queue lldb_private::Mutex m_packet_queue_mutex; // Mutex for accessing queue Condition m_condition_queue_not_empty; // Condition variable to wait for packets @@ -372,13 +368,10 @@ private: HostThread m_listen_thread; std::string m_listen_url; - //------------------------------------------------------------------ - // For GDBRemoteCommunication only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunication); }; } // namespace process_gdb_remote } // namespace lldb_private -#endif // liblldb_GDBRemoteCommunication_h_ +#endif // liblldb_GDBRemoteCommunication_h_ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 4847aad52f2..2c41d199ca5 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include <map> +#include <string> #include <vector> // Other libraries and framework includes @@ -28,12 +30,9 @@ namespace process_gdb_remote { class GDBRemoteCommunicationClient : public GDBRemoteCommunication { public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ GDBRemoteCommunicationClient(); - ~GDBRemoteCommunicationClient(); + ~GDBRemoteCommunicationClient() override; //------------------------------------------------------------------ // After connecting, send the handshake to the server to make sure @@ -79,6 +78,7 @@ public: const char *packet_payload, size_t packet_length, StringExtractorGDBRemote &response); + bool SendvContPacket (ProcessGDBRemote *process, const char *payload, @@ -164,7 +164,7 @@ public: SendLaunchArchPacket (const char *arch); int - SendLaunchEventDataPacket (const char *data, bool *was_supported = NULL); + SendLaunchEventDataPacket(const char *data, bool *was_supported = nullptr); //------------------------------------------------------------------ /// Sends a "vAttach:PID" where PID is in hex. @@ -185,7 +185,6 @@ public: SendAttach (lldb::pid_t pid, StringExtractorGDBRemote& response); - //------------------------------------------------------------------ /// Sends a GDB remote protocol 'I' packet that delivers stdin /// data to the remote process. @@ -399,6 +398,7 @@ public: default: return false; } } + uint8_t SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint bool insert, // Insert or remove? @@ -508,11 +508,11 @@ public: GetFileExists (const FileSpec& file_spec); Error - RunShellCommand(const char *command, // Shouldn't be NULL + RunShellCommand(const char *command, // Shouldn't be nullptr const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory - int *status_ptr, // Pass NULL if you don't want the process exit status - int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit - std::string *command_output, // Pass NULL if you don't want the command output + int *status_ptr, // Pass nullptr if you don't want the process exit status + int *signo_ptr, // Pass nullptr if you don't want the signal that caused the process to exit + std::string *command_output, // Pass nullptr if you don't want the command output uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish bool @@ -570,26 +570,6 @@ public: ServeSymbolLookups(lldb_private::Process *process); protected: - - PacketResult - SendPacketAndWaitForResponseNoLock (const char *payload, - size_t payload_length, - StringExtractorGDBRemote &response); - - bool - GetCurrentProcessInfo (bool allow_lazy_pid = true); - - bool - GetGDBServerVersion(); - - // Given the list of compression types that the remote debug stub can support, - // possibly enable compression if we find an encoding we can handle. - void - MaybeEnableCompression (std::vector<std::string> supported_compressions); - - //------------------------------------------------------------------ - // Classes that inherit from GDBRemoteCommunicationClient can see and modify these - //------------------------------------------------------------------ LazyBool m_supports_not_sending_acks; LazyBool m_supports_thread_suffix; LazyBool m_supports_threads_in_stop_reply; @@ -642,7 +622,6 @@ protected: lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc - uint32_t m_num_supported_hardware_watchpoints; // If we need to send a packet while the target is running, the m_async_XXX @@ -670,18 +649,31 @@ protected: uint32_t m_default_packet_timeout; uint64_t m_max_packet_size; // as returned by qSupported - + PacketResult + SendPacketAndWaitForResponseNoLock (const char *payload, + size_t payload_length, + StringExtractorGDBRemote &response); + + bool + GetCurrentProcessInfo (bool allow_lazy_pid = true); + + bool + GetGDBServerVersion(); + + // Given the list of compression types that the remote debug stub can support, + // possibly enable compression if we find an encoding we can handle. + void + MaybeEnableCompression (std::vector<std::string> supported_compressions); + bool DecodeProcessInfoResponse (StringExtractorGDBRemote &response, ProcessInstanceInfo &process_info); + private: - //------------------------------------------------------------------ - // For GDBRemoteCommunicationClient only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient); }; } // namespace process_gdb_remote } // namespace lldb_private -#endif // liblldb_GDBRemoteCommunicationClient_h_ +#endif // liblldb_GDBRemoteCommunicationClient_h_ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h index 44c0f6a32f5..1d512bf1de5 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h @@ -39,8 +39,7 @@ public: GDBRemoteCommunicationServer(const char *comm_name, const char *listener_name); - virtual - ~GDBRemoteCommunicationServer(); + ~GDBRemoteCommunicationServer() override; void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler); @@ -73,13 +72,10 @@ protected: SendOKResponse (); private: - //------------------------------------------------------------------ - // For GDBRemoteCommunicationServer only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer); }; } // namespace process_gdb_remote } // namespace lldb_private -#endif // liblldb_GDBRemoteCommunicationServer_h_ +#endif // liblldb_GDBRemoteCommunicationServer_h_ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h index 4eff8042086..f55b2eb3f4d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h @@ -12,13 +12,14 @@ // C Includes // C++ Includes +#include <string> // Other libraries and framework includes +// Project includes #include "lldb/lldb-private-forward.h" #include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" -// Project includes #include "GDBRemoteCommunicationServer.h" #include "GDBRemoteCommunicationServerCommon.h" @@ -35,8 +36,7 @@ class GDBRemoteCommunicationServerCommon : public: GDBRemoteCommunicationServerCommon(const char *comm_name, const char *listener_name); - virtual - ~GDBRemoteCommunicationServerCommon(); + ~GDBRemoteCommunicationServerCommon() override; protected: ProcessLaunchInfo m_process_launch_info; @@ -204,4 +204,4 @@ protected: } // namespace process_gdb_remote } // namespace lldb_private -#endif // liblldb_GDBRemoteCommunicationServerCommon_h_ +#endif // liblldb_GDBRemoteCommunicationServerCommon_h_ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h index e34189f9ec1..95fa18d4b40 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -10,12 +10,16 @@ #ifndef liblldb_GDBRemoteCommunicationServerPlatform_h_ #define liblldb_GDBRemoteCommunicationServerPlatform_h_ -#include "GDBRemoteCommunicationServerCommon.h" +// C Includes +// C++ Includes +#include <map> +#include <set> +// Other libraries and framework includes +// Project includes +#include "GDBRemoteCommunicationServerCommon.h" #include "lldb/Host/Socket.h" -#include <set> - namespace lldb_private { namespace process_gdb_remote { @@ -27,8 +31,7 @@ public: GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol); - virtual - ~GDBRemoteCommunicationServerPlatform(); + ~GDBRemoteCommunicationServerPlatform() override; Error LaunchProcess () override; @@ -112,13 +115,10 @@ private: static FileSpec GetDomainSocketPath(const char* prefix); - //------------------------------------------------------------------ - // For GDBRemoteCommunicationServerPlatform only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServerPlatform); }; } // namespace process_gdb_remote } // namespace lldb_private -#endif // liblldb_GDBRemoteCommunicationServerPlatform_h_ +#endif // liblldb_GDBRemoteCommunicationServerPlatform_h_ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h index 117d280cc54..2383b374daf 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h @@ -42,32 +42,22 @@ public: { } - ~GDBRemoteDynamicRegisterInfo () - { - } + ~GDBRemoteDynamicRegisterInfo() override = default; void HardcodeARMRegisters(bool from_scratch); - }; class GDBRemoteRegisterContext : public RegisterContext { public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ GDBRemoteRegisterContext (ThreadGDBRemote &thread, uint32_t concrete_frame_idx, GDBRemoteDynamicRegisterInfo ®_info, bool read_all_at_once); - virtual - ~GDBRemoteRegisterContext (); + ~GDBRemoteRegisterContext() override; - //------------------------------------------------------------------ - // Subclasses must override these functions - //------------------------------------------------------------------ void InvalidateAllRegisters () override; @@ -166,13 +156,10 @@ private: bool SetPrimordialRegister(const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm); - //------------------------------------------------------------------ - // For GDBRemoteRegisterContext only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (GDBRemoteRegisterContext); }; } // namespace process_gdb_remote } // namespace lldb_private -#endif // lldb_GDBRemoteRegisterContext_h_ +#endif // lldb_GDBRemoteRegisterContext_h_ diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 8ed7e45f1a2..cea0589d870 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Host/Config.h" - // C Includes #include <errno.h> #include <stdlib.h> @@ -25,6 +23,9 @@ #include <map> #include <mutex> +// Other libraries and framework includes +// Project includes +#include "lldb/Host/Config.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Interpreter/Args.h" #include "lldb/Core/ArchSpec.h" @@ -65,7 +66,6 @@ #include "lldb/Target/SystemRuntime.h" #include "lldb/Utility/PseudoTerminal.h" -// Project includes #include "lldb/Host/Host.h" #include "Plugins/Process/Utility/GDBRemoteSignals.h" #include "Plugins/Process/Utility/InferiorCallPOSIX.h" @@ -78,6 +78,7 @@ #include "ThreadGDBRemote.h" #define DEBUGSERVER_BASENAME "debugserver" + using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_gdb_remote; @@ -98,7 +99,7 @@ namespace lldb if (error.Success()) ((ProcessGDBRemote *)p)->GetGDBRemote().DumpHistory (strm); } -} +} // namespace lldb namespace { @@ -119,7 +120,6 @@ namespace { class PluginProperties : public Properties { public: - static ConstString GetSettingName () { @@ -132,12 +132,9 @@ namespace { m_collection_sp.reset (new OptionValueProperties(GetSettingName())); m_collection_sp->Initialize(g_properties); } - - virtual - ~PluginProperties() - { - } - + + ~PluginProperties() override = default; + uint64_t GetPacketTimeout() { @@ -171,16 +168,14 @@ namespace { return g_settings_sp; } -} // anonymous namespace end +} // anonymous namespace class ProcessGDBRemote::GDBLoadedModuleInfoList { public: - class LoadedModuleInfo { public: - enum e_data_point { e_has_name = 0, @@ -201,6 +196,7 @@ public: m_name = name; m_has[e_has_name] = true; } + bool get_name (std::string & out) const { out = m_name; @@ -212,6 +208,7 @@ public: m_base = base; m_has[e_has_base] = true; } + bool get_base (lldb::addr_t & out) const { out = m_base; @@ -222,6 +219,7 @@ public: { m_base_is_offset = is_offset; } + bool get_base_is_offset(bool & out) const { out = m_base_is_offset; @@ -233,6 +231,7 @@ public: m_link_map = addr; m_has[e_has_link_map] = true; } + bool get_link_map (lldb::addr_t & out) const { out = m_link_map; @@ -244,6 +243,7 @@ public: m_dynamic = addr; m_has[e_has_dynamic] = true; } + bool get_dynamic (lldb::addr_t & out) const { out = m_dynamic; @@ -257,7 +257,6 @@ public: } protected: - bool m_has[e_num]; std::string m_name; lldb::addr_t m_link_map; @@ -333,7 +332,6 @@ ProcessGDBRemote::Terminate() PluginManager::UnregisterPlugin (ProcessGDBRemote::CreateInstance); } - lldb::ProcessSP ProcessGDBRemote::CreateInstance (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file_path) { @@ -376,9 +374,6 @@ ProcessGDBRemote::CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_n return true; } -//---------------------------------------------------------------------- -// ProcessGDBRemote constructor -//---------------------------------------------------------------------- ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener) : Process (target_sp, listener), m_flags (0), @@ -433,9 +428,6 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener) m_gdb_comm.SetPacketTimeout(timeout_seconds); } -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- ProcessGDBRemote::~ProcessGDBRemote() { // m_mach_process.UnregisterNotificationCallbacks (this); @@ -563,7 +555,6 @@ SplitCommaSeparatedRegisterNumberString(const llvm::StringRef &comma_separated_r return regnums.size(); } - void ProcessGDBRemote::BuildDynamicRegisterInfo (bool force) { @@ -1156,10 +1147,8 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) exe_module->GetArchitecture().GetArchitectureName()); } return error; - } - Error ProcessGDBRemote::ConnectToDebugserver (const char *connect_url) { @@ -1206,7 +1195,6 @@ ProcessGDBRemote::ConnectToDebugserver (const char *connect_url) return error; } - // Start the communications read thread so all incoming data can be // parsed into packets and queued as they arrive. if (GetTarget().GetNonStopModeEnabled()) @@ -1474,7 +1462,6 @@ ProcessGDBRemote::DidAttach (ArchSpec &process_arch) DidLaunchOrAttach (process_arch); } - Error ProcessGDBRemote::WillResume () { @@ -1927,7 +1914,6 @@ ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new return true; } - bool ProcessGDBRemote::GetThreadStopInfoFromJSON (ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp) { @@ -1985,7 +1971,6 @@ ProcessGDBRemote::CalculateThreadStopInfo (ThreadGDBRemote *thread) return false; } - ThreadSP ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid, ExpeditedRegisterMap &expedited_register_map, @@ -2359,7 +2344,6 @@ ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict) return true; // Keep iterating through all array items }); } - } else if (key == g_key_signal) signo = object->GetIntegerValue(LLDB_INVALID_SIGNAL_NUMBER); @@ -2680,7 +2664,6 @@ ProcessGDBRemote::RefreshStateAfterStop () // Let all threads recover from stopping and do any clean up based // on the previous thread state (if any). m_thread_list_real.RefreshStateAfterStop(); - } Error @@ -2742,7 +2725,6 @@ ProcessGDBRemote::DoDetach(bool keep_stopped) return error; } - Error ProcessGDBRemote::DoDestroy () { @@ -3172,7 +3154,6 @@ Error ProcessGDBRemote::GetMemoryRegionInfo (addr_t load_addr, MemoryRegionInfo ®ion_info) { - Error error (m_gdb_comm.GetMemoryRegionInfo (load_addr, region_info)); return error; } @@ -3180,7 +3161,6 @@ ProcessGDBRemote::GetMemoryRegionInfo (addr_t load_addr, Error ProcessGDBRemote::GetWatchpointSupportInfo (uint32_t &num) { - Error error (m_gdb_comm.GetWatchpointSupportInfo (num)); return error; } @@ -3227,7 +3207,6 @@ ProcessGDBRemote::DoDeallocateMemory (lldb::addr_t addr) return error; } - //------------------------------------------------------------------ // Process STDIO //------------------------------------------------------------------ @@ -4030,7 +4009,6 @@ ProcessGDBRemote::NewThreadNotifyBreakpointHit (void *baton, return false; } - bool ProcessGDBRemote::StartNoticingNewThreads() { @@ -4198,7 +4176,6 @@ ProcessGDBRemote::GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_addres return object_sp; } - // Establish the largest memory read/write payloads we should use. // If the remote stub has a max packet size, stay under that size. // @@ -4491,7 +4468,7 @@ ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemot return true; } -} // namespace {} +} // anonymous namespace // query the target of gdb-remote for extended target information @@ -4522,7 +4499,6 @@ ProcessGDBRemote::GetGDBServerRegisterInfo () { return false; } - XMLDocument xml_document; @@ -4890,7 +4866,6 @@ ProcessGDBRemote::GetFileLoadAddress(const FileSpec& file, bool& is_loaded, lldb return Error("Unknown error happened during sending the load address packet"); } - void ProcessGDBRemote::ModulesDidLoad (ModuleList &module_list) { @@ -4902,7 +4877,6 @@ ProcessGDBRemote::ModulesDidLoad (ModuleList &module_list) m_gdb_comm.ServeSymbolLookups(this); } - class CommandObjectProcessGDBRemoteSpeedTest: public CommandObjectParsed { public: @@ -4924,10 +4898,7 @@ public: m_option_group.Finalize(); } - ~CommandObjectProcessGDBRemoteSpeedTest () - { - } - + ~CommandObjectProcessGDBRemoteSpeedTest() override = default; Options * GetOptions () override @@ -4968,19 +4939,17 @@ public: result.SetStatus (eReturnStatusFailed); return false; } + protected: OptionGroupOptions m_option_group; OptionGroupUInt64 m_num_packets; OptionGroupUInt64 m_max_send; OptionGroupUInt64 m_max_recv; OptionGroupBoolean m_json; - }; class CommandObjectProcessGDBRemotePacketHistory : public CommandObjectParsed { -private: - public: CommandObjectProcessGDBRemotePacketHistory(CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, @@ -4989,11 +4958,9 @@ public: NULL) { } - - ~CommandObjectProcessGDBRemotePacketHistory () - { - } - + + ~CommandObjectProcessGDBRemotePacketHistory() override = default; + bool DoExecute (Args& command, CommandReturnObject &result) override { @@ -5019,8 +4986,6 @@ public: class CommandObjectProcessGDBRemotePacketXferSize : public CommandObjectParsed { -private: - public: CommandObjectProcessGDBRemotePacketXferSize(CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, @@ -5029,11 +4994,9 @@ public: NULL) { } - - ~CommandObjectProcessGDBRemotePacketXferSize () - { - } - + + ~CommandObjectProcessGDBRemotePacketXferSize() override = default; + bool DoExecute (Args& command, CommandReturnObject &result) override { @@ -5063,11 +5026,8 @@ public: } }; - class CommandObjectProcessGDBRemotePacketSend : public CommandObjectParsed { -private: - public: CommandObjectProcessGDBRemotePacketSend(CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, @@ -5077,11 +5037,9 @@ public: NULL) { } - - ~CommandObjectProcessGDBRemotePacketSend () - { - } - + + ~CommandObjectProcessGDBRemotePacketSend() override = default; + bool DoExecute (Args& command, CommandReturnObject &result) override { @@ -5124,8 +5082,6 @@ public: class CommandObjectProcessGDBRemotePacketMonitor : public CommandObjectRaw { -private: - public: CommandObjectProcessGDBRemotePacketMonitor(CommandInterpreter &interpreter) : CommandObjectRaw (interpreter, @@ -5135,11 +5091,9 @@ public: NULL) { } - - ~CommandObjectProcessGDBRemotePacketMonitor () - { - } - + + ~CommandObjectProcessGDBRemotePacketMonitor() override = default; + bool DoExecute (const char *command, CommandReturnObject &result) override { @@ -5177,8 +5131,6 @@ public: class CommandObjectProcessGDBRemotePacket : public CommandObjectMultiword { -private: - public: CommandObjectProcessGDBRemotePacket(CommandInterpreter &interpreter) : CommandObjectMultiword (interpreter, @@ -5192,10 +5144,8 @@ public: LoadSubCommand ("xfer-size", CommandObjectSP (new CommandObjectProcessGDBRemotePacketXferSize (interpreter))); LoadSubCommand ("speed-test", CommandObjectSP (new CommandObjectProcessGDBRemoteSpeedTest (interpreter))); } - - ~CommandObjectProcessGDBRemotePacket () - { - } + + ~CommandObjectProcessGDBRemotePacket() override = default; }; class CommandObjectMultiwordProcessGDBRemote : public CommandObjectMultiword @@ -5210,9 +5160,7 @@ public: LoadSubCommand ("packet", CommandObjectSP (new CommandObjectProcessGDBRemotePacket (interpreter))); } - ~CommandObjectMultiwordProcessGDBRemote () - { - } + ~CommandObjectMultiwordProcessGDBRemote() override = default; }; CommandObject * diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index c3b201bddeb..0a0f32e69be 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -11,12 +11,14 @@ #define liblldb_ProcessGDBRemote_h_ // C Includes - // C++ Includes -#include <list> +#include <atomic> +#include <map> +#include <string> #include <vector> // Other libraries and framework includes +// Project includes #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/ConstString.h" @@ -42,9 +44,10 @@ class ThreadGDBRemote; class ProcessGDBRemote : public Process { public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ + ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener); + + ~ProcessGDBRemote() override; + static lldb::ProcessSP CreateInstance (lldb::TargetSP target_sp, Listener &listener, @@ -66,14 +69,6 @@ public: GetPluginDescriptionStatic(); //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener); - - virtual - ~ProcessGDBRemote(); - - //------------------------------------------------------------------ // Check if a given Process //------------------------------------------------------------------ bool @@ -263,20 +258,62 @@ protected: class GDBLoadedModuleInfoList; + //------------------------------------------------------------------ + /// Broadcaster event bits definitions. + //------------------------------------------------------------------ + enum + { + eBroadcastBitAsyncContinue = (1 << 0), + eBroadcastBitAsyncThreadShouldExit = (1 << 1), + eBroadcastBitAsyncThreadDidExit = (1 << 2) + }; + + Flags m_flags; // Process specific flags (see eFlags enums) + GDBRemoteCommunicationClient m_gdb_comm; + std::atomic<lldb::pid_t> m_debugserver_pid; + std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable + Mutex m_last_stop_packet_mutex; + GDBRemoteDynamicRegisterInfo m_register_info; + Broadcaster m_async_broadcaster; + Listener m_async_listener; + HostThread m_async_thread; + Mutex m_async_thread_state_mutex; + typedef std::vector<lldb::tid_t> tid_collection; + typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection; + typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap; + typedef std::map<uint32_t, std::string> ExpeditedRegisterMap; + tid_collection m_thread_ids; // Thread IDs for all threads. This list gets updated after stopping + StructuredData::ObjectSP m_jstopinfo_sp; // Stop info only for any threads that have valid stop infos + StructuredData::ObjectSP m_jthreadsinfo_sp; // Full stop info, expedited registers and memory for all threads if "jThreadsInfo" packet is supported + tid_collection m_continue_c_tids; // 'c' for continue + tid_sig_collection m_continue_C_tids; // 'C' for continue with signal + tid_collection m_continue_s_tids; // 's' for step + tid_sig_collection m_continue_S_tids; // 'S' for step with signal + uint64_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory + uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote gdb stub can handle + MMapMap m_addr_to_mmap_size; + lldb::BreakpointSP m_thread_create_bp_sp; + bool m_waiting_for_attach; + bool m_destroy_tried_resuming; + lldb::CommandObjectSP m_command_sp; + int64_t m_breakpoint_pc_offset; + lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach + //---------------------------------------------------------------------- // Accessors //---------------------------------------------------------------------- bool IsRunning ( lldb::StateType state ) { - return state == lldb::eStateRunning || IsStepping(state); + return state == lldb::eStateRunning || IsStepping(state); } bool IsStepping ( lldb::StateType state) { - return state == lldb::eStateStepping; + return state == lldb::eStateStepping; } + bool CanResume ( lldb::StateType state) { @@ -341,47 +378,6 @@ protected: size_t UpdateThreadIDsFromStopReplyThreadsValue (std::string &value); - //------------------------------------------------------------------ - /// Broadcaster event bits definitions. - //------------------------------------------------------------------ - enum - { - eBroadcastBitAsyncContinue = (1 << 0), - eBroadcastBitAsyncThreadShouldExit = (1 << 1), - eBroadcastBitAsyncThreadDidExit = (1 << 2) - }; - - Flags m_flags; // Process specific flags (see eFlags enums) - GDBRemoteCommunicationClient m_gdb_comm; - std::atomic<lldb::pid_t> m_debugserver_pid; - std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable - Mutex m_last_stop_packet_mutex; - GDBRemoteDynamicRegisterInfo m_register_info; - Broadcaster m_async_broadcaster; - Listener m_async_listener; - HostThread m_async_thread; - Mutex m_async_thread_state_mutex; - typedef std::vector<lldb::tid_t> tid_collection; - typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection; - typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap; - typedef std::map<uint32_t, std::string> ExpeditedRegisterMap; - tid_collection m_thread_ids; // Thread IDs for all threads. This list gets updated after stopping - StructuredData::ObjectSP m_jstopinfo_sp; // Stop info only for any threads that have valid stop infos - StructuredData::ObjectSP m_jthreadsinfo_sp; // Full stop info, expedited registers and memory for all threads if "jThreadsInfo" packet is supported - tid_collection m_continue_c_tids; // 'c' for continue - tid_sig_collection m_continue_C_tids; // 'C' for continue with signal - tid_collection m_continue_s_tids; // 's' for step - tid_sig_collection m_continue_S_tids; // 'S' for step with signal - uint64_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory - uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote gdb stub can handle - MMapMap m_addr_to_mmap_size; - lldb::BreakpointSP m_thread_create_bp_sp; - bool m_waiting_for_attach; - bool m_destroy_tried_resuming; - lldb::CommandObjectSP m_command_sp; - int64_t m_breakpoint_pc_offset; - lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach - bool HandleNotifyPacket(StringExtractorGDBRemote &packet); @@ -469,10 +465,9 @@ private: lldb::user_id_t break_loc_id); DISALLOW_COPY_AND_ASSIGN (ProcessGDBRemote); - }; } // namespace process_gdb_remote } // namespace lldb_private -#endif // liblldb_ProcessGDBRemote_h_ +#endif // liblldb_ProcessGDBRemote_h_ diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index 175433a3e20..d7e8e4e57aa 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -10,8 +10,12 @@ #ifndef liblldb_ThreadGDBRemote_h_ #define liblldb_ThreadGDBRemote_h_ +// C Includes +// C++ Includes #include <string> +// Other libraries and framework includes +// Project includes #include "lldb/Core/StructuredData.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -28,8 +32,7 @@ class ThreadGDBRemote : public Thread public: ThreadGDBRemote (Process &process, lldb::tid_t tid); - virtual - ~ThreadGDBRemote (); + ~ThreadGDBRemote() override; void WillResume (lldb::StateType resume_state) override; @@ -101,9 +104,14 @@ public: FetchThreadExtendedInfo () override; protected: - friend class ProcessGDBRemote; + std::string m_thread_name; + std::string m_dispatch_queue_name; + lldb::addr_t m_thread_dispatch_qaddr; + lldb::QueueKind m_queue_kind; // Queue info from stop reply/stop info for thread + uint64_t m_queue_serial; // Queue info from stop reply/stop info for thread + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); @@ -113,18 +121,6 @@ protected: { return m_queue_kind != lldb::eQueueKindUnknown; } - //------------------------------------------------------------------ - // Member variables. - //------------------------------------------------------------------ - std::string m_thread_name; - std::string m_dispatch_queue_name; - lldb::addr_t m_thread_dispatch_qaddr; - lldb::QueueKind m_queue_kind; // Queue info from stop reply/stop info for thread - uint64_t m_queue_serial; // Queue info from stop reply/stop info for thread - //------------------------------------------------------------------ - // Member variables. - //------------------------------------------------------------------ - void SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id); @@ -135,4 +131,4 @@ protected: } // namespace process_gdb_remote } // namespace lldb_private -#endif // liblldb_ThreadGDBRemote_h_ +#endif // liblldb_ThreadGDBRemote_h_ |