Vendor import of lldb trunk r308421:

https://llvm.org/svn/llvm-project/lldb/trunk@308421
This commit is contained in:
Dimitry Andric 2017-07-19 07:03:07 +00:00
parent e75e363cb7
commit a884e64959
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/lldb/dist/; revision=321194
svn path=/vendor/lldb/lldb-trunk-r308421/; revision=321195; tag=vendor/lldb/lldb-trunk-r308421
68 changed files with 508 additions and 647 deletions

View file

@ -10,15 +10,20 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darw
set(LLDB_LINKER_SUPPORTS_GROUPS ON)
endif()
set(LLDB_DEFAULT_DISABLE_PYTHON 0)
set(LLDB_DEFAULT_DISABLE_CURSES 0)
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
set(LLDB_DEFAULT_DISABLE_PYTHON 0)
set(LLDB_DEFAULT_DISABLE_CURSES 1)
elseif (CMAKE_SYSTEM_NAME MATCHES "Android" )
set(LLDB_DEFAULT_DISABLE_PYTHON 1)
set(LLDB_DEFAULT_DISABLE_CURSES 1)
else()
set(LLDB_DEFAULT_DISABLE_PYTHON 0)
set(LLDB_DEFAULT_DISABLE_CURSES 0)
elseif(IOS)
set(LLDB_DEFAULT_DISABLE_PYTHON 1)
endif()
if(IOS)
add_definitions(-DNO_XPC_SERVICES)
endif()
set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL
@ -298,13 +303,15 @@ if (NOT LIBXML2_FOUND AND NOT (CMAKE_SYSTEM_NAME MATCHES "Windows"))
endif()
# Find libraries or frameworks that may be needed
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_library(CARBON_LIBRARY Carbon)
if (APPLE)
if(NOT IOS)
find_library(CARBON_LIBRARY Carbon)
find_library(CORE_SERVICES_LIBRARY CoreServices)
find_library(DEBUG_SYMBOLS_LIBRARY DebugSymbols PATHS "/System/Library/PrivateFrameworks")
endif()
find_library(FOUNDATION_LIBRARY Foundation)
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
find_library(CORE_SERVICES_LIBRARY CoreServices)
find_library(SECURITY_LIBRARY Security)
find_library(DEBUG_SYMBOLS_LIBRARY DebugSymbols PATHS "/System/Library/PrivateFrameworks")
set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Output directory for LLDB.framework")
set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
@ -312,10 +319,13 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources)
add_definitions( -DLIBXML2_DEFINED )
list(APPEND system_libs xml2 ${CURSES_LIBRARIES})
list(APPEND system_libs ${CARBON_LIBRARY} ${FOUNDATION_LIBRARY}
${CORE_FOUNDATION_LIBRARY} ${CORE_SERVICES_LIBRARY} ${SECURITY_LIBRARY}
${DEBUG_SYMBOLS_LIBRARY})
list(APPEND system_libs xml2
${CURSES_LIBRARIES}
${FOUNDATION_LIBRARY}
${CORE_FOUNDATION_LIBRARY}
${CORE_SERVICES_LIBRARY}
${SECURITY_LIBRARY}
${DEBUG_SYMBOLS_LIBRARY})
else()
if (LIBXML2_FOUND)

View file

@ -2,7 +2,6 @@
# standalone project, using LLVM as an external library:
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(lldb)
cmake_minimum_required(VERSION 2.8.12.2)
if (POLICY CMP0022)
cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required

View file

@ -12,8 +12,8 @@
#include "lldb/Host/Config.h"
#include "lldb/Host/MainLoopBase.h"
#include "llvm/ADT/DenseMap.h"
#include <csignal>
#if !HAVE_PPOLL && !HAVE_SYS_EVENT_H
#define SIGNAL_POLLING_UNSUPPORTED 1

View file

@ -16,6 +16,8 @@
#if defined(_WIN32)
#include "lldb/Host/windows/PosixApi.h"
#else
#include <unistd.h>
#endif
#endif

View file

@ -151,6 +151,11 @@ class SocketAddress {
//------------------------------------------------------------------
bool IsAnyAddr() const;
//------------------------------------------------------------------
// Returns true if the socket is INADDR_LOOPBACK
//------------------------------------------------------------------
bool IsLocalhost() const;
//------------------------------------------------------------------
// Direct access to all of the sockaddr structures
//------------------------------------------------------------------

View file

@ -33,8 +33,7 @@ class ResumeActionList;
//------------------------------------------------------------------
// NativeProcessProtocol
//------------------------------------------------------------------
class NativeProcessProtocol
: public std::enable_shared_from_this<NativeProcessProtocol> {
class NativeProcessProtocol {
friend class SoftwareBreakpoint;
public:
@ -268,7 +267,7 @@ class NativeProcessProtocol
/// A NativeProcessProtocol shared pointer if the operation succeeded or
/// an error object if it failed.
//------------------------------------------------------------------
virtual llvm::Expected<NativeProcessProtocolSP>
virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
MainLoop &mainloop) const = 0;
@ -292,7 +291,7 @@ class NativeProcessProtocol
/// A NativeProcessProtocol shared pointer if the operation succeeded or
/// an error object if it failed.
//------------------------------------------------------------------
virtual llvm::Expected<NativeProcessProtocolSP>
virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
MainLoop &mainloop) const = 0;
};

View file

@ -23,7 +23,7 @@ namespace lldb_private {
class NativeThreadProtocol
: public std::enable_shared_from_this<NativeThreadProtocol> {
public:
NativeThreadProtocol(NativeProcessProtocol *process, lldb::tid_t tid);
NativeThreadProtocol(NativeProcessProtocol &process, lldb::tid_t tid);
virtual ~NativeThreadProtocol() {}
@ -46,7 +46,7 @@ class NativeThreadProtocol
lldb::tid_t GetID() const { return m_tid; }
NativeProcessProtocolSP GetProcess();
NativeProcessProtocol &GetProcess() { return m_process; }
// ---------------------------------------------------------------------
// Thread-specific watchpoints
@ -64,7 +64,7 @@ class NativeThreadProtocol
virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr) = 0;
protected:
NativeProcessProtocolWP m_process_wp;
NativeProcessProtocol &m_process;
lldb::tid_t m_tid;
};
}

