forked from OSchip/llvm-project
Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes.
llvm-svn: 262441
This commit is contained in:
parent
5e4c46de6d
commit
896ddd03e9
|
@ -75,7 +75,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator< (const BroadcastEventSpec &rhs) const;
|
bool operator< (const BroadcastEventSpec &rhs) const;
|
||||||
const BroadcastEventSpec &operator= (const BroadcastEventSpec &rhs);
|
BroadcastEventSpec &operator=(const BroadcastEventSpec &rhs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConstString m_broadcaster_class;
|
ConstString m_broadcaster_class;
|
||||||
|
@ -194,15 +194,11 @@ private:
|
||||||
|
|
||||||
bool operator () (const event_listener_key input) const
|
bool operator () (const event_listener_key input) const
|
||||||
{
|
{
|
||||||
if (input.second == m_listener)
|
return (input.second == m_listener);
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Listener *m_listener;
|
const Listener *m_listener;
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -463,4 +459,4 @@ private:
|
||||||
|
|
||||||
} // namespace lldb_private
|
} // namespace lldb_private
|
||||||
|
|
||||||
#endif // liblldb_Broadcaster_h_
|
#endif // liblldb_Broadcaster_h_
|
||||||
|
|
|
@ -8,6 +8,13 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "lldb/Core/Address.h"
|
#include "lldb/Core/Address.h"
|
||||||
|
|
||||||
|
// C Includes
|
||||||
|
// C++ Includes
|
||||||
|
#include "llvm/ADT/Triple.h"
|
||||||
|
|
||||||
|
// Other libraries and framework includes
|
||||||
|
// Project includes
|
||||||
#include "lldb/Core/Module.h"
|
#include "lldb/Core/Module.h"
|
||||||
#include "lldb/Core/Section.h"
|
#include "lldb/Core/Section.h"
|
||||||
#include "lldb/Symbol/Block.h"
|
#include "lldb/Symbol/Block.h"
|
||||||
|
@ -20,15 +27,13 @@
|
||||||
#include "lldb/Target/Target.h"
|
#include "lldb/Target/Target.h"
|
||||||
#include "lldb/Symbol/SymbolVendor.h"
|
#include "lldb/Symbol/SymbolVendor.h"
|
||||||
|
|
||||||
#include "llvm/ADT/Triple.h"
|
|
||||||
|
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
ReadBytes (ExecutionContextScope *exe_scope, const Address &address, void *dst, size_t dst_len)
|
ReadBytes (ExecutionContextScope *exe_scope, const Address &address, void *dst, size_t dst_len)
|
||||||
{
|
{
|
||||||
if (exe_scope == NULL)
|
if (exe_scope == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TargetSP target_sp (exe_scope->CalculateTarget());
|
TargetSP target_sp (exe_scope->CalculateTarget());
|
||||||
|
@ -46,7 +51,7 @@ GetByteOrderAndAddressSize (ExecutionContextScope *exe_scope, const Address &add
|
||||||
{
|
{
|
||||||
byte_order = eByteOrderInvalid;
|
byte_order = eByteOrderInvalid;
|
||||||
addr_size = 0;
|
addr_size = 0;
|
||||||
if (exe_scope == NULL)
|
if (exe_scope == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TargetSP target_sp (exe_scope->CalculateTarget());
|
TargetSP target_sp (exe_scope->CalculateTarget());
|
||||||
|
@ -72,7 +77,7 @@ static uint64_t
|
||||||
ReadUIntMax64 (ExecutionContextScope *exe_scope, const Address &address, uint32_t byte_size, bool &success)
|
ReadUIntMax64 (ExecutionContextScope *exe_scope, const Address &address, uint32_t byte_size, bool &success)
|
||||||
{
|
{
|
||||||
uint64_t uval64 = 0;
|
uint64_t uval64 = 0;
|
||||||
if (exe_scope == NULL || byte_size > sizeof(uint64_t))
|
if (exe_scope == nullptr || byte_size > sizeof(uint64_t))
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -99,10 +104,9 @@ ReadUIntMax64 (ExecutionContextScope *exe_scope, const Address &address, uint32_
|
||||||
static bool
|
static bool
|
||||||
ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t pointer_size, Address &deref_so_addr)
|
ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t pointer_size, Address &deref_so_addr)
|
||||||
{
|
{
|
||||||
if (exe_scope == NULL)
|
if (exe_scope == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
addr_t deref_addr = ReadUIntMax64 (exe_scope, address, pointer_size, success);
|
addr_t deref_addr = ReadUIntMax64 (exe_scope, address, pointer_size, success);
|
||||||
if (success)
|
if (success)
|
||||||
|
@ -140,7 +144,7 @@ ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t
|
||||||
static bool
|
static bool
|
||||||
DumpUInt (ExecutionContextScope *exe_scope, const Address &address, uint32_t byte_size, Stream* strm)
|
DumpUInt (ExecutionContextScope *exe_scope, const Address &address, uint32_t byte_size, Stream* strm)
|
||||||
{
|
{
|
||||||
if (exe_scope == NULL || byte_size == 0)
|
if (exe_scope == nullptr || byte_size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
std::vector<uint8_t> buf(byte_size, 0);
|
std::vector<uint8_t> buf(byte_size, 0);
|
||||||
|
|
||||||
|
@ -168,11 +172,10 @@ DumpUInt (ExecutionContextScope *exe_scope, const Address &address, uint32_t byt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
ReadCStringFromMemory (ExecutionContextScope *exe_scope, const Address &address, Stream *strm)
|
ReadCStringFromMemory (ExecutionContextScope *exe_scope, const Address &address, Stream *strm)
|
||||||
{
|
{
|
||||||
if (exe_scope == NULL)
|
if (exe_scope == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
const size_t k_buf_len = 256;
|
const size_t k_buf_len = 256;
|
||||||
char buf[k_buf_len+1];
|
char buf[k_buf_len+1];
|
||||||
|
@ -334,7 +337,7 @@ Address::GetCallableLoadAddress (Target *target, bool is_indirect) const
|
||||||
{
|
{
|
||||||
ProcessSP processSP = target->GetProcessSP();
|
ProcessSP processSP = target->GetProcessSP();
|
||||||
Error error;
|
Error error;
|
||||||
if (processSP.get())
|
if (processSP)
|
||||||
{
|
{
|
||||||
code_addr = processSP->ResolveIndirectFunction(this, error);
|
code_addr = processSP->ResolveIndirectFunction(this, error);
|
||||||
if (!error.Success())
|
if (!error.Success())
|
||||||
|
@ -398,7 +401,7 @@ Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target, AddressCl
|
||||||
bool
|
bool
|
||||||
Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const
|
Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const
|
||||||
{
|
{
|
||||||
// If the section was NULL, only load address is going to work unless we are
|
// If the section was nullptr, only load address is going to work unless we are
|
||||||
// trying to deref a pointer
|
// trying to deref a pointer
|
||||||
SectionSP section_sp (GetSection());
|
SectionSP section_sp (GetSection());
|
||||||
if (!section_sp && style != DumpStyleResolvedPointerDescription)
|
if (!section_sp && style != DumpStyleResolvedPointerDescription)
|
||||||
|
@ -545,59 +548,55 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eSectionTypeDataCStringPointers:
|
case eSectionTypeDataCStringPointers:
|
||||||
|
if (ReadAddress(exe_scope, *this, pointer_size, so_addr))
|
||||||
{
|
{
|
||||||
if (ReadAddress (exe_scope, *this, pointer_size, so_addr))
|
|
||||||
{
|
|
||||||
#if VERBOSE_OUTPUT
|
#if VERBOSE_OUTPUT
|
||||||
s->PutCString("(char *)");
|
s->PutCString("(char *)");
|
||||||
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
||||||
s->PutCString(": ");
|
s->PutCString(": ");
|
||||||
#endif
|
#endif
|
||||||
showed_info = true;
|
showed_info = true;
|
||||||
ReadCStringFromMemory (exe_scope, so_addr, s);
|
ReadCStringFromMemory(exe_scope, so_addr, s);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eSectionTypeDataObjCMessageRefs:
|
case eSectionTypeDataObjCMessageRefs:
|
||||||
|
if (ReadAddress(exe_scope, *this, pointer_size, so_addr))
|
||||||
{
|
{
|
||||||
if (ReadAddress (exe_scope, *this, pointer_size, so_addr))
|
if (target && so_addr.IsSectionOffset())
|
||||||
{
|
{
|
||||||
if (target && so_addr.IsSectionOffset())
|
SymbolContext func_sc;
|
||||||
|
target->GetImages().ResolveSymbolContextForAddress(so_addr,
|
||||||
|
eSymbolContextEverything,
|
||||||
|
func_sc);
|
||||||
|
if (func_sc.function != nullptr || func_sc.symbol != nullptr)
|
||||||
{
|
{
|
||||||
SymbolContext func_sc;
|
showed_info = true;
|
||||||
target->GetImages().ResolveSymbolContextForAddress (so_addr,
|
#if VERBOSE_OUTPUT
|
||||||
eSymbolContextEverything,
|
s->PutCString ("(objc_msgref *) -> { (func*)");
|
||||||
func_sc);
|
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
||||||
if (func_sc.function || func_sc.symbol)
|
#else
|
||||||
|
s->PutCString ("{ ");
|
||||||
|
#endif
|
||||||
|
Address cstr_addr(*this);
|
||||||
|
cstr_addr.SetOffset(cstr_addr.GetOffset() + pointer_size);
|
||||||
|
func_sc.DumpStopContext(s, exe_scope, so_addr, true, true, false, true, true);
|
||||||
|
if (ReadAddress(exe_scope, cstr_addr, pointer_size, so_addr))
|
||||||
{
|
{
|
||||||
showed_info = true;
|
|
||||||
#if VERBOSE_OUTPUT
|
#if VERBOSE_OUTPUT
|
||||||
s->PutCString ("(objc_msgref *) -> { (func*)");
|
s->PutCString("), (char *)");
|
||||||
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
||||||
|
s->PutCString(" (");
|
||||||
#else
|
#else
|
||||||
s->PutCString ("{ ");
|
s->PutCString(", ");
|
||||||
#endif
|
|
||||||
Address cstr_addr(*this);
|
|
||||||
cstr_addr.SetOffset(cstr_addr.GetOffset() + pointer_size);
|
|
||||||
func_sc.DumpStopContext(s, exe_scope, so_addr, true, true, false, true, true);
|
|
||||||
if (ReadAddress (exe_scope, cstr_addr, pointer_size, so_addr))
|
|
||||||
{
|
|
||||||
#if VERBOSE_OUTPUT
|
|
||||||
s->PutCString("), (char *)");
|
|
||||||
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
|
||||||
s->PutCString(" (");
|
|
||||||
#else
|
|
||||||
s->PutCString(", ");
|
|
||||||
#endif
|
|
||||||
ReadCStringFromMemory (exe_scope, so_addr, s);
|
|
||||||
}
|
|
||||||
#if VERBOSE_OUTPUT
|
|
||||||
s->PutCString(") }");
|
|
||||||
#else
|
|
||||||
s->PutCString(" }");
|
|
||||||
#endif
|
#endif
|
||||||
|
ReadCStringFromMemory (exe_scope, so_addr, s);
|
||||||
}
|
}
|
||||||
|
#if VERBOSE_OUTPUT
|
||||||
|
s->PutCString(") }");
|
||||||
|
#else
|
||||||
|
s->PutCString(" }");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -645,26 +644,24 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
|
||||||
|
|
||||||
case eSectionTypeDataPointers:
|
case eSectionTypeDataPointers:
|
||||||
// Read the pointer data and display it
|
// Read the pointer data and display it
|
||||||
|
if (ReadAddress(exe_scope, *this, pointer_size, so_addr))
|
||||||
{
|
{
|
||||||
if (ReadAddress (exe_scope, *this, pointer_size, so_addr))
|
s->PutCString ("(void *)");
|
||||||
{
|
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
||||||
s->PutCString ("(void *)");
|
|
||||||
so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
|
|
||||||
|
|
||||||
showed_info = true;
|
showed_info = true;
|
||||||
if (so_addr.IsSectionOffset())
|
if (so_addr.IsSectionOffset())
|
||||||
|
{
|
||||||
|
SymbolContext pointer_sc;
|
||||||
|
if (target)
|
||||||
{
|
{
|
||||||
SymbolContext pointer_sc;
|
target->GetImages().ResolveSymbolContextForAddress(so_addr,
|
||||||
if (target)
|
eSymbolContextEverything,
|
||||||
|
pointer_sc);
|
||||||
|
if (pointer_sc.function != nullptr || pointer_sc.symbol != nullptr)
|
||||||
{
|
{
|
||||||
target->GetImages().ResolveSymbolContextForAddress (so_addr,
|
s->PutCString(": ");
|
||||||
eSymbolContextEverything,
|
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false, false, true, true);
|
||||||
pointer_sc);
|
|
||||||
if (pointer_sc.function || pointer_sc.symbol)
|
|
||||||
{
|
|
||||||
s->PutCString(": ");
|
|
||||||
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false, false, true, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -690,7 +687,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
|
||||||
const bool show_inlined_frames = true;
|
const bool show_inlined_frames = true;
|
||||||
const bool show_function_arguments = (style != DumpStyleResolvedDescriptionNoFunctionArguments);
|
const bool show_function_arguments = (style != DumpStyleResolvedDescriptionNoFunctionArguments);
|
||||||
const bool show_function_name = (style != DumpStyleNoFunctionName);
|
const bool show_function_name = (style != DumpStyleNoFunctionName);
|
||||||
if (sc.function == NULL && sc.symbol != NULL)
|
if (sc.function == nullptr && sc.symbol != nullptr)
|
||||||
{
|
{
|
||||||
// If we have just a symbol make sure it is in the right section
|
// If we have just a symbol make sure it is in the right section
|
||||||
if (sc.symbol->ValueIsAddress())
|
if (sc.symbol->ValueIsAddress())
|
||||||
|
@ -749,7 +746,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
|
||||||
// the last symbol that came before the address that we are
|
// the last symbol that came before the address that we are
|
||||||
// looking up that has nothing to do with our address lookup.
|
// looking up that has nothing to do with our address lookup.
|
||||||
if (sc.symbol->ValueIsAddress() && sc.symbol->GetAddressRef().GetSection() != GetSection())
|
if (sc.symbol->ValueIsAddress() && sc.symbol->GetAddressRef().GetSection() != GetSection())
|
||||||
sc.symbol = NULL;
|
sc.symbol = nullptr;
|
||||||
}
|
}
|
||||||
sc.GetDescription(s, eDescriptionLevelBrief, target);
|
sc.GetDescription(s, eDescriptionLevelBrief, target);
|
||||||
|
|
||||||
|
@ -797,6 +794,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DumpStyleResolvedPointerDescription:
|
case DumpStyleResolvedPointerDescription:
|
||||||
{
|
{
|
||||||
Process *process = exe_ctx.GetProcessPtr();
|
Process *process = exe_ctx.GetProcessPtr();
|
||||||
|
@ -897,7 +895,7 @@ Address::CalculateSymbolContextCompileUnit () const
|
||||||
return sc.comp_unit;
|
return sc.comp_unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Function *
|
Function *
|
||||||
|
@ -914,7 +912,7 @@ Address::CalculateSymbolContextFunction () const
|
||||||
return sc.function;
|
return sc.function;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block *
|
Block *
|
||||||
|
@ -931,7 +929,7 @@ Address::CalculateSymbolContextBlock () const
|
||||||
return sc.block;
|
return sc.block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Symbol *
|
Symbol *
|
||||||
|
@ -948,7 +946,7 @@ Address::CalculateSymbolContextSymbol () const
|
||||||
return sc.symbol;
|
return sc.symbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -985,11 +983,10 @@ Address::CompareFileAddress (const Address& a, const Address& b)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Address::CompareLoadAddress (const Address& a, const Address& b, Target *target)
|
Address::CompareLoadAddress (const Address& a, const Address& b, Target *target)
|
||||||
{
|
{
|
||||||
assert (target != NULL);
|
assert(target != nullptr);
|
||||||
addr_t a_load_addr = a.GetLoadAddress (target);
|
addr_t a_load_addr = a.GetLoadAddress (target);
|
||||||
addr_t b_load_addr = b.GetLoadAddress (target);
|
addr_t b_load_addr = b.GetLoadAddress (target);
|
||||||
if (a_load_addr < b_load_addr)
|
if (a_load_addr < b_load_addr)
|
||||||
|
@ -1021,7 +1018,6 @@ Address::CompareModulePointerAndOffset (const Address& a, const Address& b)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
Address::MemorySize () const
|
Address::MemorySize () const
|
||||||
{
|
{
|
||||||
|
@ -1030,7 +1026,6 @@ Address::MemorySize () const
|
||||||
return sizeof(Address);
|
return sizeof(Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// NOTE: Be careful using this operator. It can correctly compare two
|
// NOTE: Be careful using this operator. It can correctly compare two
|
||||||
// addresses from the same Module correctly. It can't compare two
|
// addresses from the same Module correctly. It can't compare two
|
||||||
|
@ -1086,7 +1081,6 @@ lldb_private::operator> (const Address& lhs, const Address& rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The operator == checks for exact equality only (same section, same offset)
|
// The operator == checks for exact equality only (same section, same offset)
|
||||||
bool
|
bool
|
||||||
lldb_private::operator== (const Address& a, const Address& rhs)
|
lldb_private::operator== (const Address& a, const Address& rhs)
|
||||||
|
@ -1094,6 +1088,7 @@ lldb_private::operator== (const Address& a, const Address& rhs)
|
||||||
return a.GetOffset() == rhs.GetOffset() &&
|
return a.GetOffset() == rhs.GetOffset() &&
|
||||||
a.GetSection() == rhs.GetSection();
|
a.GetSection() == rhs.GetSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The operator != checks for exact inequality only (differing section, or
|
// The operator != checks for exact inequality only (differing section, or
|
||||||
// different offset)
|
// different offset)
|
||||||
bool
|
bool
|
||||||
|
@ -1129,4 +1124,3 @@ Address::SetLoadAddress (lldb::addr_t load_addr, Target *target)
|
||||||
m_offset = load_addr;
|
m_offset = load_addr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
#include "lldb/Core/AddressResolverName.h"
|
#include "lldb/Core/AddressResolverName.h"
|
||||||
|
|
||||||
|
// C Includes
|
||||||
|
// C++ Includes
|
||||||
|
// Other libraries and framework includes
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "lldb/Core/Log.h"
|
#include "lldb/Core/Log.h"
|
||||||
#include "lldb/Core/Module.h"
|
#include "lldb/Core/Module.h"
|
||||||
|
@ -20,16 +23,13 @@
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
AddressResolverName::AddressResolverName
|
AddressResolverName::AddressResolverName(const char *func_name,
|
||||||
(
|
AddressResolver::MatchType type) :
|
||||||
const char *func_name,
|
AddressResolver(),
|
||||||
AddressResolver::MatchType type
|
m_func_name(func_name),
|
||||||
) :
|
m_class_name(nullptr),
|
||||||
AddressResolver (),
|
m_regex(),
|
||||||
m_func_name (func_name),
|
m_match_type(type)
|
||||||
m_class_name (NULL),
|
|
||||||
m_regex (),
|
|
||||||
m_match_type (type)
|
|
||||||
{
|
{
|
||||||
if (m_match_type == AddressResolver::Regexp)
|
if (m_match_type == AddressResolver::Regexp)
|
||||||
{
|
{
|
||||||
|
@ -43,50 +43,37 @@ AddressResolverName::AddressResolverName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressResolverName::AddressResolverName
|
AddressResolverName::AddressResolverName(RegularExpression &func_regex) :
|
||||||
(
|
AddressResolver(),
|
||||||
RegularExpression &func_regex
|
m_func_name(nullptr),
|
||||||
) :
|
m_class_name(nullptr),
|
||||||
AddressResolver (),
|
m_regex(func_regex),
|
||||||
m_func_name (NULL),
|
m_match_type(AddressResolver::Regexp)
|
||||||
m_class_name (NULL),
|
|
||||||
m_regex (func_regex),
|
|
||||||
m_match_type (AddressResolver::Regexp)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressResolverName::AddressResolverName
|
AddressResolverName::AddressResolverName(const char *class_name,
|
||||||
(
|
const char *method,
|
||||||
const char *class_name,
|
AddressResolver::MatchType type) :
|
||||||
const char *method,
|
|
||||||
AddressResolver::MatchType type
|
|
||||||
) :
|
|
||||||
AddressResolver (),
|
AddressResolver (),
|
||||||
m_func_name (method),
|
m_func_name (method),
|
||||||
m_class_name (class_name),
|
m_class_name (class_name),
|
||||||
m_regex (),
|
m_regex (),
|
||||||
m_match_type (type)
|
m_match_type (type)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressResolverName::~AddressResolverName ()
|
AddressResolverName::~AddressResolverName() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Right now we look at the module level, and call the module's "FindFunctions".
|
// FIXME: Right now we look at the module level, and call the module's "FindFunctions".
|
||||||
// Greg says he will add function tables, maybe at the CompileUnit level to accelerate function
|
// Greg says he will add function tables, maybe at the CompileUnit level to accelerate function
|
||||||
// lookup. At that point, we should switch the depth to CompileUnit, and look in these tables.
|
// lookup. At that point, we should switch the depth to CompileUnit, and look in these tables.
|
||||||
|
|
||||||
Searcher::CallbackReturn
|
Searcher::CallbackReturn
|
||||||
AddressResolverName::SearchCallback
|
AddressResolverName::SearchCallback(SearchFilter &filter,
|
||||||
(
|
SymbolContext &context,
|
||||||
SearchFilter &filter,
|
Address *addr,
|
||||||
SymbolContext &context,
|
bool containing)
|
||||||
Address *addr,
|
|
||||||
bool containing
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
SymbolContextList func_list;
|
SymbolContextList func_list;
|
||||||
SymbolContextList sym_list;
|
SymbolContextList sym_list;
|
||||||
|
@ -116,13 +103,13 @@ AddressResolverName::SearchCallback
|
||||||
context.module_sp->FindSymbolsWithNameAndType (m_func_name,
|
context.module_sp->FindSymbolsWithNameAndType (m_func_name,
|
||||||
eSymbolTypeCode,
|
eSymbolTypeCode,
|
||||||
sym_list);
|
sym_list);
|
||||||
context.module_sp->FindFunctions (m_func_name,
|
context.module_sp->FindFunctions(m_func_name,
|
||||||
NULL,
|
nullptr,
|
||||||
eFunctionNameTypeAuto,
|
eFunctionNameTypeAuto,
|
||||||
include_symbols,
|
include_symbols,
|
||||||
include_inlines,
|
include_inlines,
|
||||||
append,
|
append,
|
||||||
func_list);
|
func_list);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -151,10 +138,10 @@ AddressResolverName::SearchCallback
|
||||||
{
|
{
|
||||||
for (i = 0; i < func_list.GetSize(); i++)
|
for (i = 0; i < func_list.GetSize(); i++)
|
||||||
{
|
{
|
||||||
if (func_list.GetContextAtIndex(i, sc) == false)
|
if (!func_list.GetContextAtIndex(i, sc))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sc.function == NULL)
|
if (sc.function == nullptr)
|
||||||
continue;
|
continue;
|
||||||
uint32_t j = 0;
|
uint32_t j = 0;
|
||||||
while (j < sym_list.GetSize())
|
while (j < sym_list.GetSize())
|
||||||
|
@ -250,4 +237,3 @@ AddressResolverName::GetDescription (Stream *s)
|
||||||
else
|
else
|
||||||
s->Printf("'%s'", m_func_name.AsCString());
|
s->Printf("'%s'", m_func_name.AsCString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,19 @@
|
||||||
|
|
||||||
#include "lldb/Core/ArchSpec.h"
|
#include "lldb/Core/ArchSpec.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
// C Includes
|
||||||
#include <errno.h>
|
// C++ Includes
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cerrno>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// Other libraries and framework includes
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/Support/COFF.h"
|
#include "llvm/Support/COFF.h"
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
|
|
||||||
|
// Project includes
|
||||||
#include "lldb/Core/RegularExpression.h"
|
#include "lldb/Core/RegularExpression.h"
|
||||||
#include "lldb/Core/StringList.h"
|
#include "lldb/Core/StringList.h"
|
||||||
#include "lldb/Host/Endian.h"
|
#include "lldb/Host/Endian.h"
|
||||||
|
@ -35,9 +38,6 @@
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
#define ARCH_SPEC_SEPARATOR_CHAR '-'
|
|
||||||
|
|
||||||
|
|
||||||
static bool cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_inverse, bool enforce_exact_match);
|
static bool cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_inverse, bool enforce_exact_match);
|
||||||
|
|
||||||
namespace lldb_private {
|
namespace lldb_private {
|
||||||
|
@ -53,7 +53,7 @@ namespace lldb_private {
|
||||||
const char * const name;
|
const char * const name;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace lldb_private
|
||||||
|
|
||||||
// This core information can be looked using the ArchSpec::Core as the index
|
// This core information can be looked using the ArchSpec::Core as the index
|
||||||
static const CoreDefinition g_core_definitions[] =
|
static const CoreDefinition g_core_definitions[] =
|
||||||
|
@ -156,7 +156,6 @@ static const CoreDefinition g_core_definitions[] =
|
||||||
// you will need to comment out the corresponding ArchSpec::Core enumeration.
|
// you will need to comment out the corresponding ArchSpec::Core enumeration.
|
||||||
static_assert(sizeof(g_core_definitions) / sizeof(CoreDefinition) == ArchSpec::kNumCores, "make sure we have one core definition for each core");
|
static_assert(sizeof(g_core_definitions) / sizeof(CoreDefinition) == ArchSpec::kNumCores, "make sure we have one core definition for each core");
|
||||||
|
|
||||||
|
|
||||||
struct ArchDefinitionEntry
|
struct ArchDefinitionEntry
|
||||||
{
|
{
|
||||||
ArchSpec::Core core;
|
ArchSpec::Core core;
|
||||||
|
@ -174,14 +173,12 @@ struct ArchDefinition
|
||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
ArchSpec::AutoComplete (const char *name, StringList &matches)
|
ArchSpec::AutoComplete (const char *name, StringList &matches)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
|
||||||
if (name && name[0])
|
if (name && name[0])
|
||||||
{
|
{
|
||||||
for (i = 0; i < llvm::array_lengthof(g_core_definitions); ++i)
|
for (uint32_t i = 0; i < llvm::array_lengthof(g_core_definitions); ++i)
|
||||||
{
|
{
|
||||||
if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name))
|
if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name))
|
||||||
matches.AppendString (g_core_definitions[i].name);
|
matches.AppendString (g_core_definitions[i].name);
|
||||||
|
@ -189,14 +186,12 @@ ArchSpec::AutoComplete (const char *name, StringList &matches)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < llvm::array_lengthof(g_core_definitions); ++i)
|
for (uint32_t i = 0; i < llvm::array_lengthof(g_core_definitions); ++i)
|
||||||
matches.AppendString (g_core_definitions[i].name);
|
matches.AppendString (g_core_definitions[i].name);
|
||||||
}
|
}
|
||||||
return matches.GetSize();
|
return matches.GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define CPU_ANY (UINT32_MAX)
|
#define CPU_ANY (UINT32_MAX)
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -205,6 +200,7 @@ ArchSpec::AutoComplete (const char *name, StringList &matches)
|
||||||
// architecture names to cpu types and subtypes. The ordering is important and
|
// architecture names to cpu types and subtypes. The ordering is important and
|
||||||
// allows the precedence to be set when the table is built.
|
// allows the precedence to be set when the table is built.
|
||||||
#define SUBTYPE_MASK 0x00FFFFFFu
|
#define SUBTYPE_MASK 0x00FFFFFFu
|
||||||
|
|
||||||
static const ArchDefinitionEntry g_macho_arch_entries[] =
|
static const ArchDefinitionEntry g_macho_arch_entries[] =
|
||||||
{
|
{
|
||||||
{ ArchSpec::eCore_arm_generic , llvm::MachO::CPU_TYPE_ARM , CPU_ANY, UINT32_MAX , UINT32_MAX },
|
{ ArchSpec::eCore_arm_generic , llvm::MachO::CPU_TYPE_ARM , CPU_ANY, UINT32_MAX , UINT32_MAX },
|
||||||
|
@ -267,6 +263,7 @@ static const ArchDefinitionEntry g_macho_arch_entries[] =
|
||||||
{ ArchSpec::eCore_uknownMach32 , 0 , 0 , 0xFF000000u, 0x00000000u },
|
{ ArchSpec::eCore_uknownMach32 , 0 , 0 , 0xFF000000u, 0x00000000u },
|
||||||
{ ArchSpec::eCore_uknownMach64 , llvm::MachO::CPU_ARCH_ABI64 , 0 , 0xFF000000u, 0x00000000u }
|
{ ArchSpec::eCore_uknownMach64 , llvm::MachO::CPU_ARCH_ABI64 , 0 , 0xFF000000u, 0x00000000u }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ArchDefinition g_macho_arch_def = {
|
static const ArchDefinition g_macho_arch_def = {
|
||||||
eArchTypeMachO,
|
eArchTypeMachO,
|
||||||
llvm::array_lengthof(g_macho_arch_entries),
|
llvm::array_lengthof(g_macho_arch_entries),
|
||||||
|
@ -346,7 +343,6 @@ static const size_t k_num_arch_definitions = llvm::array_lengthof(g_arch_definit
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Static helper functions.
|
// Static helper functions.
|
||||||
|
|
||||||
|
|
||||||
// Get the architecture definition for a given object type.
|
// Get the architecture definition for a given object type.
|
||||||
static const ArchDefinition *
|
static const ArchDefinition *
|
||||||
FindArchDefinition (ArchitectureType arch_type)
|
FindArchDefinition (ArchitectureType arch_type)
|
||||||
|
@ -357,7 +353,7 @@ FindArchDefinition (ArchitectureType arch_type)
|
||||||
if (def->type == arch_type)
|
if (def->type == arch_type)
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get an architecture definition by name.
|
// Get an architecture definition by name.
|
||||||
|
@ -369,7 +365,7 @@ FindCoreDefinition (llvm::StringRef name)
|
||||||
if (name.equals_lower(g_core_definitions[i].name))
|
if (name.equals_lower(g_core_definitions[i].name))
|
||||||
return &g_core_definitions[i];
|
return &g_core_definitions[i];
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const CoreDefinition *
|
static inline const CoreDefinition *
|
||||||
|
@ -377,15 +373,15 @@ FindCoreDefinition (ArchSpec::Core core)
|
||||||
{
|
{
|
||||||
if (core >= 0 && core < llvm::array_lengthof(g_core_definitions))
|
if (core >= 0 && core < llvm::array_lengthof(g_core_definitions))
|
||||||
return &g_core_definitions[core];
|
return &g_core_definitions[core];
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a definition entry by cpu type and subtype.
|
// Get a definition entry by cpu type and subtype.
|
||||||
static const ArchDefinitionEntry *
|
static const ArchDefinitionEntry *
|
||||||
FindArchDefinitionEntry (const ArchDefinition *def, uint32_t cpu, uint32_t sub)
|
FindArchDefinitionEntry (const ArchDefinition *def, uint32_t cpu, uint32_t sub)
|
||||||
{
|
{
|
||||||
if (def == NULL)
|
if (def == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
const ArchDefinitionEntry *entries = def->entries;
|
const ArchDefinitionEntry *entries = def->entries;
|
||||||
for (size_t i = 0; i < def->num_entries; ++i)
|
for (size_t i = 0; i < def->num_entries; ++i)
|
||||||
|
@ -394,14 +390,14 @@ FindArchDefinitionEntry (const ArchDefinition *def, uint32_t cpu, uint32_t sub)
|
||||||
if (entries[i].sub == (sub & entries[i].sub_mask))
|
if (entries[i].sub == (sub & entries[i].sub_mask))
|
||||||
return &entries[i];
|
return &entries[i];
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const ArchDefinitionEntry *
|
static const ArchDefinitionEntry *
|
||||||
FindArchDefinitionEntry (const ArchDefinition *def, ArchSpec::Core core)
|
FindArchDefinitionEntry (const ArchDefinition *def, ArchSpec::Core core)
|
||||||
{
|
{
|
||||||
if (def == NULL)
|
if (def == nullptr)
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
const ArchDefinitionEntry *entries = def->entries;
|
const ArchDefinitionEntry *entries = def->entries;
|
||||||
for (size_t i = 0; i < def->num_entries; ++i)
|
for (size_t i = 0; i < def->num_entries; ++i)
|
||||||
|
@ -409,7 +405,7 @@ FindArchDefinitionEntry (const ArchDefinition *def, ArchSpec::Core core)
|
||||||
if (entries[i].core == core)
|
if (entries[i].core == core)
|
||||||
return &entries[i];
|
return &entries[i];
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -467,9 +463,7 @@ ArchSpec::ArchSpec (ArchitectureType arch_type, uint32_t cpu, uint32_t subtype)
|
||||||
SetArchitecture (arch_type, cpu, subtype);
|
SetArchitecture (arch_type, cpu, subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchSpec::~ArchSpec()
|
ArchSpec::~ArchSpec() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Assignment and initialization.
|
// Assignment and initialization.
|
||||||
|
@ -501,7 +495,6 @@ ArchSpec::Clear()
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Predicates.
|
// Predicates.
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
ArchSpec::GetArchitectureName () const
|
ArchSpec::GetArchitectureName () const
|
||||||
{
|
{
|
||||||
|
@ -730,7 +723,6 @@ ArchSpec::SetTriple (const llvm::Triple &triple)
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return IsValid();
|
return IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,7 +732,7 @@ ParseMachCPUDashSubtypeTriple (const char *triple_cstr, ArchSpec &arch)
|
||||||
// Accept "12-10" or "12.10" as cpu type/subtype
|
// Accept "12-10" or "12.10" as cpu type/subtype
|
||||||
if (isdigit(triple_cstr[0]))
|
if (isdigit(triple_cstr[0]))
|
||||||
{
|
{
|
||||||
char *end = NULL;
|
char *end = nullptr;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
uint32_t cpu = (uint32_t)::strtoul (triple_cstr, &end, 0);
|
uint32_t cpu = (uint32_t)::strtoul (triple_cstr, &end, 0);
|
||||||
if (errno == 0 && cpu != 0 && end && ((*end == '-') || (*end == '.')))
|
if (errno == 0 && cpu != 0 && end && ((*end == '-') || (*end == '.')))
|
||||||
|
@ -779,6 +771,7 @@ ParseMachCPUDashSubtypeTriple (const char *triple_cstr, ArchSpec &arch)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ArchSpec::SetTriple (const char *triple_cstr)
|
ArchSpec::SetTriple (const char *triple_cstr)
|
||||||
{
|
{
|
||||||
|
@ -1446,7 +1439,7 @@ StopInfoOverrideCallbackTypeARM(lldb_private::Thread &thread)
|
||||||
if (opcode <= UINT32_MAX)
|
if (opcode <= UINT32_MAX)
|
||||||
{
|
{
|
||||||
const uint32_t condition = Bits32((uint32_t)opcode, 31, 28);
|
const uint32_t condition = Bits32((uint32_t)opcode, 31, 28);
|
||||||
if (ARMConditionPassed(condition, cpsr) == false)
|
if (!ARMConditionPassed(condition, cpsr))
|
||||||
{
|
{
|
||||||
// We ARE stopped on an ARM instruction whose condition doesn't
|
// We ARE stopped on an ARM instruction whose condition doesn't
|
||||||
// pass so this instruction won't get executed.
|
// pass so this instruction won't get executed.
|
||||||
|
@ -1463,7 +1456,7 @@ StopInfoOverrideCallbackTypeARM(lldb_private::Thread &thread)
|
||||||
if (ITSTATE != 0)
|
if (ITSTATE != 0)
|
||||||
{
|
{
|
||||||
const uint32_t condition = Bits32(ITSTATE, 7, 4);
|
const uint32_t condition = Bits32(ITSTATE, 7, 4);
|
||||||
if (ARMConditionPassed(condition, cpsr) == false)
|
if (!ARMConditionPassed(condition, cpsr))
|
||||||
{
|
{
|
||||||
// We ARE stopped in a Thumb IT instruction on an instruction whose
|
// We ARE stopped in a Thumb IT instruction on an instruction whose
|
||||||
// condition doesn't pass so this instruction won't get executed.
|
// condition doesn't pass so this instruction won't get executed.
|
||||||
|
@ -1482,7 +1475,7 @@ ArchSpec::GetStopInfoOverrideCallback () const
|
||||||
const llvm::Triple::ArchType machine = GetMachine();
|
const llvm::Triple::ArchType machine = GetMachine();
|
||||||
if (machine == llvm::Triple::arm)
|
if (machine == llvm::Triple::arm)
|
||||||
return StopInfoOverrideCallbackTypeARM;
|
return StopInfoOverrideCallbackTypeARM;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -47,7 +47,7 @@ Broadcaster::~Broadcaster()
|
||||||
void
|
void
|
||||||
Broadcaster::CheckInWithManager ()
|
Broadcaster::CheckInWithManager ()
|
||||||
{
|
{
|
||||||
if (m_manager != NULL)
|
if (m_manager != nullptr)
|
||||||
{
|
{
|
||||||
m_manager->SignUpListenersForBroadcaster(*this);
|
m_manager->SignUpListenersForBroadcaster(*this);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ Broadcaster::Clear()
|
||||||
|
|
||||||
m_listeners.clear();
|
m_listeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConstString &
|
const ConstString &
|
||||||
Broadcaster::GetBroadcasterName ()
|
Broadcaster::GetBroadcasterName ()
|
||||||
{
|
{
|
||||||
|
@ -108,13 +109,12 @@ Broadcaster::GetEventNames (Stream &s, uint32_t event_mask, bool prefix_with_bro
|
||||||
void
|
void
|
||||||
Broadcaster::AddInitialEventsToListener (Listener *listener, uint32_t requested_events)
|
Broadcaster::AddInitialEventsToListener (Listener *listener, uint32_t requested_events)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
Broadcaster::AddListener (Listener* listener, uint32_t event_mask)
|
Broadcaster::AddListener (Listener* listener, uint32_t event_mask)
|
||||||
{
|
{
|
||||||
if (listener == NULL)
|
if (listener == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Mutex::Locker locker(m_listeners_mutex);
|
Mutex::Locker locker(m_listeners_mutex);
|
||||||
|
@ -165,7 +165,7 @@ Broadcaster::EventTypeHasListeners (uint32_t event_type)
|
||||||
{
|
{
|
||||||
Mutex::Locker locker (m_listeners_mutex);
|
Mutex::Locker locker (m_listeners_mutex);
|
||||||
|
|
||||||
if (m_hijacking_listeners.size() > 0 && event_type & m_hijacking_masks.back())
|
if (!m_hijacking_listeners.empty() && event_type & m_hijacking_masks.back())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (m_listeners.empty())
|
if (m_listeners.empty())
|
||||||
|
@ -216,8 +216,8 @@ Broadcaster::BroadcastEventIfUnique (EventSP &event_sp)
|
||||||
void
|
void
|
||||||
Broadcaster::PrivateBroadcastEvent (EventSP &event_sp, bool unique)
|
Broadcaster::PrivateBroadcastEvent (EventSP &event_sp, bool unique)
|
||||||
{
|
{
|
||||||
// Can't add a NULL event...
|
// Can't add a nullptr event...
|
||||||
if (event_sp.get() == NULL)
|
if (!event_sp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update the broadcaster on this event
|
// Update the broadcaster on this event
|
||||||
|
@ -227,13 +227,13 @@ Broadcaster::PrivateBroadcastEvent (EventSP &event_sp, bool unique)
|
||||||
|
|
||||||
Mutex::Locker event_types_locker(m_listeners_mutex);
|
Mutex::Locker event_types_locker(m_listeners_mutex);
|
||||||
|
|
||||||
Listener *hijacking_listener = NULL;
|
Listener *hijacking_listener = nullptr;
|
||||||
if (!m_hijacking_listeners.empty())
|
if (!m_hijacking_listeners.empty())
|
||||||
{
|
{
|
||||||
assert (!m_hijacking_masks.empty());
|
assert (!m_hijacking_masks.empty());
|
||||||
hijacking_listener = m_hijacking_listeners.back();
|
hijacking_listener = m_hijacking_listeners.back();
|
||||||
if ((event_type & m_hijacking_masks.back()) == 0)
|
if ((event_type & m_hijacking_masks.back()) == 0)
|
||||||
hijacking_listener = NULL;
|
hijacking_listener = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
|
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
|
||||||
|
@ -257,7 +257,6 @@ Broadcaster::PrivateBroadcastEvent (EventSP &event_sp, bool unique)
|
||||||
{
|
{
|
||||||
collection::iterator pos, end = m_listeners.end();
|
collection::iterator pos, end = m_listeners.end();
|
||||||
|
|
||||||
|
|
||||||
// Iterate through all listener/mask pairs
|
// Iterate through all listener/mask pairs
|
||||||
for (pos = m_listeners.begin(); pos != end; ++pos)
|
for (pos = m_listeners.begin(); pos != end; ++pos)
|
||||||
{
|
{
|
||||||
|
@ -341,11 +340,7 @@ Broadcaster::GetBroadcasterClass() const
|
||||||
return class_name;
|
return class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
BroadcastEventSpec::BroadcastEventSpec (const BroadcastEventSpec &rhs) :
|
BroadcastEventSpec::BroadcastEventSpec(const BroadcastEventSpec &rhs) = default;
|
||||||
m_broadcaster_class (rhs.m_broadcaster_class),
|
|
||||||
m_event_bits (rhs.m_event_bits)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BroadcastEventSpec::operator< (const BroadcastEventSpec &rhs) const
|
BroadcastEventSpec::operator< (const BroadcastEventSpec &rhs) const
|
||||||
|
@ -360,18 +355,12 @@ BroadcastEventSpec::operator< (const BroadcastEventSpec &rhs) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const BroadcastEventSpec &
|
BroadcastEventSpec &
|
||||||
BroadcastEventSpec::operator= (const BroadcastEventSpec &rhs)
|
BroadcastEventSpec::operator=(const BroadcastEventSpec &rhs) = default;
|
||||||
{
|
|
||||||
m_broadcaster_class = rhs.m_broadcaster_class;
|
|
||||||
m_event_bits = rhs.m_event_bits;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
BroadcasterManager::BroadcasterManager() :
|
BroadcasterManager::BroadcasterManager() :
|
||||||
m_manager_mutex(Mutex::eMutexTypeRecursive)
|
m_manager_mutex(Mutex::eMutexTypeRecursive)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
@ -412,7 +401,7 @@ BroadcasterManager::UnregisterListenerForEvents (Listener &listener, BroadcastEv
|
||||||
uint32_t event_bits_to_remove = event_spec.GetEventBits();
|
uint32_t event_bits_to_remove = event_spec.GetEventBits();
|
||||||
|
|
||||||
// Go through the map and delete the exact matches, and build a list of matches that weren't exact to re-add:
|
// Go through the map and delete the exact matches, and build a list of matches that weren't exact to re-add:
|
||||||
while (1)
|
while (true)
|
||||||
{
|
{
|
||||||
collection::iterator iter, end_iter = m_event_map.end();
|
collection::iterator iter, end_iter = m_event_map.end();
|
||||||
iter = find_if (m_event_map.begin(), end_iter, predicate);
|
iter = find_if (m_event_map.begin(), end_iter, predicate);
|
||||||
|
@ -453,7 +442,7 @@ BroadcasterManager::GetListenerForEventSpec (BroadcastEventSpec event_spec) cons
|
||||||
if (iter != end_iter)
|
if (iter != end_iter)
|
||||||
return (*iter).second;
|
return (*iter).second;
|
||||||
else
|
else
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -462,11 +451,10 @@ BroadcasterManager::RemoveListener (Listener &listener)
|
||||||
Mutex::Locker locker(m_manager_mutex);
|
Mutex::Locker locker(m_manager_mutex);
|
||||||
ListenerMatches predicate (listener);
|
ListenerMatches predicate (listener);
|
||||||
|
|
||||||
|
|
||||||
if (m_listeners.erase (&listener) == 0)
|
if (m_listeners.erase (&listener) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (1)
|
while (true)
|
||||||
{
|
{
|
||||||
collection::iterator iter, end_iter = m_event_map.end();
|
collection::iterator iter, end_iter = m_event_map.end();
|
||||||
iter = find_if (m_event_map.begin(), end_iter, predicate);
|
iter = find_if (m_event_map.begin(), end_iter, predicate);
|
||||||
|
@ -502,5 +490,4 @@ BroadcasterManager::Clear ()
|
||||||
(*iter)->BroadcasterManagerWillDestruct(this);
|
(*iter)->BroadcasterManagerWillDestruct(this);
|
||||||
m_listeners.clear();
|
m_listeners.clear();
|
||||||
m_event_map.clear();
|
m_event_map.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
// C Includes
|
// C Includes
|
||||||
// C++ Includes
|
// C++ Includes
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
// Other libraries and framework includes
|
// Other libraries and framework includes
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "lldb/Core/Communication.h"
|
#include "lldb/Core/Communication.h"
|
||||||
|
@ -19,7 +21,6 @@
|
||||||
#include "lldb/Host/Host.h"
|
#include "lldb/Host/Host.h"
|
||||||
#include "lldb/Host/HostThread.h"
|
#include "lldb/Host/HostThread.h"
|
||||||
#include "lldb/Host/ThreadLauncher.h"
|
#include "lldb/Host/ThreadLauncher.h"
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
@ -31,21 +32,18 @@ Communication::GetStaticBroadcasterClass ()
|
||||||
return class_name;
|
return class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// Constructor
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
Communication::Communication(const char *name) :
|
Communication::Communication(const char *name) :
|
||||||
Broadcaster (NULL, name),
|
Broadcaster(nullptr, name),
|
||||||
m_connection_sp (),
|
m_connection_sp(),
|
||||||
m_read_thread_enabled (false),
|
m_read_thread_enabled(false),
|
||||||
m_read_thread_did_exit (false),
|
m_read_thread_did_exit(false),
|
||||||
m_bytes(),
|
m_bytes(),
|
||||||
m_bytes_mutex (Mutex::eMutexTypeRecursive),
|
m_bytes_mutex(Mutex::eMutexTypeRecursive),
|
||||||
m_write_mutex (Mutex::eMutexTypeNormal),
|
m_write_mutex(Mutex::eMutexTypeNormal),
|
||||||
m_synchronize_mutex (Mutex::eMutexTypeNormal),
|
m_synchronize_mutex(Mutex::eMutexTypeNormal),
|
||||||
m_callback (NULL),
|
m_callback(nullptr),
|
||||||
m_callback_baton (NULL),
|
m_callback_baton(nullptr),
|
||||||
m_close_on_eof (true)
|
m_close_on_eof(true)
|
||||||
|
|
||||||
{
|
{
|
||||||
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
|
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
|
||||||
|
@ -62,9 +60,6 @@ Communication::Communication(const char *name) :
|
||||||
CheckInWithManager();
|
CheckInWithManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// Destructor
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
Communication::~Communication()
|
Communication::~Communication()
|
||||||
{
|
{
|
||||||
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
|
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
|
||||||
|
@ -76,9 +71,9 @@ Communication::~Communication()
|
||||||
void
|
void
|
||||||
Communication::Clear()
|
Communication::Clear()
|
||||||
{
|
{
|
||||||
SetReadThreadBytesReceivedCallback (NULL, NULL);
|
SetReadThreadBytesReceivedCallback(nullptr, nullptr);
|
||||||
Disconnect (NULL);
|
Disconnect(nullptr);
|
||||||
StopReadThread (NULL);
|
StopReadThread(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionStatus
|
ConnectionStatus
|
||||||
|
@ -89,7 +84,7 @@ Communication::Connect (const char *url, Error *error_ptr)
|
||||||
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::Connect (url = %s)", this, url);
|
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::Connect (url = %s)", this, url);
|
||||||
|
|
||||||
lldb::ConnectionSP connection_sp (m_connection_sp);
|
lldb::ConnectionSP connection_sp (m_connection_sp);
|
||||||
if (connection_sp.get())
|
if (connection_sp)
|
||||||
return connection_sp->Connect (url, error_ptr);
|
return connection_sp->Connect (url, error_ptr);
|
||||||
if (error_ptr)
|
if (error_ptr)
|
||||||
error_ptr->SetErrorString("Invalid connection.");
|
error_ptr->SetErrorString("Invalid connection.");
|
||||||
|
@ -102,7 +97,7 @@ Communication::Disconnect (Error *error_ptr)
|
||||||
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::Disconnect ()", this);
|
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::Disconnect ()", this);
|
||||||
|
|
||||||
lldb::ConnectionSP connection_sp (m_connection_sp);
|
lldb::ConnectionSP connection_sp (m_connection_sp);
|
||||||
if (connection_sp.get())
|
if (connection_sp)
|
||||||
{
|
{
|
||||||
ConnectionStatus status = connection_sp->Disconnect (error_ptr);
|
ConnectionStatus status = connection_sp->Disconnect (error_ptr);
|
||||||
// We currently don't protect connection_sp with any mutex for
|
// We currently don't protect connection_sp with any mutex for
|
||||||
|
@ -123,16 +118,14 @@ Communication::Disconnect (Error *error_ptr)
|
||||||
bool
|
bool
|
||||||
Communication::IsConnected () const
|
Communication::IsConnected () const
|
||||||
{
|
{
|
||||||
lldb::ConnectionSP connection_sp (m_connection_sp);
|
lldb::ConnectionSP connection_sp(m_connection_sp);
|
||||||
if (connection_sp.get())
|
return (connection_sp ? connection_sp->IsConnected() : false);
|
||||||
return connection_sp->IsConnected ();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Communication::HasConnection () const
|
Communication::HasConnection () const
|
||||||
{
|
{
|
||||||
return m_connection_sp.get() != NULL;
|
return m_connection_sp.get() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
@ -156,7 +149,7 @@ Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, Connectio
|
||||||
return cached_bytes;
|
return cached_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_connection_sp.get() == NULL)
|
if (!m_connection_sp)
|
||||||
{
|
{
|
||||||
if (error_ptr)
|
if (error_ptr)
|
||||||
error_ptr->SetErrorString("Invalid connection.");
|
error_ptr->SetErrorString("Invalid connection.");
|
||||||
|
@ -174,7 +167,7 @@ Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, Connectio
|
||||||
Listener listener ("Communication::Read");
|
Listener listener ("Communication::Read");
|
||||||
listener.StartListeningForEvents (this, eBroadcastBitReadThreadGotBytes | eBroadcastBitReadThreadDidExit);
|
listener.StartListeningForEvents (this, eBroadcastBitReadThreadGotBytes | eBroadcastBitReadThreadDidExit);
|
||||||
EventSP event_sp;
|
EventSP event_sp;
|
||||||
while (listener.WaitForEvent (timeout_time.IsValid() ? &timeout_time : NULL, event_sp))
|
while (listener.WaitForEvent((timeout_time.IsValid() ? &timeout_time : nullptr), event_sp))
|
||||||
{
|
{
|
||||||
const uint32_t event_type = event_sp->GetType();
|
const uint32_t event_type = event_sp->GetType();
|
||||||
if (event_type & eBroadcastBitReadThreadGotBytes)
|
if (event_type & eBroadcastBitReadThreadGotBytes)
|
||||||
|
@ -185,7 +178,7 @@ Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, Connectio
|
||||||
if (event_type & eBroadcastBitReadThreadDidExit)
|
if (event_type & eBroadcastBitReadThreadDidExit)
|
||||||
{
|
{
|
||||||
if (GetCloseOnEOF ())
|
if (GetCloseOnEOF ())
|
||||||
Disconnect (NULL);
|
Disconnect(nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +188,7 @@ Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, Connectio
|
||||||
// We aren't using a read thread, just read the data synchronously in this
|
// We aren't using a read thread, just read the data synchronously in this
|
||||||
// thread.
|
// thread.
|
||||||
lldb::ConnectionSP connection_sp (m_connection_sp);
|
lldb::ConnectionSP connection_sp (m_connection_sp);
|
||||||
if (connection_sp.get())
|
if (connection_sp)
|
||||||
{
|
{
|
||||||
return connection_sp->Read (dst, dst_len, timeout_usec, status, error_ptr);
|
return connection_sp->Read (dst, dst_len, timeout_usec, status, error_ptr);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +199,6 @@ Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, Connectio
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
Communication::Write (const void *src, size_t src_len, ConnectionStatus &status, Error *error_ptr)
|
Communication::Write (const void *src, size_t src_len, ConnectionStatus &status, Error *error_ptr)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +212,7 @@ Communication::Write (const void *src, size_t src_len, ConnectionStatus &status,
|
||||||
(uint64_t)src_len,
|
(uint64_t)src_len,
|
||||||
connection_sp.get());
|
connection_sp.get());
|
||||||
|
|
||||||
if (connection_sp.get())
|
if (connection_sp)
|
||||||
return connection_sp->Write (src, src_len, status, error_ptr);
|
return connection_sp->Write (src, src_len, status, error_ptr);
|
||||||
|
|
||||||
if (error_ptr)
|
if (error_ptr)
|
||||||
|
@ -229,7 +221,6 @@ Communication::Write (const void *src, size_t src_len, ConnectionStatus &status,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Communication::StartReadThread (Error *error_ptr)
|
Communication::StartReadThread (Error *error_ptr)
|
||||||
{
|
{
|
||||||
|
@ -242,7 +233,6 @@ Communication::StartReadThread (Error *error_ptr)
|
||||||
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
|
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
|
||||||
"%p Communication::StartReadThread ()", this);
|
"%p Communication::StartReadThread ()", this);
|
||||||
|
|
||||||
|
|
||||||
char thread_name[1024];
|
char thread_name[1024];
|
||||||
snprintf(thread_name, sizeof(thread_name), "<lldb.comm.%s>", m_broadcaster_name.AsCString());
|
snprintf(thread_name, sizeof(thread_name), "<lldb.comm.%s>", m_broadcaster_name.AsCString());
|
||||||
|
|
||||||
|
@ -265,7 +255,7 @@ Communication::StopReadThread (Error *error_ptr)
|
||||||
|
|
||||||
m_read_thread_enabled = false;
|
m_read_thread_enabled = false;
|
||||||
|
|
||||||
BroadcastEvent (eBroadcastBitReadThreadShouldExit, NULL);
|
BroadcastEvent(eBroadcastBitReadThreadShouldExit, nullptr);
|
||||||
|
|
||||||
// error = m_read_thread.Cancel();
|
// error = m_read_thread.Cancel();
|
||||||
|
|
||||||
|
@ -287,11 +277,11 @@ size_t
|
||||||
Communication::GetCachedBytes (void *dst, size_t dst_len)
|
Communication::GetCachedBytes (void *dst, size_t dst_len)
|
||||||
{
|
{
|
||||||
Mutex::Locker locker(m_bytes_mutex);
|
Mutex::Locker locker(m_bytes_mutex);
|
||||||
if (m_bytes.size() > 0)
|
if (!m_bytes.empty())
|
||||||
{
|
{
|
||||||
// If DST is NULL and we have a thread, then return the number
|
// If DST is nullptr and we have a thread, then return the number
|
||||||
// of bytes that are available so the caller can call again
|
// of bytes that are available so the caller can call again
|
||||||
if (dst == NULL)
|
if (dst == nullptr)
|
||||||
return m_bytes.size();
|
return m_bytes.size();
|
||||||
|
|
||||||
const size_t len = std::min<size_t>(dst_len, m_bytes.size());
|
const size_t len = std::min<size_t>(dst_len, m_bytes.size());
|
||||||
|
@ -310,7 +300,7 @@ Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broad
|
||||||
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
|
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
|
||||||
"%p Communication::AppendBytesToCache (src = %p, src_len = %" PRIu64 ", broadcast = %i)",
|
"%p Communication::AppendBytesToCache (src = %p, src_len = %" PRIu64 ", broadcast = %i)",
|
||||||
this, bytes, (uint64_t)len, broadcast);
|
this, bytes, (uint64_t)len, broadcast);
|
||||||
if ((bytes == NULL || len == 0)
|
if ((bytes == nullptr || len == 0)
|
||||||
&& (status != lldb::eConnectionStatusEndOfFile))
|
&& (status != lldb::eConnectionStatusEndOfFile))
|
||||||
return;
|
return;
|
||||||
if (m_callback)
|
if (m_callback)
|
||||||
|
@ -318,7 +308,7 @@ Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broad
|
||||||
// If the user registered a callback, then call it and do not broadcast
|
// If the user registered a callback, then call it and do not broadcast
|
||||||
m_callback (m_callback_baton, bytes, len);
|
m_callback (m_callback_baton, bytes, len);
|
||||||
}
|
}
|
||||||
else if (bytes != NULL && len > 0)
|
else if (bytes != nullptr && len > 0)
|
||||||
{
|
{
|
||||||
Mutex::Locker locker(m_bytes_mutex);
|
Mutex::Locker locker(m_bytes_mutex);
|
||||||
m_bytes.append ((const char *)bytes, len);
|
m_bytes.append ((const char *)bytes, len);
|
||||||
|
@ -334,10 +324,8 @@ Communication::ReadFromConnection (void *dst,
|
||||||
ConnectionStatus &status,
|
ConnectionStatus &status,
|
||||||
Error *error_ptr)
|
Error *error_ptr)
|
||||||
{
|
{
|
||||||
lldb::ConnectionSP connection_sp (m_connection_sp);
|
lldb::ConnectionSP connection_sp(m_connection_sp);
|
||||||
if (connection_sp.get())
|
return (connection_sp ? connection_sp->Read(dst, dst_len, timeout_usec, status, error_ptr) : 0);
|
||||||
return connection_sp->Read (dst, dst_len, timeout_usec, status, error_ptr);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -425,11 +413,8 @@ Communication::ReadThread (lldb::thread_arg_t p)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Communication::SetReadThreadBytesReceivedCallback
|
Communication::SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
|
||||||
(
|
void *callback_baton)
|
||||||
ReadThreadBytesReceived callback,
|
|
||||||
void *callback_baton
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
m_callback = callback;
|
m_callback = callback;
|
||||||
m_callback_baton = callback_baton;
|
m_callback_baton = callback_baton;
|
||||||
|
@ -454,14 +439,14 @@ Communication::SynchronizeWithReadThread ()
|
||||||
|
|
||||||
// Wait for the synchronization event.
|
// Wait for the synchronization event.
|
||||||
EventSP event_sp;
|
EventSP event_sp;
|
||||||
listener.WaitForEvent(NULL, event_sp);
|
listener.WaitForEvent(nullptr, event_sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Communication::SetConnection (Connection *connection)
|
Communication::SetConnection (Connection *connection)
|
||||||
{
|
{
|
||||||
Disconnect (NULL);
|
Disconnect(nullptr);
|
||||||
StopReadThread(NULL);
|
StopReadThread(nullptr);
|
||||||
m_connection_sp.reset(connection);
|
m_connection_sp.reset(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===-- ConnectionSharedMemory.cpp ----------------------------*- C++ -*-===//
|
//===-- ConnectionSharedMemory.cpp ------------------------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -6,13 +6,12 @@
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef __ANDROID_NDK__
|
#ifndef __ANDROID_NDK__
|
||||||
|
|
||||||
#include "lldb/Core/ConnectionSharedMemory.h"
|
#include "lldb/Core/ConnectionSharedMemory.h"
|
||||||
|
|
||||||
// C Includes
|
// C Includes
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "lldb/Host/windows/windows.h"
|
#include "lldb/Host/windows/windows.h"
|
||||||
#else
|
#else
|
||||||
|
@ -23,9 +22,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C++ Includes
|
// C++ Includes
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
// Other libraries and framework includes
|
// Other libraries and framework includes
|
||||||
// Project includes
|
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
|
||||||
|
// Project includes
|
||||||
#include "lldb/Core/Communication.h"
|
#include "lldb/Core/Communication.h"
|
||||||
#include "lldb/Core/Log.h"
|
#include "lldb/Core/Log.h"
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ ConnectionSharedMemory::ConnectionSharedMemory () :
|
||||||
|
|
||||||
ConnectionSharedMemory::~ConnectionSharedMemory ()
|
ConnectionSharedMemory::~ConnectionSharedMemory ()
|
||||||
{
|
{
|
||||||
Disconnect (NULL);
|
Disconnect(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -136,7 +139,7 @@ ConnectionSharedMemory::Open (bool create, const char *name, size_t size, Error
|
||||||
if (create) {
|
if (create) {
|
||||||
handle = CreateFileMapping(
|
handle = CreateFileMapping(
|
||||||
INVALID_HANDLE_VALUE,
|
INVALID_HANDLE_VALUE,
|
||||||
NULL,
|
nullptr,
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
llvm::Hi_32(size),
|
llvm::Hi_32(size),
|
||||||
llvm::Lo_32(size),
|
llvm::Lo_32(size),
|
||||||
|
@ -159,7 +162,7 @@ ConnectionSharedMemory::Open (bool create, const char *name, size_t size, Error
|
||||||
if (m_mmap.MemoryMapFromFileDescriptor(m_fd, 0, size, true, false) == size)
|
if (m_mmap.MemoryMapFromFileDescriptor(m_fd, 0, size, true, false) == size)
|
||||||
return eConnectionStatusSuccess;
|
return eConnectionStatusSuccess;
|
||||||
|
|
||||||
Disconnect(NULL);
|
Disconnect(nullptr);
|
||||||
return eConnectionStatusError;
|
return eConnectionStatusError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===-- DataEncoder.cpp ---------------------------------------*- C++ -*-===//
|
//===-- DataEncoder.cpp -----------------------------------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -9,11 +9,16 @@
|
||||||
|
|
||||||
#include "lldb/Core/DataEncoder.h"
|
#include "lldb/Core/DataEncoder.h"
|
||||||
|
|
||||||
#include <assert.h>
|
// C Includes
|
||||||
#include <stddef.h>
|
// C++ Includes
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
// Other libraries and framework includes
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
|
||||||
|
// Project includes
|
||||||
#include "lldb/Core/DataBuffer.h"
|
#include "lldb/Core/DataBuffer.h"
|
||||||
#include "lldb/Host/Endian.h"
|
#include "lldb/Host/Endian.h"
|
||||||
|
|
||||||
|
@ -25,6 +30,7 @@ WriteInt16(unsigned char* ptr, unsigned offset, uint16_t value)
|
||||||
{
|
{
|
||||||
*(uint16_t *)(ptr + offset) = value;
|
*(uint16_t *)(ptr + offset) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
WriteInt32 (unsigned char* ptr, unsigned offset, uint32_t value)
|
WriteInt32 (unsigned char* ptr, unsigned offset, uint32_t value)
|
||||||
{
|
{
|
||||||
|
@ -59,11 +65,11 @@ WriteSwappedInt64(unsigned char* ptr, unsigned offset, uint64_t value)
|
||||||
// Default constructor.
|
// Default constructor.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
DataEncoder::DataEncoder () :
|
DataEncoder::DataEncoder () :
|
||||||
m_start (NULL),
|
m_start(nullptr),
|
||||||
m_end (NULL),
|
m_end(nullptr),
|
||||||
m_byte_order(endian::InlHostByteOrder()),
|
m_byte_order(endian::InlHostByteOrder()),
|
||||||
m_addr_size (sizeof(void*)),
|
m_addr_size(sizeof(void*)),
|
||||||
m_data_sp ()
|
m_data_sp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,21 +94,16 @@ DataEncoder::DataEncoder (void* data, uint32_t length, ByteOrder endian, uint8_t
|
||||||
// this data.
|
// this data.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
DataEncoder::DataEncoder (const DataBufferSP& data_sp, ByteOrder endian, uint8_t addr_size) :
|
DataEncoder::DataEncoder (const DataBufferSP& data_sp, ByteOrder endian, uint8_t addr_size) :
|
||||||
m_start (NULL),
|
m_start(nullptr),
|
||||||
m_end (NULL),
|
m_end(nullptr),
|
||||||
m_byte_order(endian),
|
m_byte_order(endian),
|
||||||
m_addr_size (addr_size),
|
m_addr_size(addr_size),
|
||||||
m_data_sp ()
|
m_data_sp()
|
||||||
{
|
{
|
||||||
SetData (data_sp);
|
SetData (data_sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
DataEncoder::~DataEncoder() = default;
|
||||||
// Destructor
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
DataEncoder::~DataEncoder ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Clears the object contents back to a default invalid state, and
|
// Clears the object contents back to a default invalid state, and
|
||||||
|
@ -112,8 +113,8 @@ DataEncoder::~DataEncoder ()
|
||||||
void
|
void
|
||||||
DataEncoder::Clear ()
|
DataEncoder::Clear ()
|
||||||
{
|
{
|
||||||
m_start = NULL;
|
m_start = nullptr;
|
||||||
m_end = NULL;
|
m_end = nullptr;
|
||||||
m_byte_order = endian::InlHostByteOrder();
|
m_byte_order = endian::InlHostByteOrder();
|
||||||
m_addr_size = sizeof(void*);
|
m_addr_size = sizeof(void*);
|
||||||
m_data_sp.reset();
|
m_data_sp.reset();
|
||||||
|
@ -126,13 +127,13 @@ DataEncoder::Clear ()
|
||||||
size_t
|
size_t
|
||||||
DataEncoder::GetSharedDataOffset () const
|
DataEncoder::GetSharedDataOffset () const
|
||||||
{
|
{
|
||||||
if (m_start != NULL)
|
if (m_start != nullptr)
|
||||||
{
|
{
|
||||||
const DataBuffer * data = m_data_sp.get();
|
const DataBuffer * data = m_data_sp.get();
|
||||||
if (data != NULL)
|
if (data != nullptr)
|
||||||
{
|
{
|
||||||
const uint8_t * data_bytes = data->GetBytes();
|
const uint8_t * data_bytes = data->GetBytes();
|
||||||
if (data_bytes != NULL)
|
if (data_bytes != nullptr)
|
||||||
{
|
{
|
||||||
assert(m_start >= data_bytes);
|
assert(m_start >= data_bytes);
|
||||||
return m_start - data_bytes;
|
return m_start - data_bytes;
|
||||||
|
@ -157,10 +158,10 @@ DataEncoder::SetData (void *bytes, uint32_t length, ByteOrder endian)
|
||||||
{
|
{
|
||||||
m_byte_order = endian;
|
m_byte_order = endian;
|
||||||
m_data_sp.reset();
|
m_data_sp.reset();
|
||||||
if (bytes == NULL || length == 0)
|
if (bytes == nullptr || length == 0)
|
||||||
{
|
{
|
||||||
m_start = NULL;
|
m_start = nullptr;
|
||||||
m_end = NULL;
|
m_end = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -187,12 +188,12 @@ DataEncoder::SetData (void *bytes, uint32_t length, ByteOrder endian)
|
||||||
uint32_t
|
uint32_t
|
||||||
DataEncoder::SetData (const DataBufferSP& data_sp, uint32_t data_offset, uint32_t data_length)
|
DataEncoder::SetData (const DataBufferSP& data_sp, uint32_t data_offset, uint32_t data_length)
|
||||||
{
|
{
|
||||||
m_start = m_end = NULL;
|
m_start = m_end = nullptr;
|
||||||
|
|
||||||
if (data_length > 0)
|
if (data_length > 0)
|
||||||
{
|
{
|
||||||
m_data_sp = data_sp;
|
m_data_sp = data_sp;
|
||||||
if (data_sp.get())
|
if (data_sp)
|
||||||
{
|
{
|
||||||
const size_t data_size = data_sp->GetByteSize();
|
const size_t data_size = data_sp->GetByteSize();
|
||||||
if (data_offset < data_size)
|
if (data_offset < data_size)
|
||||||
|
@ -232,7 +233,7 @@ DataEncoder::PutU8 (uint32_t offset, uint8_t value)
|
||||||
m_start[offset] = value;
|
m_start[offset] = value;
|
||||||
return offset + 1;
|
return offset + 1;
|
||||||
}
|
}
|
||||||
return UINT32_MAX;
|
return std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
@ -247,7 +248,7 @@ DataEncoder::PutU16 (uint32_t offset, uint16_t value)
|
||||||
|
|
||||||
return offset + sizeof (value);
|
return offset + sizeof (value);
|
||||||
}
|
}
|
||||||
return UINT32_MAX;
|
return std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
@ -262,7 +263,7 @@ DataEncoder::PutU32 (uint32_t offset, uint32_t value)
|
||||||
|
|
||||||
return offset + sizeof (value);
|
return offset + sizeof (value);
|
||||||
}
|
}
|
||||||
return UINT32_MAX;
|
return std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
@ -277,7 +278,7 @@ DataEncoder::PutU64 (uint32_t offset, uint64_t value)
|
||||||
|
|
||||||
return offset + sizeof (value);
|
return offset + sizeof (value);
|
||||||
}
|
}
|
||||||
return UINT32_MAX;
|
return std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -303,13 +304,13 @@ DataEncoder::PutMaxU64 (uint32_t offset, uint32_t byte_size, uint64_t value)
|
||||||
assert(!"GetMax64 unhandled case!");
|
assert(!"GetMax64 unhandled case!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return UINT32_MAX;
|
return std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
DataEncoder::PutData (uint32_t offset, const void *src, uint32_t src_len)
|
DataEncoder::PutData (uint32_t offset, const void *src, uint32_t src_len)
|
||||||
{
|
{
|
||||||
if (src == NULL || src_len == 0)
|
if (src == nullptr || src_len == 0)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
if (ValidOffsetForDataOfSize(offset, src_len))
|
if (ValidOffsetForDataOfSize(offset, src_len))
|
||||||
|
@ -317,7 +318,7 @@ DataEncoder::PutData (uint32_t offset, const void *src, uint32_t src_len)
|
||||||
memcpy (m_start + offset, src, src_len);
|
memcpy (m_start + offset, src, src_len);
|
||||||
return offset + src_len;
|
return offset + src_len;
|
||||||
}
|
}
|
||||||
return UINT32_MAX;
|
return std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
@ -329,7 +330,7 @@ DataEncoder::PutAddress (uint32_t offset, lldb::addr_t addr)
|
||||||
uint32_t
|
uint32_t
|
||||||
DataEncoder::PutCString (uint32_t offset, const char *cstr)
|
DataEncoder::PutCString (uint32_t offset, const char *cstr)
|
||||||
{
|
{
|
||||||
if (cstr)
|
if (cstr != nullptr)
|
||||||
return PutData (offset, cstr, strlen(cstr) + 1);
|
return PutData (offset, cstr, strlen(cstr) + 1);
|
||||||
return UINT32_MAX;
|
return std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue