Remove old local-only linux debugging code

Summary:
Currently, the local-only path fails about 50% of the tests, which means that: a) nobody is using
it; and b) the remote debugging path is much more stable. This commit removes the local-only
linux debugging code (ProcessLinux) and makes remote-loopback the only way to debug local
applications (the same architecture as OSX). The ProcessPOSIX code is moved to the FreeBSD
directory, which is now the only user of this class. Hopefully, FreeBSD will soon move to the new
architecture as well and then this code can be removed completely.

Test Plan: Test suite passes via remote stub.

Reviewers: emaste, vharron, ovyalov, clayborg

Subscribers: tberghammer, emaste, lldb-commits

Differential Revision: http://reviews.llvm.org/D10661

llvm-svn: 240543
This commit is contained in:
Pavel Labath
2015-06-24 14:43:20 +00:00
parent 51aa1f86fb
commit b36f917854
38 changed files with 26 additions and 3363 deletions

View File

@@ -55,10 +55,6 @@
#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
#endif
#if defined(__linux__)
#include "Plugins/Process/Linux/ProcessLinux.h"
#endif
#if defined(_MSC_VER)
#include "lldb/Host/windows/windows.h"
#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
@@ -265,12 +261,6 @@ SystemInitializerFull::Initialize()
SystemRuntimeMacOSX::Initialize();
RenderScriptRuntime::Initialize();
#if defined(__linux__)
//----------------------------------------------------------------------
// Linux hosted plugins
//----------------------------------------------------------------------
process_linux::ProcessLinux::Initialize();
#endif
#if defined(_MSC_VER)
DynamicLoaderWindows::Initialize();
ProcessWindows::Initialize();
@@ -380,10 +370,6 @@ SystemInitializerFull::Terminate()
DynamicLoaderWindows::Terminate();
#endif
#if defined(__linux__)
process_linux::ProcessLinux::Terminate();
#endif
#if defined(__FreeBSD__)
ProcessFreeBSD::Terminate();
#endif

View File

@@ -42,7 +42,6 @@
#endif
#if defined(__linux__)
#include "Plugins/Process/Linux/ProcessLinux.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#endif

View File

