2015-02-11 18:29:30 +08:00
|
|
|
//===-- GDBRemoteCommunicationServerLLGS.h ----------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef liblldb_GDBRemoteCommunicationServerLLGS_h_
|
|
|
|
#define liblldb_GDBRemoteCommunicationServerLLGS_h_
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
#include "lldb/lldb-private-forward.h"
|
|
|
|
#include "lldb/Core/Communication.h"
|
|
|
|
#include "lldb/Host/Mutex.h"
|
|
|
|
#include "lldb/Host/common/NativeProcessProtocol.h"
|
Introduce a MainLoop class and switch llgs to use it
Summary:
This is the first part of our effort to make llgs single threaded. Currently, llgs consists of
about three threads and the synchronisation between them is a major source of latency when
debugging linux and android applications.
In order to be able to go single threaded, we must have the ability to listen for events from
multiple sources (primarily, client commands coming over the network and debug events from the
inferior) and perform necessary actions. For this reason I introduce the concept of a MainLoop.
A main loop has the ability to register callback's which will be invoked upon receipt of certain
events. MainLoopPosix has the ability to listen for file descriptors and signals.
For the moment, I have merely made the GDBRemoteCommunicationServerLLGS class use MainLoop
instead of waiting on the network socket directly, but the other threads still remain. In the
followup patches I indend to migrate NativeProcessLinux to this class and remove the remaining
threads.
Reviewers: ovyalov, clayborg, amccarth, zturner, emaste
Subscribers: tberghammer, lldb-commits
Differential Revision: http://reviews.llvm.org/D11066
llvm-svn: 242018
2015-07-13 18:44:55 +08:00
|
|
|
#include "lldb/Host/MainLoop.h"
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
// Project includes
|
|
|
|
#include "GDBRemoteCommunicationServerCommon.h"
|
|
|
|
|
|
|
|
class StringExtractorGDBRemote;
|
|
|
|
|
2015-03-31 17:52:22 +08:00
|
|
|
namespace lldb_private {
|
Introduce a MainLoop class and switch llgs to use it
Summary:
This is the first part of our effort to make llgs single threaded. Currently, llgs consists of
about three threads and the synchronisation between them is a major source of latency when
debugging linux and android applications.
In order to be able to go single threaded, we must have the ability to listen for events from
multiple sources (primarily, client commands coming over the network and debug events from the
inferior) and perform necessary actions. For this reason I introduce the concept of a MainLoop.
A main loop has the ability to register callback's which will be invoked upon receipt of certain
events. MainLoopPosix has the ability to listen for file descriptors and signals.
For the moment, I have merely made the GDBRemoteCommunicationServerLLGS class use MainLoop
instead of waiting on the network socket directly, but the other threads still remain. In the
followup patches I indend to migrate NativeProcessLinux to this class and remove the remaining
threads.
Reviewers: ovyalov, clayborg, amccarth, zturner, emaste
Subscribers: tberghammer, lldb-commits
Differential Revision: http://reviews.llvm.org/D11066
llvm-svn: 242018
2015-07-13 18:44:55 +08:00
|
|
|
|
2015-03-31 17:52:22 +08:00
|
|
|
namespace process_gdb_remote {
|
|
|
|
|
|
|
|
class ProcessGDBRemote;
|
|
|
|
|
2015-02-11 18:29:30 +08:00
|
|
|
class GDBRemoteCommunicationServerLLGS :
|
|
|
|
public GDBRemoteCommunicationServerCommon,
|
2015-03-31 17:52:22 +08:00
|
|
|
public NativeProcessProtocol::NativeDelegate
|
2015-02-11 18:29:30 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Constructors and Destructors
|
|
|
|
//------------------------------------------------------------------
|
Introduce a MainLoop class and switch llgs to use it
Summary:
This is the first part of our effort to make llgs single threaded. Currently, llgs consists of
about three threads and the synchronisation between them is a major source of latency when
debugging linux and android applications.
In order to be able to go single threaded, we must have the ability to listen for events from
multiple sources (primarily, client commands coming over the network and debug events from the
inferior) and perform necessary actions. For this reason I introduce the concept of a MainLoop.
A main loop has the ability to register callback's which will be invoked upon receipt of certain
events. MainLoopPosix has the ability to listen for file descriptors and signals.
For the moment, I have merely made the GDBRemoteCommunicationServerLLGS class use MainLoop
instead of waiting on the network socket directly, but the other threads still remain. In the
followup patches I indend to migrate NativeProcessLinux to this class and remove the remaining
threads.
Reviewers: ovyalov, clayborg, amccarth, zturner, emaste
Subscribers: tberghammer, lldb-commits
Differential Revision: http://reviews.llvm.org/D11066
llvm-svn: 242018
2015-07-13 18:44:55 +08:00
|
|
|
GDBRemoteCommunicationServerLLGS(const lldb::PlatformSP& platform_sp, MainLoop &mainloop);
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
virtual
|
|
|
|
~GDBRemoteCommunicationServerLLGS();
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
/// Specify the program to launch and its arguments.
|
|
|
|
///
|
|
|
|
/// @param[in] args
|
|
|
|
/// The command line to launch.
|
|
|
|
///
|
|
|
|
/// @param[in] argc
|
|
|
|
/// The number of elements in the args array of cstring pointers.
|
|
|
|
///
|
|
|
|
/// @return
|
|
|
|
/// An Error object indicating the success or failure of making
|
|
|
|
/// the setting.
|
|
|
|
//------------------------------------------------------------------
|
2015-03-31 17:52:22 +08:00
|
|
|
Error
|
2015-02-11 18:29:30 +08:00
|
|
|
SetLaunchArguments (const char *const args[], int argc);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
/// Specify the launch flags for the process.
|
|
|
|
///
|
|
|
|
/// @param[in] launch_flags
|
|
|
|
/// The launch flags to use when launching this process.
|
|
|
|
///
|
|
|
|
/// @return
|
|
|
|
/// An Error object indicating the success or failure of making
|
|
|
|
/// the setting.
|
|
|
|
//------------------------------------------------------------------
|
2015-03-31 17:52:22 +08:00
|
|
|
Error
|
2015-02-11 18:29:30 +08:00
|
|
|
SetLaunchFlags (unsigned int launch_flags);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
/// Launch a process with the current launch settings.
|
|
|
|
///
|
|
|
|
/// This method supports running an lldb-gdbserver or similar
|
|
|
|
/// server in a situation where the startup code has been provided
|
|
|
|
/// with all the information for a child process to be launched.
|
|
|
|
///
|
|
|
|
/// @return
|
|
|
|
/// An Error object indicating the success or failure of the
|
|
|
|
/// launch.
|
|
|
|
//------------------------------------------------------------------
|
2015-03-31 17:52:22 +08:00
|
|
|
Error
|
2015-02-11 18:29:30 +08:00
|
|
|
LaunchProcess () override;
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
/// Attach to a process.
|
|
|
|
///
|
|
|
|
/// This method supports attaching llgs to a process accessible via the
|
|
|
|
/// configured Platform.
|
|
|
|
///
|
|
|
|
/// @return
|
|
|
|
/// An Error object indicating the success or failure of the
|
|
|
|
/// attach operation.
|
|
|
|
//------------------------------------------------------------------
|
2015-03-31 17:52:22 +08:00
|
|
|
Error
|
2015-02-11 18:29:30 +08:00
|
|
|
AttachToProcess (lldb::pid_t pid);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// NativeProcessProtocol::NativeDelegate overrides
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void
|
2015-03-31 17:52:22 +08:00
|
|
|
InitializeDelegate (NativeProcessProtocol *process) override;
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
void
|
2015-03-31 17:52:22 +08:00
|
|
|
ProcessStateChanged (NativeProcessProtocol *process, lldb::StateType state) override;
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
void
|
2015-03-31 17:52:22 +08:00
|
|
|
DidExec (NativeProcessProtocol *process) override;
|
2015-02-11 18:29:30 +08:00
|
|
|
|
Introduce a MainLoop class and switch llgs to use it
Summary:
This is the first part of our effort to make llgs single threaded. Currently, llgs consists of
about three threads and the synchronisation between them is a major source of latency when
debugging linux and android applications.
In order to be able to go single threaded, we must have the ability to listen for events from
multiple sources (primarily, client commands coming over the network and debug events from the
inferior) and perform necessary actions. For this reason I introduce the concept of a MainLoop.
A main loop has the ability to register callback's which will be invoked upon receipt of certain
events. MainLoopPosix has the ability to listen for file descriptors and signals.
For the moment, I have merely made the GDBRemoteCommunicationServerLLGS class use MainLoop
instead of waiting on the network socket directly, but the other threads still remain. In the
followup patches I indend to migrate NativeProcessLinux to this class and remove the remaining
threads.
Reviewers: ovyalov, clayborg, amccarth, zturner, emaste
Subscribers: tberghammer, lldb-commits
Differential Revision: http://reviews.llvm.org/D11066
llvm-svn: 242018
2015-07-13 18:44:55 +08:00
|
|
|
Error
|
|
|
|
InitializeConnection (std::unique_ptr<Connection> &&connection);
|
|
|
|
|
2015-02-11 18:29:30 +08:00
|
|
|
protected:
|
|
|
|
lldb::PlatformSP m_platform_sp;
|
Introduce a MainLoop class and switch llgs to use it
Summary:
This is the first part of our effort to make llgs single threaded. Currently, llgs consists of
about three threads and the synchronisation between them is a major source of latency when
debugging linux and android applications.
In order to be able to go single threaded, we must have the ability to listen for events from
multiple sources (primarily, client commands coming over the network and debug events from the
inferior) and perform necessary actions. For this reason I introduce the concept of a MainLoop.
A main loop has the ability to register callback's which will be invoked upon receipt of certain
events. MainLoopPosix has the ability to listen for file descriptors and signals.
For the moment, I have merely made the GDBRemoteCommunicationServerLLGS class use MainLoop
instead of waiting on the network socket directly, but the other threads still remain. In the
followup patches I indend to migrate NativeProcessLinux to this class and remove the remaining
threads.
Reviewers: ovyalov, clayborg, amccarth, zturner, emaste
Subscribers: tberghammer, lldb-commits
Differential Revision: http://reviews.llvm.org/D11066
llvm-svn: 242018
2015-07-13 18:44:55 +08:00
|
|
|
MainLoop &m_mainloop;
|
|
|
|
MainLoop::ReadHandleUP m_read_handle_up;
|
2015-02-11 18:29:30 +08:00
|
|
|
lldb::tid_t m_current_tid;
|
|
|
|
lldb::tid_t m_continue_tid;
|
2015-03-31 17:52:22 +08:00
|
|
|
Mutex m_debugged_process_mutex;
|
|
|
|
NativeProcessProtocolSP m_debugged_process_sp;
|
2015-02-11 18:29:30 +08:00
|
|
|
Communication m_stdio_communication;
|
|
|
|
lldb::StateType m_inferior_prev_state;
|
|
|
|
lldb::DataBufferSP m_active_auxv_buffer_sp;
|
2015-03-31 17:52:22 +08:00
|
|
|
Mutex m_saved_registers_mutex;
|
2015-02-11 18:29:30 +08:00
|
|
|
std::unordered_map<uint32_t, lldb::DataBufferSP> m_saved_registers_map;
|
|
|
|
uint32_t m_next_saved_registers_id;
|
Introduce a MainLoop class and switch llgs to use it
Summary:
This is the first part of our effort to make llgs single threaded. Currently, llgs consists of
about three threads and the synchronisation between them is a major source of latency when
debugging linux and android applications.
In order to be able to go single threaded, we must have the ability to listen for events from
multiple sources (primarily, client commands coming over the network and debug events from the
inferior) and perform necessary actions. For this reason I introduce the concept of a MainLoop.
A main loop has the ability to register callback's which will be invoked upon receipt of certain
events. MainLoopPosix has the ability to listen for file descriptors and signals.
For the moment, I have merely made the GDBRemoteCommunicationServerLLGS class use MainLoop
instead of waiting on the network socket directly, but the other threads still remain. In the
followup patches I indend to migrate NativeProcessLinux to this class and remove the remaining
threads.
Reviewers: ovyalov, clayborg, amccarth, zturner, emaste
Subscribers: tberghammer, lldb-commits
Differential Revision: http://reviews.llvm.org/D11066
llvm-svn: 242018
2015-07-13 18:44:55 +08:00
|
|
|
bool m_handshake_completed : 1;
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
PacketResult
|
|
|
|
SendONotification (const char *buffer, uint32_t len);
|
|
|
|
|
|
|
|
PacketResult
|
2015-03-31 17:52:22 +08:00
|
|
|
SendWResponse (NativeProcessProtocol *process);
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
PacketResult
|
|
|
|
SendStopReplyPacketForThread (lldb::tid_t tid);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
SendStopReasonForState (lldb::StateType process_state, bool flush_on_exit);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_k (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qProcessInfo (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qC (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_QSetDisableASLR (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_QSetWorkingDir (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qGetWorkingDir (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_C (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_c (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_vCont (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_vCont_actions (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_stop_reason (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qRegisterInfo (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qfThreadInfo (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qsThreadInfo (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_p (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_P (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_H (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_I (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_interrupt (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_m (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_M (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qMemoryRegionInfoSupported (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qMemoryRegionInfo (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_Z (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_z (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_s (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qXfer_auxv_read (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_QSaveRegisterState (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_QRestoreRegisterState (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_vAttach (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_D (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qThreadStopInfo (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
PacketResult
|
|
|
|
Handle_qWatchpointSupportInfo (StringExtractorGDBRemote &packet);
|
|
|
|
|
2015-06-19 04:43:56 +08:00
|
|
|
PacketResult
|
|
|
|
Handle_qFileLoadAddress (StringExtractorGDBRemote &packet);
|
|
|
|
|
2015-02-11 18:29:30 +08:00
|
|
|
void
|
|
|
|
SetCurrentThreadID (lldb::tid_t tid);
|
|
|
|
|
|
|
|
lldb::tid_t
|
|
|
|
GetCurrentThreadID () const;
|
|
|
|
|
|
|
|
void
|
|
|
|
SetContinueThreadID (lldb::tid_t tid);
|
|
|
|
|
|
|
|
lldb::tid_t
|
|
|
|
GetContinueThreadID () const { return m_continue_tid; }
|
|
|
|
|
2015-03-31 17:52:22 +08:00
|
|
|
Error
|
2015-02-11 18:29:30 +08:00
|
|
|
SetSTDIOFileDescriptor (int fd);
|
|
|
|
|
|
|
|
static void
|
|
|
|
STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
|
|
|
|
|
2015-03-31 17:52:22 +08:00
|
|
|
FileSpec
|
|
|
|
FindModuleFile (const std::string& module_path, const ArchSpec& arch) override;
|
2015-03-24 19:15:23 +08:00
|
|
|
|
2015-02-11 18:29:30 +08:00
|
|
|
private:
|
|
|
|
bool
|
|
|
|
DebuggedProcessReaped (lldb::pid_t pid);
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ReapDebuggedProcess (void *callback_baton,
|
|
|
|
lldb::pid_t pid,
|
|
|
|
bool exited,
|
|
|
|
int signal,
|
|
|
|
int status);
|
|
|
|
|
|
|
|
void
|
2015-03-31 17:52:22 +08:00
|
|
|
HandleInferiorState_Exited (NativeProcessProtocol *process);
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
void
|
2015-03-31 17:52:22 +08:00
|
|
|
HandleInferiorState_Stopped (NativeProcessProtocol *process);
|
2015-02-11 18:29:30 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
FlushInferiorOutput ();
|
|
|
|
|
2015-03-31 17:52:22 +08:00
|
|
|
NativeThreadProtocolSP
|
2015-02-11 18:29:30 +08:00
|
|
|
GetThreadFromSuffix (StringExtractorGDBRemote &packet);
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GetNextSavedRegistersID ();
|
|
|
|
|
|
|
|
void
|
|
|
|
MaybeCloseInferiorTerminalConnection ();
|
|
|
|
|
|
|
|
void
|
|
|
|
ClearProcessSpecificData ();
|
|
|
|
|
|
|
|
void
|
|
|
|
RegisterPacketHandlers ();
|
|
|
|
|
Introduce a MainLoop class and switch llgs to use it
Summary:
This is the first part of our effort to make llgs single threaded. Currently, llgs consists of
about three threads and the synchronisation between them is a major source of latency when
debugging linux and android applications.
In order to be able to go single threaded, we must have the ability to listen for events from
multiple sources (primarily, client commands coming over the network and debug events from the
inferior) and perform necessary actions. For this reason I introduce the concept of a MainLoop.
A main loop has the ability to register callback's which will be invoked upon receipt of certain
events. MainLoopPosix has the ability to listen for file descriptors and signals.
For the moment, I have merely made the GDBRemoteCommunicationServerLLGS class use MainLoop
instead of waiting on the network socket directly, but the other threads still remain. In the
followup patches I indend to migrate NativeProcessLinux to this class and remove the remaining
threads.
Reviewers: ovyalov, clayborg, amccarth, zturner, emaste
Subscribers: tberghammer, lldb-commits
Differential Revision: http://reviews.llvm.org/D11066
llvm-svn: 242018
2015-07-13 18:44:55 +08:00
|
|
|
void
|
|
|
|
DataAvailableCallback ();
|
|
|
|
|
2015-02-11 18:29:30 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
// For GDBRemoteCommunicationServerLLGS only
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServerLLGS);
|
|
|
|
};
|
|
|
|
|
2015-03-31 17:52:22 +08:00
|
|
|
} // namespace process_gdb_remote
|
|
|
|
} // namespace lldb_private
|
|
|
|
|
2015-02-11 18:29:30 +08:00
|
|
|
#endif // liblldb_GDBRemoteCommunicationServerLLGS_h_
|