Create a HostThread abstraction.

This patch moves creates a thread abstraction that represents a
thread running inside the LLDB process.  This is a replacement for
otherwise using lldb::thread_t, and provides a platform agnostic
interface to managing these threads.

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

Reviewed by: Jim Ingham

llvm-svn: 217460
This commit is contained in:
Zachary Turner 2014-09-09 20:54:56 +00:00
parent 7decae153b
commit 39de311071
64 changed files with 1619 additions and 821 deletions

View File

@ -19,6 +19,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
#include "lldb/lldb-private.h"
@ -350,7 +351,7 @@ private:
protected:
lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class.
lldb::thread_t m_read_thread; ///< The read thread handle in case we need to cancel the thread.
HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread.
bool m_read_thread_enabled;
std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
Mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes.

View File

@ -14,6 +14,8 @@
#include <stdint.h>
#include <string.h>
#include "lldb/lldb-types.h"
namespace lldb_private {
//----------------------------------------------------------------------

View File

@ -25,6 +25,7 @@
#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Target/ExecutionContext.h"
@ -364,7 +365,7 @@ public:
bool
IsHandlingEvents () const
{
return IS_VALID_LLDB_HOST_THREAD(m_event_handler_thread);
return m_event_handler_thread.GetState() == eThreadStateRunning;
}
protected:
@ -432,8 +433,8 @@ protected:
static LoadPluginCallbackType g_load_plugin_callback;
typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
LoadedPluginsList m_loaded_plugins;
lldb::thread_t m_event_handler_thread;
lldb::thread_t m_io_handler_thread;
HostThread m_event_handler_thread;
HostThread m_io_handler_thread;
lldb::ListenerSP m_forward_listener_sp;
void
InstanceInitialize ();

View File

@ -21,6 +21,7 @@
#include "lldb/Core/StringList.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
namespace lldb_private {
@ -38,9 +39,6 @@ class Host
{
public:
/// A value of std::numeric_limits<uint32_t>::max() is used if there is no practical limit.
static const uint32_t MAX_THREAD_NAME_LENGTH;
typedef bool (*MonitorChildProcessCallback) (void *callback_baton,
lldb::pid_t pid,
bool exited,
@ -86,11 +84,8 @@ public:
///
/// @see static void Host::StopMonitoringChildProcess (uint32_t)
//------------------------------------------------------------------
static lldb::thread_t
StartMonitoringChildProcess (MonitorChildProcessCallback callback,
void *callback_baton,
lldb::pid_t pid,
bool monitor_signals);
static HostThread StartMonitoringChildProcess(MonitorChildProcessCallback callback, void *callback_baton, lldb::pid_t pid,
bool monitor_signals);
enum SystemLogType
{
@ -140,36 +135,6 @@ public:
static void
WillTerminate ();
//------------------------------------------------------------------
/// Host specific thread created function call.
///
/// This function call lets the current host OS do any thread
/// specific initialization that it needs, including naming the
/// thread. No cleanup routine is expected to be called
///
/// @param[in] name
/// The current thread's name in the current process.
//------------------------------------------------------------------
static void
ThreadCreated (const char *name);
static lldb::thread_t
ThreadCreate (const char *name,
lldb::thread_func_t function,
lldb::thread_arg_t thread_arg,
Error *err);
static bool
ThreadCancel (lldb::thread_t thread,
Error *error);
static bool
ThreadDetach (lldb::thread_t thread,
Error *error);
static bool
ThreadJoin (lldb::thread_t thread,
lldb::thread_result_t *thread_result_ptr,
Error *error);
typedef void (*ThreadLocalStorageCleanupCallback) (void *p);
@ -182,65 +147,6 @@ public:
static void
ThreadLocalStorageSet(lldb::thread_key_t key, void *value);
//------------------------------------------------------------------
/// Gets the name of a thread in a process.
///
/// This function will name a thread in a process using it's own
/// thread name pool, and also will attempt to set a thread name
/// using any supported host OS APIs.
///
/// @param[in] pid
/// The process ID in which we are trying to get the name of
/// a thread.
///
/// @param[in] tid
/// The thread ID for which we are trying retrieve the name of.
///
/// @return
/// A std::string containing the thread name.
//------------------------------------------------------------------
static std::string
GetThreadName (lldb::pid_t pid, lldb::tid_t tid);
//------------------------------------------------------------------
/// Sets the name of a thread in the current process.
///
/// @param[in] pid
/// The process ID in which we are trying to name a thread.
///
/// @param[in] tid
/// The thread ID which we are trying to name.
///
/// @param[in] name
/// The current thread's name in the current process to \a name.
///
/// @return
/// \b true if the thread name was able to be set, \b false
/// otherwise.
//------------------------------------------------------------------
static bool
SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name);
//------------------------------------------------------------------
/// Sets a shortened name of a thread in the current process.
///
/// @param[in] pid
/// The process ID in which we are trying to name a thread.
///
/// @param[in] tid
/// The thread ID which we are trying to name.
///
/// @param[in] name
/// The current thread's name in the current process to \a name.
///
/// @param[in] len
/// The maximum length for the thread's shortened name.
///
/// @return
/// \b true if the thread name was able to be set, \b false
/// otherwise.
static bool
SetShortThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name, size_t len);
//------------------------------------------------------------------
/// Given an address in the current process (the process that

View File

@ -44,6 +44,14 @@ class HostInfoBase
//------------------------------------------------------------------
static uint32_t GetNumberCPUS();
//------------------------------------------------------------------
/// Returns the maximum length of a thread name on this platform.
///
/// @return
/// Maximum length of a thread name on this platform.
//------------------------------------------------------------------
static uint32_t GetMaxThreadNameLength();
//------------------------------------------------------------------
/// Gets the host vendor string.
///

View File

@ -0,0 +1,39 @@
//===-- HostNativeThread.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostNativeThread_h_
#define lldb_Host_HostNativeThread_h_
#if defined(_WIN32)
#include "lldb/Host/windows/HostThreadWindows.h"
namespace lldb_private
{
typedef HostThreadWindows HostNativeThread;
}
#elif defined(__linux__)
#include "lldb/Host/linux/HostThreadLinux.h"
namespace lldb_private
{
typedef HostThreadLinux HostNativeThread;
}
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "lldb/Host/freebsd/HostThreadFreeBSD.h"
namespace lldb_private
{
typedef HostThreadFreeBSD HostNativeThread;
}
#elif defined(__APPLE__)
#include "lldb/Host/macosx/HostThreadMacOSX.h"
namespace lldb_private
{
typedef HostThreadMacOSX HostNativeThread;
}
#endif
#endif

View File

@ -0,0 +1,56 @@
//===-- HostNativeThreadBase.h ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostNativeThreadBase_h_
#define lldb_Host_HostNativeThreadBase_h_
#include "lldb/Core/Error.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
#include "lldb/lldb-private-enumerations.h"
namespace lldb_private
{
#if defined(_WIN32)
#define THREAD_ROUTINE __stdcall
#else
#define THREAD_ROUTINE
#endif
class HostNativeThreadBase
{
friend class ThreadLauncher;
DISALLOW_COPY_AND_ASSIGN(HostNativeThreadBase);
public:
HostNativeThreadBase();
explicit HostNativeThreadBase(lldb::thread_t thread);
virtual ~HostNativeThreadBase() {}
virtual Error Join(lldb::thread_result_t *result) = 0;
virtual Error Cancel() = 0;
virtual void Reset();
lldb::thread_t Release();
void SetState(ThreadState state);
ThreadState GetState() const;
lldb::thread_t GetSystemHandle() const;
lldb::thread_result_t GetResult() const;
protected:
static lldb::thread_result_t THREAD_ROUTINE ThreadCreateTrampoline(lldb::thread_arg_t arg);
lldb::thread_t m_thread;
ThreadState m_state;
lldb::thread_result_t m_result;
};
}
#endif

View File

@ -0,0 +1,56 @@
//===-- HostThread.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostThread_h_
#define lldb_Host_HostThread_h_
#include "lldb/Core/Error.h"
#include "lldb/lldb-types.h"
#include <memory>
namespace lldb_private
{
class HostNativeThreadBase;
//----------------------------------------------------------------------
/// @class HostInfo HostInfo.h "lldb/Host/HostThread.h"
/// @brief A class that represents a thread running inside of a process on the
/// local machine.
///
/// HostThread allows querying and manipulation of threads running on the host
/// machine.
///
//----------------------------------------------------------------------
class HostThread
{
public:
HostThread();
HostThread(lldb::thread_t thread);
Error Join(lldb::thread_result_t *result);
Error Cancel();
void Reset();
lldb::thread_t Release();
void SetState(ThreadState state);
ThreadState GetState() const;
HostNativeThreadBase &GetNativeThread();
const HostNativeThreadBase &GetNativeThread() const;
lldb::thread_result_t GetResult() const;
bool EqualsThread(lldb::thread_t thread) const;
private:
std::shared_ptr<HostNativeThreadBase> m_native_thread;
};
}
#endif

View File

@ -0,0 +1,40 @@
//===-- ThisThread.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_ThisThread_h_
#define lldb_Host_ThisThread_h_
#include "llvm/ADT/StringRef.h"
#include <string>
namespace llvm
{
template <class T> class SmallVectorImpl;
}
namespace lldb_private
{
class ThisThread
{
private:
ThisThread();
public:
// ThisThread common functions.
static void SetName(llvm::StringRef name, int max_length);
// ThisThread platform-specific functions.
static void SetName(llvm::StringRef name);
static void GetName(llvm::SmallVectorImpl<char> &name);
};
}
#endif

View File

@ -0,0 +1,44 @@
//===-- ThreadLauncher.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_ThreadLauncher_h_
#define lldb_Host_ThreadLauncher_h_
#include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/StringRef.h"
namespace lldb_private
{
class ThreadLauncher
{
public:
static HostThread LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, lldb::thread_arg_t thread_arg,
Error *error_ptr);
struct HostThreadCreateInfo
{
std::string thread_name;
lldb::thread_func_t thread_fptr;
lldb::thread_arg_t thread_arg;
HostThreadCreateInfo(const char *name, lldb::thread_func_t fptr, lldb::thread_arg_t arg)
: thread_name(name ? name : "")
, thread_fptr(fptr)
, thread_arg(arg)
{
}
};
};
}
#endif

View File

@ -19,6 +19,7 @@ namespace lldb_private
class HostInfoFreeBSD : public HostInfoPosix
{
public:
static uint32_t GetMaxThreadNameLength();
static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);

View File

@ -0,0 +1,32 @@
//===-- HostThreadFreeBSD.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_freebsd_HostThreadFreeBSD_h_
#define lldb_Host_freebsd_HostThreadFreeBSD_h_
#include "lldb/Host/posix/HostThreadPosix.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallString.h"
namespace lldb_private
{
class HostThreadFreeBSD : public HostThreadPosix
{
public:
HostThreadFreeBSD();
HostThreadFreeBSD(lldb::thread_t thread);
static void SetName(lldb::thread_t thread, llvm::StringRef name);
static void GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name);
};
}
#endif

View File

@ -31,6 +31,7 @@ class HostInfoLinux : public HostInfoPosix
public:
static void Initialize();
static uint32_t GetMaxThreadNameLength();
static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
static llvm::StringRef GetDistributionId();

View File

@ -0,0 +1,32 @@
//===-- HostThreadLinux.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_linux_HostThreadLinux_h_
#define lldb_Host_linux_HostThreadLinux_h_
#include "lldb/Host/posix/HostThreadPosix.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallString.h"
namespace lldb_private
{
class HostThreadLinux : public HostThreadPosix
{
public:
HostThreadLinux();
HostThreadLinux(lldb::thread_t thread);
static void SetName(lldb::thread_t thread, llvm::StringRef name);
static void GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name);
};
}
#endif

View File

@ -0,0 +1,31 @@
//===-- HostThreadMacOSX.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_macosx_HostThreadMacOSX_h_
#define lldb_Host_macosx_HostThreadMacOSX_h_
#include "lldb/Host/posix/HostThreadPosix.h"
namespace lldb_private
{
class HostThreadMacOSX : public HostThreadPosix
{
friend class ThreadLauncher;
public:
HostThreadMacOSX();
HostThreadMacOSX(lldb::thread_t thread);
protected:
static lldb::thread_result_t ThreadCreateTrampoline(lldb::thread_arg_t arg);
};
}
#endif

View File

@ -0,0 +1,34 @@
//===-- HostThreadWindows.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_posix_HostThreadPosix_h_
#define lldb_Host_posix_HostThreadPosix_h_
#include "lldb/Host/HostNativeThreadBase.h"
namespace lldb_private
{
class HostThreadPosix : public HostNativeThreadBase
{
DISALLOW_COPY_AND_ASSIGN(HostThreadPosix);
public:
HostThreadPosix();
HostThreadPosix(lldb::thread_t thread);
virtual ~HostThreadPosix();
virtual Error Join(lldb::thread_result_t *result);
virtual Error Cancel();
Error Detach();
};
}
#endif

View File

@ -0,0 +1,40 @@
//===-- HostThreadWindows.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_windows_HostThreadWindows_h_
#define lldb_Host_windows_HostThreadWindows_h_
#include "lldb/Host/HostNativeThreadBase.h"
#include "llvm/ADT/SmallString.h"
namespace lldb_private
{
class HostThreadWindows : public HostNativeThreadBase
{
DISALLOW_COPY_AND_ASSIGN(HostThreadWindows);
public:
HostThreadWindows();
HostThreadWindows(lldb::thread_t thread);
virtual ~HostThreadWindows();
virtual Error Join(lldb::thread_result_t *result);
virtual Error Cancel();
virtual void Reset();
lldb::tid_t GetThreadId() const;
protected:
llvm::SmallString<32> m_thread_name;
};
}
#endif

View File