@@ -57,11 +57,6 @@ static uint32_t g_initialize_count = 0;
namespace
{
enum
{
ePropertyUseLlgsForLocal = 0,
};
class PlatformLinuxProperties : public Properties
{
public:
@@ -73,9 +68,6 @@ namespace
virtual
~PlatformLinuxProperties() = default;
bool
GetUseLlgsForLocal() const;
private:
static const PropertyDefinition*
GetStaticPropertyDefinitions();
@@ -99,27 +91,15 @@ PlatformLinuxProperties::GetSettingName ()
return g_setting_name;
}
bool
PlatformLinuxProperties::GetUseLlgsForLocal() const
{
const uint32_t idx = ePropertyUseLlgsForLocal;
return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, GetStaticPropertyDefinitions()[idx].default_uint_value != 0);
}
const PropertyDefinition*
PlatformLinuxProperties::GetStaticPropertyDefinitions()
{
static PropertyDefinition
g_properties[] =
{
{ "use-llgs-for-local" , OptionValue::eTypeBoolean, true, true, NULL, NULL, "Control whether the platform uses llgs for local debug sessions." },
{ NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
};
// Allow environment variable to disable llgs-local.
if (getenv("PLATFORM_LINUX_DISABLE_LLGS_LOCAL"))
g_properties[ePropertyUseLlgsForLocal].default_uint_value = false;
return g_properties;
}
@@ -677,22 +657,12 @@ PlatformLinux::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
return resume_count;
}
bool
PlatformLinux::UseLlgsForLocalDebugging ()
{
PlatformLinuxPropertiesSP properties_sp = GetGlobalProperties ();
assert (properties_sp && "global properties shared pointer is null");
return properties_sp ? properties_sp->GetUseLlgsForLocal () : false;
}
bool
PlatformLinux::CanDebugProcess ()
{
if (IsHost ())
{
// The platform only does local debugging (i.e. uses llgs) when the setting indicates we do that.
// Otherwise, we'll use ProcessLinux/ProcessPOSIX to handle with ProcessMonitor.
return UseLlgsForLocalDebugging ();
return true;
}
else
{
@@ -724,14 +694,6 @@ PlatformLinux::DebugProcess (ProcessLaunchInfo &launch_info,
ProcessSP process_sp;
// Ensure we're using llgs for local debugging.
if (!UseLlgsForLocalDebugging ())
{
assert (false && "we're trying to debug a local process but platform.plugin.linux.use-llgs-for-local is false, should never get here");
error.SetErrorString ("attempted to start gdb-remote-based debugging for local process but platform.plugin.linux.use-llgs-for-local is false");
return process_sp;
}
// Make sure we stop at the entry point
launch_info.GetFlags ().Set (eLaunchFlagDebug);

View File

@@ -122,9 +122,6 @@ namespace platform_linux {
uint64_t
ConvertMmapFlagsToPlatform(unsigned flags) override;
static bool
UseLlgsForLocalDebugging ();
private:
DISALLOW_COPY_AND_ASSIGN (PlatformLinux);
};

View File

@@ -8,4 +8,13 @@ add_lldb_library(lldbPluginProcessFreeBSD
ProcessFreeBSD.cpp
FreeBSDThread.cpp
ProcessMonitor.cpp
ProcessPOSIX.cpp
POSIXThread.cpp
POSIXStopInfo.cpp
RegisterContextPOSIXProcessMonitor_arm.cpp
RegisterContextPOSIXProcessMonitor_arm64.cpp
RegisterContextPOSIXProcessMonitor_powerpc.cpp
RegisterContextPOSIXProcessMonitor_x86.cpp
RegisterContextPOSIXProcessMonitor_mips64.cpp
)

View File

@@ -29,16 +29,12 @@
#include "POSIXThread.h"
#include "ProcessPOSIX.h"
#include "ProcessPOSIXLog.h"
#include "Plugins/Process/Linux/ProcessMonitor.h"
#include "ProcessMonitor.h"
#include "RegisterContextPOSIXProcessMonitor_arm.h"
#include "RegisterContextPOSIXProcessMonitor_arm64.h"
#include "RegisterContextPOSIXProcessMonitor_mips64.h"
#include "RegisterContextPOSIXProcessMonitor_powerpc.h"
#include "RegisterContextPOSIXProcessMonitor_x86.h"
#include "Plugins/Process/Utility/RegisterContextLinux_arm.h"
#include "Plugins/Process/Utility/RegisterContextLinux_arm64.h"
#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
@@ -195,36 +191,6 @@ POSIXThread::GetRegisterContext()
}
break;
case llvm::Triple::Linux:
switch (target_arch.GetMachine())
{
case llvm::Triple::aarch64:
assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) && "Register setting path assumes this is a 64-bit host");
reg_interface = static_cast<RegisterInfoInterface*>(new RegisterContextLinux_arm64(target_arch));
break;
case llvm::Triple::arm:
assert(HostInfo::GetArchitecture().GetAddressByteSize() == 4);
reg_interface = static_cast<RegisterInfoInterface*>(new RegisterContextLinux_arm(target_arch));
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
if (HostInfo::GetArchitecture().GetAddressByteSize() == 4)
{
// 32-bit hosts run with a RegisterContextLinux_i386 context.
reg_interface = static_cast<RegisterInfoInterface*>(new RegisterContextLinux_i386(target_arch));
}
else
{
assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
"Register setting path assumes this is a 64-bit host");
// X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the x86_64 register context.
reg_interface = static_cast<RegisterInfoInterface*>(new RegisterContextLinux_x86_64(target_arch));
}
break;
default:
break;
}
default:
break;
}
@@ -328,18 +294,6 @@ POSIXThread::GetUnwinder()
return m_unwinder_ap.get();
}
// Overridden by FreeBSDThread; this is used only on Linux.
void
POSIXThread::WillResume(lldb::StateType resume_state)
{
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
if (log)
log->Printf ("POSIXThread::%s (tid = %" PRIi64 ") setting thread resume state to %s", __FUNCTION__, GetID(), StateAsCString(resume_state));
// TODO: the line below shouldn't really be done, but
// the POSIXThread might rely on this so I will leave this in for now
SetResumeState(resume_state);
}
void
POSIXThread::DidStop()
{

View File

@@ -37,9 +37,6 @@ public:
void
RefreshStateAfterStop() override;
void
WillResume(lldb::StateType resume_state) override;
// This notifies the thread when a private stop occurs.
void
DidStop () override;

View File

@@ -28,8 +28,8 @@
#include "ProcessPOSIX.h"
#include "ProcessPOSIXLog.h"
#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "Plugins/Process/Linux/ProcessMonitor.h"
#include "POSIXThread.h"
#include "ProcessMonitor.h"
#include "lldb/Host/posix/Fcntl.h"

View File

@@ -13,8 +13,8 @@
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h"
#include "ProcessPOSIX.h"
#include "ProcessMonitor.h"
#include "RegisterContextPOSIXProcessMonitor_arm64.h"
#include "Plugins/Process/Linux/ProcessMonitor.h"
#define REG_CONTEXT_SIZE (GetGPRSize())

View File

@@ -13,8 +13,8 @@
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
#include "ProcessPOSIX.h"
#include "ProcessMonitor.h"
#include "RegisterContextPOSIXProcessMonitor_mips64.h"
#include "Plugins/Process/Linux/ProcessMonitor.h"
using namespace lldb_private;
using namespace lldb;

View File

@@ -11,13 +11,9 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
#include "Plugins/Process/POSIX/ProcessPOSIX.h"
#include "Plugins/Process/FreeBSD/ProcessPOSIX.h"
#include "RegisterContextPOSIXProcessMonitor_x86.h"
#if defined(__FreeBSD__)
#include "Plugins/Process/FreeBSD/ProcessMonitor.h"
#else
#include "Plugins/Process/Linux/ProcessMonitor.h"
#endif
using namespace lldb_private;
using namespace lldb;

View File

@@ -5,7 +5,6 @@ include_directories(../POSIX)
include_directories(../Utility)
add_lldb_library(lldbPluginProcessLinux
LinuxThread.cpp
NativeProcessLinux.cpp
NativeRegisterContextLinux.cpp
NativeRegisterContextLinux_arm.cpp
@@ -13,7 +12,5 @@ add_lldb_library(lldbPluginProcessLinux
NativeRegisterContextLinux_x86_64.cpp
NativeRegisterContextLinux_mips64.cpp
NativeThreadLinux.cpp
ProcessLinux.cpp
ProcessMonitor.cpp
ProcFileReader.cpp
)

View File

@@ -1,43 +0,0 @@
//===-- LinuxThread.cpp -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "LinuxThread.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_linux;
//------------------------------------------------------------------------------
// Constructors and destructors.
LinuxThread::LinuxThread(Process &process, lldb::tid_t tid)
: POSIXThread(process, tid)
{
}
LinuxThread::~LinuxThread()
{
}
//------------------------------------------------------------------------------
// ProcessInterface protocol.
void
LinuxThread::RefreshStateAfterStop()
{
// Invalidate the thread names every time we get a stop event on Linux so we
// will re-read the procfs comm virtual file when folks ask for the thread name.
m_thread_name_valid = false;
POSIXThread::RefreshStateAfterStop();
}

View File

@@ -1,44 +0,0 @@
//===-- LinuxThread.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_LinuxThread_H_
#define liblldb_LinuxThread_H_
// Other libraries and framework includes
#include "Plugins/Process/POSIX/POSIXThread.h"
namespace lldb_private {
namespace process_linux {
//------------------------------------------------------------------------------
// @class LinuxThread
// @brief Abstraction of a Linux thread.
class LinuxThread : public POSIXThread
{
public:
//------------------------------------------------------------------
// Constructors and destructors
//------------------------------------------------------------------
LinuxThread(Process &process, lldb::tid_t tid);
virtual ~LinuxThread();
//--------------------------------------------------------------------------
// LinuxThread internal API.
// POSIXThread override
void
RefreshStateAfterStop() override;
};
} // namespace process_linux
} // namespace lldb_private
#endif // #ifndef liblldb_LinuxThread_H_

View File

@@ -1,233 +0,0 @@
//===-- ProcessLinux.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C Includes
#include <errno.h>
// C++ Includes
#include <mutex>
// Other libraries and framework includes
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Target.h"
#include "ProcessLinux.h"
#include "Plugins/Platform/Linux/PlatformLinux.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "Plugins/Process/Utility/LinuxSignals.h"
#include "ProcessMonitor.h"
#include "LinuxThread.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_linux;
namespace
{
UnixSignalsSP&
GetStaticLinuxSignalsSP ()
{
static UnixSignalsSP s_unix_signals_sp (new process_linux::LinuxSignals ());
return s_unix_signals_sp;
}
}
//------------------------------------------------------------------------------
// Static functions.
ProcessSP
ProcessLinux::CreateInstance(Target &target, Listener &listener, const FileSpec *core_file)
{
return ProcessSP(new ProcessLinux(target, listener, core_file));
}
void
ProcessLinux::Initialize()
{
static std::once_flag g_once_flag;
std::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(),
CreateInstance);
ProcessPOSIXLog::Initialize(GetPluginNameStatic());
});
}
//------------------------------------------------------------------------------
// Constructors and destructors.
ProcessLinux::ProcessLinux(Target& target, Listener &listener, const FileSpec *core_file)
: ProcessPOSIX(target, listener, GetStaticLinuxSignalsSP ()), m_core_file(core_file), m_stopping_threads(false)
{
#if 0
// FIXME: Putting this code in the ctor and saving the byte order in a
// member variable is a hack to avoid const qual issues in GetByteOrder.
ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
m_byte_order = obj_file->GetByteOrder();
#else
// XXX: Will work only for local processes.
m_byte_order = lldb::endian::InlHostByteOrder();
#endif
}
void
ProcessLinux::Terminate()
{
}
lldb_private::ConstString
ProcessLinux::GetPluginNameStatic()
{
static ConstString g_name("linux");
return g_name;
}
const char *
ProcessLinux::GetPluginDescriptionStatic()
{
return "Process plugin for Linux";
}
bool
ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
{
new_thread_list = old_thread_list;
return new_thread_list.GetSize(false) > 0;
}
//------------------------------------------------------------------------------
// ProcessInterface protocol.
lldb_private::ConstString
ProcessLinux::GetPluginName()
{
return GetPluginNameStatic();
}
uint32_t
ProcessLinux::GetPluginVersion()
{
return 1;
}
void
ProcessLinux::GetPluginCommandHelp(const char *command, Stream *strm)
{
}
Error
ProcessLinux::ExecutePluginCommand(Args &command, Stream *strm)
{
return Error(1, eErrorTypeGeneric);
}
Log *
ProcessLinux::EnablePluginLogging(Stream *strm, Args &command)
{
return NULL;
}
Error
ProcessLinux::DoDetach(bool keep_stopped)
{
Error error;
if (keep_stopped)
{
// FIXME: If you want to implement keep_stopped,
// this would be the place to do it.
error.SetErrorString("Detaching with keep_stopped true is not currently supported on Linux.");
return error;
}
Mutex::Locker lock(m_thread_list.GetMutex());
uint32_t thread_count = m_thread_list.GetSize(false);
for (uint32_t i = 0; i < thread_count; ++i)
{
POSIXThread *thread = static_cast<POSIXThread*>(
m_thread_list.GetThreadAtIndex(i, false).get());
error = m_monitor->Detach(thread->GetID());
}
if (error.Success())
SetPrivateState(eStateDetached);
return error;
}
// ProcessPOSIX override
void
ProcessLinux::StopAllThreads(lldb::tid_t stop_tid)
{
// If a breakpoint occurs while we're stopping threads, we'll get back
// here, but we don't want to do it again. Only the MonitorChildProcess
// thread calls this function, so we don't need to protect this flag.
if (m_stopping_threads)
return;
m_stopping_threads = true;
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
if (log)
log->Printf ("ProcessLinux::%s() stopping all threads", __FUNCTION__);
// Walk the thread list and stop the other threads. The thread that caused
// the stop should already be marked as stopped before we get here.
Mutex::Locker thread_list_lock(m_thread_list.GetMutex());
uint32_t thread_count = m_thread_list.GetSize(false);
for (uint32_t i = 0; i < thread_count; ++i)
{
POSIXThread *thread = static_cast<POSIXThread*>(
m_thread_list.GetThreadAtIndex(i, false).get());
assert(thread);
lldb::tid_t tid = thread->GetID();
if (!StateIsStoppedState(thread->GetState(), false))
m_monitor->StopThread(tid);
}
m_stopping_threads = false;
if (log)
log->Printf ("ProcessLinux::%s() finished", __FUNCTION__);
}
// ProcessPOSIX override
POSIXThread *
ProcessLinux::CreateNewPOSIXThread(lldb_private::Process &process, lldb::tid_t tid)
{
return new LinuxThread(process, tid);
}
bool
ProcessLinux::CanDebug(Target &target, bool plugin_specified_by_name)
{
if (plugin_specified_by_name)
return true;
/* If core file is specified then let elf-core plugin handle it */
if (m_core_file)
return false;
// If we're using llgs for local debugging, we must not say that this process
// is used for debugging.
if (platform_linux::PlatformLinux::UseLlgsForLocalDebugging ())
return false;
return ProcessPOSIX::CanDebug(target, plugin_specified_by_name);
}

