summaryrefslogtreecommitdiff
path: root/source/Target
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-02-09 01:44:09 +0000
committerEd Maste <emaste@FreeBSD.org>2015-02-09 01:44:09 +0000
commit12bd4897ff0678fa663e09d78ebc22dd255ceb86 (patch)
treea8f4b3abea3e6937e60728991c736e6e3d322fc1 /source/Target
parent205afe679855a4ce8149cdaa94d3f0868ce796dc (diff)
Notes
Diffstat (limited to 'source/Target')
-rw-r--r--source/Target/ExecutionContext.cpp6
-rw-r--r--source/Target/LanguageRuntime.cpp3
-rw-r--r--source/Target/NativeRegisterContext.cpp470
-rw-r--r--source/Target/NativeRegisterContextRegisterInfo.cpp44
-rw-r--r--source/Target/ObjCLanguageRuntime.cpp46
-rw-r--r--source/Target/Platform.cpp85
-rw-r--r--source/Target/Process.cpp10
-rw-r--r--source/Target/ProcessLaunchInfo.cpp9
-rw-r--r--source/Target/StackFrame.cpp5
-rw-r--r--source/Target/StopInfo.cpp5
-rw-r--r--source/Target/TargetList.cpp48
-rw-r--r--source/Target/Thread.cpp23
-rw-r--r--source/Target/ThreadPlanTracer.cpp2
-rw-r--r--source/Target/UnixSignals.cpp4
14 files changed, 201 insertions, 559 deletions
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index db4025f40c05c..e03a560bd0635 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -705,7 +705,11 @@ ExecutionContextRef::SetTargetPtr (Target* target, bool adopt_selected)
if (process_sp)
{
// Only fill in the thread and frame if our process is stopped
- if (StateIsStoppedState (process_sp->GetState(), true))
+ // Don't just check the state, since we might be in the middle of
+ // resuming.
+ Process::StopLocker stop_locker;
+
+ if (stop_locker.TryLock(&process_sp->GetRunLock()) && StateIsStoppedState (process_sp->GetState(), true))
{
lldb::ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread());
if (!thread_sp)
diff --git a/source/Target/LanguageRuntime.cpp b/source/Target/LanguageRuntime.cpp
index 358bffee3a4d4..123ee93d322fd 100644
--- a/source/Target/LanguageRuntime.cpp
+++ b/source/Target/LanguageRuntime.cpp
@@ -337,6 +337,9 @@ struct language_name_pair language_names[] =
{ "swift", eLanguageTypeSwift },
{ "julia", eLanguageTypeJulia },
{ "dylan", eLanguageTypeDylan },
+ { "c++14", eLanguageTypeC_plus_plus_14 },
+ { "fortran03", eLanguageTypeFortran03 },
+ { "fortran08", eLanguageTypeFortran08 },
// Now synonyms, in arbitrary order
{ "objc", eLanguageTypeObjC },
{ "objc++", eLanguageTypeObjC_plus_plus }
diff --git a/source/Target/NativeRegisterContext.cpp b/source/Target/NativeRegisterContext.cpp
deleted file mode 100644
index d84e2279a4590..0000000000000
--- a/source/Target/NativeRegisterContext.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-//===-- NativeRegisterContext.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/Target/NativeRegisterContext.h"
-
-#include "lldb/Core/Log.h"
-#include "lldb/Core/RegisterValue.h"
-
-#include "lldb/lldb-private-log.h"
-
-#include "Host/common/NativeProcessProtocol.h"
-#include "Host/common/NativeThreadProtocol.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-NativeRegisterContext::NativeRegisterContext (NativeThreadProtocol &thread, uint32_t concrete_frame_idx) :
- m_thread (thread),
- m_concrete_frame_idx (concrete_frame_idx)
-{
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-NativeRegisterContext::~NativeRegisterContext()
-{
-}
-
-// FIXME revisit invalidation, process stop ids, etc. Right now we don't
-// support caching in NativeRegisterContext. We can do this later by
-// utilizing NativeProcessProtocol::GetStopID () and adding a stop id to
-// NativeRegisterContext.
-
-// void
-// NativeRegisterContext::InvalidateIfNeeded (bool force)
-// {
-// ProcessSP process_sp (m_thread.GetProcess());
-// bool invalidate = force;
-// uint32_t process_stop_id = UINT32_MAX;
-
-// if (process_sp)
-// process_stop_id = process_sp->GetStopID();
-// else
-// invalidate = true;
-
-// if (!invalidate)
-// invalidate = process_stop_id != GetStopID();
-
-// if (invalidate)
-// {
-// InvalidateAllRegisters ();
-// SetStopID (process_stop_id);
-// }
-// }
-
-
-const RegisterInfo *
-NativeRegisterContext::GetRegisterInfoByName (const char *reg_name, uint32_t start_idx)
-{
- if (reg_name && reg_name[0])
- {
- const uint32_t num_registers = GetRegisterCount();
- for (uint32_t reg = start_idx; reg < num_registers; ++reg)
- {
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex(reg);
-
- if ((reg_info->name != nullptr && ::strcasecmp (reg_info->name, reg_name) == 0) ||
- (reg_info->alt_name != nullptr && ::strcasecmp (reg_info->alt_name, reg_name) == 0))
- {
- return reg_info;
- }
- }
- }
- return nullptr;
-}
-
-const RegisterInfo *
-NativeRegisterContext::GetRegisterInfo (uint32_t kind, uint32_t num)
-{
- const uint32_t reg_num = ConvertRegisterKindToRegisterNumber(kind, num);
- if (reg_num == LLDB_INVALID_REGNUM)
- return nullptr;
- return GetRegisterInfoAtIndex (reg_num);
-}
-
-const char *
-NativeRegisterContext::GetRegisterName (uint32_t reg)
-{
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex(reg);
- if (reg_info)
- return reg_info->name;
- return nullptr;
-}
-
-const char*
-NativeRegisterContext::GetRegisterSetNameForRegisterAtIndex (uint32_t reg_index) const
-{
- const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index);
- if (!reg_info)
- return nullptr;
-
- for (uint32_t set_index = 0; set_index < GetRegisterSetCount (); ++set_index)
- {
- const RegisterSet *const reg_set = GetRegisterSet (set_index);
- if (!reg_set)
- continue;
-
- for (uint32_t reg_num_index = 0; reg_num_index < reg_set->num_registers; ++reg_num_index)
- {
- const uint32_t reg_num = reg_set->registers[reg_num_index];
- // FIXME double check we're checking the right register kind here.
- if (reg_info->kinds[RegisterKind::eRegisterKindLLDB] == reg_num)
- {
- // The given register is a member of this register set. Return the register set name.
- return reg_set->name;
- }
- }
- }
-
- // Didn't find it.
- return nullptr;
-}
-
-lldb::addr_t
-NativeRegisterContext::GetPC (lldb::addr_t fail_value)
-{
- Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- if (log)
- log->Printf ("NativeRegisterContext::%s using reg index %" PRIu32 " (default %" PRIu64 ")", __FUNCTION__, reg, fail_value);
-
- const uint64_t retval = ReadRegisterAsUnsigned (reg, fail_value);
-
- if (log)
- log->Printf ("NativeRegisterContext::%s " PRIu32 " retval %" PRIu64, __FUNCTION__, retval);
-
- return retval;
-}
-
-Error
-NativeRegisterContext::SetPC (lldb::addr_t pc)
-{
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- return WriteRegisterFromUnsigned (reg, pc);
-}
-
-lldb::addr_t
-NativeRegisterContext::GetSP (lldb::addr_t fail_value)
-{
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
- return ReadRegisterAsUnsigned (reg, fail_value);
-}
-
-Error
-NativeRegisterContext::SetSP (lldb::addr_t sp)
-{
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
- return WriteRegisterFromUnsigned (reg, sp);
-}
-
-lldb::addr_t
-NativeRegisterContext::GetFP (lldb::addr_t fail_value)
-{
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
- return ReadRegisterAsUnsigned (reg, fail_value);
-}
-
-Error
-NativeRegisterContext::SetFP (lldb::addr_t fp)
-{
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
- return WriteRegisterFromUnsigned (reg, fp);
-}
-
-lldb::addr_t
-NativeRegisterContext::GetReturnAddress (lldb::addr_t fail_value)
-{
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
- return ReadRegisterAsUnsigned (reg, fail_value);
-}
-
-lldb::addr_t
-NativeRegisterContext::GetFlags (lldb::addr_t fail_value)
-{
- uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
- return ReadRegisterAsUnsigned (reg, fail_value);
-}
-
-
-lldb::addr_t
-NativeRegisterContext::ReadRegisterAsUnsigned (uint32_t reg, lldb::addr_t fail_value)
-{
- if (reg != LLDB_INVALID_REGNUM)
- return ReadRegisterAsUnsigned (GetRegisterInfoAtIndex (reg), fail_value);
- return fail_value;
-}
-
-uint64_t
-NativeRegisterContext::ReadRegisterAsUnsigned (const RegisterInfo *reg_info, lldb::addr_t fail_value)
-{
- Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-
- if (reg_info)
- {
- RegisterValue value;
- Error error = ReadRegister (reg_info, value);
- if (error.Success ())
- {
- if (log)
- log->Printf ("NativeRegisterContext::%s ReadRegister() succeeded, value %" PRIu64, __FUNCTION__, value.GetAsUInt64());
- return value.GetAsUInt64();
- }
- else
- {
- if (log)
- log->Printf ("NativeRegisterContext::%s ReadRegister() failed, error %s", __FUNCTION__, error.AsCString ());
- }
- }
- else
- {
- if (log)
- log->Printf ("NativeRegisterContext::%s ReadRegister() null reg_info", __FUNCTION__);
- }
- return fail_value;
-}
-
-Error
-NativeRegisterContext::WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval)
-{
- if (reg == LLDB_INVALID_REGNUM)
- return Error ("NativeRegisterContext::%s (): reg is invalid", __FUNCTION__);
- return WriteRegisterFromUnsigned (GetRegisterInfoAtIndex (reg), uval);
-}
-
-Error
-NativeRegisterContext::WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval)
-{
- assert (reg_info);
- if (!reg_info)
- return Error ("reg_info is nullptr");
-
- RegisterValue value;
- if (!value.SetUInt(uval, reg_info->byte_size))
- return Error ("RegisterValue::SetUInt () failed");
-
- return WriteRegister (reg_info, value);
-}
-
-lldb::tid_t
-NativeRegisterContext::GetThreadID() const
-{
- return m_thread.GetID();
-}
-
-uint32_t
-NativeRegisterContext::NumSupportedHardwareBreakpoints ()
-{
- return 0;
-}
-
-uint32_t
-NativeRegisterContext::SetHardwareBreakpoint (lldb::addr_t addr, size_t size)
-{
- return LLDB_INVALID_INDEX32;
-}
-
-bool
-NativeRegisterContext::ClearHardwareBreakpoint (uint32_t hw_idx)
-{
- return false;
-}
-
-
-uint32_t
-NativeRegisterContext::NumSupportedHardwareWatchpoints ()
-{
- return 0;
-}
-
-uint32_t
-NativeRegisterContext::SetHardwareWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags)
-{
- return LLDB_INVALID_INDEX32;
-}
-
-bool
-NativeRegisterContext::ClearHardwareWatchpoint (uint32_t hw_index)
-{
- return false;
-}
-
-bool
-NativeRegisterContext::HardwareSingleStep (bool enable)
-{
- return false;
-}
-
-Error
-NativeRegisterContext::ReadRegisterValueFromMemory (
- const RegisterInfo *reg_info,
- lldb::addr_t src_addr,
- lldb::addr_t src_len,
- RegisterValue &reg_value)
-{
- Error error;
- if (reg_info == nullptr)
- {
- error.SetErrorString ("invalid register info argument.");
- return error;
- }
-
-
- // Moving from addr into a register
- //
- // Case 1: src_len == dst_len
- //
- // |AABBCCDD| Address contents
- // |AABBCCDD| Register contents
- //
- // Case 2: src_len > dst_len
- //
- // Error! (The register should always be big enough to hold the data)
- //
- // Case 3: src_len < dst_len
- //
- // |AABB| Address contents
- // |AABB0000| Register contents [on little-endian hardware]
- // |0000AABB| Register contents [on big-endian hardware]
- if (src_len > RegisterValue::kMaxRegisterByteSize)
- {
- error.SetErrorString ("register too small to receive memory data");
- return error;
- }
-
- const lldb::addr_t dst_len = reg_info->byte_size;
-
- if (src_len > dst_len)
- {
- error.SetErrorStringWithFormat("%" PRIu64 " bytes is too big to store in register %s (%" PRIu64 " bytes)", src_len, reg_info->name, dst_len);
- return error;
- }
-
- NativeProcessProtocolSP process_sp (m_thread.GetProcess ());
- if (!process_sp)
- {
- error.SetErrorString("invalid process");
- return error;
- }
-
- uint8_t src[RegisterValue::kMaxRegisterByteSize];
-
- // Read the memory
- lldb::addr_t bytes_read;
- error = process_sp->ReadMemory (src_addr, src, src_len, bytes_read);
- if (error.Fail ())
- return error;
-
- // Make sure the memory read succeeded...
- if (bytes_read != src_len)
- {
- // This might happen if we read _some_ bytes but not all
- error.SetErrorStringWithFormat("read %" PRIu64 " of %" PRIu64 " bytes", bytes_read, src_len);
- return error;
- }
-
- // We now have a memory buffer that contains the part or all of the register
- // value. Set the register value using this memory data.
- // 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))
- {
- error.SetErrorString ( "NativeProcessProtocol::GetByteOrder () failed");
- return error;
- }
-
- reg_value.SetFromMemoryData (
- reg_info,
- src,
- src_len,
- byte_order,
- error);
-
- return error;
-}
-
-Error
-NativeRegisterContext::WriteRegisterValueToMemory (
- const RegisterInfo *reg_info,
- lldb::addr_t dst_addr,
- lldb::addr_t dst_len,
- const RegisterValue &reg_value)
-{
-
- uint8_t dst[RegisterValue::kMaxRegisterByteSize];
-
- Error error;
-
- NativeProcessProtocolSP process_sp (m_thread.GetProcess ());
- if (process_sp)
- {
-
- // 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 Error ("NativeProcessProtocol::GetByteOrder () failed");
-
- const lldb::addr_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
- {
- lldb::addr_t bytes_written;
- error = process_sp->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", bytes_written, bytes_copied);
- }
- }
- }
- }
- else
- error.SetErrorString("invalid process");
-
- return error;
-}
-
-uint32_t
-NativeRegisterContext::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const
-{
- const uint32_t num_regs = GetRegisterCount();
-
- assert (kind < kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
- {
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
-
- return LLDB_INVALID_REGNUM;
-}
-
-
diff --git a/source/Target/NativeRegisterContextRegisterInfo.cpp b/source/Target/NativeRegisterContextRegisterInfo.cpp
deleted file mode 100644
index e37014546646a..0000000000000
--- a/source/Target/NativeRegisterContextRegisterInfo.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//===-- NativeRegisterContex.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/lldb-types.h"
-#include "lldb/lldb-private-forward.h"
-#include "lldb/Target/NativeRegisterContextRegisterInfo.h"
-
-using namespace lldb_private;
-
-NativeRegisterContextRegisterInfo::NativeRegisterContextRegisterInfo (NativeThreadProtocol &thread,
- uint32_t concrete_frame_idx,
- RegisterInfoInterface *register_info_interface) :
- NativeRegisterContext (thread, concrete_frame_idx),
- m_register_info_interface_up (register_info_interface)
-{
- assert (register_info_interface && "null register_info_interface");
-}
-
-uint32_t
-NativeRegisterContextRegisterInfo::GetRegisterCount () const
-{
- return m_register_info_interface_up->GetRegisterCount ();
-}
-
-const RegisterInfo *
-NativeRegisterContextRegisterInfo::GetRegisterInfoAtIndex (uint32_t reg_index) const
-{
- if (reg_index <= GetRegisterCount ())
- return m_register_info_interface_up->GetRegisterInfo () + reg_index;
- else
- return nullptr;
-}
-
-const RegisterInfoInterface&
-NativeRegisterContextRegisterInfo::GetRegisterInfoInterface () const
-{
- return *m_register_info_interface_up;
-}
diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp
index b182407bf68ec..3d7a9021343ad 100644
--- a/source/Target/ObjCLanguageRuntime.cpp
+++ b/source/Target/ObjCLanguageRuntime.cpp
@@ -34,9 +34,14 @@ ObjCLanguageRuntime::~ObjCLanguageRuntime()
ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) :
LanguageRuntime (process),
+ m_impl_cache(),
m_has_new_literals_and_indexing (eLazyBoolCalculate),
m_isa_to_descriptor(),
- m_isa_to_descriptor_stop_id (UINT32_MAX)
+ m_hash_to_isa_map(),
+ m_type_size_cache(),
+ m_isa_to_descriptor_stop_id (UINT32_MAX),
+ m_complete_class_cache(),
+ m_negative_complete_class_cache()
{
}
@@ -626,3 +631,42 @@ ObjCLanguageRuntime::GetEncodingToType ()
{
return nullptr;
}
+
+bool
+ObjCLanguageRuntime::GetTypeBitSize (const ClangASTType& clang_type,
+ uint64_t &size)
+{
+ void *opaque_ptr = clang_type.GetQualType().getAsOpaquePtr();
+ size = m_type_size_cache.Lookup(opaque_ptr);
+ // an ObjC object will at least have an ISA, so 0 is definitely not OK
+ if (size > 0)
+ return true;
+
+ ClassDescriptorSP class_descriptor_sp = GetClassDescriptorFromClassName(clang_type.GetTypeName());
+ if (!class_descriptor_sp)
+ return false;
+
+ int32_t max_offset = INT32_MIN;
+ uint64_t sizeof_max = 0;
+ bool found = false;
+
+ for (size_t idx = 0;
+ idx < class_descriptor_sp->GetNumIVars();
+ idx++)
+ {
+ const auto& ivar = class_descriptor_sp->GetIVarAtIndex(idx);
+ int32_t cur_offset = ivar.m_offset;
+ if (cur_offset > max_offset)
+ {
+ max_offset = cur_offset;
+ sizeof_max = ivar.m_size;
+ found = true;
+ }
+ }
+
+ size = 8 * (max_offset + sizeof_max);
+ if (found)
+ m_type_size_cache.Insert(opaque_ptr, size);
+
+ return found;
+}
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 4ebd18b8bfd09..09c9efc14b088 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -286,8 +286,7 @@ Platform::Platform (bool is_host) :
m_minor_os_version (UINT32_MAX),
m_update_os_version (UINT32_MAX),
m_system_arch(),
- m_uid_map_mutex (Mutex::eMutexTypeNormal),
- m_gid_map_mutex (Mutex::eMutexTypeNormal),
+ m_mutex (Mutex::eMutexTypeRecursive),
m_uid_map(),
m_gid_map(),
m_max_uid_name_len (0),
@@ -299,8 +298,7 @@ Platform::Platform (bool is_host) :
m_ssh_opts (),
m_ignores_remote_hostname (false),
m_trap_handlers(),
- m_calculated_trap_handlers (false),
- m_trap_handler_mutex()
+ m_calculated_trap_handlers (false)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
@@ -384,6 +382,8 @@ Platform::GetOSVersion (uint32_t &major,
uint32_t &minor,
uint32_t &update)
{
+ Mutex::Locker locker (m_mutex);
+
bool success = m_major_os_version != UINT32_MAX;
if (IsHost())
{
@@ -463,7 +463,7 @@ Platform::GetOSKernelDescription (std::string &s)
}
void
-Platform::AddClangModuleCompilationOptions (std::vector<std::string> &options)
+Platform::AddClangModuleCompilationOptions (Target *target, std::vector<std::string> &options)
{
std::vector<std::string> default_compilation_options =
{
@@ -1103,6 +1103,20 @@ Platform::LaunchProcess (ProcessLaunchInfo &launch_info)
return error;
}
+Error
+Platform::KillProcess (const lldb::pid_t pid)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf ("Platform::%s, pid %" PRIu64, __FUNCTION__, pid);
+
+ if (!IsHost ())
+ return Error ("base lldb_private::Platform class can't launch remote processes");
+
+ Host::Kill (pid, SIGTERM);
+ return Error();
+}
+
lldb::ProcessSP
Platform::DebugProcess (ProcessLaunchInfo &launch_info,
Debugger &debugger,
@@ -1233,7 +1247,64 @@ Platform::PutFile (const FileSpec& source,
uint32_t uid,
uint32_t gid)
{
- Error error("unimplemented");
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("[PutFile] Using block by block transfer....\n");
+
+ uint32_t source_open_options = File::eOpenOptionRead;
+ if (source.GetFileType() == FileSpec::eFileTypeSymbolicLink)
+ source_open_options |= File::eOpenoptionDontFollowSymlinks;
+
+ File source_file(source, source_open_options, lldb::eFilePermissionsUserRW);
+ Error error;
+ uint32_t permissions = source_file.GetPermissions(error);
+ if (permissions == 0)
+ permissions = lldb::eFilePermissionsFileDefault;
+
+ if (!source_file.IsValid())
+ return Error("PutFile: unable to open source file");
+ lldb::user_id_t dest_file = OpenFile (destination,
+ File::eOpenOptionCanCreate |
+ File::eOpenOptionWrite |
+ File::eOpenOptionTruncate,
+ permissions,
+ error);
+ if (log)
+ log->Printf ("dest_file = %" PRIu64 "\n", dest_file);
+
+ if (error.Fail())
+ return error;
+ if (dest_file == UINT64_MAX)
+ return Error("unable to open target file");
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
+ uint64_t offset = 0;
+ for (;;)
+ {
+ size_t bytes_read = buffer_sp->GetByteSize();
+ error = source_file.Read(buffer_sp->GetBytes(), bytes_read);
+ if (error.Fail() || bytes_read == 0)
+ break;
+
+ const uint64_t bytes_written = WriteFile(dest_file, offset,
+ buffer_sp->GetBytes(), bytes_read, error);
+ if (error.Fail())
+ break;
+
+ offset += bytes_written;
+ if (bytes_written != bytes_read)
+ {
+ // We didn't write the correct number of bytes, so adjust
+ // the file position in the source file we are reading from...
+ source_file.SeekFromStart(offset);
+ }
+ }
+ CloseFile(dest_file, error);
+
+ if (uid == UINT32_MAX && gid == UINT32_MAX)
+ return error;
+
+ // TODO: ChownFile?
+
return error;
}
@@ -1528,7 +1599,7 @@ Platform::GetTrapHandlerSymbolNames ()
{
if (!m_calculated_trap_handlers)
{
- Mutex::Locker locker (m_trap_handler_mutex);
+ Mutex::Locker locker (m_mutex);
if (!m_calculated_trap_handlers)
{
CalculateTrapHandlerSymbolNames();
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 106678da2684e..f7a26f676aba6 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -720,6 +720,7 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
m_process_input_reader (),
m_stdio_communication ("process.stdio"),
m_stdio_communication_mutex (Mutex::eMutexTypeRecursive),
+ m_stdio_disable(true),
m_stdout_data (),
m_stderr_data (),
m_profile_data_comm_mutex (Mutex::eMutexTypeRecursive),
@@ -3121,6 +3122,11 @@ Process::Launch (ProcessLaunchInfo &launch_info)
StartPrivateStateThread ();
m_stop_info_override_callback = GetTarget().GetArchitecture().GetStopInfoOverrideCallback();
+
+ // Target was stopped at entry as was intended. Need to notify the listeners
+ // about it.
+ if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == true)
+ HandlePrivateEvent(event_sp);
}
else if (state == eStateExited)
{
@@ -3643,7 +3649,8 @@ Process::PrivateResume ()
}
else
{
- // Somebody wanted to run without running. So generate a continue & a stopped event,
+ // Somebody wanted to run without running (e.g. we were faking a step from one frame of a set of inlined
+ // frames that share the same PC to another.) So generate a continue & a stopped event,
// and let the world handle them.
if (log)
log->Printf ("Process::PrivateResume() asked to simulate a start & stop.");
@@ -3905,6 +3912,7 @@ Process::Destroy ()
}
m_stdio_communication.StopReadThread();
m_stdio_communication.Disconnect();
+ m_stdio_disable = true;
if (m_process_input_reader)
{
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp
index 451c42d18bfa3..b841b2c066a3e 100644
--- a/source/Target/ProcessLaunchInfo.cpp
+++ b/source/Target/ProcessLaunchInfo.cpp
@@ -344,7 +344,14 @@ ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty)
log->Printf ("ProcessLaunchInfo::%s default_to_use_pty is set, and at least one stdin/stderr/stdout is unset, so generating a pty to use for it",
__FUNCTION__);
- if (m_pty->OpenFirstAvailableMaster(O_RDWR| O_NOCTTY, NULL, 0))
+ int open_flags = O_RDWR | O_NOCTTY;
+#if !defined(_MSC_VER)
+ // We really shouldn't be specifying platform specific flags
+ // that are intended for a system call in generic code. But
+ // this will have to do for now.
+ open_flags |= O_CLOEXEC;
+#endif
+ if (m_pty->OpenFirstAvailableMaster(open_flags, NULL, 0))
{
const char *slave_path = m_pty->GetSlaveName(NULL, 0);
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index c46db4cfadf9b..01a8c9ab88f26 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -18,6 +18,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Core/ValueObjectConstResult.h"
@@ -1373,11 +1374,11 @@ StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker)
if (frame_marker)
s.PutCString(frame_marker);
- const char *frame_format = NULL;
+ const FormatEntity::Entry *frame_format = NULL;
Target *target = exe_ctx.GetTargetPtr();
if (target)
frame_format = target->GetDebugger().GetFrameFormat();
- if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s))
+ if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx, NULL, NULL, false, false))
{
strm->Write(s.GetData(), s.GetSize());
}
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 4b57ca65a2dff..457b94c1dc20a 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -479,7 +479,12 @@ protected:
condition_says_stop);
}
if (!condition_says_stop)
+ {
+ // We don't want to increment the hit count of breakpoints if the condition fails.
+ // We've already bumped it by the time we get here, so undo the bump:
+ bp_loc_sp->UndoBumpHitCount();
continue;
+ }
}
}
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index 28ad47e3d81d7..bbed0fb0bc127 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -98,12 +98,12 @@ TargetList::CreateTarget (Debugger &debugger,
Error
TargetList::CreateTargetInternal (Debugger &debugger,
- const char *user_exe_path,
- const char *triple_cstr,
- bool get_dependent_files,
- const OptionGroupPlatform *platform_options,
- TargetSP &target_sp,
- bool is_dummy_target)
+ const char *user_exe_path,
+ const char *triple_cstr,
+ bool get_dependent_files,
+ const OptionGroupPlatform *platform_options,
+ TargetSP &target_sp,
+ bool is_dummy_target)
{
Error error;
PlatformSP platform_sp;
@@ -126,16 +126,24 @@ TargetList::CreateTargetInternal (Debugger &debugger,
bool prefer_platform_arch = false;
CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
+
+ // let's see if there is already an existing plaform before we go creating another...
+ platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
+
if (platform_options && platform_options->PlatformWasSpecified ())
{
- const bool select_platform = true;
- platform_sp = platform_options->CreatePlatformWithOptions (interpreter,
- arch,
- select_platform,
- error,
- platform_arch);
- if (!platform_sp)
- return error;
+ // Create a new platform if it doesn't match the selected platform
+ if (!platform_options->PlatformMatches(platform_sp))
+ {
+ const bool select_platform = true;
+ platform_sp = platform_options->CreatePlatformWithOptions (interpreter,
+ arch,
+ select_platform,
+ error,
+ platform_arch);
+ if (!platform_sp)
+ return error;
+ }
}
if (user_exe_path && user_exe_path[0])
@@ -361,12 +369,12 @@ TargetList::CreateDummyTarget (Debugger &debugger,
Error
TargetList::CreateTargetInternal (Debugger &debugger,
- const char *user_exe_path,
- const ArchSpec& specified_arch,
- bool get_dependent_files,
- lldb::PlatformSP &platform_sp,
- lldb::TargetSP &target_sp,
- bool is_dummy_target)
+ const char *user_exe_path,
+ const ArchSpec& specified_arch,
+ bool get_dependent_files,
+ lldb::PlatformSP &platform_sp,
+ lldb::TargetSP &target_sp,
+ bool is_dummy_target)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index b532d8d71c8f8..6fd5cdf0d15c6 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -13,6 +13,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
@@ -66,8 +67,8 @@ g_properties[] =
{ "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, step-in will not stop in functions with no debug information." },
{ "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with "
"debug information. Passing a frame argument to step-out will override this option." },
- { "step-avoid-regexp", OptionValue::eTypeRegex , true , REG_EXTENDED, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
- { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , REG_EXTENDED, NULL, NULL, "A list of libraries that source stepping won't stop in." },
+ { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
+ { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, NULL, NULL, "A list of libraries that source stepping won't stop in." },
{ "trace-thread", OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." },
{ NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
};
@@ -2033,7 +2034,7 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
StackFrameSP frame_sp;
SymbolContext frame_sc;
- if (frame_idx != LLDB_INVALID_INDEX32)
+ if (frame_idx != LLDB_INVALID_FRAME_ID)
{
frame_sp = GetStackFrameAtIndex (frame_idx);
if (frame_sp)
@@ -2043,13 +2044,17 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
}
}
- const char *thread_format = exe_ctx.GetTargetRef().GetDebugger().GetThreadFormat();
+ const FormatEntity::Entry *thread_format = exe_ctx.GetTargetRef().GetDebugger().GetThreadFormat();
assert (thread_format);
- Debugger::FormatPrompt (thread_format,
- frame_sp ? &frame_sc : NULL,
- &exe_ctx,
- NULL,
- strm);
+
+ FormatEntity::Format(*thread_format,
+ strm,
+ frame_sp ? &frame_sc : NULL,
+ &exe_ctx,
+ NULL,
+ NULL,
+ false,
+ false);
}
void
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index d2b039d69f673..0629eb9981efa 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -212,7 +212,7 @@ ThreadPlanAssemblyTracer::Log ()
const bool show_bytes = true;
const bool show_address = true;
Instruction *instruction = instruction_list.GetInstructionAtIndex(0).get();
- const char *disassemble_format = "${addr-file-or-load}: ";
+ const FormatEntity::Entry *disassemble_format = m_thread.GetProcess()->GetTarget().GetDebugger().GetDisassemblyFormat();
instruction->Dump (stream,
max_opcode_byte_size,
show_address,
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index 16a35b5f5a2f3..7f57579c1ee5b 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Host/StringConvert.h"
using namespace lldb_private;
@@ -148,7 +148,7 @@ UnixSignals::GetSignalNumberFromName (const char *name) const
return pos->first;
}
- const int32_t signo = Args::StringToSInt32(name, LLDB_INVALID_SIGNAL_NUMBER, 0);
+ const int32_t signo = StringConvert::ToSInt32(name, LLDB_INVALID_SIGNAL_NUMBER, 0);
if (signo != LLDB_INVALID_SIGNAL_NUMBER)
return signo;
return LLDB_INVALID_SIGNAL_NUMBER;