@ -38,6 +38,7 @@
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ProcessRunLock.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/Options.h"
@ -2909,7 +2910,7 @@ public:
ProcessRunLock &
GetRunLock ()
{
if (Host::GetCurrentThread() == m_private_state_thread)
if (m_private_state_thread.EqualsThread(Host::GetCurrentThread()))
return m_private_run_lock;
else
return m_public_run_lock;
@ -3007,7 +3008,7 @@ protected:
bool
PrivateStateThreadIsValid () const
{
return IS_VALID_LLDB_HOST_THREAD(m_private_state_thread);
return m_private_state_thread.GetState() != eThreadStateInvalid;
}
void
@ -3042,7 +3043,7 @@ protected:
Broadcaster m_private_state_control_broadcaster; // This is the control broadcaster, used to pause, resume & stop the private state thread.
Listener m_private_state_listener; // This is the listener for the private state thread.
Predicate<bool> m_private_state_control_wait; /// This Predicate is used to signal that a control operation is complete.
lldb::thread_t m_private_state_thread; // Thread ID for the thread that watches internal state events
HostThread m_private_state_thread; // Thread ID for the thread that watches internal state events
ProcessModID m_mod_id; ///< Tracks the state of the process over stops and other alterations.
uint32_t m_process_unique_id; ///< Each lldb_private::Process class that is created gets a unique integer ID that increments with each new instance
uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index that won't get re-used.

View File

@ -240,6 +240,18 @@ typedef enum ExitType {
eExitTypeStop, // The exit status represents the stop signal that caused the program to exit (i.e. WIFSTOPPED() was true)
} ExitType;
//----------------------------------------------------------------------
// State for running threads
//----------------------------------------------------------------------
enum ThreadState
{
eThreadStateInvalid, // The thread does not represent a current or past thread.
eThreadStateRunning, // The thread is currently running.
eThreadStateExited, // The thread's start routine returned normally.
eThreadStateCancelling, // The thread has been sent a cancellation request.
eThreadStateCancelled // The thread was cancelled before completing normally.
};
//----------------------------------------------------------------------
// Boolean result of running a Type Validator
//----------------------------------------------------------------------

View File

@ -50,9 +50,9 @@ namespace lldb
typedef void* condition_t;
typedef void* rwlock_t;
typedef void* process_t; // Process type is HANDLE
typedef uintptr_t thread_t; // Host thread type
typedef void* thread_t; // Host thread type
typedef uint32_t thread_key_t;
typedef void * thread_arg_t; // Host thread argument type
typedef void* thread_arg_t; // Host thread argument type
typedef unsigned thread_result_t; // Host thread result type
typedef thread_result_t (*thread_func_t)(void *); // Host thread function type
}

View File