View File

@@ -1,110 +0,0 @@
//===-- ProcessLinux.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_ProcessLinux_H_
#define liblldb_ProcessLinux_H_
// C Includes
// C++ Includes
#include <queue>
// Other libraries and framework includes
#include "lldb/Target/Process.h"
#include "Plugins/Process/POSIX/ProcessMessage.h"
#include "Plugins/Process/POSIX/ProcessPOSIX.h"
class ProcessMonitor;
namespace lldb_private {
namespace process_linux {
class ProcessLinux : public ProcessPOSIX
{
public:
//------------------------------------------------------------------
// Static functions.
//------------------------------------------------------------------
static lldb::ProcessSP
CreateInstance(Target& target,
Listener &listener,
const FileSpec *);
static void
Initialize();
static void
Terminate();
static ConstString
GetPluginNameStatic();
static const char *
GetPluginDescriptionStatic();
//------------------------------------------------------------------
// Constructors and destructors
//------------------------------------------------------------------
ProcessLinux(Target& target,
Listener &listener,
const FileSpec *core_file);
Error
DoDetach(bool keep_stopped) override;
bool
DetachRequiresHalt() override { return true; }
bool
UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
ConstString
GetPluginName() override;
uint32_t
GetPluginVersion() override;
virtual void
GetPluginCommandHelp(const char *command, Stream *strm);
virtual Error
ExecutePluginCommand(Args &command,
Stream *strm);
virtual Log *
EnablePluginLogging(Stream *strm,
Args &command);
bool
CanDebug(Target &target, bool plugin_specified_by_name) override;
//------------------------------------------------------------------
// ProcessPOSIX overrides
//------------------------------------------------------------------
void
StopAllThreads(lldb::tid_t stop_tid) override;
POSIXThread *
CreateNewPOSIXThread(Process &process, lldb::tid_t tid) override;
private:
const FileSpec *m_core_file;
// Flag to avoid recursion when stopping all threads.
bool m_stopping_threads;
};
} // namespace process_linux
} // namespace lldb_private
#endif // liblldb_ProcessLinux_H_

