563 changes: 211 additions & 352 deletions lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Large diffs are not rendered by default.

68 changes: 8 additions & 60 deletions lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,6 @@ namespace process_linux {
ArchSpec m_arch;

std::unique_ptr<Monitor> m_monitor_up;
HostThread m_operation_thread;

// current operation which must be executed on the priviliged thread
void *m_operation;
Mutex m_operation_mutex;

// semaphores notified when Operation is ready to be processed and when
// the operation is complete.
sem_t m_operation_pending;
sem_t m_operation_done;

LazyBool m_supports_mem_region;
std::vector<MemoryRegionInfo> m_mem_region_cache;
Expand All @@ -198,25 +188,13 @@ namespace process_linux {
// the relevan breakpoint
std::map<lldb::tid_t, lldb::addr_t> m_threads_stepping_with_breakpoint;

struct OperationArgs
{
OperationArgs(NativeProcessLinux *monitor);

~OperationArgs();

NativeProcessLinux *m_monitor; // The monitor performing the attach.
sem_t m_semaphore; // Posted to once operation complete.
Error m_error; // Set if process operation failed.
};

/// @class LauchArgs
///
/// @brief Simple structure to pass data to the thread responsible for
/// launching a child process.
struct LaunchArgs : OperationArgs
struct LaunchArgs
{
LaunchArgs(NativeProcessLinux *monitor,
Module *module,
LaunchArgs(Module *module,
char const **argv,
char const **envp,
const std::string &stdin_path,
Expand All @@ -237,15 +215,7 @@ namespace process_linux {
const ProcessLaunchInfo &m_launch_info;
};

struct AttachArgs : OperationArgs
{
AttachArgs(NativeProcessLinux *monitor,
lldb::pid_t pid);

~AttachArgs();

lldb::pid_t m_pid; // pid of the process to be attached.
};
typedef std::function<::pid_t(Error &)> InitialOperation;

// ---------------------------------------------------------------------
// Private Instance Methods
Expand All @@ -272,32 +242,17 @@ namespace process_linux {
AttachToInferior (lldb::pid_t pid, Error &error);

void
StartMonitorThread(Error &error);

void
StartLaunchOpThread(LaunchArgs *args, Error &error);
StartMonitorThread(const InitialOperation &operation, Error &error);

static void *
LaunchOpThread(void *arg);

static bool
Launch(LaunchArgs *args);
::pid_t
Launch(LaunchArgs *args, Error &error);

void
StartAttachOpThread(AttachArgs *args, Error &error);

static void *
AttachOpThread(void *args);

static bool
Attach(AttachArgs *args);
::pid_t
Attach(lldb::pid_t pid, Error &error);

static Error
SetDefaultPtraceOpts(const lldb::pid_t);

static void
ServeOperation(OperationArgs *args);

static bool
DupDescriptor(const char *path, int fd, int flags);

Expand Down Expand Up @@ -336,13 +291,6 @@ namespace process_linux {
GetCrashReasonForSIGBUS(const siginfo_t *info);
#endif

void
DoOperation(void *op);

/// Stops the operation thread used to attach/launch a process.
void
StopOpThread();

Error
StartCoordinatorThread ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def test_signal_break_dwarf(self):
self.do_thread_actions(num_breakpoint_threads=1, num_signal_threads=1)

@dwarf_test
@expectedFailureLinux # this test fails 2/100 dosep runs
def test_delay_signal_break_dwarf(self):
"""Test (1-second delay) signal and a breakpoint in multiple threads."""
self.buildDwarf(dictionary=self.getBuildFlags())
Expand Down