@ -589,6 +589,14 @@
3FDFE53119A292F0009756A7 /* HostInfoPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFE53019A292F0009756A7 /* HostInfoPosix.cpp */; };
3FDFE53319A29304009756A7 /* HostInfoPosix.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FDFE53219A29304009756A7 /* HostInfoPosix.h */; };
3FDFE53519A29327009756A7 /* HostInfoBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFE53419A29327009756A7 /* HostInfoBase.cpp */; };
3FDFE56C19AF9C44009756A7 /* HostProcessPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFE56A19AF9C44009756A7 /* HostProcessPosix.cpp */; };
3FDFE56D19AF9C44009756A7 /* HostThreadPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFE56B19AF9C44009756A7 /* HostThreadPosix.cpp */; };
3FDFED0B19B7C8DE009756A7 /* HostThreadMacOSX.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED0519B7C898009756A7 /* HostThreadMacOSX.mm */; };
3FDFED0C19B7C8E7009756A7 /* ThisThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED0619B7C898009756A7 /* ThisThread.cpp */; };
3FDFED0F19B7D269009756A7 /* ThisThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED0D19B7D269009756A7 /* ThisThread.cpp */; };
3FDFED2719BA6D96009756A7 /* HostNativeThreadBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED2419BA6D96009756A7 /* HostNativeThreadBase.cpp */; };
3FDFED2819BA6D96009756A7 /* HostThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED2519BA6D96009756A7 /* HostThread.cpp */; };
3FDFED2919BA6D96009756A7 /* ThreadLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED2619BA6D96009756A7 /* ThreadLauncher.cpp */; };
449ACC98197DEA0B008D175E /* FastDemangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 449ACC96197DE9EC008D175E /* FastDemangle.cpp */; };
490A36C0180F0E6F00BA31F8 /* PlatformWindows.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490A36BD180F0E6F00BA31F8 /* PlatformWindows.cpp */; };
490A36C2180F0E9300BA31F8 /* PlatformWindows.h in Headers */ = {isa = PBXBuildFile; fileRef = 490A36BE180F0E6F00BA31F8 /* PlatformWindows.h */; };
@ -1759,7 +1767,7 @@
3FDFDDC1199D34E2009756A7 /* FileSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FileSystem.h; path = include/lldb/Host/FileSystem.h; sourceTree = "<group>"; };
3FDFDDC5199D37ED009756A7 /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSystem.cpp; path = source/Host/posix/FileSystem.cpp; sourceTree = "<group>"; };
3FDFE52B19A2917A009756A7 /* HostInfoMacOSX.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = HostInfoMacOSX.mm; path = source/Host/macosx/HostInfoMacOSX.mm; sourceTree = "<group>"; };
3FDFE52D19A291AF009756A7 /* HostInfoMacOSX.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostInfoMacOSX.h; path = include/lldb/Host/macosx/HostInfoMacOSX.h; sourceTree = "<group>"; };
3FDFE52D19A291AF009756A7 /* HostInfoMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostInfoMacOSX.h; path = include/lldb/Host/macosx/HostInfoMacOSX.h; sourceTree = "<group>"; };
3FDFE53019A292F0009756A7 /* HostInfoPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HostInfoPosix.cpp; path = source/Host/posix/HostInfoPosix.cpp; sourceTree = "<group>"; };
3FDFE53219A29304009756A7 /* HostInfoPosix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostInfoPosix.h; path = include/lldb/Host/posix/HostInfoPosix.h; sourceTree = "<group>"; };
3FDFE53419A29327009756A7 /* HostInfoBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HostInfoBase.cpp; sourceTree = "<group>"; };
@ -1782,6 +1790,38 @@
3FDFE54919A2946B009756A7 /* HostInfoWindows.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostInfoWindows.h; path = include/lldb/Host/windows/HostInfoWindows.h; sourceTree = "<group>"; };
3FDFE54A19A2946B009756A7 /* win32.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = win32.h; path = include/lldb/Host/windows/win32.h; sourceTree = "<group>"; };
3FDFE54B19A2946B009756A7 /* windows.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = windows.h; path = include/lldb/Host/windows/windows.h; sourceTree = "<group>"; };
3FDFE55E19AF9B14009756A7 /* Host.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Host.cpp; path = source/Host/freebsd/Host.cpp; sourceTree = "<group>"; };
3FDFE55F19AF9B14009756A7 /* HostThreadFreeBSD.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = HostThreadFreeBSD.cpp; path = source/Host/freebsd/HostThreadFreeBSD.cpp; sourceTree = "<group>"; };
3FDFE56019AF9B39009756A7 /* HostThreadFreeBSD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostThreadFreeBSD.h; path = include/lldb/Host/freebsd/HostThreadFreeBSD.h; sourceTree = "<group>"; };
3FDFE56219AF9B60009756A7 /* HostThreadLinux.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HostThreadLinux.cpp; sourceTree = "<group>"; };
3FDFE56319AF9B77009756A7 /* Config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/linux/Config.h; sourceTree = SOURCE_ROOT; };
3FDFE56419AF9B77009756A7 /* HostInfoLinux.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostInfoLinux.h; path = include/lldb/Host/linux/HostInfoLinux.h; sourceTree = SOURCE_ROOT; };
3FDFE56519AF9B77009756A7 /* HostThreadLinux.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostThreadLinux.h; path = include/lldb/Host/linux/HostThreadLinux.h; sourceTree = SOURCE_ROOT; };
3FDFE56619AF9BB2009756A7 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/macosx/Config.h; sourceTree = "<group>"; };
3FDFE56719AF9BB2009756A7 /* HostThreadMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostThreadMacOSX.h; path = include/lldb/Host/macosx/HostThreadMacOSX.h; sourceTree = "<group>"; };
3FDFE56A19AF9C44009756A7 /* HostProcessPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HostProcessPosix.cpp; path = source/Host/posix/HostProcessPosix.cpp; sourceTree = "<group>"; };
3FDFE56B19AF9C44009756A7 /* HostThreadPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HostThreadPosix.cpp; path = source/Host/posix/HostThreadPosix.cpp; sourceTree = "<group>"; };
3FDFE56E19AF9C5A009756A7 /* HostProcessPosix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostProcessPosix.h; path = include/lldb/Host/posix/HostProcessPosix.h; sourceTree = "<group>"; };
3FDFE56F19AF9C5A009756A7 /* HostThreadPosix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostThreadPosix.h; path = include/lldb/Host/posix/HostThreadPosix.h; sourceTree = "<group>"; };
3FDFE57019AF9CA0009756A7 /* HostProcessWindows.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = HostProcessWindows.cpp; path = source/Host/windows/HostProcessWindows.cpp; sourceTree = "<group>"; };
3FDFE57119AF9CA0009756A7 /* HostThreadWindows.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = HostThreadWindows.cpp; path = source/Host/windows/HostThreadWindows.cpp; sourceTree = "<group>"; };
3FDFE57219AF9CD3009756A7 /* HostProcessWindows.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostProcessWindows.h; path = include/lldb/Host/windows/HostProcessWindows.h; sourceTree = "<group>"; };
3FDFE57319AF9CD3009756A7 /* HostThreadWindows.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostThreadWindows.h; path = include/lldb/Host/windows/HostThreadWindows.h; sourceTree = "<group>"; };
3FDFE57419AFABFD009756A7 /* HostProcess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostProcess.h; path = include/lldb/Host/HostProcess.h; sourceTree = "<group>"; };
3FDFE57519AFABFD009756A7 /* HostThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostThread.h; path = include/lldb/Host/HostThread.h; sourceTree = "<group>"; };
3FDFED0519B7C898009756A7 /* HostThreadMacOSX.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = HostThreadMacOSX.mm; path = source/Host/macosx/HostThreadMacOSX.mm; sourceTree = "<group>"; };
3FDFED0619B7C898009756A7 /* ThisThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThisThread.cpp; path = source/Host/macosx/ThisThread.cpp; sourceTree = "<group>"; };
3FDFED0919B7C8C7009756A7 /* ThisThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThisThread.h; path = include/lldb/Host/ThisThread.h; sourceTree = "<group>"; };
3FDFED0D19B7D269009756A7 /* ThisThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThisThread.cpp; path = source/Host/common/ThisThread.cpp; sourceTree = "<group>"; };
3FDFED1E19BA6D55009756A7 /* Debug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Debug.h; path = include/lldb/Host/Debug.h; sourceTree = "<group>"; };
3FDFED1F19BA6D55009756A7 /* HostGetOpt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostGetOpt.h; path = include/lldb/Host/HostGetOpt.h; sourceTree = "<group>"; };
3FDFED2019BA6D55009756A7 /* HostNativeThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostNativeThread.h; path = include/lldb/Host/HostNativeThread.h; sourceTree = "<group>"; };
3FDFED2119BA6D55009756A7 /* HostNativeThreadBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostNativeThreadBase.h; path = include/lldb/Host/HostNativeThreadBase.h; sourceTree = "<group>"; };
3FDFED2219BA6D55009756A7 /* ProcessRunLock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ProcessRunLock.h; path = include/lldb/Host/ProcessRunLock.h; sourceTree = "<group>"; };
3FDFED2319BA6D55009756A7 /* ThreadLauncher.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadLauncher.h; path = include/lldb/Host/ThreadLauncher.h; sourceTree = "<group>"; };
3FDFED2419BA6D96009756A7 /* HostNativeThreadBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HostNativeThreadBase.cpp; sourceTree = "<group>"; };
3FDFED2519BA6D96009756A7 /* HostThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HostThread.cpp; sourceTree = "<group>"; };
3FDFED2619BA6D96009756A7 /* ThreadLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadLauncher.cpp; sourceTree = "<group>"; };
449ACC96197DE9EC008D175E /* FastDemangle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FastDemangle.cpp; path = source/Core/FastDemangle.cpp; sourceTree = "<group>"; };
4906FD4012F2255300A2A77C /* ASTDumper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTDumper.cpp; path = source/Expression/ASTDumper.cpp; sourceTree = "<group>"; };
4906FD4412F2257600A2A77C /* ASTDumper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTDumper.h; path = include/lldb/Expression/ASTDumper.h; sourceTree = "<group>"; };
@ -2331,9 +2371,13 @@
233B009C19610D130090E598 /* linux */ = {
isa = PBXGroup;
children = (
3FDFE56319AF9B77009756A7 /* Config.h */,
233B009D19610D6B0090E598 /* Host.cpp */,
237C577A19AF9D9F00213D59 /* HostInfoLinux.h */,
3FDFE53619A2933E009756A7 /* HostInfoLinux.cpp */,
3FDFE56419AF9B77009756A7 /* HostInfoLinux.h */,
3FDFE56219AF9B60009756A7 /* HostThreadLinux.cpp */,
3FDFE56519AF9B77009756A7 /* HostThreadLinux.h */,
);
name = linux;
path = source/Host/linux;
@ -3526,6 +3570,7 @@
3FDFE53E19A2940E009756A7 /* windows */,
26BC7DD210F1B7D500F91463 /* Condition.h */,
266F5CBB12FC846200DFCE33 /* Config.h */,
3FDFED1E19BA6D55009756A7 /* Debug.h */,
26CFDCA01861638D000E63E5 /* Editline.h */,
26BC7DD310F1B7D500F91463 /* Endian.h */,
260C6EA013011578005E16B0 /* File.h */,
@ -3534,8 +3579,13 @@
26FA4315130103F400E71120 /* FileSpec.h */,
3FDFDDC1199D34E2009756A7 /* FileSystem.h */,
26BC7DD410F1B7D500F91463 /* Host.h */,
3FDFED1F19BA6D55009756A7 /* HostGetOpt.h */,
3FDFE53719A2936B009756A7 /* HostInfo.h */,
3FDFE53819A2936B009756A7 /* HostInfoBase.h */,
3FDFED2019BA6D55009756A7 /* HostNativeThread.h */,
3FDFED2119BA6D55009756A7 /* HostNativeThreadBase.h */,
3FDFE57419AFABFD009756A7 /* HostProcess.h */,
3FDFE57519AFABFD009756A7 /* HostThread.h */,
236124A61986B50E004EFC37 /* IOObject.h */,
26BC7DD510F1B7D500F91463 /* Mutex.h */,
232CB60B191E00CC00EF39FC /* NativeBreakpoint.cpp */,
@ -3549,6 +3599,7 @@
A36FF33D17D8E98800244D40 /* OptionParser.h */,
260A39A519647A3A004B4130 /* Pipe.h */,
26BC7DD610F1B7D500F91463 /* Predicate.h */,
3FDFED2219BA6D55009756A7 /* ProcessRunLock.h */,
236124A71986B50E004EFC37 /* Socket.h */,
26D7E45B13D5E2F9007FD12B /* SocketAddress.h */,
26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */,
@ -3556,6 +3607,9 @@
232CB614191E00CD00EF39FC /* SoftwareBreakpoint.h */,
2689B0A4113EE3CD00A4AEDB /* Symbols.h */,
268DA871130095D000C9483A /* Terminal.h */,
3FDFED0D19B7D269009756A7 /* ThisThread.cpp */,
3FDFED0919B7C8C7009756A7 /* ThisThread.h */,
3FDFED2319BA6D55009756A7 /* ThreadLauncher.h */,
26B4E26E112F35F700AB3F64 /* TimeValue.h */,
);
name = Host;
@ -3775,8 +3829,7 @@
26BC7EE510F1B88100F91463 /* MacOSX */ = {
isa = PBXGroup;
children = (
3FDFE52D19A291AF009756A7 /* HostInfoMacOSX.h */,
3FDFE52B19A2917A009756A7 /* HostInfoMacOSX.mm */,
3FDFE56619AF9BB2009756A7 /* Config.h */,
26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */,
26BC7EEE10F1B8AD00F91463 /* CFCBundle.h */,
26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */,
@ -3791,7 +3844,12 @@
26BC7EF810F1B8AD00F91463 /* CFCString.cpp */,
26BC7EF910F1B8AD00F91463 /* CFCString.h */,
26BC7EE810F1B88F00F91463 /* Host.mm */,
3FDFE52B19A2917A009756A7 /* HostInfoMacOSX.mm */,
3FDFE52D19A291AF009756A7 /* HostInfoMacOSX.h */,
3FDFED0519B7C898009756A7 /* HostThreadMacOSX.mm */,
3FDFE56719AF9BB2009756A7 /* HostThreadMacOSX.h */,
2689B0B5113EE47E00A4AEDB /* Symbols.cpp */,
3FDFED0619B7C898009756A7 /* ThisThread.cpp */,
EDC6D49114E5C15C001B75F8 /* launcherXPCService */,
);
name = MacOSX;
@ -3991,8 +4049,12 @@
3FDFDDC4199D37BE009756A7 /* posix */ = {
isa = PBXGroup;
children = (
3FDFE53219A29304009756A7 /* HostInfoPosix.h */,
3FDFE53019A292F0009756A7 /* HostInfoPosix.cpp */,
3FDFE53219A29304009756A7 /* HostInfoPosix.h */,
3FDFE56A19AF9C44009756A7 /* HostProcessPosix.cpp */,
3FDFE56E19AF9C5A009756A7 /* HostProcessPosix.h */,
3FDFE56B19AF9C44009756A7 /* HostThreadPosix.cpp */,
3FDFE56F19AF9C5A009756A7 /* HostThreadPosix.h */,
3FDFDDC5199D37ED009756A7 /* FileSystem.cpp */,
);
name = posix;
@ -4002,8 +4064,11 @@
isa = PBXGroup;
children = (
3FDFE53C19A293CA009756A7 /* Config.h */,
3FDFE53D19A293CA009756A7 /* HostInfoFreeBSD.h */,
3FDFE55E19AF9B14009756A7 /* Host.cpp */,
3FDFE53B19A293B3009756A7 /* HostInfoFreeBSD.cpp */,
3FDFE53D19A293CA009756A7 /* HostInfoFreeBSD.h */,
3FDFE55F19AF9B14009756A7 /* HostThreadFreeBSD.cpp */,
3FDFE56019AF9B39009756A7 /* HostThreadFreeBSD.h */,
);
name = freebsd;
sourceTree = "<group>";
@ -4017,13 +4082,17 @@
3FDFE54019A29448009756A7 /* EditLineWin.cpp */,
3FDFE54119A29448009756A7 /* FileSystem.cpp */,
3FDFE54219A29448009756A7 /* Host.cpp */,
3FDFE54919A2946B009756A7 /* HostInfoWindows.h */,
3FDFE54319A29448009756A7 /* HostInfoWindows.cpp */,
3FDFE54919A2946B009756A7 /* HostInfoWindows.h */,
3FDFE57019AF9CA0009756A7 /* HostProcessWindows.cpp */,
3FDFE57219AF9CD3009756A7 /* HostProcessWindows.h */,
3FDFE57119AF9CA0009756A7 /* HostThreadWindows.cpp */,
3FDFE57319AF9CD3009756A7 /* HostThreadWindows.h */,
3FDFE54419A29448009756A7 /* Mutex.cpp */,
3FDFE54519A29448009756A7 /* ProcessRunLock.cpp */,
3FDFE54A19A2946B009756A7 /* win32.h */,
3FDFE54B19A2946B009756A7 /* windows.h */,
3FDFE54619A29448009756A7 /* Windows.cpp */,
3FDFE54B19A2946B009756A7 /* windows.h */,
);
name = windows;
sourceTree = "<group>";
@ -4125,6 +4194,8 @@
69A01E1B1236C5D400C660B5 /* Condition.cpp */,
69A01E1C1236C5D400C660B5 /* Host.cpp */,
3FDFE53419A29327009756A7 /* HostInfoBase.cpp */,
3FDFED2419BA6D96009756A7 /* HostNativeThreadBase.cpp */,
3FDFED2519BA6D96009756A7 /* HostThread.cpp */,
236124A21986B4E2004EFC37 /* IOObject.cpp */,
69A01E1E1236C5D400C660B5 /* Mutex.cpp */,
A36FF33B17D8E94600244D40 /* OptionParser.cpp */,
@ -4133,6 +4204,7 @@
236124A31986B4E2004EFC37 /* Socket.cpp */,
69A01E1F1236C5D400C660B5 /* Symbols.cpp */,
268DA873130095ED00C9483A /* Terminal.cpp */,
3FDFED2619BA6D96009756A7 /* ThreadLauncher.cpp */,
69A01E201236C5D400C660B5 /* TimeValue.cpp */,
);
name = common;
@ -4953,6 +5025,7 @@
8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */,
2689005D13353E0400698AC0 /* VMRange.cpp in Sources */,
2689005E13353E0E00698AC0 /* ClangASTSource.cpp in Sources */,
3FDFED0F19B7D269009756A7 /* ThisThread.cpp in Sources */,
2689005F13353E0E00698AC0 /* ClangFunction.cpp in Sources */,
2689006013353E0E00698AC0 /* ClangExpressionDeclMap.cpp in Sources */,
2689006113353E0E00698AC0 /* ClangExpressionParser.cpp in Sources */,
@ -5022,6 +5095,7 @@
AF1729D6182C907200E0AB97 /* HistoryThread.cpp in Sources */,
268900AF13353E5000698AC0 /* UnwindLLDB.cpp in Sources */,
268900B013353E5000698AC0 /* RegisterContextLLDB.cpp in Sources */,
3FDFE56C19AF9C44009756A7 /* HostProcessPosix.cpp in Sources */,
268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */,
268900B513353E5000698AC0 /* StopInfoMachException.cpp in Sources */,
268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */,
@ -5078,6 +5152,7 @@
268900E013353E6F00698AC0 /* SymbolVendor.cpp in Sources */,
268900E113353E6F00698AC0 /* Symtab.cpp in Sources */,
268900E213353E6F00698AC0 /* Type.cpp in Sources */,
3FDFED2719BA6D96009756A7 /* HostNativeThreadBase.cpp in Sources */,
268900E313353E6F00698AC0 /* TypeList.cpp in Sources */,
268900E413353E6F00698AC0 /* UnwindPlan.cpp in Sources */,
268900E513353E6F00698AC0 /* UnwindTable.cpp in Sources */,
@ -5114,11 +5189,13 @@
232CB61B191E00CD00EF39FC /* NativeThreadProtocol.cpp in Sources */,
2689010113353E6F00698AC0 /* ThreadPlanStepOut.cpp in Sources */,
2689010213353E6F00698AC0 /* ThreadPlanStepOverBreakpoint.cpp in Sources */,
3FDFED2919BA6D96009756A7 /* ThreadLauncher.cpp in Sources */,
232CB617191E00CD00EF39FC /* NativeBreakpointList.cpp in Sources */,
232CB615191E00CD00EF39FC /* NativeBreakpoint.cpp in Sources */,
2689010313353E6F00698AC0 /* ThreadPlanStepRange.cpp in Sources */,
2689010413353E6F00698AC0 /* ThreadPlanStepInRange.cpp in Sources */,
2689010513353E6F00698AC0 /* ThreadPlanStepOverRange.cpp in Sources */,
3FDFE56D19AF9C44009756A7 /* HostThreadPosix.cpp in Sources */,
2689010613353E6F00698AC0 /* ThreadPlanRunToAddress.cpp in Sources */,
2689010713353E6F00698AC0 /* ThreadPlanStepThrough.cpp in Sources */,
2689010813353E6F00698AC0 /* ThreadPlanStepUntil.cpp in Sources */,
@ -5142,6 +5219,7 @@
264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */,
2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */,
26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */,
3FDFED0B19B7C8DE009756A7 /* HostThreadMacOSX.mm in Sources */,
266603CA1345B5A8004DA8B6 /* ConnectionSharedMemory.cpp in Sources */,
2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */,
4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */,
@ -5214,6 +5292,7 @@
26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */,
26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */,
94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */,
3FDFED2819BA6D96009756A7 /* HostThread.cpp in Sources */,
949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */,
B27318421416AC12006039C8 /* WatchpointList.cpp in Sources */,
26CFDCA3186163A4000E63E5 /* Editline.cpp in Sources */,
@ -5247,6 +5326,7 @@
260CC64915D0440D002BF2E0 /* OptionValueArray.cpp in Sources */,
260CC64A15D0440D002BF2E0 /* OptionValueBoolean.cpp in Sources */,
260CC64B15D0440D002BF2E0 /* OptionValueProperties.cpp in Sources */,
3FDFED0C19B7C8E7009756A7 /* ThisThread.cpp in Sources */,
260CC64C15D0440D002BF2E0 /* OptionValueDictionary.cpp in Sources */,
49DCF6FE170E6B4A0092F75E /* IRMemoryMap.cpp in Sources */,
260CC64D15D0440D002BF2E0 /* OptionValueEnumeration.cpp in Sources */,

View File

@ -13,6 +13,12 @@
#include "lldb/Core/Log.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
#if !defined(_WIN32)
#include "lldb/Host/HostNativeThread.h"
#endif
using namespace lldb;
using namespace lldb_private;
@ -69,31 +75,54 @@ SBHostOS::ThreadCreate
// FIXME: You should log the return value?
return Host::ThreadCreate (name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL);
HostThread thread(ThreadLauncher::LaunchThread(name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL));
return thread.Release();
}
void
SBHostOS::ThreadCreated (const char *name)
{
Host::ThreadCreated (name);
}
bool
SBHostOS::ThreadCancel (lldb::thread_t thread, SBError *error_ptr)
{
return Host::ThreadCancel (thread, error_ptr ? error_ptr->get() : NULL);
Error error;
HostThread host_thread(thread);
error = host_thread.Cancel();
if (error_ptr)
error_ptr->SetError(error);
host_thread.Release();
return error.Success();
}
bool
SBHostOS::ThreadDetach (lldb::thread_t thread, SBError *error_ptr)
{
return Host::ThreadDetach (thread, error_ptr ? error_ptr->get() : NULL);
Error error;
#if defined(_WIN32)
if (error_ptr)
error_ptr->SetErrorString("ThreadDetach is not supported on this platform");
#else
HostThread host_thread(thread);
error = ((HostThreadPosix &)host_thread.GetNativeThread()).Detach();
if (error_ptr)
error_ptr->SetError(error);
host_thread.Release();
#endif
return error.Success();
}
bool
SBHostOS::ThreadJoin (lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr)
{
return Host::ThreadJoin (thread, result, error_ptr ? error_ptr->get() : NULL);
Error error;
HostThread host_thread(thread);
error = host_thread.Join(result);
if (error_ptr)
error_ptr->SetError(error);
host_thread.Release();
return error.Success();
}

View File