File diff suppressed because it is too large Load Diff

View File

@@ -1,334 +0,0 @@
//===-- ProcessMonitor.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_ProcessMonitor_H_
#define liblldb_ProcessMonitor_H_
// C Includes
#include <semaphore.h>
#include <signal.h>
// C++ Includes
// Other libraries and framework includes
#include "lldb/lldb-types.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
class Error;
class Module;
class Scalar;
namespace process_linux {
class ProcessLinux;
} // namespace process_linux
} // namespace lldb_private
class Operation;
/// @class ProcessMonitor
/// @brief Manages communication with the inferior (debugee) process.
///
/// Upon construction, this class prepares and launches an inferior process for
/// debugging.
///
/// Changes in the inferior process state are propagated to the associated
/// ProcessLinux instance by calling ProcessLinux::SendMessage with the
/// appropriate ProcessMessage events.
///
/// A purposely minimal set of operations are provided to interrogate and change
/// the inferior process state.
class ProcessMonitor
{
public:
/// Launches an inferior process ready for debugging. Forms the
/// implementation of Process::DoLaunch.
ProcessMonitor(ProcessPOSIX *process,
lldb_private::Module *module,
char const *argv[],
char const *envp[],
const lldb_private::FileSpec &stdin_file_spec,
const lldb_private::FileSpec &stdout_file_spec,
const lldb_private::FileSpec &stderr_file_spec,
const lldb_private::FileSpec &working_dir,
const lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Error &error);
ProcessMonitor(ProcessPOSIX *process,
lldb::pid_t pid,
lldb_private::Error &error);
~ProcessMonitor();
enum ResumeSignals
{
eResumeSignalNone = 0
};
/// Provides the process number of debugee.
lldb::pid_t
GetPID() const { return m_pid; }
/// Returns the process associated with this ProcessMonitor.
lldb_private::process_linux::ProcessLinux &
GetProcess() { return *m_process; }
/// Returns a file descriptor to the controlling terminal of the inferior
/// process.
///
/// Reads from this file descriptor yield both the standard output and
/// standard error of this debugee. Even if stderr and stdout were
/// redirected on launch it may still happen that data is available on this
/// descriptor (if the inferior process opens /dev/tty, for example). This descriptor is
/// closed after a call to StopMonitor().
///
/// If this monitor was attached to an existing process this method returns
/// -1.
int
GetTerminalFD() const { return m_terminal_fd; }
/// Reads @p size bytes from address @vm_adder in the inferior process
/// address space.
///
/// This method is provided to implement Process::DoReadMemory.
size_t
ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
lldb_private::Error &error);
/// Writes @p size bytes from address @p vm_adder in the inferior process
/// address space.
///
/// This method is provided to implement Process::DoWriteMemory.
size_t
WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
lldb_private::Error &error);
/// Reads the contents from the register identified by the given (architecture
/// dependent) offset.
///
/// This method is provided for use by RegisterContextLinux derivatives.
bool
ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name,
unsigned size, lldb_private::RegisterValue &value);
/// Writes the given value to the register identified by the given
/// (architecture dependent) offset.
///
/// This method is provided for use by RegisterContextLinux derivatives.
bool
WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name,
const lldb_private::RegisterValue &value);
/// Reads all general purpose registers into the specified buffer.
bool
ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size);
/// Reads generic floating point registers into the specified buffer.
bool
ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size);
#if defined (__arm64__) || defined (__aarch64__)
/// Reads hardware breakpoints and watchpoints capability information.
bool
ReadHardwareDebugInfo (lldb::tid_t tid, unsigned int &watch_count ,
unsigned int &break_count);
/// Write hardware breakpoint/watchpoint control and address registers.
bool
WriteHardwareDebugRegs (lldb::tid_t tid, lldb::addr_t *addr_buf,
uint32_t *cntrl_buf, int type, int count);
#endif
/// Reads the specified register set into the specified buffer.
/// For instance, the extended floating-point register set.
bool
ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset);
/// Writes all general purpose registers into the specified buffer.
bool
WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size);
/// Writes generic floating point registers into the specified buffer.
bool
WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size);
/// Writes the specified register set into the specified buffer.
/// For instance, the extended floating-point register set.
bool
WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset);
/// Reads the value of the thread-specific pointer for a given thread ID.
bool
ReadThreadPointer(lldb::tid_t tid, lldb::addr_t &value);
/// Writes a siginfo_t structure corresponding to the given thread ID to the
/// memory region pointed to by @p siginfo.
bool
GetSignalInfo(lldb::tid_t tid, void *siginfo, int &ptrace_err);
/// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG)
/// corresponding to the given thread IDto the memory pointed to by @p
/// message.
bool
GetEventMessage(lldb::tid_t tid, unsigned long *message);
/// Resumes the given thread. If @p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
bool
Resume(lldb::tid_t tid, uint32_t signo);
/// Single steps the given thread. If @p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
bool
SingleStep(lldb::tid_t tid, uint32_t signo);
/// Terminate the traced process.
bool
Kill();
lldb_private::Error
Detach(lldb::tid_t tid);
/// Stops the monitoring the child process thread.
void
StopMonitor();
/// Stops the requested thread and waits for the stop signal.
bool
StopThread(lldb::tid_t tid);
// Waits for the initial stop message from a new thread.
bool
WaitForInitialTIDStop(lldb::tid_t tid);
private:
lldb_private::process_linux::ProcessLinux *m_process;
lldb_private::HostThread m_operation_thread;
lldb_private::HostThread m_monitor_thread;
lldb::pid_t m_pid;
int m_terminal_fd;
// current operation which must be executed on the priviliged thread
Operation *m_operation;
lldb_private::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;
struct OperationArgs
{
OperationArgs(ProcessMonitor *monitor);
~OperationArgs();
ProcessMonitor *m_monitor; // The monitor performing the attach.
sem_t m_semaphore; // Posted to once operation complete.
lldb_private::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
{
LaunchArgs(ProcessMonitor *monitor,
lldb_private::Module *module,
char const **argv,
char const **envp,
const lldb_private::FileSpec &stdin_file_spec,
const lldb_private::FileSpec &stdout_file_spec,
const lldb_private::FileSpec &stderr_file_spec,
const lldb_private::FileSpec &working_dir,
const lldb_private::ProcessLaunchInfo &launch_info);
~LaunchArgs();
lldb_private::Module *m_module; // The executable image to launch.
char const **m_argv; // Process arguments.
char const **m_envp; // Process environment.
const lldb_private::FileSpec m_stdin_file_spec; // Redirect stdin or empty.
const lldb_private::FileSpec m_stdout_file_spec; // Redirect stdout or empty.
const lldb_private::FileSpec m_stderr_file_spec; // Redirect stderr or empty.
const lldb_private::FileSpec m_working_dir; // Working directory or empty.
const lldb_private::ProcessLaunchInfo &m_launch_info;
};
void
StartLaunchOpThread(LaunchArgs *args, lldb_private::Error &error);
static void *
LaunchOpThread(void *arg);
static bool
Launch(LaunchArgs *args);
struct AttachArgs : OperationArgs
{
AttachArgs(ProcessMonitor *monitor,
lldb::pid_t pid);
~AttachArgs();
lldb::pid_t m_pid; // pid of the process to be attached.
};
void
StartAttachOpThread(AttachArgs *args, lldb_private::Error &error);
static void *
AttachOpThread(void *args);
static bool
Attach(AttachArgs *args);
static bool
SetDefaultPtraceOpts(const lldb::pid_t);
static void
ServeOperation(OperationArgs *args);
static bool
DupDescriptor(const lldb_private::FileSpec &file_spec, int fd, int flags);
static bool
MonitorCallback(void *callback_baton,
lldb::pid_t pid, bool exited, int signal, int status);
static ProcessMessage
MonitorSIGTRAP(ProcessMonitor *monitor,
const siginfo_t *info, lldb::pid_t pid);
static ProcessMessage
MonitorSignal(ProcessMonitor *monitor,
const siginfo_t *info, lldb::pid_t pid);
void
DoOperation(Operation *op);
/// Stops the child monitor thread.
void
StopMonitoringChildProcess();
/// Stops the operation thread used to attach/launch a process.
void
StopOpThread();
};
#endif // #ifndef liblldb_ProcessMonitor_H_