View file

@ -539,7 +539,7 @@ class CommandInterpreter : public Broadcaster,
std::string m_repeat_command; // Stores the command that will be executed for
// an empty command string.
lldb::ScriptInterpreterSP m_script_interpreter_sp;
std::mutex m_script_interpreter_mutex;
std::recursive_mutex m_script_interpreter_mutex;
lldb::IOHandlerSP m_command_io_handler_sp;
char m_comment_char;
bool m_batch_command_mode;

View file

@ -15,6 +15,7 @@
#include "lldb/lldb-forward.h" // for DataBufferSP
#include "lldb/lldb-types.h"
#include <cassert>
#include <stdint.h>
#include <string.h>

View file

@ -30,10 +30,6 @@ class UnixSignals;
// SP/WP decls.
// ---------------------------------------------------------------
typedef std::shared_ptr<NativeBreakpoint> NativeBreakpointSP;
typedef std::shared_ptr<lldb_private::NativeProcessProtocol>
NativeProcessProtocolSP;
typedef std::weak_ptr<lldb_private::NativeProcessProtocol>
NativeProcessProtocolWP;
typedef std::shared_ptr<lldb_private::NativeRegisterContext>
NativeRegisterContextSP;
typedef std::shared_ptr<lldb_private::NativeThreadProtocol>

View file

