Remove a few files missed in the last lldb import.
This commit is contained in:
parent
b229c1a0b0
commit
58df0addff
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/clang380-import/; revision=293577
@ -1,708 +0,0 @@
|
||||
//===-- NSArray.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/DataFormatters/CXXFormatterFunctions.h"
|
||||
|
||||
#include "lldb/Core/DataBufferHeap.h"
|
||||
#include "lldb/Core/Error.h"
|
||||
#include "lldb/Core/Stream.h"
|
||||
#include "lldb/Core/ValueObject.h"
|
||||
#include "lldb/Core/ValueObjectConstResult.h"
|
||||
#include "lldb/Host/Endian.h"
|
||||
#include "lldb/Symbol/ClangASTContext.h"
|
||||
#include "lldb/Target/ObjCLanguageRuntime.h"
|
||||
#include "lldb/Target/Target.h"
|
||||
|
||||
#include "clang/AST/ASTContext.h"
|
||||
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
using namespace lldb_private::formatters;
|
||||
|
||||
namespace lldb_private {
|
||||
namespace formatters {
|
||||
class NSArrayMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
|
||||
{
|
||||
public:
|
||||
NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
|
||||
|
||||
virtual size_t
|
||||
CalculateNumChildren ();
|
||||
|
||||
virtual lldb::ValueObjectSP
|
||||
GetChildAtIndex (size_t idx);
|
||||
|
||||
virtual bool
|
||||
Update() = 0;
|
||||
|
||||
virtual bool
|
||||
MightHaveChildren ();
|
||||
|
||||
virtual size_t
|
||||
GetIndexOfChildWithName (const ConstString &name);
|
||||
|
||||
virtual
|
||||
~NSArrayMSyntheticFrontEnd () {}
|
||||
|
||||
protected:
|
||||
virtual lldb::addr_t
|
||||
GetDataAddress () = 0;
|
||||
|
||||
virtual uint64_t
|
||||
GetUsedCount () = 0;
|
||||
|
||||
virtual uint64_t
|
||||
GetOffset () = 0;
|
||||
|
||||
virtual uint64_t
|
||||
GetSize () = 0;
|
||||
|
||||
ExecutionContextRef m_exe_ctx_ref;
|
||||
uint8_t m_ptr_size;
|
||||
ClangASTType m_id_type;
|
||||
std::vector<lldb::ValueObjectSP> m_children;
|
||||
};
|
||||
|
||||
class NSArrayMSyntheticFrontEnd_109 : public NSArrayMSyntheticFrontEnd
|
||||
{
|
||||
private:
|
||||
struct DataDescriptor_32
|
||||
{
|
||||
uint32_t _used;
|
||||
uint32_t _priv1 : 2 ;
|
||||
uint32_t _size : 30;
|
||||
uint32_t _priv2 : 2;
|
||||
uint32_t _offset : 30;
|
||||
uint32_t _priv3;
|
||||
uint32_t _data;
|
||||
};
|
||||
struct DataDescriptor_64
|
||||
{
|
||||
uint64_t _used;
|
||||
uint64_t _priv1 : 2 ;
|
||||
uint64_t _size : 62;
|
||||
uint64_t _priv2 : 2;
|
||||
uint64_t _offset : 62;
|
||||
uint32_t _priv3;
|
||||
uint64_t _data;
|
||||
};
|
||||
public:
|
||||
NSArrayMSyntheticFrontEnd_109 (lldb::ValueObjectSP valobj_sp);
|
||||
|
||||
virtual bool
|
||||
Update();
|
||||
|
||||
virtual
|
||||
~NSArrayMSyntheticFrontEnd_109 ();
|
||||
|
||||
protected:
|
||||
virtual lldb::addr_t
|
||||
GetDataAddress ();
|
||||
|
||||
virtual uint64_t
|
||||
GetUsedCount ();
|
||||
|
||||
virtual uint64_t
|
||||
GetOffset ();
|
||||
|
||||
virtual uint64_t
|
||||
GetSize ();
|
||||
|
||||
private:
|
||||
DataDescriptor_32 *m_data_32;
|
||||
DataDescriptor_64 *m_data_64;
|
||||
};
|
||||
|
||||
class NSArrayMSyntheticFrontEnd_1010 : public NSArrayMSyntheticFrontEnd
|
||||
{
|
||||
private:
|
||||
struct DataDescriptor_32
|
||||
{
|
||||
uint32_t _used;
|
||||
uint32_t _offset;
|
||||
uint32_t _size : 28;
|
||||
uint64_t _priv1 : 4;
|
||||
uint32_t _priv2;
|
||||
uint32_t _data;
|
||||
};
|
||||
struct DataDescriptor_64
|
||||
{
|
||||
uint64_t _used;
|
||||
uint64_t _offset;
|
||||
uint64_t _size : 60;
|
||||
uint64_t _priv1 : 4;
|
||||
uint32_t _priv2;
|
||||
uint64_t _data;
|
||||
};
|
||||
public:
|
||||
NSArrayMSyntheticFrontEnd_1010 (lldb::ValueObjectSP valobj_sp);
|
||||
|
||||
virtual bool
|
||||
Update();
|
||||
|
||||
virtual
|
||||
~NSArrayMSyntheticFrontEnd_1010 ();
|
||||
|
||||
protected:
|
||||
virtual lldb::addr_t
|
||||
GetDataAddress ();
|
||||
|
||||
virtual uint64_t
|
||||
GetUsedCount ();
|
||||
|
||||
virtual uint64_t
|
||||
GetOffset ();
|
||||
|
||||
virtual uint64_t
|
||||
GetSize ();
|
||||
|
||||
private:
|
||||
DataDescriptor_32 *m_data_32;
|
||||
DataDescriptor_64 *m_data_64;
|
||||
};
|
||||
|
||||
class NSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd
|
||||
{
|
||||
public:
|
||||
NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
|
||||
|
||||
virtual size_t
|
||||
CalculateNumChildren ();
|
||||
|
||||
virtual lldb::ValueObjectSP
|
||||
GetChildAtIndex (size_t idx);
|
||||
|
||||
virtual bool
|
||||
Update();
|
||||
|
||||
virtual bool
|
||||
MightHaveChildren ();
|
||||
|
||||
virtual size_t
|
||||
GetIndexOfChildWithName (const ConstString &name);
|
||||
|
||||
virtual
|
||||
~NSArrayISyntheticFrontEnd ();
|
||||
private:
|
||||
ExecutionContextRef m_exe_ctx_ref;
|
||||
uint8_t m_ptr_size;
|
||||
uint64_t m_items;
|
||||
lldb::addr_t m_data_ptr;
|
||||
ClangASTType m_id_type;
|
||||
std::vector<lldb::ValueObjectSP> m_children;
|
||||
};
|
||||
|
||||
class NSArrayCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
|
||||
{
|
||||
public:
|
||||
NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
|
||||
|
||||
virtual size_t
|
||||
CalculateNumChildren ();
|
||||
|
||||
virtual lldb::ValueObjectSP
|
||||
GetChildAtIndex (size_t idx);
|
||||
|
||||
virtual bool
|
||||
Update();
|
||||
|
||||
virtual bool
|
||||
MightHaveChildren ();
|
||||
|
||||
virtual size_t
|
||||
GetIndexOfChildWithName (const ConstString &name);
|
||||
|
||||
virtual
|
||||
~NSArrayCodeRunningSyntheticFrontEnd ();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
|
||||
{
|
||||
ProcessSP process_sp = valobj.GetProcessSP();
|
||||
if (!process_sp)
|
||||
return false;
|
||||
|
||||
ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
|
||||
|
||||
if (!runtime)
|
||||
return false;
|
||||
|
||||
ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
|
||||
|
||||
if (!descriptor.get() || !descriptor->IsValid())
|
||||
return false;
|
||||
|
||||
uint32_t ptr_size = process_sp->GetAddressByteSize();
|
||||
|
||||
lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
|
||||
|
||||
if (!valobj_addr)
|
||||
return false;
|
||||
|
||||
uint64_t value = 0;
|
||||
|
||||
const char* class_name = descriptor->GetClassName().GetCString();
|
||||
|
||||
if (!class_name || !*class_name)
|
||||
return false;
|
||||
|
||||
if (!strcmp(class_name,"__NSArrayI"))
|
||||
{
|
||||
Error error;
|
||||
value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
|
||||
if (error.Fail())
|
||||
return false;
|
||||
}
|
||||
else if (!strcmp(class_name,"__NSArrayM"))
|
||||
{
|
||||
Error error;
|
||||
value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
|
||||
if (error.Fail())
|
||||
return false;
|
||||
}
|
||||
else if (!strcmp(class_name,"__NSCFArray"))
|
||||
{
|
||||
Error error;
|
||||
value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + 2 * ptr_size, ptr_size, 0, error);
|
||||
if (error.Fail())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ExtractValueFromObjCExpression(valobj, "int", "count", value))
|
||||
return false;
|
||||
}
|
||||
|
||||
stream.Printf("@\"%" PRIu64 " object%s\"",
|
||||
value,
|
||||
value == 1 ? "" : "s");
|
||||
return true;
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd::NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
|
||||
SyntheticChildrenFrontEnd(*valobj_sp),
|
||||
m_exe_ctx_ref(),
|
||||
m_ptr_size(8),
|
||||
m_id_type(),
|
||||
m_children()
|
||||
{
|
||||
if (valobj_sp)
|
||||
{
|
||||
clang::ASTContext *ast = valobj_sp->GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext()->getASTContext();
|
||||
if (ast)
|
||||
m_id_type = ClangASTType(ast, ast->ObjCBuiltinIdTy);
|
||||
if (valobj_sp->GetProcessSP())
|
||||
m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize();
|
||||
}
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::NSArrayMSyntheticFrontEnd_109 (lldb::ValueObjectSP valobj_sp) :
|
||||
NSArrayMSyntheticFrontEnd(valobj_sp),
|
||||
m_data_32(NULL),
|
||||
m_data_64(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::NSArrayMSyntheticFrontEnd_1010 (lldb::ValueObjectSP valobj_sp) :
|
||||
NSArrayMSyntheticFrontEnd(valobj_sp),
|
||||
m_data_32(NULL),
|
||||
m_data_64(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
size_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd::CalculateNumChildren ()
|
||||
{
|
||||
return GetUsedCount();
|
||||
}
|
||||
|
||||
lldb::ValueObjectSP
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetChildAtIndex (size_t idx)
|
||||
{
|
||||
if (idx >= CalculateNumChildren())
|
||||
return lldb::ValueObjectSP();
|
||||
lldb::addr_t object_at_idx = GetDataAddress();
|
||||
size_t pyhs_idx = idx;
|
||||
pyhs_idx += GetOffset();
|
||||
if (GetSize() <= pyhs_idx)
|
||||
pyhs_idx -= GetSize();
|
||||
object_at_idx += (pyhs_idx * m_ptr_size);
|
||||
StreamString idx_name;
|
||||
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
|
||||
lldb::ValueObjectSP retval_sp = CreateValueObjectFromAddress(idx_name.GetData(),
|
||||
object_at_idx,
|
||||
m_exe_ctx_ref,
|
||||
m_id_type);
|
||||
m_children.push_back(retval_sp);
|
||||
return retval_sp;
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::Update()
|
||||
{
|
||||
m_children.clear();
|
||||
ValueObjectSP valobj_sp = m_backend.GetSP();
|
||||
m_ptr_size = 0;
|
||||
delete m_data_32;
|
||||
m_data_32 = NULL;
|
||||
delete m_data_64;
|
||||
m_data_64 = NULL;
|
||||
if (!valobj_sp)
|
||||
return false;
|
||||
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
|
||||
Error error;
|
||||
error.Clear();
|
||||
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
|
||||
if (!process_sp)
|
||||
return false;
|
||||
m_ptr_size = process_sp->GetAddressByteSize();
|
||||
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
|
||||
if (m_ptr_size == 4)
|
||||
{
|
||||
m_data_32 = new DataDescriptor_32();
|
||||
process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data_64 = new DataDescriptor_64();
|
||||
process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
|
||||
}
|
||||
if (error.Fail())
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::Update()
|
||||
{
|
||||
m_children.clear();
|
||||
ValueObjectSP valobj_sp = m_backend.GetSP();
|
||||
m_ptr_size = 0;
|
||||
delete m_data_32;
|
||||
m_data_32 = NULL;
|
||||
delete m_data_64;
|
||||
m_data_64 = NULL;
|
||||
if (!valobj_sp)
|
||||
return false;
|
||||
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
|
||||
Error error;
|
||||
error.Clear();
|
||||
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
|
||||
if (!process_sp)
|
||||
return false;
|
||||
m_ptr_size = process_sp->GetAddressByteSize();
|
||||
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
|
||||
if (m_ptr_size == 4)
|
||||
{
|
||||
m_data_32 = new DataDescriptor_32();
|
||||
process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data_64 = new DataDescriptor_64();
|
||||
process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
|
||||
}
|
||||
if (error.Fail())
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd::MightHaveChildren ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
|
||||
{
|
||||
const char* item_name = name.GetCString();
|
||||
uint32_t idx = ExtractIndexFromString(item_name);
|
||||
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
|
||||
return UINT32_MAX;
|
||||
return idx;
|
||||
}
|
||||
|
||||
lldb::addr_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::GetDataAddress ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
return m_data_32 ? m_data_32->_data :
|
||||
m_data_64->_data;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::GetUsedCount ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return 0;
|
||||
return m_data_32 ? m_data_32->_used :
|
||||
m_data_64->_used;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::GetOffset ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return 0;
|
||||
return m_data_32 ? m_data_32->_offset :
|
||||
m_data_64->_offset;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::GetSize ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return 0;
|
||||
return m_data_32 ? m_data_32->_size :
|
||||
m_data_64->_size;
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::~NSArrayMSyntheticFrontEnd_109 ()
|
||||
{
|
||||
delete m_data_32;
|
||||
m_data_32 = NULL;
|
||||
delete m_data_64;
|
||||
m_data_64 = NULL;
|
||||
}
|
||||
|
||||
lldb::addr_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::GetDataAddress ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
return m_data_32 ? m_data_32->_data :
|
||||
m_data_64->_data;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::GetUsedCount ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return 0;
|
||||
return m_data_32 ? m_data_32->_used :
|
||||
m_data_64->_used;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::GetOffset ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return 0;
|
||||
return m_data_32 ? m_data_32->_offset :
|
||||
m_data_64->_offset;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::GetSize ()
|
||||
{
|
||||
if (!m_data_32 && !m_data_64)
|
||||
return 0;
|
||||
return m_data_32 ? m_data_32->_size :
|
||||
m_data_64->_size;
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::~NSArrayMSyntheticFrontEnd_1010 ()
|
||||
{
|
||||
delete m_data_32;
|
||||
m_data_32 = NULL;
|
||||
delete m_data_64;
|
||||
m_data_64 = NULL;
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
|
||||
SyntheticChildrenFrontEnd (*valobj_sp.get()),
|
||||
m_exe_ctx_ref (),
|
||||
m_ptr_size (8),
|
||||
m_items (0),
|
||||
m_data_ptr (0)
|
||||
{
|
||||
if (valobj_sp)
|
||||
{
|
||||
clang::ASTContext *ast = valobj_sp->GetClangType().GetASTContext();
|
||||
if (ast)
|
||||
m_id_type = ClangASTType(ast, ast->ObjCBuiltinIdTy);
|
||||
}
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::~NSArrayISyntheticFrontEnd ()
|
||||
{
|
||||
}
|
||||
|
||||
size_t
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
|
||||
{
|
||||
const char* item_name = name.GetCString();
|
||||
uint32_t idx = ExtractIndexFromString(item_name);
|
||||
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
|
||||
return UINT32_MAX;
|
||||
return idx;
|
||||
}
|
||||
|
||||
size_t
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::CalculateNumChildren ()
|
||||
{
|
||||
return m_items;
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::Update()
|
||||
{
|
||||
m_ptr_size = 0;
|
||||
m_items = 0;
|
||||
m_data_ptr = 0;
|
||||
m_children.clear();
|
||||
ValueObjectSP valobj_sp = m_backend.GetSP();
|
||||
if (!valobj_sp)
|
||||
return false;
|
||||
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
|
||||
Error error;
|
||||
error.Clear();
|
||||
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
|
||||
if (!process_sp)
|
||||
return false;
|
||||
m_ptr_size = process_sp->GetAddressByteSize();
|
||||
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
|
||||
m_items = process_sp->ReadPointerFromMemory(data_location, error);
|
||||
if (error.Fail())
|
||||
return false;
|
||||
m_data_ptr = data_location+m_ptr_size;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::MightHaveChildren ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
lldb::ValueObjectSP
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex (size_t idx)
|
||||
{
|
||||
if (idx >= CalculateNumChildren())
|
||||
return lldb::ValueObjectSP();
|
||||
lldb::addr_t object_at_idx = m_data_ptr;
|
||||
object_at_idx += (idx * m_ptr_size);
|
||||
ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
|
||||
if (!process_sp)
|
||||
return lldb::ValueObjectSP();
|
||||
Error error;
|
||||
if (error.Fail())
|
||||
return lldb::ValueObjectSP();
|
||||
StreamString idx_name;
|
||||
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
|
||||
lldb::ValueObjectSP retval_sp = CreateValueObjectFromAddress(idx_name.GetData(),
|
||||
object_at_idx,
|
||||
m_exe_ctx_ref,
|
||||
m_id_type);
|
||||
m_children.push_back(retval_sp);
|
||||
return retval_sp;
|
||||
}
|
||||
|
||||
SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
|
||||
{
|
||||
return nullptr; // Avoid need for AppleObjCRuntime on FreeBSD
|
||||
#if 0
|
||||
if (!valobj_sp)
|
||||
return nullptr;
|
||||
|
||||
lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
|
||||
if (!process_sp)
|
||||
return NULL;
|
||||
AppleObjCRuntime *runtime = (AppleObjCRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
|
||||
if (!runtime)
|
||||
return NULL;
|
||||
|
||||
ClangASTType valobj_type(valobj_sp->GetClangType());
|
||||
Flags flags(valobj_type.GetTypeInfo());
|
||||
|
||||
if (flags.IsClear(eTypeIsPointer))
|
||||
{
|
||||
Error error;
|
||||
valobj_sp = valobj_sp->AddressOf(error);
|
||||
if (error.Fail() || !valobj_sp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
|
||||
|
||||
if (!descriptor.get() || !descriptor->IsValid())
|
||||
return NULL;
|
||||
|
||||
const char* class_name = descriptor->GetClassName().GetCString();
|
||||
|
||||
if (!class_name || !*class_name)
|
||||
return NULL;
|
||||
|
||||
if (!strcmp(class_name,"__NSArrayI"))
|
||||
{
|
||||
return (new NSArrayISyntheticFrontEnd(valobj_sp));
|
||||
}
|
||||
else if (!strcmp(class_name,"__NSArrayM"))
|
||||
{
|
||||
if (runtime->GetFoundationVersion() >= 1100)
|
||||
return (new NSArrayMSyntheticFrontEnd_1010(valobj_sp));
|
||||
else
|
||||
return (new NSArrayMSyntheticFrontEnd_109(valobj_sp));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (new NSArrayCodeRunningSyntheticFrontEnd(valobj_sp));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
|
||||
SyntheticChildrenFrontEnd(*valobj_sp.get())
|
||||
{}
|
||||
|
||||
size_t
|
||||
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::CalculateNumChildren ()
|
||||
{
|
||||
uint64_t count = 0;
|
||||
if (ExtractValueFromObjCExpression(m_backend, "int", "count", count))
|
||||
return count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
lldb::ValueObjectSP
|
||||
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetChildAtIndex (size_t idx)
|
||||
{
|
||||
StreamString idx_name;
|
||||
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
|
||||
lldb::ValueObjectSP valobj_sp = CallSelectorOnObject(m_backend,"id","objectAtIndex:",idx);
|
||||
if (valobj_sp)
|
||||
valobj_sp->SetName(ConstString(idx_name.GetData()));
|
||||
return valobj_sp;
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::Update()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::MightHaveChildren ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t
|
||||
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::~NSArrayCodeRunningSyntheticFrontEnd ()
|
||||
{}
|
@ -1,665 +0,0 @@
|
||||
//===-- POSIXThread.cpp -----------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// C Includes
|
||||
#include <errno.h>
|
||||
|
||||
// C++ Includes
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/Breakpoint/Watchpoint.h"
|
||||
#include "lldb/Breakpoint/BreakpointLocation.h"
|
||||
#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"
|
||||
#include "ProcessPOSIXLog.h"
|
||||
#include "ProcessMonitor.h"
|
||||
#include "RegisterContextPOSIXProcessMonitor_arm.h"
|
||||
#include "RegisterContextPOSIXProcessMonitor_arm64.h"
|
||||
#include "RegisterContextPOSIXProcessMonitor_mips64.h"
|
||||
#include "RegisterContextPOSIXProcessMonitor_powerpc.h"
|
||||
#include "RegisterContextPOSIXProcessMonitor_x86.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
|
||||
#include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
|
||||
#include "Plugins/Process/Utility/UnwindLLDB.h"
|
||||
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
|
||||
POSIXThread::POSIXThread(Process &process, lldb::tid_t tid)
|
||||
: Thread(process, tid),
|
||||
m_frame_ap (),
|
||||
m_breakpoint (),
|
||||
m_thread_name_valid (false),
|
||||
m_thread_name (),
|
||||
m_posix_thread(NULL)
|
||||
{
|
||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
|
||||
if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
|
||||
log->Printf ("POSIXThread::%s (tid = %" PRIi64 ")", __FUNCTION__, tid);
|
||||
|
||||
// Set the current watchpoints for this thread.
|
||||
Target &target = GetProcess()->GetTarget();
|
||||
const WatchpointList &wp_list = target.GetWatchpointList();
|
||||
size_t wp_size = wp_list.GetSize();
|
||||
|
||||
for (uint32_t wp_idx = 0; wp_idx < wp_size; wp_idx++)
|
||||
{
|
||||
lldb::WatchpointSP wp = wp_list.GetByIndex(wp_idx);
|
||||
if (wp.get() && wp->IsEnabled())
|
||||
{
|
||||
// This watchpoint as been enabled; obviously this "new" thread
|
||||
// has been created since that watchpoint was enabled. Since
|
||||
// the POSIXBreakpointProtocol has yet to be initialized, its
|
||||
// m_watchpoints_initialized member will be FALSE. Attempting to
|
||||
// read the debug status register to determine if a watchpoint
|
||||
// has been hit would result in the zeroing of that register.
|
||||
// Since the active debug registers would have been cloned when
|
||||
// this thread was created, simply force the m_watchpoints_initized
|
||||
// member to TRUE and avoid resetting dr6 and dr7.
|
||||
GetPOSIXBreakpointProtocol()->ForceWatchpointsInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
POSIXThread::~POSIXThread()
|
||||
{
|
||||
DestroyThread();
|
||||
}
|
||||
|
||||
ProcessMonitor &
|
||||
POSIXThread::GetMonitor()
|
||||
{
|
||||
ProcessSP base = GetProcess();
|
||||
ProcessPOSIX &process = static_cast<ProcessPOSIX&>(*base);
|
||||
return process.GetMonitor();
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::RefreshStateAfterStop()
|
||||
{
|
||||
// Invalidate all registers in our register context. We don't set "force" to
|
||||
// true because the stop reply packet might have had some register values
|
||||
// that were expedited and these will already be copied into the register
|
||||
// context by the time this function gets called. The KDPRegisterContext
|
||||
// class has been made smart enough to detect when it needs to invalidate
|
||||
// which registers are valid by putting hooks in the register read and
|
||||
// register supply functions where they check the process stop ID and do
|
||||
// the right thing.
|
||||
//if (StateIsStoppedState(GetState())
|
||||
{
|
||||
const bool force = false;
|
||||
GetRegisterContext()->InvalidateIfNeeded (force);
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
POSIXThread::GetInfo()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::SetName (const char *name)
|
||||
{
|
||||
m_thread_name_valid = (name && name[0]);
|
||||
if (m_thread_name_valid)
|
||||
m_thread_name.assign (name);
|
||||
else
|
||||
m_thread_name.clear();
|
||||
}
|
||||
|
||||
const char *
|
||||
POSIXThread::GetName ()
|
||||
{
|
||||
if (!m_thread_name_valid)
|
||||
{
|
||||
llvm::SmallString<32> thread_name;
|
||||
HostNativeThread::GetName(GetID(), thread_name);
|
||||
m_thread_name = thread_name.c_str();
|
||||
m_thread_name_valid = true;
|
||||
}
|
||||
|
||||
if (m_thread_name.empty())
|
||||
return NULL;
|
||||
return m_thread_name.c_str();
|
||||
}
|
||||
|
||||
lldb::RegisterContextSP
|
||||
POSIXThread::GetRegisterContext()
|
||||
{
|
||||
if (!m_reg_context_sp)
|
||||
{
|
||||
m_posix_thread = NULL;
|
||||
|
||||
RegisterInfoInterface *reg_interface = NULL;
|
||||
const ArchSpec &target_arch = GetProcess()->GetTarget().GetArchitecture();
|
||||
|
||||
switch (target_arch.GetTriple().getOS())
|
||||
{
|
||||
case llvm::Triple::FreeBSD:
|
||||
switch (target_arch.GetMachine())
|
||||
{
|
||||
case llvm::Triple::aarch64:
|
||||
reg_interface = new RegisterContextFreeBSD_arm64(target_arch);
|
||||
break;
|
||||
case llvm::Triple::arm:
|
||||
reg_interface = new RegisterContextFreeBSD_arm(target_arch);
|
||||
break;
|
||||
case llvm::Triple::ppc:
|
||||
#ifndef __powerpc64__
|
||||
reg_interface = new RegisterContextFreeBSD_powerpc32(target_arch);
|
||||
break;
|
||||
#endif
|
||||
case llvm::Triple::ppc64:
|
||||
reg_interface = new RegisterContextFreeBSD_powerpc64(target_arch);
|
||||
break;
|
||||
case llvm::Triple::mips64:
|
||||
reg_interface = new RegisterContextFreeBSD_mips64(target_arch);
|
||||
break;
|
||||
case llvm::Triple::x86:
|
||||
reg_interface = new RegisterContextFreeBSD_i386(target_arch);
|
||||
break;
|
||||
case llvm::Triple::x86_64:
|
||||
reg_interface = new RegisterContextFreeBSD_x86_64(target_arch);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
assert(reg_interface && "OS or CPU not supported!");
|
||||
|
||||
switch (target_arch.GetMachine())
|
||||
{
|
||||
case llvm::Triple::aarch64:
|
||||
{
|
||||
RegisterContextPOSIXProcessMonitor_arm64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_arm64(*this, 0, reg_interface);
|
||||
m_posix_thread = reg_ctx;
|
||||
m_reg_context_sp.reset(reg_ctx);
|
||||
break;
|
||||
}
|
||||
case llvm::Triple::arm:
|
||||
{
|
||||
RegisterContextPOSIXProcessMonitor_arm *reg_ctx = new RegisterContextPOSIXProcessMonitor_arm(*this, 0, reg_interface);
|
||||
m_posix_thread = reg_ctx;
|
||||
m_reg_context_sp.reset(reg_ctx);
|
||||
break;
|
||||
}
|
||||
case llvm::Triple::mips64:
|
||||
{
|
||||
RegisterContextPOSIXProcessMonitor_mips64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_mips64(*this, 0, reg_interface);
|
||||
m_posix_thread = reg_ctx;
|
||||
m_reg_context_sp.reset(reg_ctx);
|
||||
break;
|
||||
}
|
||||
case llvm::Triple::ppc:
|
||||
case llvm::Triple::ppc64:
|
||||
{
|
||||
RegisterContextPOSIXProcessMonitor_powerpc *reg_ctx = new RegisterContextPOSIXProcessMonitor_powerpc(*this, 0, reg_interface);
|
||||
m_posix_thread = reg_ctx;
|
||||
m_reg_context_sp.reset(reg_ctx);
|
||||
break;
|
||||
}
|
||||
case llvm::Triple::x86:
|
||||
case llvm::Triple::x86_64:
|
||||
{
|
||||
RegisterContextPOSIXProcessMonitor_x86_64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_x86_64(*this, 0, reg_interface);
|
||||
m_posix_thread = reg_ctx;
|
||||
m_reg_context_sp.reset(reg_ctx);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m_reg_context_sp;
|
||||
}
|
||||
|
||||
lldb::RegisterContextSP
|
||||
POSIXThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame)
|
||||
{
|
||||
lldb::RegisterContextSP reg_ctx_sp;
|
||||
uint32_t concrete_frame_idx = 0;
|
||||
|
||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
|
||||
if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
|
||||
log->Printf ("POSIXThread::%s ()", __FUNCTION__);
|
||||
|
||||
if (frame)
|
||||
concrete_frame_idx = frame->GetConcreteFrameIndex();
|
||||
|
||||
if (concrete_frame_idx == 0)
|
||||
reg_ctx_sp = GetRegisterContext();
|
||||
else
|
||||
{
|
||||
assert(GetUnwinder());
|
||||
reg_ctx_sp = GetUnwinder()->CreateRegisterContextForFrame(frame);
|
||||
}
|
||||
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
lldb::addr_t
|
||||
POSIXThread::GetThreadPointer ()
|
||||
{
|
||||
ProcessMonitor &monitor = GetMonitor();
|
||||
addr_t addr;
|
||||
if (monitor.ReadThreadPointer (GetID(), addr))
|
||||
return addr;
|
||||
else
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
bool
|
||||
POSIXThread::CalculateStopInfo()
|
||||
{
|
||||
SetStopInfo (m_stop_info_sp);
|
||||
return true;
|
||||
}
|
||||
|
||||
Unwind *
|
||||
POSIXThread::GetUnwinder()
|
||||
{
|
||||
if (m_unwinder_ap.get() == NULL)
|
||||
m_unwinder_ap.reset(new UnwindLLDB(*this));
|
||||
|
||||
return m_unwinder_ap.get();
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::DidStop()
|
||||
{
|
||||
// Don't set the thread state to stopped unless we really stopped.
|
||||
}
|
||||
|
||||
bool
|
||||
POSIXThread::Resume()
|
||||
{
|
||||
lldb::StateType resume_state = GetResumeState();
|
||||
ProcessMonitor &monitor = GetMonitor();
|
||||
bool status;
|
||||
|
||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
|
||||
if (log)
|
||||
log->Printf ("POSIXThread::%s (), resume_state = %s", __FUNCTION__,
|
||||
StateAsCString(resume_state));
|
||||
|
||||
switch (resume_state)
|
||||
{
|
||||
default:
|
||||
assert(false && "Unexpected state for resume!");
|
||||
status = false;
|
||||
break;
|
||||
|
||||
case lldb::eStateRunning:
|
||||
SetState(resume_state);
|
||||
status = monitor.Resume(GetID(), GetResumeSignal());
|
||||
break;
|
||||
|
||||
case lldb::eStateStepping:
|
||||
SetState(resume_state);
|
||||
status = monitor.SingleStep(GetID(), GetResumeSignal());
|
||||
break;
|
||||
case lldb::eStateStopped:
|
||||
case lldb::eStateSuspended:
|
||||
status = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::Notify(const ProcessMessage &message)
|
||||
{
|
||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
|
||||
if (log)
|
||||
log->Printf ("POSIXThread::%s () message kind = '%s' for tid %" PRIu64,
|
||||
__FUNCTION__, message.PrintKind(), GetID());
|
||||
|
||||
switch (message.GetKind())
|
||||
{
|
||||
default:
|
||||
assert(false && "Unexpected message kind!");
|
||||
break;
|
||||
|
||||
case ProcessMessage::eExitMessage:
|
||||
// Nothing to be done.
|
||||
break;
|
||||
|
||||
case ProcessMessage::eLimboMessage:
|
||||
LimboNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eSignalMessage:
|
||||
SignalNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eSignalDeliveredMessage:
|
||||
SignalDeliveredNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eTraceMessage:
|
||||
TraceNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eBreakpointMessage:
|
||||
BreakNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eWatchpointMessage:
|
||||
WatchNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eCrashMessage:
|
||||
CrashNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eNewThreadMessage:
|
||||
ThreadNotify(message);
|
||||
break;
|
||||
|
||||
case ProcessMessage::eExecMessage:
|
||||
ExecNotify(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
POSIXThread::EnableHardwareWatchpoint(Watchpoint *wp)
|
||||
{
|
||||
bool wp_set = false;
|
||||
if (wp)
|
||||
{
|
||||
addr_t wp_addr = wp->GetLoadAddress();
|
||||
size_t wp_size = wp->GetByteSize();
|
||||
bool wp_read = wp->WatchpointRead();
|
||||
bool wp_write = wp->WatchpointWrite();
|
||||
uint32_t wp_hw_index = wp->GetHardwareIndex();
|
||||
POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
|
||||
if (reg_ctx)
|
||||
wp_set = reg_ctx->SetHardwareWatchpointWithIndex(wp_addr, wp_size,
|
||||
wp_read, wp_write,
|
||||
wp_hw_index);
|
||||
}
|
||||
return wp_set;
|
||||
}
|
||||
|
||||
bool
|
||||
POSIXThread::DisableHardwareWatchpoint(Watchpoint *wp)
|
||||
{
|
||||
bool result = false;
|
||||
if (wp)
|
||||
{
|
||||
lldb::RegisterContextSP reg_ctx_sp = GetRegisterContext();
|
||||
if (reg_ctx_sp.get())
|
||||
result = reg_ctx_sp->ClearHardwareWatchpoint(wp->GetHardwareIndex());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
POSIXThread::NumSupportedHardwareWatchpoints()
|
||||
{
|
||||
lldb::RegisterContextSP reg_ctx_sp = GetRegisterContext();
|
||||
if (reg_ctx_sp.get())
|
||||
return reg_ctx_sp->NumSupportedHardwareWatchpoints();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
POSIXThread::FindVacantWatchpointIndex()
|
||||
{
|
||||
uint32_t hw_index = LLDB_INVALID_INDEX32;
|
||||
uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
|
||||
uint32_t wp_idx;
|
||||
POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
|
||||
if (reg_ctx)
|
||||
{
|
||||
for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
|
||||
{
|
||||
if (reg_ctx->IsWatchpointVacant(wp_idx))
|
||||
{
|
||||
hw_index = wp_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hw_index;
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::BreakNotify(const ProcessMessage &message)
|
||||
{
|
||||
bool status;
|
||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
|
||||
|
||||
assert(GetRegisterContext());
|
||||
status = GetPOSIXBreakpointProtocol()->UpdateAfterBreakpoint();
|
||||
assert(status && "Breakpoint update failed!");
|
||||
|
||||
// With our register state restored, resolve the breakpoint object
|
||||
// corresponding to our current PC.
|
||||
assert(GetRegisterContext());
|
||||
lldb::addr_t pc = GetRegisterContext()->GetPC();
|
||||
if (log)
|
||||
log->Printf ("POSIXThread::%s () PC=0x%8.8" PRIx64, __FUNCTION__, pc);
|
||||
lldb::BreakpointSiteSP bp_site(GetProcess()->GetBreakpointSiteList().FindByAddress(pc));
|
||||
|
||||
// If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
|
||||
// we create a stop reason with should_stop=false. If there is no breakpoint location, then report
|
||||
// an invalid stop reason. We don't need to worry about stepping over the breakpoint here, that will
|
||||
// be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
|
||||
if (bp_site)
|
||||
{
|
||||
lldb::break_id_t bp_id = bp_site->GetID();
|
||||
// If we have an operating system plug-in, we might have set a thread specific breakpoint using the
|
||||
// operating system thread ID, so we can't make any assumptions about the thread ID so we must always
|
||||
// report the breakpoint regardless of the thread.
|
||||
if (bp_site->ValidForThisThread(this) || GetProcess()->GetOperatingSystem () != NULL)
|
||||
SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id));
|
||||
else
|
||||
{
|
||||
const bool should_stop = false;
|
||||
SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id, should_stop));
|
||||
}
|
||||
}
|
||||
else
|
||||
SetStopInfo(StopInfoSP());
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::WatchNotify(const ProcessMessage &message)
|
||||
{
|
||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
|
||||
|
||||
lldb::addr_t halt_addr = message.GetHWAddress();
|
||||
if (log)
|
||||
log->Printf ("POSIXThread::%s () Hardware Watchpoint Address = 0x%8.8"
|
||||
PRIx64, __FUNCTION__, halt_addr);
|
||||
|
||||
POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
|
||||
if (reg_ctx)
|
||||
{
|
||||
uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints();
|
||||
uint32_t wp_idx;
|
||||
for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
|
||||
{
|
||||
if (reg_ctx->IsWatchpointHit(wp_idx))
|
||||
{
|
||||
// Clear the watchpoint hit here
|
||||
reg_ctx->ClearWatchpointHits();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wp_idx == num_hw_wps)
|
||||
return;
|
||||
|
||||
Target &target = GetProcess()->GetTarget();
|
||||
lldb::addr_t wp_monitor_addr = reg_ctx->GetWatchpointAddress(wp_idx);
|
||||
const WatchpointList &wp_list = target.GetWatchpointList();
|
||||
lldb::WatchpointSP wp_sp = wp_list.FindByAddress(wp_monitor_addr);
|
||||
|
||||
assert(wp_sp.get() && "No watchpoint found");
|
||||
SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID(*this,
|
||||
wp_sp->GetID()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::TraceNotify(const ProcessMessage &message)
|
||||
{
|
||||
POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
|
||||
if (reg_ctx)
|
||||
{
|
||||
uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints();
|
||||
uint32_t wp_idx;
|
||||
for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
|
||||
{
|
||||
if (reg_ctx->IsWatchpointHit(wp_idx))
|
||||
{
|
||||
WatchNotify(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetStopInfo (StopInfo::CreateStopReasonToTrace(*this));
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::LimboNotify(const ProcessMessage &message)
|
||||
{
|
||||
SetStopInfo (lldb::StopInfoSP(new POSIXLimboStopInfo(*this)));
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::SignalNotify(const ProcessMessage &message)
|
||||
{
|
||||
int signo = message.GetSignal();
|
||||
SetStopInfo (StopInfo::CreateStopReasonWithSignal(*this, signo));
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::SignalDeliveredNotify(const ProcessMessage &message)
|
||||
{
|
||||
int signo = message.GetSignal();
|
||||
SetStopInfo (StopInfo::CreateStopReasonWithSignal(*this, signo));
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::CrashNotify(const ProcessMessage &message)
|
||||
{
|
||||
// FIXME: Update stop reason as per bugzilla 14598
|
||||
int signo = message.GetSignal();
|
||||
|
||||
assert(message.GetKind() == ProcessMessage::eCrashMessage);
|
||||
|
||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
|
||||
if (log)
|
||||
log->Printf ("POSIXThread::%s () signo = %i, reason = '%s'",
|
||||
__FUNCTION__, signo, message.PrintCrashReason());
|
||||
|
||||
SetStopInfo (lldb::StopInfoSP(new POSIXCrashStopInfo(*this, signo,
|
||||
message.GetCrashReason(),
|
||||
message.GetFaultAddress())));
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::ThreadNotify(const ProcessMessage &message)
|
||||
{
|
||||
SetStopInfo (lldb::StopInfoSP(new POSIXNewThreadStopInfo(*this)));
|
||||
}
|
||||
|
||||
unsigned
|
||||
POSIXThread::GetRegisterIndexFromOffset(unsigned offset)
|
||||
{
|
||||
unsigned reg = LLDB_INVALID_REGNUM;
|
||||
ArchSpec arch = HostInfo::GetArchitecture();
|
||||
|
||||
switch (arch.GetMachine())
|
||||
{
|
||||
default:
|
||||
llvm_unreachable("CPU type not supported!");
|
||||
break;
|
||||
|
||||
case llvm::Triple::aarch64:
|
||||
case llvm::Triple::arm:
|
||||
case llvm::Triple::mips64:
|
||||
case llvm::Triple::ppc:
|
||||
case llvm::Triple::ppc64:
|
||||
case llvm::Triple::x86:
|
||||
case llvm::Triple::x86_64:
|
||||
{
|
||||
POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
|
||||
reg = reg_ctx->GetRegisterIndexFromOffset(offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
void
|
||||
POSIXThread::ExecNotify(const ProcessMessage &message)
|
||||
{
|
||||
SetStopInfo (StopInfo::CreateStopReasonWithExec(*this));
|
||||
}
|
||||
|
||||
const char *
|
||||
POSIXThread::GetRegisterName(unsigned reg)
|
||||
{
|
||||
const char * name = nullptr;
|
||||
ArchSpec arch = HostInfo::GetArchitecture();
|
||||
|
||||
switch (arch.GetMachine())
|
||||
{
|
||||
default:
|
||||
assert(false && "CPU type not supported!");
|
||||
break;
|
||||
|
||||
case llvm::Triple::aarch64:
|
||||
case llvm::Triple::arm:
|
||||
case llvm::Triple::mips64:
|
||||
case llvm::Triple::ppc:
|
||||
case llvm::Triple::ppc64:
|
||||
case llvm::Triple::x86:
|
||||
case llvm::Triple::x86_64:
|
||||
name = GetRegisterContext()->GetRegisterName(reg);
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *
|
||||
POSIXThread::GetRegisterNameFromOffset(unsigned offset)
|
||||
{
|
||||
return GetRegisterName(GetRegisterIndexFromOffset(offset));
|
||||
}
|
||||
|
@ -1,205 +0,0 @@
|
||||
//===-- ProcessPOSIX.h ------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef liblldb_ProcessPOSIX_H_
|
||||
#define liblldb_ProcessPOSIX_H_
|
||||
|
||||
// C Includes
|
||||
|
||||
// C++ Includes
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
// Other libraries and framework includes
|
||||
#include "lldb/Target/Process.h"
|
||||
#include "Plugins/Process/POSIX/ProcessMessage.h"
|
||||
|
||||
class ProcessMonitor;
|
||||
class POSIXThread;
|
||||
|
||||
class ProcessPOSIX :
|
||||
public lldb_private::Process
|
||||
{
|
||||
public:
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Constructors and destructors
|
||||
//------------------------------------------------------------------
|
||||
ProcessPOSIX(lldb_private::Target& target,
|
||||
lldb_private::Listener &listener,
|
||||
lldb::UnixSignalsSP &unix_signals_sp);
|
||||
|
||||
virtual
|
||||
~ProcessPOSIX();
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Process protocol.
|
||||
//------------------------------------------------------------------
|
||||
void
|
||||
Finalize() override;
|
||||
|
||||
bool
|
||||
CanDebug(lldb_private::Target &target, bool plugin_specified_by_name) override;
|
||||
|
||||
lldb_private::Error
|
||||
WillLaunch(lldb_private::Module *module) override;
|
||||
|
||||
lldb_private::Error
|
||||
DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override;
|
||||
|
||||
lldb_private::Error
|
||||
DoLaunch (lldb_private::Module *exe_module,
|
||||
lldb_private::ProcessLaunchInfo &launch_info) override;
|
||||
|
||||
void
|
||||
DidLaunch() override;
|
||||
|
||||
lldb_private::Error
|
||||
DoResume() override;
|
||||
|
||||
lldb_private::Error
|
||||
DoHalt(bool &caused_stop) override;
|
||||
|
||||
lldb_private::Error
|
||||
DoDetach(bool keep_stopped) override = 0;
|
||||
|
||||
lldb_private::Error
|
||||
DoSignal(int signal) override;
|
||||
|
||||
lldb_private::Error
|
||||
DoDestroy() override;
|
||||
|
||||
void
|
||||
DoDidExec() override;
|
||||
|
||||
void
|
||||
RefreshStateAfterStop() override;
|
||||
|
||||
bool
|
||||
IsAlive() override;
|
||||
|
||||
size_t
|
||||
DoReadMemory(lldb::addr_t vm_addr,
|
||||
void *buf,
|
||||
size_t size,
|
||||
lldb_private::Error &error) override;
|
||||
|
||||
size_t
|
||||
DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
|
||||
lldb_private::Error &error) override;
|
||||
|
||||
lldb::addr_t
|
||||
DoAllocateMemory(size_t size, uint32_t permissions,
|
||||
lldb_private::Error &error) override;
|
||||
|
||||
lldb_private::Error
|
||||
DoDeallocateMemory(lldb::addr_t ptr) override;
|
||||
|
||||
virtual size_t
|
||||
GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
|
||||
|
||||
lldb_private::Error
|
||||
EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
|
||||
|
||||
lldb_private::Error
|
||||
DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
|
||||
|
||||
lldb_private::Error
|
||||
EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
|
||||
|
||||
lldb_private::Error
|
||||
DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
|
||||
|
||||
lldb_private::Error
|
||||
GetWatchpointSupportInfo(uint32_t &num) override;
|
||||
|
||||
lldb_private::Error
|
||||
GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
|
||||
|
||||
virtual uint32_t
|
||||
UpdateThreadListIfNeeded();
|
||||
|
||||
bool
|
||||
UpdateThreadList(lldb_private::ThreadList &old_thread_list,
|
||||
lldb_private::ThreadList &new_thread_list) override = 0;
|
||||
|
||||
virtual lldb::ByteOrder
|
||||
GetByteOrder() const;
|
||||
|
||||
lldb::addr_t
|
||||
GetImageInfoAddress() override;
|
||||
|
||||
size_t
|
||||
PutSTDIN(const char *buf, size_t len, lldb_private::Error &error) override;
|
||||
|
||||
const lldb::DataBufferSP
|
||||
GetAuxvData () override;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// ProcessPOSIX internal API.
|
||||
|
||||
/// Registers the given message with this process.
|
||||
virtual void
|
||||
SendMessage(const ProcessMessage &message);
|
||||
|
||||
ProcessMonitor &
|
||||
GetMonitor() { assert(m_monitor); return *m_monitor; }
|
||||
|
||||
lldb_private::FileSpec
|
||||
GetFileSpec(const lldb_private::FileAction *file_action,
|
||||
const lldb_private::FileSpec &default_file_spec,
|
||||
const lldb_private::FileSpec &dbg_pts_file_spec);
|
||||
|
||||
/// Adds the thread to the list of threads for which we have received the initial stopping signal.
|
||||
/// The \p stop_tid parameter indicates the thread which the stop happened for.
|
||||
bool
|
||||
AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid);
|
||||
|
||||
bool
|
||||
WaitingForInitialStop(lldb::tid_t stop_tid);
|
||||
|
||||
virtual POSIXThread *
|
||||
CreateNewPOSIXThread(lldb_private::Process &process, lldb::tid_t tid);
|
||||
|
||||
protected:
|
||||
/// Target byte order.
|
||||
lldb::ByteOrder m_byte_order;
|
||||
|
||||
/// Process monitor;
|
||||
ProcessMonitor *m_monitor;
|
||||
|
||||
/// The module we are executing.
|
||||
lldb_private::Module *m_module;
|
||||
|
||||
/// Message queue notifying this instance of inferior process state changes.
|
||||
lldb_private::Mutex m_message_mutex;
|
||||
std::queue<ProcessMessage> m_message_queue;
|
||||
|
||||
/// Drive any exit events to completion.
|
||||
bool m_exit_now;
|
||||
|
||||
/// Returns true if the process has exited.
|
||||
bool HasExited();
|
||||
|
||||
/// Returns true if the process is stopped.
|
||||
bool IsStopped();
|
||||
|
||||
/// Returns true if at least one running is currently running
|
||||
bool IsAThreadRunning();
|
||||
|
||||
typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
|
||||
MMapMap m_addr_to_mmap_size;
|
||||
|
||||
typedef std::set<lldb::tid_t> ThreadStopSet;
|
||||
/// Every thread begins with a stop signal. This keeps track
|
||||
/// of the threads for which we have received the stop signal.
|
||||
ThreadStopSet m_seen_initial_stop;
|
||||
};
|
||||
|
||||
#endif // liblldb_MacOSXProcess_H_
|
Loading…
Reference in New Issue
Block a user