View File

@@ -1,19 +1,10 @@
set(LLVM_NO_RTTI 1)
include_directories(.)
include_directories(../Linux)
include_directories(../Utility)
add_lldb_library(lldbPluginProcessPOSIX
CrashReason.cpp
POSIXStopInfo.cpp
POSIXThread.cpp
ProcessMessage.cpp
ProcessPOSIX.cpp
ProcessPOSIXLog.cpp
RegisterContextPOSIXProcessMonitor_arm.cpp
RegisterContextPOSIXProcessMonitor_arm64.cpp
RegisterContextPOSIXProcessMonitor_mips64.cpp
RegisterContextPOSIXProcessMonitor_powerpc.cpp
RegisterContextPOSIXProcessMonitor_x86.cpp
)

View File

@@ -14,7 +14,6 @@
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/StreamFile.h"
#include "ProcessPOSIX.h"
#include "ProcessPOSIXLog.h"
using namespace lldb;

View File

@@ -128,7 +128,7 @@ class ProcessLaunchTestCase(TestBase):
@skipIfFreeBSD # llvm.org/pr16684
@expectedFailureDarwin("llvm.org/pr20265")
@expectedFailureLLGS("llvm.org/pr20265")
@expectedFailureLinux("llvm.org/pr20265")
@dwarf_test
def test_set_working_dir_with_dwarf (self):
"""Test that '-w dir' sets the working dir when running the inferior."""