@ -18,6 +18,8 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/Event.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
#include <string.h>
using namespace lldb;
@ -36,7 +38,6 @@ Communication::GetStaticBroadcasterClass ()
Communication::Communication(const char *name) :
Broadcaster (NULL, name),
m_connection_sp (),
m_read_thread (LLDB_INVALID_HOST_THREAD),
m_read_thread_enabled (false),
m_bytes(),
m_bytes_mutex (Mutex::eMutexTypeRecursive),
@ -232,7 +233,7 @@ Communication::StartReadThread (Error *error_ptr)
if (error_ptr)
error_ptr->Clear();
if (IS_VALID_LLDB_HOST_THREAD(m_read_thread))
if (m_read_thread.GetState() == eThreadStateRunning)
return true;
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
@ -243,8 +244,8 @@ Communication::StartReadThread (Error *error_ptr)
snprintf(thread_name, sizeof(thread_name), "<lldb.comm.%s>", m_broadcaster_name.AsCString());
m_read_thread_enabled = true;
m_read_thread = Host::ThreadCreate (thread_name, Communication::ReadThread, this, error_ptr);
if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread))
m_read_thread = ThreadLauncher::LaunchThread(thread_name, Communication::ReadThread, this, error_ptr);
if (m_read_thread.GetState() != eThreadStateRunning)
m_read_thread_enabled = false;
return m_read_thread_enabled;
}
@ -252,7 +253,7 @@ Communication::StartReadThread (Error *error_ptr)
bool
Communication::StopReadThread (Error *error_ptr)
{
if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread))
if (m_read_thread.GetState() != eThreadStateRunning)
return true;
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
@ -262,22 +263,22 @@ Communication::StopReadThread (Error *error_ptr)
BroadcastEvent (eBroadcastBitReadThreadShouldExit, NULL);
//Host::ThreadCancel (m_read_thread, error_ptr);
// error = m_read_thread.Cancel();
bool status = Host::ThreadJoin (m_read_thread, NULL, error_ptr);
m_read_thread = LLDB_INVALID_HOST_THREAD;
return status;
Error error = m_read_thread.Join(nullptr);
m_read_thread.Reset();
return error.Success();
}
bool
Communication::JoinReadThread (Error *error_ptr)
{
if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread))
if (m_read_thread.GetState() != eThreadStateRunning)
return true;
bool success = Host::ThreadJoin (m_read_thread, NULL, error_ptr);
m_read_thread = LLDB_INVALID_HOST_THREAD;
return success;
Error error = m_read_thread.Join(nullptr);
m_read_thread.Reset();
return error.Success();
}
size_t

View File

@ -36,6 +36,7 @@
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValueSInt64.h"
#include "lldb/Interpreter/OptionValueString.h"
@ -620,24 +621,22 @@ Debugger::FindTargetWithProcess (Process *process)
return target_sp;
}
Debugger::Debugger (lldb::LogOutputCallback log_callback, void *baton) :
UserID (g_unique_id++),
Properties(OptionValuePropertiesSP(new OptionValueProperties())),
m_input_file_sp (new StreamFile (stdin, false)),
m_output_file_sp (new StreamFile (stdout, false)),
m_error_file_sp (new StreamFile (stderr, false)),
m_terminal_state (),
m_target_list (*this),
m_platform_list (),
m_listener ("lldb.Debugger"),
m_source_manager_ap(),
m_source_file_cache(),
m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)),
m_input_reader_stack (),
m_instance_name (),
m_loaded_plugins (),
m_event_handler_thread (LLDB_INVALID_HOST_THREAD),
m_io_handler_thread (LLDB_INVALID_HOST_THREAD)
Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
: UserID(g_unique_id++)
, Properties(OptionValuePropertiesSP(new OptionValueProperties()))
, m_input_file_sp(new StreamFile(stdin, false))
, m_output_file_sp(new StreamFile(stdout, false))
, m_error_file_sp(new StreamFile(stderr, false))
, m_terminal_state()
, m_target_list(*this)
, m_platform_list()
, m_listener("lldb.Debugger")
, m_source_manager_ap()
, m_source_file_cache()
, m_command_interpreter_ap(new CommandInterpreter(*this, eScriptLanguageDefault, false))
, m_input_reader_stack()
, m_instance_name()
, m_loaded_plugins()
{
char instance_cstr[256];
snprintf(instance_cstr, sizeof(instance_cstr), "debugger_%d", (int)GetID());
@ -3337,19 +3336,19 @@ Debugger::EventHandlerThread (lldb::thread_arg_t arg)
bool
Debugger::StartEventHandlerThread()
{
if (!IS_VALID_LLDB_HOST_THREAD(m_event_handler_thread))
m_event_handler_thread = Host::ThreadCreate("lldb.debugger.event-handler", EventHandlerThread, this, NULL);
return IS_VALID_LLDB_HOST_THREAD(m_event_handler_thread);
if (m_event_handler_thread.GetState() != eThreadStateRunning)
m_event_handler_thread = ThreadLauncher::LaunchThread("lldb.debugger.event-handler", EventHandlerThread, this, NULL);
return m_event_handler_thread.GetState() == eThreadStateRunning;
}
void
Debugger::StopEventHandlerThread()
{
if (IS_VALID_LLDB_HOST_THREAD(m_event_handler_thread))
if (m_event_handler_thread.GetState() == eThreadStateRunning)
{
GetCommandInterpreter().BroadcastEvent(CommandInterpreter::eBroadcastBitQuitCommandReceived);
Host::ThreadJoin(m_event_handler_thread, NULL, NULL);
m_event_handler_thread = LLDB_INVALID_HOST_THREAD;
m_event_handler_thread.Join(nullptr);
m_event_handler_thread.Reset();
}
}
@ -3366,20 +3365,20 @@ Debugger::IOHandlerThread (lldb::thread_arg_t arg)
bool
Debugger::StartIOHandlerThread()
{
if (!IS_VALID_LLDB_HOST_THREAD(m_io_handler_thread))
m_io_handler_thread = Host::ThreadCreate("lldb.debugger.io-handler", IOHandlerThread, this, NULL);
return IS_VALID_LLDB_HOST_THREAD(m_io_handler_thread);
if (m_io_handler_thread.GetState() != eThreadStateRunning)
m_io_handler_thread = ThreadLauncher::LaunchThread("lldb.debugger.io-handler", IOHandlerThread, this, NULL);
return m_io_handler_thread.GetState() == eThreadStateRunning;
}
void
Debugger::StopIOHandlerThread()
{
if (IS_VALID_LLDB_HOST_THREAD(m_io_handler_thread))
if (m_io_handler_thread.GetState() == eThreadStateRunning)
{
if (m_input_file_sp)
m_input_file_sp->GetFile().Close();
Host::ThreadJoin(m_io_handler_thread, NULL, NULL);
m_io_handler_thread = LLDB_INVALID_HOST_THREAD;
m_io_handler_thread.Join(nullptr);
m_io_handler_thread.Reset();
}
}

View File

@ -26,9 +26,12 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/ThisThread.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Interpreter/Args.h"
#include "llvm/ADT/SmallString.h"
using namespace lldb;
using namespace lldb_private;
@ -113,7 +116,8 @@ Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args)
// Add the thread name if requested
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME))
{
std::string thread_name (Host::GetThreadName (getpid(), Host::GetCurrentThreadID()));
llvm::SmallString<32> thread_name;
ThisThread::GetName(thread_name);
if (!thread_name.empty())
header.Printf ("%s ", thread_name.c_str());
}

View File

@ -11,6 +11,8 @@ add_host_subdirectory(common
common/FileSpec.cpp
common/Host.cpp
common/HostInfoBase.cpp
common/HostNativeThreadBase.cpp
common/HostThread.cpp
common/IOObject.cpp
common/Mutex.cpp
common/NativeBreakpoint.cpp
@ -25,34 +27,41 @@ add_host_subdirectory(common
common/SoftwareBreakpoint.cpp
common/Symbols.cpp
common/Terminal.cpp
common/ThisThread.cpp
common/ThreadLauncher.cpp
common/TimeValue.cpp
)
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_host_subdirectory(windows
windows/Condition.cpp
windows/EditLineWin.cpp
windows/FileSystem.cpp
windows/Host.cpp
windows/HostInfoWindows.cpp
windows/HostProcessWindows.cpp
windows/ProcessRunLock.cpp
windows/HostThreadWindows.cpp
windows/Mutex.cpp
windows/Condition.cpp
windows/ProcessRunLock.cpp
windows/ThisThread.cpp
windows/Windows.cpp
windows/EditLineWin.cpp
)
else()
add_host_subdirectory(posix
posix/FileSystem.cpp
posix/HostInfoPosix.cpp
posix/HostProcessPosix.cpp
posix/HostThreadPosix.cpp
)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
add_host_subdirectory(macosx
macosx/Host.mm
macosx/Symbols.cpp
macosx/HostInfoMacOSX.mm
macosx/HostThreadMacOSX.mm
macosx/Symbols.cpp
macosx/ThisThread.cpp
macosx/cfcpp/CFCBundle.cpp
macosx/cfcpp/CFCData.cpp
macosx/cfcpp/CFCMutableArray.cpp
@ -65,11 +74,15 @@ else()
add_host_subdirectory(linux
linux/Host.cpp
linux/HostInfoLinux.cpp
linux/HostThreadLinux.cpp
linux/ThisThread.cpp
)
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_host_subdirectory(freebsd
freebsd/Host.cpp
freebsd/HostInfoFreeBSD.cpp
freebsd/HostThreadFreeBSD.cpp
freebsd/ThisThread.cpp
)
endif()
endif()

View File

@ -48,6 +48,10 @@
#include <pthread_np.h>
#endif
#if defined(__linux__)
#include "Plugins/Process/Linux/ProcFileReader.h"
#endif
// C++ includes
#include <limits>
@ -66,6 +70,7 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/Process.h"
@ -95,13 +100,6 @@ extern "C"
using namespace lldb;
using namespace lldb_private;
// Define maximum thread name length
#if defined (__linux__) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__NetBSD__)
uint32_t const Host::MAX_THREAD_NAME_LENGTH = 16;
#else
uint32_t const Host::MAX_THREAD_NAME_LENGTH = std::numeric_limits<uint32_t>::max ();
#endif
#if !defined (__APPLE__) && !defined (_WIN32)
struct MonitorInfo
{
@ -114,16 +112,9 @@ struct MonitorInfo
static thread_result_t
MonitorChildProcessThreadFunction (void *arg);
lldb::thread_t
Host::StartMonitoringChildProcess
(
Host::MonitorChildProcessCallback callback,
void *callback_baton,
lldb::pid_t pid,
bool monitor_signals
)
HostThread
Host::StartMonitoringChildProcess(Host::MonitorChildProcessCallback callback, void *callback_baton, lldb::pid_t pid, bool monitor_signals)
{
lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
MonitorInfo * info_ptr = new MonitorInfo();
info_ptr->pid = pid;
@ -132,24 +123,8 @@ Host::StartMonitoringChildProcess
info_ptr->monitor_signals = monitor_signals;
char thread_name[256];
if (Host::MAX_THREAD_NAME_LENGTH <= 16)
{
// On some platforms, the thread name is limited to 16 characters. We need to
// abbreviate there or the pid info would get truncated.
::snprintf (thread_name, sizeof(thread_name), "wait4(%" PRIu64 ")", pid);
}
else
{
::snprintf (thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
}
thread = ThreadCreate (thread_name,
MonitorChildProcessThreadFunction,
info_ptr,
NULL);
return thread;
::snprintf(thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
return ThreadLauncher::LaunchThread(thread_name, MonitorChildProcessThreadFunction, info_ptr, NULL);
}
//------------------------------------------------------------------
@ -428,11 +403,6 @@ Host::WillTerminate ()
#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) && !defined (__linux__) // see macosx/Host.mm
void
Host::ThreadCreated (const char *thread_name)
{
}
void
Host::Backtrace (Stream &strm, uint32_t max_frames)
{
@ -448,101 +418,8 @@ Host::GetEnvironment (StringList &env)
#endif // #if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) && !defined (__linux__)
struct HostThreadCreateInfo
{
std::string thread_name;
thread_func_t thread_fptr;
thread_arg_t thread_arg;
HostThreadCreateInfo (const char *name, thread_func_t fptr, thread_arg_t arg) :
thread_name (name ? name : ""),
thread_fptr (fptr),
thread_arg (arg)
{
}
};
static thread_result_t
#ifdef _WIN32
__stdcall
#endif
ThreadCreateTrampoline (thread_arg_t arg)
{
HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg;
Host::ThreadCreated (info->thread_name.c_str());
thread_func_t thread_fptr = info->thread_fptr;
thread_arg_t thread_arg = info->thread_arg;
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
if (log)
log->Printf("thread created");
delete info;
return thread_fptr (thread_arg);
}
lldb::thread_t
Host::ThreadCreate
(
const char *thread_name,
thread_func_t thread_fptr,
thread_arg_t thread_arg,
Error *error
)
{
lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
// Host::ThreadCreateTrampoline will delete this pointer for us.
HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg);
#ifdef _WIN32
thread = ::_beginthreadex(0, 0, ThreadCreateTrampoline, info_ptr, 0, NULL);
int err = thread <= 0 ? GetLastError() : 0;
#else
int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr);
#endif
if (err == 0)
{
if (error)
error->Clear();
return thread;
}
if (error)
error->SetError (err, eErrorTypePOSIX);
return LLDB_INVALID_HOST_THREAD;
}
#ifndef _WIN32
bool
Host::ThreadCancel (lldb::thread_t thread, Error *error)
{
int err = ::pthread_cancel (thread);
if (error)
error->SetError(err, eErrorTypePOSIX);
return err == 0;
}
bool
Host::ThreadDetach (lldb::thread_t thread, Error *error)
{
int err = ::pthread_detach (thread);
if (error)
error->SetError(err, eErrorTypePOSIX);
return err == 0;
}
bool
Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error)
{
int err = ::pthread_join (thread, thread_result_ptr);
if (error)
error->SetError(err, eErrorTypePOSIX);
return err == 0;
}
lldb::thread_key_t
Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback)
{
@ -563,99 +440,6 @@ Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value)
::pthread_setspecific (key, value);
}
bool
Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
{
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
lldb::pid_t curr_pid = Host::GetCurrentProcessID();
lldb::tid_t curr_tid = Host::GetCurrentThreadID();
if (pid == LLDB_INVALID_PROCESS_ID)
pid = curr_pid;
if (tid == LLDB_INVALID_THREAD_ID)
tid = curr_tid;
// Set the pthread name if possible
if (pid == curr_pid && tid == curr_tid)
{
if (::pthread_setname_np (name) == 0)
return true;
}
return false;
#elif defined (__FreeBSD__)
lldb::pid_t curr_pid = Host::GetCurrentProcessID();
lldb::tid_t curr_tid = Host::GetCurrentThreadID();
if (pid == LLDB_INVALID_PROCESS_ID)
pid = curr_pid;
if (tid == LLDB_INVALID_THREAD_ID)
tid = curr_tid;
// Set the pthread name if possible
if (pid == curr_pid && tid == curr_tid)
{
::pthread_set_name_np (::pthread_self(), name);
return true;
}
return false;
#elif defined (__linux__) || defined (__GLIBC__)
void *fn = dlsym (RTLD_DEFAULT, "pthread_setname_np");
if (fn)
{
lldb::pid_t curr_pid = Host::GetCurrentProcessID();
lldb::tid_t curr_tid = Host::GetCurrentThreadID();
if (pid == LLDB_INVALID_PROCESS_ID)
pid = curr_pid;
if (tid == LLDB_INVALID_THREAD_ID)
tid = curr_tid;
if (pid == curr_pid && tid == curr_tid)
{
int (*pthread_setname_np_func)(pthread_t thread, const char *name);
*reinterpret_cast<void **> (&pthread_setname_np_func) = fn;
if (pthread_setname_np_func (::pthread_self(), name) == 0)
return true;
}
}
return false;
#else
return false;
#endif
}
bool
Host::SetShortThreadName (lldb::pid_t pid, lldb::tid_t tid,
const char *thread_name, size_t len)
{
std::unique_ptr<char[]> namebuf(new char[len+1]);
// Thread names are coming in like '<lldb.comm.debugger.edit>' and
// '<lldb.comm.debugger.editline>'. So just chopping the end of the string
// off leads to a lot of similar named threads. Go through the thread name
// and search for the last dot and use that.
const char *lastdot = ::strrchr (thread_name, '.');
if (lastdot && lastdot != thread_name)
thread_name = lastdot + 1;
::strncpy (namebuf.get(), thread_name, len);
namebuf[len] = 0;
int namebuflen = strlen(namebuf.get());
if (namebuflen > 0)
{
if (namebuf[namebuflen - 1] == '(' || namebuf[namebuflen - 1] == '>')
{
// Trim off trailing '(' and '>' characters for a bit more cleanup.
namebuflen--;
namebuf[namebuflen] = 0;
}
return Host::SetThreadName (pid, tid, namebuf.get());
}
return false;
}
#endif
#if !defined (__APPLE__) // see Host.mm

View File

@ -94,6 +94,12 @@ HostInfoBase::GetNumberCPUS()
return g_fields->m_number_cpus;
}
uint32_t
HostInfoBase::GetMaxThreadNameLength()
{
return 0;
}
llvm::StringRef
HostInfoBase::GetVendorString()
{

View File

@ -0,0 +1,92 @@
//===-- HostNativeThreadBase.cpp --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/Log.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostNativeThreadBase.h"
#include "lldb/Host/ThisThread.h"
#include "lldb/Host/ThreadLauncher.h"
#include "llvm/ADT/StringExtras.h"
using namespace lldb;
using namespace lldb_private;
HostNativeThreadBase::HostNativeThreadBase()
: m_thread(LLDB_INVALID_HOST_THREAD)
, m_state(eThreadStateInvalid)
, m_result(0)
{
}
HostNativeThreadBase::HostNativeThreadBase(thread_t thread)
: m_thread(thread)
, m_state((thread == LLDB_INVALID_HOST_THREAD) ? eThreadStateInvalid : eThreadStateRunning)
, m_result(0)
{
}
void
HostNativeThreadBase::SetState(ThreadState state)
{
m_state = state;
}
ThreadState
HostNativeThreadBase::GetState() const
{
return m_state;
}
lldb::thread_t
HostNativeThreadBase::GetSystemHandle() const
{
return m_thread;
}
lldb::thread_result_t
HostNativeThreadBase::GetResult() const
{
return m_result;
}
void
HostNativeThreadBase::Reset()
{
m_thread = LLDB_INVALID_HOST_THREAD;
m_state = eThreadStateInvalid;
m_result = 0;
}
lldb::thread_t
HostNativeThreadBase::Release()
{
lldb::thread_t result = m_thread;
m_thread = LLDB_INVALID_HOST_THREAD;
m_state = eThreadStateInvalid;
m_result = 0;
return result;
}
lldb::thread_result_t
HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg)
{
ThreadLauncher::HostThreadCreateInfo *info = (ThreadLauncher::HostThreadCreateInfo *)arg;
ThisThread::SetName(info->thread_name.c_str(), HostInfo::GetMaxThreadNameLength());
thread_func_t thread_fptr = info->thread_fptr;
thread_arg_t thread_arg = info->thread_arg;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
if (log)
log->Printf("thread created");
delete info;
return thread_fptr(thread_arg);
}