@ -13,16 +13,10 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include <assert.h>
#include <signal.h>
#include <stdint.h>
//----------------------------------------------------------------------
// All host systems must define:
// lldb::condition_t The native condition type (or a substitute class)
// for conditions on the host system.
// lldb::mutex_t The native mutex type for mutex objects on the host
// system.
// lldb::thread_t The native thread type for spawned threads on the
// system
// lldb::thread_arg_t The type of the one any only thread creation
@ -34,32 +28,22 @@
// #define LLDB_INVALID_PROCESS_ID ...
// #define LLDB_INVALID_THREAD_ID ...
// #define LLDB_INVALID_HOST_THREAD ...
// #define IS_VALID_LLDB_HOST_THREAD ...
//----------------------------------------------------------------------
// TODO: Add a bunch of ifdefs to determine the host system and what
// things should be defined. Currently MacOSX is being assumed by default
// since that is what lldb was first developed for.
#ifndef _MSC_VER
#include <stdbool.h>
#include <unistd.h>
#endif
#ifdef _WIN32
#include <process.h>
namespace lldb {
typedef void *mutex_t;
typedef void *condition_t;
typedef void *rwlock_t;
typedef void *process_t; // Process type is HANDLE
typedef void *thread_t; // Host thread type
typedef void *file_t; // Host file type
typedef void *pipe_t; // Host pipe type
typedef unsigned int __w64 socket_t; // Host socket type
typedef uint32_t thread_key_t;
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
@ -73,15 +57,11 @@ namespace lldb {
//----------------------------------------------------------------------
// MacOSX Types
//----------------------------------------------------------------------
typedef ::pthread_mutex_t mutex_t;
typedef pthread_cond_t condition_t;
typedef pthread_rwlock_t rwlock_t;
typedef uint64_t process_t; // Process type is just a pid.
typedef pthread_t thread_t; // Host thread type
typedef int file_t; // Host file type
typedef int pipe_t; // Host pipe type
typedef int socket_t; // Host socket type
typedef pthread_key_t thread_key_t;
typedef void *thread_arg_t; // Host thread argument type
typedef void *thread_result_t; // Host thread result type
typedef void *(*thread_func_t)(void *); // Host thread function type
@ -100,10 +80,6 @@ typedef bool (*ExpressionCancelCallback)(ExpressionEvaluationPhase phase,
#define LLDB_INVALID_PROCESS ((lldb::process_t)-1)
#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD)
#define LLDB_INVALID_HOST_TIME \
{ 0, 0 }
namespace lldb {
typedef uint64_t addr_t;

View file

@ -23,32 +23,8 @@ class UnwindFromExpressionTest(TestBase):
def build_and_run_to_bkpt(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
# Create the breakpoint.
breakpoint = target.BreakpointCreateBySourceRegex(
"// Set a breakpoint here to get started", self.main_spec)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.LaunchProcess() failed")
if process.GetState() != lldb.eStateStopped:
self.fail("Process should be in the 'stopped' state, "
"instead the actual state is: '%s'" %
lldbutil.state_type_to_str(process.GetState()))
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
process, breakpoint)
self.assertIsNotNone(
self.thread, "Expected one thread to be stopped at the breakpoint")
(target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
"// Set a breakpoint here to get started", self.main_spec)
# Next set a breakpoint in this function, set up Expression options to stop on
# breakpoint hits, and call the function.

View file

@ -30,46 +30,13 @@ def setUp(self):
def address_breakpoints(self):
"""Test that breakpoints set on a bad address say they are bad."""
exe = os.path.join(os.getcwd(), "a.out")
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateBySourceRegex(
"Set a breakpoint here", lldb.SBFileSpec("main.c"))
self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
# Get the breakpoint location from breakpoint after we verified that,
# indeed, it has one location.
location = breakpoint.GetLocationAtIndex(0)
self.assertTrue(location and
location.IsEnabled(),
VALID_BREAKPOINT_LOCATION)
launch_info = lldb.SBLaunchInfo(None)
error = lldb.SBError()
process = target.Launch(launch_info, error)
self.assertTrue(process, PROCESS_IS_VALID)
# Did we hit our breakpoint?
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
threads = get_threads_stopped_at_breakpoint(process, breakpoint)
self.assertTrue(
len(threads) == 1,
"There should be a thread stopped at our breakpoint")
# The hit count for the breakpoint should be 1.
self.assertTrue(breakpoint.GetHitCount() == 1)
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
"Set a breakpoint here", lldb.SBFileSpec("main.c"))
# Now see if we can read from 0. If I can't do that, I don't have a good way to know
# what an illegal address is...
error.Clear()
error = lldb.SBError()
ptr = process.ReadPointerFromMemory(0x0, error)

View file

@ -18,29 +18,9 @@ class ConsecutiveBreakpointsTestCase(TestBase):
def prepare_test(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
# Create a target by the debugger.
self.target = self.dbg.CreateTarget(exe)
self.assertTrue(self.target, VALID_TARGET)
breakpoint1 = self.target.BreakpointCreateBySourceRegex(
"Set breakpoint here", lldb.SBFileSpec("main.cpp"))
self.assertTrue(
breakpoint1 and breakpoint1.GetNumLocations() == 1,
VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
self.process = self.target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertIsNotNone(self.process, PROCESS_IS_VALID)
# We should be stopped at the first breakpoint
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
self.process, breakpoint1)
self.assertIsNotNone(
self.thread,
"Expected one thread to be stopped at breakpoint 1")
(self.target, self.process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(
self, "Set breakpoint here", lldb.SBFileSpec("main.cpp"))
# Set breakpoint to the next instruction
frame = self.thread.GetFrameAtIndex(0)

View file

@ -103,6 +103,10 @@ else()
macosx/cfcpp/CFCMutableSet.cpp
macosx/cfcpp/CFCString.cpp
)
if(IOS)
set_property(SOURCE macosx/Host.mm APPEND PROPERTY
COMPILE_DEFINITIONS "NO_XPC_SERVICES=1")
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")

View file

@ -21,6 +21,7 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
#endif
#include "llvm/Support/ConvertUTF.h"

View file

@ -46,6 +46,7 @@
#endif
// C++ Includes
#include <csignal>
// Other libraries and framework includes
// Project includes

View file

@ -10,6 +10,7 @@
#include "llvm/Config/llvm-config.h"
#include "lldb/Host/MainLoop.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Utility/Status.h"
#include <algorithm>
#include <cassert>

View file

@ -345,17 +345,12 @@ Status NativeRegisterContext::ReadRegisterValueFromMemory(
return error;
}
NativeProcessProtocolSP process_sp(m_thread.GetProcess());
if (!process_sp) {
error.SetErrorString("invalid process");
return error;
}
NativeProcessProtocol &process = m_thread.GetProcess();
uint8_t src[RegisterValue::kMaxRegisterByteSize];
// Read the memory
size_t bytes_read;
error = process_sp->ReadMemory(src_addr, src, src_len, bytes_read);
error = process.ReadMemory(src_addr, src, src_len, bytes_read);
if (error.Fail())
return error;
@ -374,7 +369,7 @@ Status NativeRegisterContext::ReadRegisterValueFromMemory(
// order of the memory data doesn't match the process. For now we are assuming
// they are the same.
lldb::ByteOrder byte_order;
if (!process_sp->GetByteOrder(byte_order)) {
if (process.GetByteOrder(byte_order)) {
error.SetErrorString("NativeProcessProtocol::GetByteOrder () failed");
return error;
}
@ -392,41 +387,37 @@ Status NativeRegisterContext::WriteRegisterValueToMemory(
Status error;
NativeProcessProtocolSP process_sp(m_thread.GetProcess());
if (process_sp) {
NativeProcessProtocol &process = m_thread.GetProcess();
// TODO: we might need to add a parameter to this function in case the byte
// order of the memory data doesn't match the process. For now we are
// assuming
// they are the same.
lldb::ByteOrder byte_order;
if (!process_sp->GetByteOrder(byte_order))
return Status("NativeProcessProtocol::GetByteOrder () failed");
// TODO: we might need to add a parameter to this function in case the byte
// order of the memory data doesn't match the process. For now we are
// assuming
// they are the same.
lldb::ByteOrder byte_order;
if (!process.GetByteOrder(byte_order))
return Status("NativeProcessProtocol::GetByteOrder () failed");
const size_t bytes_copied =
reg_value.GetAsMemoryData(reg_info, dst, dst_len, byte_order, error);
const size_t bytes_copied =
reg_value.GetAsMemoryData(reg_info, dst, dst_len, byte_order, error);
if (error.Success()) {
if (bytes_copied == 0) {
error.SetErrorString("byte copy failed.");
} else {
size_t bytes_written;
error =
process_sp->WriteMemory(dst_addr, dst, bytes_copied, bytes_written);
if (error.Fail())
return error;
if (error.Success()) {
if (bytes_copied == 0) {
error.SetErrorString("byte copy failed.");
} else {
size_t bytes_written;
error = process.WriteMemory(dst_addr, dst, bytes_copied, bytes_written);
if (error.Fail())
return error;
if (bytes_written != bytes_copied) {
// This might happen if we read _some_ bytes but not all
error.SetErrorStringWithFormat("only wrote %" PRIu64 " of %" PRIu64
" bytes",
static_cast<uint64_t>(bytes_written),
static_cast<uint64_t>(bytes_copied));
}
if (bytes_written != bytes_copied) {
// This might happen if we read _some_ bytes but not all
error.SetErrorStringWithFormat("only wrote %" PRIu64 " of %" PRIu64
" bytes",
static_cast<uint64_t>(bytes_written),
static_cast<uint64_t>(bytes_copied));
}
}
} else
error.SetErrorString("invalid process");
}
return error;
}

View file

@ -16,9 +16,9 @@
using namespace lldb;
using namespace lldb_private;
NativeThreadProtocol::NativeThreadProtocol(NativeProcessProtocol *process,
NativeThreadProtocol::NativeThreadProtocol(NativeProcessProtocol &process,
lldb::tid_t tid)
: m_process_wp(process->shared_from_this()), m_tid(tid) {}
: m_process(process), m_tid(tid) {}
Status NativeThreadProtocol::ReadRegister(uint32_t reg,
RegisterValue &reg_value) {
@ -62,7 +62,3 @@ Status NativeThreadProtocol::RestoreAllRegisters(lldb::DataBufferSP &data_sp) {
return Status("no register context");
return register_context_sp->ReadAllRegisterValues(data_sp);
}
NativeProcessProtocolSP NativeThreadProtocol::GetProcess() {
return m_process_wp.lock();
}

View file

@ -29,6 +29,7 @@
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#endif
#ifdef __linux__

View file

@ -317,6 +317,13 @@ bool SocketAddress::IsAnyAddr() const {
: 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr, &in6addr_any, 16);
}
bool SocketAddress::IsLocalhost() const {
return (GetFamily() == AF_INET)
? m_socket_addr.sa_ipv4.sin_addr.s_addr == htonl(INADDR_LOOPBACK)
: 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr, &in6addr_loopback,
16);
}
bool SocketAddress::operator==(const SocketAddress &rhs) const {
if (GetFamily() != rhs.GetFamily())
return false;

View file

@ -34,6 +34,7 @@
#define CLOSE_SOCKET closesocket
typedef const char *set_socket_option_arg_type;
#else
#include <unistd.h>
#define CLOSE_SOCKET ::close
typedef const void *set_socket_option_arg_type;
#endif

View file

@ -16,6 +16,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
// C++ Includes
// Other libraries and framework includes

View file

@ -16,6 +16,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <algorithm>
#include <mutex> // std::once

View file

@ -30,6 +30,7 @@
#ifndef LLDB_DISABLE_POSIX
#include <termios.h>
#include <unistd.h>
#endif
// C++ Includes

View file

@ -15,6 +15,7 @@
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef __linux__
#include <linux/magic.h>
#include <sys/mount.h>

View file

@ -13,7 +13,9 @@
#include "llvm/ADT/STLExtras.h"
#include <csignal>
#include <limits.h>
#include <unistd.h>
using namespace lldb_private;

View file

@ -10,6 +10,7 @@
#include "lldb/Host/posix/LockFilePosix.h"
#include <fcntl.h>
#include <unistd.h>
using namespace lldb;
using namespace lldb_private;

View file

@ -19,8 +19,10 @@
#include <limits.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sstream>
#include <csignal>
#ifdef __ANDROID__
#include <android/api-level.h>

View file

@ -2475,7 +2475,7 @@ void CommandInterpreter::HandleCommandsFromFile(
}
ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create) {
std::lock_guard<std::mutex> locker(m_script_interpreter_mutex);
std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
if (!m_script_interpreter_sp) {
if (!can_create)
return nullptr;

View file

@ -7,24 +7,12 @@
//
//===----------------------------------------------------------------------===//
// C Includes
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
// C++ Includes
// Other libraries and framework includes
#include "AuxVector.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
#if defined(__linux__) || defined(__FreeBSD__)
#include "Plugins/Process/elf-core/ProcessElfCore.h"
#endif
#include "AuxVector.h"
using namespace lldb;
using namespace lldb_private;

View file

@ -451,16 +451,16 @@ void ClangModulesDeclVendorImpl::ForEachMacro(
bool first_arg = true;
for (clang::MacroInfo::arg_iterator ai = macro_info->arg_begin(),
ae = macro_info->arg_end();
ai != ae; ++ai) {
for (auto pi = macro_info->param_begin(),
pe = macro_info->param_end();
pi != pe; ++pi) {
if (!first_arg) {
macro_expansion.append(", ");
} else {
first_arg = false;
}
macro_expansion.append((*ai)->getName().str());
macro_expansion.append((*pi)->getName().str());
}
if (macro_info->isC99Varargs()) {

View file

@ -274,6 +274,28 @@ bool CPlusPlusNameParser::ConsumeAnonymousNamespace() {
return true;
}
bool CPlusPlusNameParser::ConsumeLambda() {
Bookmark start_position = SetBookmark();
if (!ConsumeToken(tok::l_brace)) {
return false;
}
constexpr llvm::StringLiteral g_lambda("lambda");
if (HasMoreTokens() && Peek().is(tok::raw_identifier) &&
Peek().getRawIdentifier() == g_lambda) {
// Put the matched brace back so we can use ConsumeBrackets
TakeBack();
} else {
return false;
}
if (!ConsumeBrackets(tok::l_brace, tok::r_brace)) {
return false;
}
start_position.Remove();
return true;
}
bool CPlusPlusNameParser::ConsumeBrackets(tok::TokenKind left,
tok::TokenKind right) {
Bookmark start_position = SetBookmark();
@ -502,6 +524,15 @@ CPlusPlusNameParser::ParseFullNameImpl() {
state = State::AfterTwoColons;
break;
}
case tok::l_brace:
if (state == State::Beginning || state == State::AfterTwoColons) {
if (ConsumeLambda()) {
state = State::AfterIdentifier;
break;
}
}
continue_parsing = false;
break;
case tok::coloncolon: // Type nesting delimiter.
if (state != State::Beginning && state != State::AfterIdentifier &&
state != State::AfterTemplate) {

View file

@ -143,6 +143,9 @@ class CPlusPlusNameParser {
// Consumes '(anonymous namespace)'
bool ConsumeAnonymousNamespace();
// Consumes '{lambda ...}'
bool ConsumeLambda();
// Consumes operator declaration like 'operator *' or 'operator delete []'
bool ConsumeOperator();

View file

@ -23,6 +23,7 @@
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"

View file

@ -214,7 +214,7 @@ static Status EnsureFDFlags(int fd, int flags) {
// Public Static Methods
// -----------------------------------------------------------------------------
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
NativeProcessLinux::Factory::Launch(ProcessLaunchInfo &launch_info,
NativeDelegate &native_delegate,
MainLoop &mainloop) const {
@ -259,14 +259,13 @@ NativeProcessLinux::Factory::Launch(ProcessLaunchInfo &launch_info,
return status.ToError();
}
std::shared_ptr<NativeProcessLinux> process_sp(new NativeProcessLinux(
return std::unique_ptr<NativeProcessLinux>(new NativeProcessLinux(
pid, launch_info.GetPTY().ReleaseMasterFileDescriptor(), native_delegate,
arch, mainloop));
process_sp->InitializeThreads({pid});
return process_sp;
arch, mainloop, {pid}));
}
llvm::Expected<NativeProcessProtocolSP> NativeProcessLinux::Factory::Attach(
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
NativeProcessLinux::Factory::Attach(
lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
MainLoop &mainloop) const {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
@ -282,10 +281,8 @@ llvm::Expected<NativeProcessProtocolSP> NativeProcessLinux::Factory::Attach(
if (!tids_or)
return tids_or.takeError();
std::shared_ptr<NativeProcessLinux> process_sp(
new NativeProcessLinux(pid, -1, native_delegate, arch, mainloop));
process_sp->InitializeThreads(*tids_or);
return process_sp;
return std::unique_ptr<NativeProcessLinux>(new NativeProcessLinux(
pid, -1, native_delegate, arch, mainloop, *tids_or));
}
// -----------------------------------------------------------------------------
@ -294,7 +291,8 @@ llvm::Expected<NativeProcessProtocolSP> NativeProcessLinux::Factory::Attach(
NativeProcessLinux::NativeProcessLinux(::pid_t pid, int terminal_fd,
NativeDelegate &delegate,
const ArchSpec &arch, MainLoop &mainloop)
const ArchSpec &arch, MainLoop &mainloop,
llvm::ArrayRef<::pid_t> tids)
: NativeProcessProtocol(pid, terminal_fd, delegate), m_arch(arch) {
if (m_terminal_fd != -1) {
Status status = EnsureFDFlags(m_terminal_fd, O_NONBLOCK);
@ -305,9 +303,7 @@ NativeProcessLinux::NativeProcessLinux(::pid_t pid, int terminal_fd,
m_sigchld_handle = mainloop.RegisterSignal(
SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status);
assert(m_sigchld_handle && status.Success());
}
void NativeProcessLinux::InitializeThreads(llvm::ArrayRef<::pid_t> tids) {
for (const auto &tid : tids) {
NativeThreadLinuxSP thread_sp = AddThread(tid);
assert(thread_sp && "AddThread() returned a nullptr thread");
@ -2009,7 +2005,7 @@ NativeThreadLinuxSP NativeProcessLinux::AddThread(lldb::tid_t thread_id) {
if (m_threads.empty())
SetCurrentThreadID(thread_id);
auto thread_sp = std::make_shared<NativeThreadLinux>(this, thread_id);
auto thread_sp = std::make_shared<NativeThreadLinux>(*this, thread_id);
m_threads.push_back(thread_sp);
if (m_pt_proces_trace_id != LLDB_INVALID_UID) {

View file

@ -10,7 +10,7 @@
#ifndef liblldb_NativeProcessLinux_H_
#define liblldb_NativeProcessLinux_H_
// C++ Includes
#include <csignal>
#include <unordered_set>
// Other libraries and framework includes
@ -42,11 +42,11 @@ class NativeProcessLinux : public NativeProcessProtocol {
public:
class Factory : public NativeProcessProtocol::Factory {
public:
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
MainLoop &mainloop) const override;
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
MainLoop &mainloop) const override;
};
@ -160,15 +160,14 @@ class NativeProcessLinux : public NativeProcessProtocol {
// Private Instance Methods
// ---------------------------------------------------------------------
NativeProcessLinux(::pid_t pid, int terminal_fd, NativeDelegate &delegate,
const ArchSpec &arch, MainLoop &mainloop);
const ArchSpec &arch, MainLoop &mainloop,
llvm::ArrayRef<::pid_t> tids);
// Returns a list of process threads that we have attached to.
static llvm::Expected<std::vector<::pid_t>> Attach(::pid_t pid);
static Status SetDefaultPtraceOpts(const lldb::pid_t);
void InitializeThreads(llvm::ArrayRef<::pid_t> tids);
void MonitorCallback(lldb::pid_t pid, bool exited, WaitStatus status);
void WaitForNewThread(::pid_t tid);

View file

@ -30,11 +30,7 @@ lldb::ByteOrder NativeRegisterContextLinux::GetByteOrder() const {
// read.
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid;
NativeProcessProtocolSP process_sp(m_thread.GetProcess());
if (!process_sp)
return byte_order;
if (!process_sp->GetByteOrder(byte_order)) {
if (!m_thread.GetProcess().GetByteOrder(byte_order)) {
// FIXME log here
}

View file

@ -873,7 +873,7 @@ Status NativeRegisterContextLinux_arm64::DoReadRegisterValue(
PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, sizeof regs);
if (error.Success()) {
ArchSpec arch;
if (m_thread.GetProcess()->GetArchitecture(arch))
if (m_thread.GetProcess().GetArchitecture(arch))
value.SetBytes((void *)(((unsigned char *)(&regs)) + offset), 16,
arch.GetByteOrder());
else
@ -890,7 +890,7 @@ Status NativeRegisterContextLinux_arm64::DoReadRegisterValue(
PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, sizeof regs);
if (error.Success()) {
ArchSpec arch;
if (m_thread.GetProcess()->GetArchitecture(arch))
if (m_thread.GetProcess().GetArchitecture(arch))
value.SetBytes((void *)(((unsigned char *)(regs)) + offset), 8,
arch.GetByteOrder());
else

View file

@ -953,7 +953,7 @@ NativeRegisterContextLinux_mips64::GetWatchpointHitAddress(uint32_t wp_index) {
return LLDB_INVALID_ADDRESS;
EmulatorBaton baton(
static_cast<NativeProcessLinux *>(m_thread.GetProcess().get()), this);
static_cast<NativeProcessLinux *>(&m_thread.GetProcess()), this);
emulator_ap->SetBaton(&baton);
emulator_ap->SetReadMemCallback(&ReadMemoryCallback);
emulator_ap->SetReadRegCallback(&ReadRegisterCallback);
@ -1034,7 +1034,7 @@ Status NativeRegisterContextLinux_mips64::Read_SR_Config(uint32_t offset,
PTRACE_GETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
if (error.Success()) {
lldb_private::ArchSpec arch;
if (m_thread.GetProcess()->GetArchitecture(arch)) {
if (m_thread.GetProcess().GetArchitecture(arch)) {
void *target_address = ((uint8_t *)&regs) + offset +
4 * (arch.GetMachine() == llvm::Triple::mips);
value.SetUInt(*(uint32_t *)target_address, size);

View file

@ -85,7 +85,7 @@ void LogThreadStopInfo(Log &log, const ThreadStopInfo &stop_info,
}
}
NativeThreadLinux::NativeThreadLinux(NativeProcessLinux *process,
NativeThreadLinux::NativeThreadLinux(NativeProcessLinux &process,
lldb::tid_t tid)
: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
m_stop_info(), m_reg_context_sp(), m_stop_description() {}
@ -144,12 +144,8 @@ NativeRegisterContextSP NativeThreadLinux::GetRegisterContext() {
if (m_reg_context_sp)
return m_reg_context_sp;
NativeProcessProtocolSP m_process_sp = m_process_wp.lock();
if (!m_process_sp)
return NativeRegisterContextSP();
ArchSpec target_arch;
if (!m_process_sp->GetArchitecture(target_arch))
if (!m_process.GetArchitecture(target_arch))
return NativeRegisterContextSP();
const uint32_t concrete_frame_idx = 0;
@ -460,20 +456,10 @@ void NativeThreadLinux::MaybeLogStateChange(lldb::StateType new_state) {
if (new_state == old_state)
return;
NativeProcessProtocolSP m_process_sp = m_process_wp.lock();
lldb::pid_t pid =
m_process_sp ? m_process_sp->GetID() : LLDB_INVALID_PROCESS_ID;
// Log it.
log->Printf("NativeThreadLinux: thread (pid=%" PRIu64 ", tid=%" PRIu64
") changing from state %s to %s",
pid, GetID(), StateAsCString(old_state),
StateAsCString(new_state));
LLDB_LOG(log, "pid={0}, tid={1}: changing from state {2} to {3}",
m_process.GetID(), GetID(), old_state, new_state);
}
NativeProcessLinux &NativeThreadLinux::GetProcess() {
auto process_sp = std::static_pointer_cast<NativeProcessLinux>(
NativeThreadProtocol::GetProcess());
assert(process_sp);
return *process_sp;
return static_cast<NativeProcessLinux &>(m_process);
}

View file

@ -14,6 +14,7 @@
#include "lldb/Host/common/NativeThreadProtocol.h"
#include "lldb/lldb-private-forward.h"
#include <csignal>
#include <map>
#include <memory>
#include <string>
@ -27,7 +28,7 @@ class NativeThreadLinux : public NativeThreadProtocol {
friend class NativeProcessLinux;
public:
NativeThreadLinux(NativeProcessLinux *process, lldb::tid_t tid);
NativeThreadLinux(NativeProcessLinux &process, lldb::tid_t tid);
// ---------------------------------------------------------------------
// NativeThreadProtocol Interface

View file

@ -18,6 +18,7 @@
#include <linux/perf_event.h>
#include <sys/mman.h>
#include <unistd.h>
namespace lldb_private {

View file

@ -64,7 +64,7 @@ static Status EnsureFDFlags(int fd, int flags) {
// Public Static Methods
// -----------------------------------------------------------------------------
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
NativeProcessNetBSD::Factory::Launch(ProcessLaunchInfo &launch_info,
NativeDelegate &native_delegate,
MainLoop &mainloop) const {
@ -101,24 +101,25 @@ NativeProcessNetBSD::Factory::Launch(ProcessLaunchInfo &launch_info,
LLDB_LOG(log, "pid = {0:x}, detected architecture {1}", pid,
arch.GetArchitectureName());
std::shared_ptr<NativeProcessNetBSD> process_sp(new NativeProcessNetBSD(
std::unique_ptr<NativeProcessNetBSD> process_up(new NativeProcessNetBSD(
pid, launch_info.GetPTY().ReleaseMasterFileDescriptor(), native_delegate,
arch, mainloop));
status = process_sp->ReinitializeThreads();
status = process_up->ReinitializeThreads();
if (status.Fail())
return status.ToError();
for (const auto &thread_sp : process_sp->m_threads) {
for (const auto &thread_sp : process_up->m_threads) {
static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
SIGSTOP);
}
process_sp->SetState(StateType::eStateStopped);
process_up->SetState(StateType::eStateStopped);
return process_sp;
return std::move(process_up);
}
llvm::Expected<NativeProcessProtocolSP> NativeProcessNetBSD::Factory::Attach(
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
NativeProcessNetBSD::Factory::Attach(
lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
MainLoop &mainloop) const {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
@ -130,14 +131,14 @@ llvm::Expected<NativeProcessProtocolSP> NativeProcessNetBSD::Factory::Attach(
if (!status.Success())
return status.ToError();
std::shared_ptr<NativeProcessNetBSD> process_sp(
std::unique_ptr<NativeProcessNetBSD> process_up(
new NativeProcessNetBSD(pid, -1, native_delegate, arch, mainloop));
status = process_sp->Attach();
status = process_up->Attach();
if (!status.Success())
return status.ToError();
return process_sp;
return std::move(process_up);
}
// -----------------------------------------------------------------------------
@ -787,7 +788,7 @@ NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) {
if (m_threads.empty())
SetCurrentThreadID(thread_id);
auto thread_sp = std::make_shared<NativeThreadNetBSD>(this, thread_id);
auto thread_sp = std::make_shared<NativeThreadNetBSD>(*this, thread_id);
m_threads.push_back(thread_sp);
return thread_sp;
}

View file

@ -34,11 +34,11 @@ class NativeProcessNetBSD : public NativeProcessProtocol {
public:
class Factory : public NativeProcessProtocol::Factory {
public:
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
MainLoop &mainloop) const override;
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
MainLoop &mainloop) const override;
};

View file

@ -104,15 +104,9 @@ Status NativeRegisterContextNetBSD::DoWriteDBR(void *buf) {
}
NativeProcessNetBSD &NativeRegisterContextNetBSD::GetProcess() {
auto process_sp =
std::static_pointer_cast<NativeProcessNetBSD>(m_thread.GetProcess());
assert(process_sp);
return *process_sp;
return static_cast<NativeProcessNetBSD &>(m_thread.GetProcess());
}
::pid_t NativeRegisterContextNetBSD::GetProcessPid() {
NativeProcessNetBSD &process = GetProcess();
lldb::pid_t pid = process.GetID();
return pid;
return GetProcess().GetID();
}

View file

@ -24,7 +24,7 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_netbsd;
NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD *process,
NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD &process,
lldb::tid_t tid)
: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
m_stop_info(), m_reg_context_sp(), m_stop_description() {}
@ -144,12 +144,8 @@ NativeRegisterContextSP NativeThreadNetBSD::GetRegisterContext() {
if (m_reg_context_sp)
return m_reg_context_sp;
NativeProcessProtocolSP m_process_sp = m_process_wp.lock();
if (!m_process_sp)
return NativeRegisterContextSP();
ArchSpec target_arch;
if (!m_process_sp->GetArchitecture(target_arch))
if (!m_process.GetArchitecture(target_arch))
return NativeRegisterContextSP();
const uint32_t concrete_frame_idx = 0;

View file

@ -12,6 +12,7 @@
#include "lldb/Host/common/NativeThreadProtocol.h"
#include <csignal>
#include <map>
#include <string>
@ -24,7 +25,7 @@ class NativeThreadNetBSD : public NativeThreadProtocol {
friend class NativeProcessNetBSD;
public:
NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid);
NativeThreadNetBSD(NativeProcessNetBSD &process, lldb::tid_t tid);
// ---------------------------------------------------------------------
// NativeThreadProtocol Interface

View file

@ -114,7 +114,7 @@ class GDBRemoteCommunicationServerLLGS
lldb::tid_t m_current_tid = LLDB_INVALID_THREAD_ID;
lldb::tid_t m_continue_tid = LLDB_INVALID_THREAD_ID;
std::recursive_mutex m_debugged_process_mutex;
NativeProcessProtocolSP m_debugged_process_sp;
std::unique_ptr<NativeProcessProtocol> m_debugged_process_up;
Communication m_stdio_communication;
MainLoop::ReadHandleUP m_stdio_handle_up;

View file

@ -16,6 +16,7 @@
#include <netinet/in.h>
#include <sys/mman.h> // for mmap
#include <sys/socket.h>
#include <unistd.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
@ -40,6 +41,7 @@
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"

View file

@ -34,6 +34,7 @@
#include "lldb/Expression/REPL.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionGroupWatchpoint.h"

View file

@ -49,8 +49,8 @@ endif()
# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script
set(LLDB_TEST_USER_ARGS
"${LLDB_TEST_USER_ARGS_New}"
CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'" FORCE)
""
CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'")
set(LLDB_TEST_COMMON_ARGS
--arch=${LLDB_TEST_ARCH}
@ -101,19 +101,19 @@ if(CMAKE_HOST_APPLE)
list(APPEND LLDB_TEST_COMMON_ARGS --server $<TARGET_FILE:debugserver>)
endif()
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
add_python_test_target(check-lldb-single
${LLDB_SOURCE_DIR}/test/dotest.py
"--no-multiprocess;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
"Testing LLDB with args: ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
"--no-multiprocess;${LLDB_DOTEST_ARGS}"
"Testing LLDB with args: ${LLDB_DOTEST_ARGS}"
)
set(LLDB_DOTEST_ARGS -q;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
# If tests crash cause LLDB to crash, or things are otherwise unstable, or if machine-parsable
# output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target.
add_python_test_target(check-lldb
${LLDB_SOURCE_DIR}/test/dotest.py
"${LLDB_DOTEST_ARGS}"
"-q;${LLDB_DOTEST_ARGS}"
"Testing LLDB (parallel execution, with a separate subprocess per test)"
)

View file

@ -1,2 +1,19 @@
project(C CXX ASM-ATT)
cmake_minimum_required(VERSION 3.4.3)
project(Debugserver LANGUAGES C CXX ASM-ATT)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/../../cmake"
"${CMAKE_SOURCE_DIR}/../../cmake/modules"
)
include(LLDBStandalone)
include(AddLLDB)
set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
include_directories(${LLDB_SOURCE_DIR}/include)
endif()
add_subdirectory(source)

View file

@ -1,3 +1,4 @@
include(CheckCXXCompilerFlag)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
include_directories(${LLDB_SOURCE_DIR}/source)
include_directories(MacOSX/DarwinLog)
@ -25,7 +26,6 @@ if (CXX_SUPPORTS_NO_EXTENDED_OFFSETOF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extended-offsetof")
endif ()
find_library(COCOA_LIBRARY Cocoa)
add_subdirectory(MacOSX)
set(generated_mach_interfaces
@ -91,11 +91,23 @@ set(lldbDebugserverCommonSources
add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
if (APPLE)
if(IOS)
find_library(COCOA_LIBRARY UIKit)
target_link_libraries(lldbDebugserverCommon INTERFACE ${COCOA_LIBRARY} ${CORE_FOUNDATION_LIBRARY} ${FOUNDATION_LIBRARY})
else()
find_library(COCOA_LIBRARY Cocoa)
target_link_libraries(lldbDebugserverCommon INTERFACE ${COCOA_LIBRARY})
endif()
endif()
target_link_libraries(lldbDebugserverCommon
INTERFACE ${COCOA_LIBRARY}
lldbDebugserverMacOSX_I386
lldbDebugserverMacOSX_X86_64
lldbDebugserverMacOSX_DarwinLog)
${CORE_FOUNDATION_LIBRARY}
${FOUNDATION_LIBRARY}
lldbDebugserverArchSupport
lldbDebugserverDarwin_DarwinLog)
set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK

View file

@ -1,8 +1,23 @@
#add_subdirectory(arm64)
#add_subdirectory(arm)
add_subdirectory(i386)
#add_subdirectory(ppc)
add_subdirectory(x86_64)
if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*arm.*")
list(APPEND SOURCES arm/DNBArchImpl.cpp arm64/DNBArchImplARM64.cpp)
include_directories(${CURRENT_SOURCE_DIR}/arm ${CURRENT_SOURCE_DIR}/arm64)
endif()
if(NOT CMAKE_OSX_ARCHITECTURES OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*86.*")
list(APPEND SOURCES i386/DNBArchImplI386.cpp x86_64/DNBArchImplX86_64.cpp)
include_directories(${CURRENT_SOURCE_DIR}/i386 ${CURRENT_SOURCE_DIR}/x86_64)
endif()
if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*ppc.*")
list(APPEND SOURCES ppc/DNBArchImpl.cpp)
include_directories(${CURRENT_SOURCE_DIR}/ppc)
endif()
add_subdirectory(DarwinLog)
include_directories(..)
include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
add_library(lldbDebugserverArchSupport
${SOURCES}
)

View file

@ -3,7 +3,7 @@
# we must include the grandparent directory...
include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
add_library(lldbDebugserverMacOSX_DarwinLog
add_library(lldbDebugserverDarwin_DarwinLog
ActivityStore.cpp
DarwinLogCollector.cpp
LogFilter.cpp

View file

@ -1,4 +0,0 @@
include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
add_library(lldbDebugserverMacOSX_I386
DNBArchImplI386.cpp
)

View file

@ -1,8 +0,0 @@
# Due to sources including headers like:
# #include "MacOSX/i386/DNBArchImplI386.h"
# we must include the grandparent directory...
include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
add_library(lldbDebugserverMacOSX_X86_64
DNBArchImplX86_64.cpp
)

View file

@ -79,9 +79,17 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port,
return rnb_err;
}
bool any_addr = (strcmp(listen_host, "*") == 0);
// If the user wants to allow connections from any address we should create
// sockets on all families that can resolve localhost. This will allow us to
// listen for IPv6 and IPv4 connections from all addresses if those interfaces
// are available.
const char *local_addr = any_addr ? "localhost" : listen_host;
std::map<int, lldb_private::SocketAddress> sockets;
auto addresses = lldb_private::SocketAddress::GetAddressInfo(
listen_host, NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
local_addr, NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
for (auto address : addresses) {
int sock_fd = ::socket(address.GetFamily(), SOCK_STREAM, IPPROTO_TCP);
@ -90,9 +98,15 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port,
SetSocketOption(sock_fd, SOL_SOCKET, SO_REUSEADDR, 1);
address.SetPort(port);
lldb_private::SocketAddress bind_address = address;
int error = ::bind(sock_fd, &address.sockaddr(), address.GetLength());
if(any_addr || !bind_address.IsLocalhost())
bind_address.SetToAnyAddress(bind_address.GetFamily(), port);
else
bind_address.SetPort(port);
int error =
::bind(sock_fd, &bind_address.sockaddr(), bind_address.GetLength());
if (error == -1) {
ClosePort(sock_fd, false);
continue;
@ -179,6 +193,7 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port,
DNBLogThreaded("error: rejecting connection from %s (expecting %s)\n",
accept_addr.GetIPAddress().c_str(),
addr_in.GetIPAddress().c_str());
err.Clear();
}
}
}

View file

@ -9,6 +9,7 @@
#include "Driver.h"
#include <csignal>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>

View file

@ -17,6 +17,7 @@
#include "lldb/API/SBTypeCategory.h"
#include "lldb/API/SBTypeNameSpecifier.h"
#include "lldb/API/SBTypeSummary.h"
#include <cassert>
// In-house headers:
#include "MICmnLLDBDebugSessionInfo.h"

View file

@ -9,6 +9,8 @@
// Third party headers:
#include "lldb/API/SBError.h"
#include <cassert>
#include <csignal>
#include <fstream>
// In-house headers:

View file

@ -33,6 +33,7 @@
// Third party headers:
#include "lldb/API/SBHostOS.h"
#include <csignal>
#include <stdio.h>
// In house headers:

View file

@ -67,13 +67,13 @@ typedef process_netbsd::NativeProcessNetBSD::Factory NativeProcessFactory;
// Dummy implementation to make sure the code compiles
class NativeProcessFactory : public NativeProcessProtocol::Factory {
public:
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Launch(ProcessLaunchInfo &launch_info,
NativeProcessProtocol::NativeDelegate &delegate,
MainLoop &mainloop) const override {
llvm_unreachable("Not implemented");
}
llvm::Expected<NativeProcessProtocolSP>
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Attach(lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &delegate,
MainLoop &mainloop) const override {
llvm_unreachable("Not implemented");

View file

@ -62,6 +62,11 @@ TEST(CPlusPlusLanguage, MethodNameParsing) {
"XX::(anonymous namespace)::anon_class", "anon_func", "()", "const",
"XX::(anonymous namespace)::anon_class::anon_func"},
// Lambda
{"main::{lambda()#1}::operator()() const::{lambda()#1}::operator()() const",
"main::{lambda()#1}::operator()() const::{lambda()#1}", "operator()", "()", "const",
"main::{lambda()#1}::operator()() const::{lambda()#1}::operator()"},
// Function pointers
{"string (*f(vector<int>&&))(float)", "", "f", "(vector<int>&&)", "",
"f"},

View file

@ -85,6 +85,8 @@ TEST(RNBSocket, LoopBackListenIPv4) { TestSocketListen("127.0.0.1"); }
TEST(RNBSocket, LoopBackListenIPv6) { TestSocketListen("::1"); }
TEST(RNBSocket, AnyListen) { TestSocketListen("*"); }
void TestSocketConnect(const char *addr) {
// Skip IPv6 tests if there isn't a valid interafce
auto addresses = lldb_private::SocketAddress::GetAddressInfo(