View File

@@ -22,7 +22,7 @@ class BreakpointAfterJoinTestCase(TestBase):
@expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_with_dwarf(self):
"""Test breakpoint handling after a thread join."""

View File

@@ -38,7 +38,7 @@ class CreateDuringStepTestCase(TestBase):
@expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_step_inst_with_dwarf(self):
"""Test thread creation during step-inst handling."""
@@ -47,7 +47,7 @@ class CreateDuringStepTestCase(TestBase):
@expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_step_over_with_dwarf(self):
"""Test thread creation during step-over handling."""
@@ -56,7 +56,7 @@ class CreateDuringStepTestCase(TestBase):
@expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_step_in_with_dwarf(self):
"""Test thread creation during step-in handling."""

View File

@@ -22,7 +22,7 @@ class ExitDuringBreakpointTestCase(TestBase):
@expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_with_dwarf(self):
"""Test thread exit during breakpoint handling."""

View File

@@ -22,7 +22,7 @@ class ExitDuringStepTestCase(TestBase):
@expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_thread_state_is_stopped_with_dwarf(self):
"""Test thread exit during step handling."""
@@ -58,7 +58,7 @@ class ExitDuringStepTestCase(TestBase):
self.exit_during_step_inst_test()
@skipIfFreeBSD # llvm.org/pr21411: test is hanging
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_step_over_with_dwarf(self):
"""Test thread exit during step-over handling."""
@@ -66,7 +66,7 @@ class ExitDuringStepTestCase(TestBase):
self.exit_during_step_over_test()
@skipIfFreeBSD # llvm.org/pr21411: test is hanging
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_step_in_with_dwarf(self):
"""Test thread exit during step-in handling."""