View File

@ -0,0 +1,84 @@
//===-- HostThread.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/HostNativeThread.h"
#include "lldb/Host/HostThread.h"
using namespace lldb;
using namespace lldb_private;
HostThread::HostThread()
: m_native_thread(new HostNativeThread)
{
}
HostThread::HostThread(lldb::thread_t thread)
: m_native_thread(new HostNativeThread(thread))
{
}
Error
HostThread::Join(lldb::thread_result_t *result)
{
return m_native_thread->Join(result);
}
Error
HostThread::Cancel()
{
return m_native_thread->Cancel();
}
void
HostThread::Reset()
{
return m_native_thread->Reset();
}
lldb::thread_t
HostThread::Release()
{
return m_native_thread->Release();
}
void
HostThread::SetState(ThreadState state)
{
m_native_thread->SetState(state);
}
ThreadState
HostThread::GetState() const
{
return m_native_thread->GetState();
}
HostNativeThreadBase &
HostThread::GetNativeThread()
{
return *m_native_thread;
}
const HostNativeThreadBase &
HostThread::GetNativeThread() const
{
return *m_native_thread;
}
lldb::thread_result_t
HostThread::GetResult() const
{
return m_native_thread->GetResult();
}
bool
HostThread::EqualsThread(lldb::thread_t thread) const
{
return m_native_thread->GetSystemHandle() == thread;
}

View File

@ -0,0 +1,52 @@
//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/Error.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ThisThread.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
using namespace lldb;
using namespace lldb_private;
void
ThisThread::SetName(llvm::StringRef name, int max_length)
{
std::string truncated_name(name.data());
// Thread names are coming in like '<lldb.comm.debugger.edit>' and
// '<lldb.comm.debugger.editline>'. So just chopping the end of the string
// off leads to a lot of similar named threads. Go through the thread name
// and search for the last dot and use that.
if (max_length > 0 && truncated_name.length() > max_length)
{
// First see if we can get lucky by removing any initial or final braces.
std::string::size_type begin = truncated_name.find_first_not_of("(<");
std::string::size_type end = truncated_name.find_last_not_of(")>.");
if (end - begin > max_length)
{
// We're still too long. Since this is a dotted component, use everything after the last
// dot, up to a maximum of |length| characters.
std::string::size_type last_dot = truncated_name.find_last_of(".");
if (last_dot != std::string::npos)
begin = last_dot + 1;
end = std::min(end, begin + max_length);
}
std::string::size_type count = end - begin + 1;
truncated_name = truncated_name.substr(begin, count);
}
SetName(truncated_name.c_str());
}

View File

@ -0,0 +1,48 @@
//===-- ThreadLauncher.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// lldb Includes
#include "lldb/Core/Log.h"
#include "lldb/Host/HostNativeThread.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThisThread.h"
#include "lldb/Host/ThreadLauncher.h"
#if defined(_WIN32)
#include "lldb/Host/windows/windows.h"
#endif
using namespace lldb;
using namespace lldb_private;
HostThread
ThreadLauncher::LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, lldb::thread_arg_t thread_arg, Error *error_ptr)
{
Error error;
if (error_ptr)
error_ptr->Clear();
// Host::ThreadCreateTrampoline will delete this pointer for us.
HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo(name.data(), thread_function, thread_arg);
lldb::thread_t thread;
#ifdef _WIN32
thread = (lldb::thread_t)::_beginthreadex(0, 0, HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL);
if (thread == (lldb::thread_t)(-1L))
error.SetError(::GetLastError(), eErrorTypeWin32);
#else
int err = ::pthread_create(&thread, NULL, HostNativeThread::ThreadCreateTrampoline, info_ptr);
error.SetError(err, eErrorTypePOSIX);
#endif
if (error_ptr)
*error_ptr = error;
if (!error.Success())
thread = LLDB_INVALID_HOST_THREAD;
return HostThread(thread);
}

View File

@ -50,80 +50,6 @@ extern "C" {
using namespace lldb;
using namespace lldb_private;
class FreeBSDThread
{
public:
FreeBSDThread(const char *thread_name)
{
Host::SetThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name);
}
static void PThreadDestructor (void *v)
{
delete (FreeBSDThread*)v;
}
};
static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT;
static pthread_key_t g_thread_create_key = 0;
static void
InitThreadCreated()
{
::pthread_key_create (&g_thread_create_key, FreeBSDThread::PThreadDestructor);
}
void
Host::ThreadCreated (const char *thread_name)
{
::pthread_once (&g_thread_create_once, InitThreadCreated);
if (g_thread_create_key)
{
::pthread_setspecific (g_thread_create_key, new FreeBSDThread(thread_name));
}
Host::SetShortThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name, 16);
}
std::string
Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
{
struct kinfo_proc *kp = nullptr, *nkp;
size_t len = 0;
int error;
int name[4] = {
CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, (int)pid
};
while (1) {
error = sysctl(name, 4, kp, &len, nullptr, 0);
if (kp == nullptr || (error != 0 && errno == ENOMEM)) {
// Add extra space in case threads are added before next call.
len += sizeof(*kp) + len / 10;
nkp = (struct kinfo_proc *)realloc(kp, len);
if (nkp == nullptr)
{
free(kp);
return std::string();
}
kp = nkp;
continue;
}
if (error != 0)
len = 0;
break;
}
std::string thread_name;
for (size_t i = 0; i < len / sizeof(*kp); i++) {
if (kp[i].ki_tid == (int)tid) {
thread_name = kp[i].ki_tdname;
break;
}
}
free(kp);
return thread_name;
}
void
Host::Backtrace (Stream &strm, uint32_t max_frames)
{

View File

@ -17,6 +17,12 @@
using namespace lldb_private;
uint32_t
HostInfoFreeBSD::GetMaxThreadNameLength()
{
return 16;
}
bool
HostInfoFreeBSD::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update)
{

View File

@ -0,0 +1,80 @@
//===-- HostThreadFreeBSD.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// lldb Includes
#include "lldb/Host/freebsd/HostThreadFreeBSD.h"
// C includes
#include <pthread.h>
#include <pthread_np.h>
#include <stdlib.h>
#include <sys/sysctl.h>
// C++ includes
#include <string>
using namespace lldb_private;
HostThreadFreeBSD::HostThreadFreeBSD()
{
}
HostThreadFreeBSD::HostThreadFreeBSD(lldb::thread_t thread)
: HostThreadPosix(thread)
{
}
void
HostThreadFreeBSD::SetName(lldb::thread_t thread, llvm::StringRef name)
{
::pthread_set_name_np(thread, name);
}
void
HostThreadFreeBSD::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
{
name.clear();
int pid = Host::GetCurrentProcessID();
struct kinfo_proc *kp = nullptr, *nkp;
size_t len = 0;
int error;
int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, (int)pid};
while (1)
{
error = sysctl(ctl, 4, kp, &len, nullptr, 0);
if (kp == nullptr || (error != 0 && errno == ENOMEM))
{
// Add extra space in case threads are added before next call.
len += sizeof(*kp) + len / 10;
nkp = (struct kinfo_proc *)realloc(kp, len);
if (nkp == nullptr)
{
free(kp);
return;
}
kp = nkp;
continue;
}
if (error != 0)
len = 0;
break;
}
for (size_t i = 0; i < len / sizeof(*kp); i++)
{
if (kp[i].ki_tid == (int)thread)
{
name.append(kp[i].ki_tdname, strlen(kp[i].ki_tdname));
break;
}
}
free(kp);
}

View File

@ -0,0 +1,29 @@
//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/linux/HostThreadLinux.h"
#include "lldb/Host/ThisThread.h"
#include "llvm/ADT/SmallVector.h"
#include <pthread.h>
using namespace lldb_private;
void
ThisThread::SetName(llvm::StringRef name)
{
HostThread::SetName(::pthread_self(), name);
}
void
ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
{
HostThread::GetName(::pthread_self(), name);
}

View File