View File

@@ -22,7 +22,7 @@ class MultipleBreakpointTestCase(TestBase):
@expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_with_dwarf(self):
"""Test simultaneous breakpoints in multiple threads."""

View File

@@ -22,7 +22,7 @@ class ThreadStateTestCase(TestBase):
@expectedFailureDarwin("rdar://15367566")
@expectedFailureFreeBSD('llvm.org/pr15824')
@expectedFailureLLGS("llvm.org/pr15824") # thread states not properly maintained
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
@dwarf_test
def test_state_after_breakpoint_with_dwarf(self):
"""Test thread state after breakpoint."""

View File

@@ -712,15 +712,6 @@ def expectedFailureAndroid(bugnumber=None, api_levels=None):
return expectedFailure(fn, bugnumber)
def expectedFailureLLGS(bugnumber=None, compilers=None):
def fn(self):
# llgs local is only an option on Linux targets
if self.getPlatform() != 'linux':
return False
self.runCmd('settings show platform.plugin.linux.use-llgs-for-local')
return 'true' in self.res.GetOutput() and self.expectedCompiler(compilers)
return expectedFailure(fn, bugnumber)
def skipIfRemote(func):
"""Decorate the item to skip tests if testing remotely."""
if isinstance(func, type) and issubclass(func, unittest2.TestCase):