@ -372,31 +372,6 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
return GetProcessAndStatInfo (pid, process_info, stat_info, tracerpid);
}
void
Host::ThreadCreated (const char *thread_name)
{
if (!Host::SetThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name))
{
Host::SetShortThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name, 16);
}
}
std::string
Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
{
assert(pid != LLDB_INVALID_PROCESS_ID);
assert(tid != LLDB_INVALID_THREAD_ID);
// Read /proc/$TID/comm file.
lldb::DataBufferSP buf_sp = ProcFileReader::ReadIntoDataBuffer (tid, "comm");
const char *comm_str = (const char *)buf_sp->GetBytes();
const char *cr_str = ::strchr(comm_str, '\n');
size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
std::string thread_name(comm_str, length);
return thread_name;
}
void
Host::Backtrace (Stream &strm, uint32_t max_frames)
{

View File

@ -47,6 +47,12 @@ HostInfoLinux::Initialize()
g_fields = new HostInfoLinuxFields();
}
uint32_t
HostInfoLinux::GetMaxThreadNameLength()
{
return 16;
}
bool
HostInfoLinux::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update)
{

View File

@ -0,0 +1,47 @@
//===-- HostThreadLinux.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/DataBuffer.h"
#include "lldb/Host/linux/HostThreadLinux.h"
#include "Plugins/Process/Linux/ProcFileReader.h"
#include "llvm/ADT/SmallVector.h"
#include <pthread.h>
using namespace lldb_private;
HostThreadLinux::HostThreadLinux()
: HostThreadPosix()
{
}
HostThreadLinux::HostThreadLinux(lldb::thread_t thread)
: HostThreadPosix(thread)
{
}
void
HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name)
{
::pthread_setname_np(thread, name.data());
}
void
HostThreadLinux::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
{
// Read /proc/$TID/comm file.
lldb::DataBufferSP buf_sp = ProcFileReader::ReadIntoDataBuffer(thread, "comm");
const char *comm_str = (const char *)buf_sp->GetBytes();
const char *cr_str = ::strchr(comm_str, '\n');
size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
name.clear();
name.append(comm_str, comm_str + length);
}

View File

@ -0,0 +1,29 @@
//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/HostNativeThread.h"
#include "lldb/Host/ThisThread.h"
#include "llvm/ADT/SmallVector.h"
#include <pthread.h>
using namespace lldb_private;
void
ThisThread::SetName(llvm::StringRef name)
{
HostNativeThread::SetName(::pthread_self(), name);
}
void
ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
{
HostNativeThread::GetName(::pthread_self(), name);
}

View File

@ -47,7 +47,9 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Host/Endian.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/CleanUp.h"
@ -77,107 +79,6 @@ extern "C"
using namespace lldb;
using namespace lldb_private;
static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT;
static pthread_key_t g_thread_create_key = 0;
class MacOSXDarwinThread
{
public:
MacOSXDarwinThread(const char *thread_name) :
m_pool (nil)
{
// Register our thread with the collector if garbage collection is enabled.
if (objc_collectingEnabled())
{
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
// On Leopard and earlier there is no way objc_registerThreadWithCollector
// function, so we do it manually.
auto_zone_register_thread(auto_zone());
#else
// On SnowLeopard and later we just call the thread registration function.
objc_registerThreadWithCollector();
#endif
}
else
{
m_pool = [[NSAutoreleasePool alloc] init];
}
Host::SetThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name);
}
~MacOSXDarwinThread()
{
if (m_pool)
{
[m_pool drain];
m_pool = nil;
}
}
static void PThreadDestructor (void *v)
{
if (v)
delete static_cast<MacOSXDarwinThread*>(v);
::pthread_setspecific (g_thread_create_key, NULL);
}
protected:
NSAutoreleasePool * m_pool;
private:
DISALLOW_COPY_AND_ASSIGN (MacOSXDarwinThread);
};
static void
InitThreadCreated()
{
::pthread_key_create (&g_thread_create_key, MacOSXDarwinThread::PThreadDestructor);
}
void
Host::ThreadCreated (const char *thread_name)
{
::pthread_once (&g_thread_create_once, InitThreadCreated);
if (g_thread_create_key)
{
::pthread_setspecific (g_thread_create_key, new MacOSXDarwinThread(thread_name));
}
}
std::string
Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
{
std::string thread_name;
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
// We currently can only get the name of a thread in the current process.
if (pid == Host::GetCurrentProcessID())
{
char pthread_name[1024];
if (::pthread_getname_np (::pthread_from_mach_thread_np (tid), pthread_name, sizeof(pthread_name)) == 0)
{
if (pthread_name[0])
{
thread_name = pthread_name;
}
}
else
{
dispatch_queue_t current_queue = ::dispatch_get_current_queue ();
if (current_queue != NULL)
{
const char *queue_name = dispatch_queue_get_label (current_queue);
if (queue_name && queue_name[0])
{
thread_name = queue_name;
}
}
}
}
#endif
return thread_name;
}
bool
Host::GetBundleDirectory (const FileSpec &file, FileSpec &bundle_directory)
{
@ -642,28 +543,23 @@ LaunchInNewTerminalWithAppleScript (const char *exe_path, ProcessLaunchInfo &lau
// in a shell and the shell will fork/exec a couple of times before we get
// to the process that we wanted to launch. So when our process actually
// gets launched, we will handshake with it and get the process ID for it.
lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name,
AcceptPIDFromInferior,
connect_url,
&lldb_error);
HostThread accept_thread = ThreadLauncher::LaunchThread(unix_socket_name, AcceptPIDFromInferior, connect_url, &lldb_error);
[applescript executeAndReturnError:nil];
thread_result_t accept_thread_result = NULL;
if (Host::ThreadJoin (accept_thread, &accept_thread_result, &lldb_error))
lldb_error = accept_thread.Join(&accept_thread_result);
if (lldb_error.Success() && accept_thread_result)
{
if (accept_thread_result)
{
pid = (intptr_t)accept_thread_result;
// Wait for process to be stopped at the entry point by watching
// for the process status to be set to SSTOP which indicates it it
// SIGSTOP'ed at the entry point
WaitForProcessToSIGSTOP (pid, 5);
}
pid = (intptr_t)accept_thread_result;
// Wait for process to be stopped at the entry point by watching
// for the process status to be set to SSTOP which indicates it it
// SIGSTOP'ed at the entry point
WaitForProcessToSIGSTOP(pid, 5);
}
::unlink (unix_socket_name);
FileSystem::Unlink(unix_socket_name);
[applescript release];
if (pid != LLDB_INVALID_PROCESS_ID)
launch_info.SetProcessID (pid);
@ -1492,13 +1388,9 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info)
return error;
}
lldb::thread_t
Host::StartMonitoringChildProcess (Host::MonitorChildProcessCallback callback,
void *callback_baton,
lldb::pid_t pid,
bool monitor_signals)
HostThread
Host::StartMonitoringChildProcess(Host::MonitorChildProcessCallback callback, void *callback_baton, lldb::pid_t pid, bool monitor_signals)
{
lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
unsigned long mask = DISPATCH_PROC_EXIT;
if (monitor_signals)
mask |= DISPATCH_PROC_SIGNAL;
@ -1584,7 +1476,7 @@ Host::StartMonitoringChildProcess (Host::MonitorChildProcessCallback callback,
::dispatch_resume (source);
}
return thread;
return HostThread();
}
//----------------------------------------------------------------------

View File

@ -0,0 +1,102 @@
//===-- HostThreadMacOSX.cpp ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/macosx/HostThreadMacOSX.h"
#include "lldb/Host/Host.h"
#include <CoreFoundation/CoreFoundation.h>
#include <Foundation/Foundation.h>
#include <objc/objc-auto.h>
#include <pthread.h>
using namespace lldb_private;
namespace
{
pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT;
pthread_key_t g_thread_create_key = 0;
class MacOSXDarwinThread
{
public:
MacOSXDarwinThread()
: m_pool(nil)
{
// Register our thread with the collector if garbage collection is enabled.
if (objc_collectingEnabled())
{
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
// On Leopard and earlier there is no way objc_registerThreadWithCollector
// function, so we do it manually.
auto_zone_register_thread(auto_zone());
#else
// On SnowLeopard and later we just call the thread registration function.
objc_registerThreadWithCollector();
#endif
}
else
{
m_pool = [[NSAutoreleasePool alloc] init];
}
}
~MacOSXDarwinThread()
{
if (m_pool)
{
[m_pool drain];
m_pool = nil;
}
}
static void
PThreadDestructor(void *v)
{
if (v)
delete static_cast<MacOSXDarwinThread *>(v);
::pthread_setspecific(g_thread_create_key, NULL);
}
protected:
NSAutoreleasePool *m_pool;
private:
DISALLOW_COPY_AND_ASSIGN(MacOSXDarwinThread);
};
void
InitThreadCreated()
{
::pthread_key_create(&g_thread_create_key, MacOSXDarwinThread::PThreadDestructor);
}
} // namespace
HostThreadMacOSX::HostThreadMacOSX()
: HostThreadPosix()
{
}
HostThreadMacOSX::HostThreadMacOSX(lldb::thread_t thread)
: HostThreadPosix(thread)
{
}
lldb::thread_result_t
HostThreadMacOSX::ThreadCreateTrampoline(lldb::thread_arg_t arg)
{
::pthread_once(&g_thread_create_once, InitThreadCreated);
if (g_thread_create_key)
{
::pthread_setspecific(g_thread_create_key, new MacOSXDarwinThread());
}
return HostThreadPosix::ThreadCreateTrampoline(arg);
}

View File

@ -0,0 +1,39 @@
//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/ThisThread.h"
#include <pthread.h>
using namespace lldb_private;
void
ThisThread::SetName(llvm::StringRef name)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
::pthread_setname_np(name);
#endif
}
void
ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
char pthread_name[1024];
dispatch_queue_t current_queue = ::dispatch_get_current_queue();
if (current_queue != NULL)
{
const char *queue_name = dispatch_queue_get_label(current_queue);
if (queue_name && queue_name[0])
{
name = queue_name;
}
}
#endif
}

View File

@ -0,0 +1,63 @@
//===-- HostThreadPosix.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/Error.h"
#include "lldb/Host/posix/HostThreadPosix.h"
#include <pthread.h>
using namespace lldb_private;
HostThreadPosix::HostThreadPosix()
{
}
HostThreadPosix::HostThreadPosix(lldb::thread_t thread)
: HostNativeThreadBase(thread)
{
}
HostThreadPosix::~HostThreadPosix()
{
}
Error
HostThreadPosix::Join(lldb::thread_result_t *result)
{
Error error;
lldb::thread_result_t thread_result;
int err = ::pthread_join(m_thread, &thread_result);
error.SetError(err, lldb::eErrorTypePOSIX);
if (err == 0)
{
m_state = (m_state == eThreadStateCancelling) ? eThreadStateCancelled : eThreadStateExited;
}
return error;
}
Error
HostThreadPosix::Cancel()
{
Error error;
int err = ::pthread_cancel(m_thread);
error.SetError(err, lldb::eErrorTypePOSIX);
if (err == 0)
m_state = eThreadStateCancelling;
return error;
}
Error
HostThreadPosix::Detach()
{
Error error;
int err = ::pthread_detach(m_thread);
error.SetError(err, lldb::eErrorTypePOSIX);
return error;
}

View File

@ -110,12 +110,6 @@ Host::GetAuxvData(lldb_private::Process *process)
return 0;
}
std::string
Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
{
return std::string();
}
lldb::tid_t
Host::GetCurrentThreadID()
{
@ -128,26 +122,6 @@ Host::GetCurrentThread ()
return lldb::thread_t(::GetCurrentThread());
}
bool
Host::ThreadCancel (lldb::thread_t thread, Error *error)
{
int err = ::TerminateThread((HANDLE)thread, 0);
return err == 0;
}
bool
Host::ThreadDetach (lldb::thread_t thread, Error *error)
{
return ThreadCancel(thread, error);
}
bool
Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error)
{
WaitForSingleObject((HANDLE) thread, INFINITE);
return true;
}
lldb::thread_key_t
Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback)
{
@ -166,19 +140,6 @@ Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value)
::TlsSetValue (key, value);
}
bool
Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
{
return false;
}
bool
Host::SetShortThreadName (lldb::pid_t pid, lldb::tid_t tid,
const char *thread_name, size_t len)
{
return false;
}
void
Host::Kill(lldb::pid_t pid, int signo)
{
@ -260,14 +221,8 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
return true;
}
lldb::thread_t
Host::StartMonitoringChildProcess
(
Host::MonitorChildProcessCallback callback,
void *callback_baton,
lldb::pid_t pid,
bool monitor_signals
)
HostThread
Host::StartMonitoringChildProcess(Host::MonitorChildProcessCallback callback, void *callback_baton, lldb::pid_t pid, bool monitor_signals)
{
return LLDB_INVALID_HOST_THREAD;
return HostThread();
}

View File

@ -0,0 +1,80 @@
//===-- HostThreadWindows.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/Error.h"
#include "lldb/Host/windows/windows.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "llvm/ADT/STLExtras.h"
using namespace lldb;
using namespace lldb_private;
HostThreadWindows::HostThreadWindows()
: HostNativeThreadBase()
{
}
HostThreadWindows::HostThreadWindows(lldb::thread_t thread)
: HostNativeThreadBase(thread)
{
}
HostThreadWindows::~HostThreadWindows()
{
Reset();
}
Error
HostThreadWindows::Join(lldb::thread_result_t *result)
{
Error error;
if (WAIT_OBJECT_0 != ::WaitForSingleObject(m_thread, INFINITE))
{
error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
return error;
}
m_state = (m_state == eThreadStateCancelling) ? eThreadStateCancelled : eThreadStateExited;
if (result)
{
DWORD dword_result = 0;
if (!::GetExitCodeThread(m_thread, &dword_result))
*result = 0;
*result = dword_result;
}
return error;
}
Error
HostThreadWindows::Cancel()
{
Error error;
DWORD result = ::QueueUserAPC(::ExitThread, m_thread, 0);
error.SetError(result, eErrorTypeWin32);
return error;
}
lldb::tid_t
HostThreadWindows::GetThreadId() const
{
return ::GetThreadId(m_thread);
}
void
HostThreadWindows::Reset()
{
if (m_thread != LLDB_INVALID_HOST_THREAD)
::CloseHandle(m_thread);
HostNativeThreadBase::Reset();
}

View File

@ -0,0 +1,60 @@
//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/Error.h"
#include "lldb/Host/windows/windows.h"
#include "lldb/Host/ThisThread.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
using namespace lldb;
using namespace lldb_private;
namespace
{
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push, 8)
struct THREADNAME_INFO
{
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to thread name
DWORD dwThreadId; // Thread ID (-1 == current thread)
DWORD dwFlags; // Reserved. Do not use.
};
#pragma pack(pop)
}
void
ThisThread::SetName(llvm::StringRef name)
{
// Other compilers don't yet support SEH, so we can only set the thread if compiling with MSVC.
// TODO(zturner): Once clang-cl supports SEH, relax this conditional.
#if defined(_MSC_VER)
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = name.data();
info.dwThreadId = ::GetCurrentThreadId();
info.dwFlags = 0;
__try { ::RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info); }
__except(EXCEPTION_EXECUTE_HANDLER) {}
#endif
}
void
ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
{
// Getting the thread name is not supported on Windows.
// TODO(zturner): In SetName(), make a TLS entry that contains the thread's name, and in this function
// try to extract that TLS entry.
name.clear();
}

View File

@ -7,7 +7,6 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_subdirectory(Windows)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(POSIX)
add_subdirectory(MacOSX-Kernel)
endif()
add_subdirectory(gdb-remote)

View File

@ -25,6 +25,7 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/PseudoTerminal.h"
@ -810,8 +811,6 @@ ProcessMonitor::ProcessMonitor(ProcessPOSIX *process,
const lldb_private::ProcessLaunchInfo & /* launch_info */,
lldb_private::Error &error)
: m_process(static_cast<ProcessFreeBSD *>(process)),
m_operation_thread(LLDB_INVALID_HOST_THREAD),
m_monitor_thread(LLDB_INVALID_HOST_THREAD),
m_pid(LLDB_INVALID_PROCESS_ID),
m_terminal_fd(-1),
m_operation(0)
@ -852,7 +851,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() != eThreadStateRunning)
{
error.SetErrorToGenericError();
error.SetErrorString("Process launch failed.");
@ -864,8 +863,6 @@ ProcessMonitor::ProcessMonitor(ProcessPOSIX *process,
lldb::pid_t pid,
lldb_private::Error &error)
: m_process(static_cast<ProcessFreeBSD *>(process)),
m_operation_thread(LLDB_INVALID_HOST_THREAD),
m_monitor_thread(LLDB_INVALID_HOST_THREAD),
m_pid(pid),
m_terminal_fd(-1),
m_operation(0)
@ -904,7 +901,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() != eThreadStateRunning)
{
error.SetErrorToGenericError();
error.SetErrorString("Process attach failed.");
@ -924,11 +921,10 @@ ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Error &error)
{
static const char *g_thread_name = "lldb.process.freebsd.operation";
if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() == eThreadStateRunning)
return;
m_operation_thread =
Host::ThreadCreate(g_thread_name, LaunchOpThread, args, &error);
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
}
void *
@ -1101,11 +1097,10 @@ ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Error &error
{
static const char *g_thread_name = "lldb.process.freebsd.operation";
if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() == eThreadStateRunning)
return;
m_operation_thread =
Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error);
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
}
void *
@ -1714,13 +1709,11 @@ ProcessMonitor::DupDescriptor(const char *path, int fd, int flags)
void
ProcessMonitor::StopMonitoringChildProcess()
{
lldb::thread_result_t thread_result;
if (IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() == eThreadStateRunning)
{
Host::ThreadCancel(m_monitor_thread, NULL);
Host::ThreadJoin(m_monitor_thread, &thread_result, NULL);
m_monitor_thread = LLDB_INVALID_HOST_THREAD;
m_monitor_thread.Cancel();
m_monitor_thread.Join(nullptr);
m_monitor_thread.Reset();
}
}
@ -1764,12 +1757,10 @@ ProcessMonitor::WaitForInitialTIDStop(lldb::tid_t tid)
void
ProcessMonitor::StopOpThread()
{
lldb::thread_result_t result;
if (!IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() != eThreadStateRunning)
return;
Host::ThreadCancel(m_operation_thread, NULL);
Host::ThreadJoin(m_operation_thread, &result, NULL);
m_operation_thread = LLDB_INVALID_HOST_THREAD;
m_operation_thread.Cancel();
m_operation_thread.Join(nullptr);
m_operation_thread.Reset();
}

View File

@ -17,6 +17,7 @@
// C++ Includes
// Other libraries and framework includes
#include "lldb/lldb-types.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private
@ -212,8 +213,8 @@ public:
private:
ProcessFreeBSD *m_process;
lldb::thread_t m_operation_thread;
lldb::thread_t m_monitor_thread;
HostThread m_operation_thread;
HostThread m_monitor_thread;
lldb::pid_t m_pid;
int m_terminal_fd;

View File

@ -45,6 +45,7 @@
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/NativeRegisterContext.h"
#include "lldb/Target/ProcessLaunchInfo.h"
@ -1209,8 +1210,6 @@ NativeProcessLinux::AttachToProcess (
NativeProcessLinux::NativeProcessLinux () :
NativeProcessProtocol (LLDB_INVALID_PROCESS_ID),
m_arch (),
m_operation_thread (LLDB_INVALID_HOST_THREAD),
m_monitor_thread (LLDB_INVALID_HOST_THREAD),
m_operation (nullptr),
m_operation_mutex (),
m_operation_pending (),
@ -1289,7 +1288,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
NativeProcessLinux::MonitorCallback, this, GetID(), true);
if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() != eThreadStateRunning)
{
error.SetErrorToGenericError();
error.SetErrorString ("Process attach failed to create monitor thread for NativeProcessLinux::MonitorCallback.");
@ -1367,7 +1366,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess (
NativeProcessLinux::MonitorCallback, this, GetID (), true);
if (!IS_VALID_LLDB_HOST_THREAD (m_monitor_thread))
if (m_monitor_thread.GetState() != eThreadStateRunning)
{
error.SetErrorToGenericError ();
error.SetErrorString ("Process attach failed to create monitor thread for NativeProcessLinux::MonitorCallback.");
@ -1388,11 +1387,10 @@ NativeProcessLinux::StartLaunchOpThread(LaunchArgs *args, Error &error)
{
static const char *g_thread_name = "lldb.process.nativelinux.operation";
if (IS_VALID_LLDB_HOST_THREAD (m_operation_thread))
if (m_operation_thread.GetState() == eThreadStateRunning)
return;
m_operation_thread =
Host::ThreadCreate (g_thread_name, LaunchOpThread, args, &error);
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
}
void *
@ -1698,11 +1696,10 @@ NativeProcessLinux::StartAttachOpThread(AttachArgs *args, lldb_private::Error &e
{
static const char *g_thread_name = "lldb.process.linux.operation";
if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() == eThreadStateRunning)
return;
m_operation_thread =
Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error);
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
}
void *
@ -3396,13 +3393,11 @@ NativeProcessLinux::DupDescriptor(const char *path, int fd, int flags)
void
NativeProcessLinux::StopMonitoringChildProcess()
{
lldb::thread_result_t thread_result;
if (IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() == eThreadStateRunning)
{
Host::ThreadCancel(m_monitor_thread, NULL);
Host::ThreadJoin(m_monitor_thread, &thread_result, NULL);
m_monitor_thread = LLDB_INVALID_HOST_THREAD;
m_monitor_thread.Cancel();
m_monitor_thread.Join(nullptr);
m_monitor_thread.Reset();
}
}
@ -3424,14 +3419,12 @@ NativeProcessLinux::StopMonitor()
void
NativeProcessLinux::StopOpThread()
{
lldb::thread_result_t result;
if (!IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() != eThreadStateRunning)
return;
Host::ThreadCancel(m_operation_thread, NULL);
Host::ThreadJoin(m_operation_thread, &result, NULL);
m_operation_thread = LLDB_INVALID_HOST_THREAD;
m_operation_thread.Cancel();
m_operation_thread.Join(nullptr);
m_operation_thread.Reset();
}
bool

View File

@ -21,6 +21,7 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/lldb-types.h"
#include "lldb/Host/Debug.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/MemoryRegionInfo.h"
@ -170,8 +171,8 @@ namespace lldb_private
lldb_private::ArchSpec m_arch;
lldb::thread_t m_operation_thread;
lldb::thread_t m_monitor_thread;
HostThread m_operation_thread;
HostThread m_monitor_thread;
// current operation which must be executed on the priviliged thread
void *m_operation;

View File

@ -18,8 +18,12 @@
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostNativeThread.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private-log.h"
#include "llvm/ADT/SmallString.h"
#include "Plugins/Process/Utility/RegisterContextLinux_arm64.h"
#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
@ -65,7 +69,9 @@ NativeThreadLinux::GetName()
return "<unknown: no process>";
// const NativeProcessLinux *const process = reinterpret_cast<NativeProcessLinux*> (process_sp->get ());
return Host::GetThreadName (process_sp->GetID (), GetID ()).c_str ();
llvm::SmallString<32> thread_name;
HostNativeThread::GetName(GetID(), thread_name);
return thread_name.c_str();
}
lldb::StateType

View File

@ -32,6 +32,8 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/PseudoTerminal.h"
@ -1104,7 +1106,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() != eThreadStateRunning)
{
error.SetErrorToGenericError();
error.SetErrorString("Process launch failed.");
@ -1155,7 +1157,7 @@ WAIT_AGAIN:
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() != eThreadStateRunning)
{
error.SetErrorToGenericError();
error.SetErrorString("Process attach failed.");
@ -1175,11 +1177,10 @@ ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Error &error)
{
static const char *g_thread_name = "lldb.process.linux.operation";
if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() == eThreadStateRunning)
return;
m_operation_thread =
Host::ThreadCreate(g_thread_name, LaunchOpThread, args, &error);
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
}
void *
@ -1399,11 +1400,10 @@ ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Error &error
{
static const char *g_thread_name = "lldb.process.linux.operation";
if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() == eThreadStateRunning)
return;
m_operation_thread =
Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error);
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
}
void *
@ -2373,13 +2373,11 @@ ProcessMonitor::DupDescriptor(const char *path, int fd, int flags)
void
ProcessMonitor::StopMonitoringChildProcess()
{
lldb::thread_result_t thread_result;
if (IS_VALID_LLDB_HOST_THREAD(m_monitor_thread))
if (m_monitor_thread.GetState() == eThreadStateRunning)
{
Host::ThreadCancel(m_monitor_thread, NULL);
Host::ThreadJoin(m_monitor_thread, &thread_result, NULL);
m_monitor_thread = LLDB_INVALID_HOST_THREAD;
m_monitor_thread.Cancel();
m_monitor_thread.Join(nullptr);
m_monitor_thread.Reset();
}
}
@ -2400,12 +2398,10 @@ ProcessMonitor::StopMonitor()
void
ProcessMonitor::StopOpThread()
{
lldb::thread_result_t result;
if (!IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
if (m_operation_thread.GetState() != eThreadStateRunning)
return;
Host::ThreadCancel(m_operation_thread, NULL);
Host::ThreadJoin(m_operation_thread, &result, NULL);
m_operation_thread = LLDB_INVALID_HOST_THREAD;
m_operation_thread.Cancel();
m_operation_thread.Join(nullptr);
m_operation_thread.Reset();
}

View File

@ -17,6 +17,7 @@
// C++ Includes
// Other libraries and framework includes
#include "lldb/lldb-types.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private
@ -195,8 +196,8 @@ public:
private:
ProcessLinux *m_process;
lldb::thread_t m_operation_thread;
lldb::thread_t m_monitor_thread;
lldb_private::HostThread m_operation_thread;
lldb_private::HostThread m_monitor_thread;
lldb::pid_t m_pid;
int m_terminal_fd;

View File

@ -23,6 +23,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
@ -176,7 +177,6 @@ ProcessKDP::ProcessKDP(Target& target, Listener &listener) :
Process (target, listener),
m_comm("lldb.process.kdp-remote.communication"),
m_async_broadcaster (NULL, "lldb.process.kdp-remote.async-broadcaster"),
m_async_thread (LLDB_INVALID_HOST_THREAD),
m_dyld_plugin_name (),
m_kernel_load_addr (LLDB_INVALID_ADDRESS),
m_command_sp(),
@ -469,8 +469,8 @@ ProcessKDP::DoResume ()
Error error;
Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS));
// Only start the async thread if we try to do any process control
if (!IS_VALID_LLDB_HOST_THREAD(m_async_thread))
StartAsyncThread ();
if (m_async_thread.GetState() != eThreadStateRunning)
StartAsyncThread();
bool resume = false;
@ -869,12 +869,12 @@ ProcessKDP::StartAsyncThread ()
if (log)
log->Printf ("ProcessKDP::StartAsyncThread ()");
if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))
if (m_async_thread.GetState() == eThreadStateRunning)
return true;
m_async_thread = Host::ThreadCreate ("<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL);
return IS_VALID_LLDB_HOST_THREAD(m_async_thread);
m_async_thread = ThreadLauncher::LaunchThread("<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL);
return m_async_thread.GetState() == eThreadStateRunning;
}
void
@ -888,10 +888,10 @@ ProcessKDP::StopAsyncThread ()
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
// Stop the stdio thread
if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))
if (m_async_thread.GetState() == eThreadStateRunning)
{
Host::ThreadJoin (m_async_thread, NULL, NULL);
m_async_thread = LLDB_INVALID_HOST_THREAD;
m_async_thread.Join(nullptr);
m_async_thread.Reset();
}
}
@ -1003,8 +1003,8 @@ ProcessKDP::AsyncThread (void *arg)
log->Printf ("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 ") thread exiting...",
arg,
pid);
process->m_async_thread = LLDB_INVALID_HOST_THREAD;
process->m_async_thread.Reset();
return NULL;
}

View File

@ -24,6 +24,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
@ -246,7 +247,7 @@ protected:
//------------------------------------------------------------------
CommunicationKDP m_comm;
lldb_private::Broadcaster m_async_broadcaster;
lldb::thread_t m_async_thread;
lldb_private::HostThread m_async_thread;
lldb_private::ConstString m_dyld_plugin_name;
lldb::addr_t m_kernel_load_addr;
lldb::CommandObjectSP m_command_sp;

View File

@ -20,11 +20,13 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostNativeThread.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
#include "llvm/ADT/SmallString.h"
#include "POSIXStopInfo.h"
#include "POSIXThread.h"
#include "ProcessPOSIX.h"
@ -140,7 +142,9 @@ POSIXThread::GetName ()
{
if (!m_thread_name_valid)
{
SetName(Host::GetThreadName(GetProcess()->GetID(), GetID()).c_str());
llvm::SmallString<32> thread_name;
HostNativeThread::GetName(GetID(), thread_name);
m_thread_name = thread_name.c_str();
m_thread_name_valid = true;
}

View File

@ -26,6 +26,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Target/Process.h"
@ -153,7 +154,6 @@ GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
m_history (512),
m_send_acks (true),
m_is_platform (is_platform),
m_listen_thread (LLDB_INVALID_HOST_THREAD),
m_listen_url ()
{
}
@ -606,7 +606,7 @@ Error
GDBRemoteCommunication::StartListenThread (const char *hostname, uint16_t port)
{
Error error;
if (IS_VALID_LLDB_HOST_THREAD(m_listen_thread))
if (m_listen_thread.GetState() == eThreadStateRunning)
{
error.SetErrorString("listen thread already running");
}
@ -619,7 +619,7 @@ GDBRemoteCommunication::StartListenThread (const char *hostname, uint16_t port)
snprintf(listen_url, sizeof(listen_url), "listen://%i", port);
m_listen_url = listen_url;
SetConnection(new ConnectionFileDescriptor());
m_listen_thread = Host::ThreadCreate (listen_url, GDBRemoteCommunication::ListenThread, this, &error);
m_listen_thread = ThreadLauncher::LaunchThread(listen_url, GDBRemoteCommunication::ListenThread, this, &error);
}
return error;
}
@ -627,10 +627,10 @@ GDBRemoteCommunication::StartListenThread (const char *hostname, uint16_t port)
bool
GDBRemoteCommunication::JoinListenThread ()
{
if (IS_VALID_LLDB_HOST_THREAD(m_listen_thread))
if (m_listen_thread.GetState() == eThreadStateRunning)
{
Host::ThreadJoin(m_listen_thread, NULL, NULL);
m_listen_thread = LLDB_INVALID_HOST_THREAD;
m_listen_thread.Join(nullptr);
m_listen_thread.Reset();
}
return true;
}

View File

@ -20,6 +20,7 @@
#include "lldb/lldb-public.h"
#include "lldb/Core/Communication.h"
#include "lldb/Core/Listener.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/TimeValue.h"
@ -281,8 +282,7 @@ protected:
ListenThread (lldb::thread_arg_t arg);
private:
lldb::thread_t m_listen_thread;
lldb_private::HostThread m_listen_thread;
std::string m_listen_url;

View File

@ -42,7 +42,9 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
@ -272,8 +274,6 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
m_last_stop_packet_mutex (Mutex::eMutexTypeNormal),
m_register_info (),
m_async_broadcaster (NULL, "lldb.process.gdb-remote.async-broadcaster"),
m_async_thread (LLDB_INVALID_HOST_THREAD),
m_async_thread_state(eAsyncThreadNotStarted),
m_async_thread_state_mutex(Mutex::eMutexTypeRecursive),
m_thread_ids (),
m_continue_c_tids (),
@ -1432,7 +1432,7 @@ ProcessGDBRemote::DoResume ()
TimeValue timeout;
timeout = TimeValue::Now();
timeout.OffsetWithSeconds (5);
if (!IS_VALID_LLDB_HOST_THREAD(m_async_thread))
if (m_async_thread.GetState() != eThreadStateRunning)
{
error.SetErrorString ("Trying to resume but the async thread is dead.");
if (log)
@ -2891,30 +2891,22 @@ ProcessGDBRemote::StartAsyncThread ()
log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__);
Mutex::Locker start_locker(m_async_thread_state_mutex);
if (m_async_thread_state == eAsyncThreadNotStarted)
if (m_async_thread.GetState() != eThreadStateRunning)
{
// Create a thread that watches our internal state and controls which
// events make it to clients (into the DCProcess event queue).
m_async_thread = Host::ThreadCreate ("<lldb.process.gdb-remote.async>", ProcessGDBRemote::AsyncThread, this, NULL);
if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))
{
m_async_thread_state = eAsyncThreadRunning;
return true;
}
else
return false;
m_async_thread = ThreadLauncher::LaunchThread("<lldb.process.gdb-remote.async>", ProcessGDBRemote::AsyncThread, this, NULL);
}
else
{
// Somebody tried to start the async thread while it was either being started or stopped. If the former, and
// it started up successfully, then say all's well. Otherwise it is an error, since we aren't going to restart it.
if (log)
log->Printf ("ProcessGDBRemote::%s () - Called when Async thread was in state: %d.", __FUNCTION__, m_async_thread_state);
if (m_async_thread_state == eAsyncThreadRunning)
return true;
else
return false;
log->Printf("ProcessGDBRemote::%s () - Called when Async thread was in state: %d.", __FUNCTION__, m_async_thread.GetState());
}
return (m_async_thread.GetState() == eThreadStateRunning);
}
void
@ -2926,7 +2918,7 @@ ProcessGDBRemote::StopAsyncThread ()
log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__);
Mutex::Locker start_locker(m_async_thread_state_mutex);
if (m_async_thread_state == eAsyncThreadRunning)
if (m_async_thread.GetState() == eThreadStateRunning)
{
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
@ -2934,16 +2926,12 @@ ProcessGDBRemote::StopAsyncThread ()
m_gdb_comm.Disconnect(); // Disconnect from the debug server.
// Stop the stdio thread
if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))
{
Host::ThreadJoin (m_async_thread, NULL, NULL);
}
m_async_thread_state = eAsyncThreadDone;
m_async_thread.Join(nullptr);
}
else
{
if (log)
log->Printf ("ProcessGDBRemote::%s () - Called when Async thread was in state: %d.", __FUNCTION__, m_async_thread_state);
log->Printf("ProcessGDBRemote::%s () - Called when Async thread was in state: %d.", __FUNCTION__, m_async_thread.GetState());
}
}
@ -3086,7 +3074,7 @@ ProcessGDBRemote::AsyncThread (void *arg)
if (log)
log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") thread exiting...", __FUNCTION__, arg, process->GetID());
process->m_async_thread = LLDB_INVALID_HOST_THREAD;
process->m_async_thread.Reset();
return NULL;
}

View File

@ -25,6 +25,7 @@
#include "lldb/Core/StringList.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Host/HostThread.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
@ -324,13 +325,6 @@ protected:
eBroadcastBitAsyncThreadShouldExit = (1 << 1),
eBroadcastBitAsyncThreadDidExit = (1 << 2)
};
typedef enum AsyncThreadState
{
eAsyncThreadNotStarted,
eAsyncThreadRunning,
eAsyncThreadDone
} AsyncThreadState;
lldb_private::Flags m_flags; // Process specific flags (see eFlags enums)
GDBRemoteCommunicationClient m_gdb_comm;
@ -339,8 +333,7 @@ protected:
lldb_private::Mutex m_last_stop_packet_mutex;
GDBRemoteDynamicRegisterInfo m_register_info;
lldb_private::Broadcaster m_async_broadcaster;
lldb::thread_t m_async_thread;
AsyncThreadState m_async_thread_state;
lldb_private::HostThread m_async_thread;
lldb_private::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;

View File

@ -27,8 +27,10 @@
#include "lldb/Expression/ClangUserExpression.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/JITLoader.h"
@ -680,7 +682,6 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
m_private_state_control_broadcaster (NULL, "lldb.process.internal_state_control_broadcaster"),
m_private_state_listener ("lldb.process.internal_state_listener"),
m_private_state_control_wait(),
m_private_state_thread (LLDB_INVALID_HOST_THREAD),
m_mod_id (),
m_process_unique_id(0),
m_thread_index_id (0),
@ -770,6 +771,11 @@ Process::~Process()
if (log)
log->Printf ("%p Process::~Process()", static_cast<void*>(this));
StopPrivateStateThread();
// ThreadList::Clear() will try to acquire this process's mutex, so
// explicitly clear the thread list here to ensure that the mutex
// is not destroyed before the thread list.
m_thread_list.Clear();
}
const ProcessPropertiesSP &
@ -3833,26 +3839,25 @@ Process::StartPrivateStateThread (bool force)
// events make it to clients (into the DCProcess event queue).
char thread_name[1024];
if (Host::MAX_THREAD_NAME_LENGTH <= 16)
if (HostInfo::GetMaxThreadNameLength() <= 30)
{
// On platforms with abbreviated thread name lengths, choose thread names that fit within the limit.
if (already_running)
snprintf(thread_name, sizeof(thread_name), "intern-state-OV");
else
snprintf(thread_name, sizeof(thread_name), "intern-state");
// On platforms with abbreviated thread name lengths, choose thread names that fit within the limit.
if (already_running)
snprintf(thread_name, sizeof(thread_name), "intern-state-OV");
else
snprintf(thread_name, sizeof(thread_name), "intern-state");
}
else
{
if (already_running)
snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state-override(pid=%" PRIu64 ")>", GetID());
snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state-override(pid=%" PRIu64 ")>", GetID());
else
snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state(pid=%" PRIu64 ")>", GetID());
snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state(pid=%" PRIu64 ")>", GetID());
}
// Create the private state thread, and start it running.
m_private_state_thread = Host::ThreadCreate (thread_name, Process::PrivateStateThread, this, NULL);
bool success = IS_VALID_LLDB_HOST_THREAD(m_private_state_thread);
if (success)
m_private_state_thread = ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread, this, NULL);
if (m_private_state_thread.GetState() == eThreadStateRunning)
{
ResumePrivateStateThread();
return true;
@ -3901,8 +3906,8 @@ Process::ControlPrivateStateThread (uint32_t signal)
// Signal the private state thread. First we should copy this is case the
// thread starts exiting since the private state thread will NULL this out
// when it exits
const lldb::thread_t private_state_thread = m_private_state_thread;
if (IS_VALID_LLDB_HOST_THREAD(private_state_thread))
HostThread private_state_thread(m_private_state_thread);
if (private_state_thread.GetState() == eThreadStateRunning)
{
TimeValue timeout_time;
bool timed_out;
@ -3920,8 +3925,7 @@ Process::ControlPrivateStateThread (uint32_t signal)
{
if (timed_out)
{
Error error;
Host::ThreadCancel (private_state_thread, &error);
Error error = private_state_thread.Cancel();
if (log)
log->Printf ("Timed out responding to the control event, cancel got error: \"%s\".", error.AsCString());
}
@ -3932,8 +3936,8 @@ Process::ControlPrivateStateThread (uint32_t signal)
}
thread_result_t result = NULL;
Host::ThreadJoin (private_state_thread, &result, NULL);
m_private_state_thread = LLDB_INVALID_HOST_THREAD;
private_state_thread.Join(&result);
m_private_state_thread.Reset();
}
}
else
@ -4177,7 +4181,7 @@ Process::RunPrivateStateThread ()
m_public_run_lock.SetStopped();
m_private_state_control_wait.SetValue (true, eBroadcastAlways);
m_private_state_thread = LLDB_INVALID_HOST_THREAD;
m_private_state_thread.Reset();
return NULL;
}
@ -4954,12 +4958,12 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
selected_tid = LLDB_INVALID_THREAD_ID;
}
lldb::thread_t backup_private_state_thread = LLDB_INVALID_HOST_THREAD;
HostThread backup_private_state_thread;
lldb::StateType old_state;
lldb::ThreadPlanSP stopper_base_plan_sp;
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS));
if (Host::GetCurrentThread() == m_private_state_thread)
if (m_private_state_thread.EqualsThread(Host::GetCurrentThread()))
{
// Yikes, we are running on the private state thread! So we can't wait for public events on this thread, since
// we are the thread that is generating public events.
@ -5564,7 +5568,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
} // END WAIT LOOP
// If we had to start up a temporary private state thread to run this thread plan, shut it down now.
if (IS_VALID_LLDB_HOST_THREAD(backup_private_state_thread))
if (backup_private_state_thread.GetState() != eThreadStateInvalid)
{
StopPrivateStateThread();
Error error;

View File

@ -32,8 +32,10 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
@ -54,7 +56,7 @@ using namespace lldb_private;
namespace
{
lldb::thread_t s_listen_thread = LLDB_INVALID_HOST_THREAD;
HostThread s_listen_thread;
std::unique_ptr<ConnectionFileDescriptor> s_listen_connection_up;
std::string s_listen_url;
}
@ -279,7 +281,7 @@ static Error
StartListenThread (const char *hostname, uint16_t port)
{
Error error;
if (IS_VALID_LLDB_HOST_THREAD(s_listen_thread))
if (s_listen_thread.GetState() == eThreadStateRunning)
{
error.SetErrorString("listen thread already running");
}
@ -293,7 +295,7 @@ StartListenThread (const char *hostname, uint16_t port)
s_listen_url = listen_url;
s_listen_connection_up.reset (new ConnectionFileDescriptor ());
s_listen_thread = Host::ThreadCreate (listen_url, ListenThread, nullptr, &error);
s_listen_thread = ThreadLauncher::LaunchThread(listen_url, ListenThread, nullptr, &error);
}
return error;
}
@ -301,10 +303,10 @@ StartListenThread (const char *hostname, uint16_t port)
static bool
JoinListenThread ()
{
if (IS_VALID_LLDB_HOST_THREAD(s_listen_thread))
if (s_listen_thread.GetState() == eThreadStateRunning)
{
Host::ThreadJoin(s_listen_thread, nullptr, nullptr);
s_listen_thread = LLDB_INVALID_HOST_THREAD;
s_listen_thread.Join(nullptr);
s_listen_thread.Reset();
}
return true;
}