// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Stream.h"
+
+// C Includes
+// C++ Includes
+#include <array>
+#include <mutex>
+
+// Other libraries and framework includes
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/RWMutex.h"
-#include <array>
-#include <mutex>
+// Project includes
+#include "lldb/Core/Stream.h"
using namespace lldb_private;
size_t
GetConstCStringLength (const char *ccstr) const
{
- if (ccstr)
+ if (ccstr != nullptr)
{
const uint8_t h = hash (llvm::StringRef(ccstr));
llvm::sys::SmartScopedReader<false> rlock(m_string_pools[h].m_mutex);
StringPoolValueType
GetMangledCounterpart (const char *ccstr) const
{
- if (ccstr)
+ if (ccstr != nullptr)
{
const uint8_t h = hash (llvm::StringRef(ccstr));
llvm::sys::SmartScopedReader<false> rlock(m_string_pools[h].m_mutex);
return GetStringMapEntryFromKeyData (ccstr).getValue();
}
- return 0;
+ return nullptr;
}
bool
SetMangledCounterparts (const char *key_ccstr, const char *value_ccstr)
{
- if (key_ccstr && value_ccstr)
+ if (key_ccstr != nullptr && value_ccstr != nullptr)
{
{
const uint8_t h = hash (llvm::StringRef(key_ccstr));
const char *
GetConstCString (const char *cstr)
{
- if (cstr)
+ if (cstr != nullptr)
return GetConstCStringWithLength (cstr, strlen (cstr));
return nullptr;
}
const char *
GetConstCStringWithLength (const char *cstr, size_t cstr_len)
{
- if (cstr)
+ if (cstr != nullptr)
return GetConstCStringWithStringRef(llvm::StringRef(cstr, cstr_len));
return nullptr;
}
const char *
GetConstCStringAndSetMangledCounterPart (const char *demangled_cstr, const char *mangled_ccstr)
{
- if (demangled_cstr)
+ if (demangled_cstr != nullptr)
{
const char *demangled_ccstr = nullptr;
const char *
GetConstTrimmedCStringWithLength (const char *cstr, size_t cstr_len)
{
- if (cstr)
+ if (cstr != nullptr)
{
const size_t trimmed_len = std::min<size_t> (strlen (cstr), cstr_len);
return GetConstCStringWithLength (cstr, trimmed_len);
lldb_private::operator << (Stream& s, const ConstString& str)
{
const char *cstr = str.GetCString();
- if (cstr)
+ if (cstr != nullptr)
s << cstr;
return s;
}
if (lhs_cstr)
- return +1; // LHS isn't NULL but RHS is
+ return +1; // LHS isn't nullptr but RHS is
else
- return -1; // LHS is NULL but RHS isn't
+ return -1; // LHS is nullptr but RHS isn't
}
void
ConstString::Dump(Stream *s, const char *fail_value) const
{
- if (s)
+ if (s != nullptr)
{
const char *cstr = AsCString (fail_value);
- if (cstr)
+ if (cstr != nullptr)
s->PutCString (cstr);
}
}
{
const char *cstr = GetCString ();
size_t cstr_len = GetLength();
- // Only print the parens if we have a non-NULL string
+ // Only print the parens if we have a non-nullptr string
const char *parens = cstr ? "\"" : "";
s->Printf("%*p: ConstString, string = %s%s%s, length = %" PRIu64,
static_cast<int>(sizeof(void*) * 2),
#endif
// C++ Includes
+#include <cerrno>
+#include <cstdarg>
+
// Other libraries and framework includes
+#include "llvm/ADT/SmallVector.h"
+
// Project includes
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
-#include "llvm/ADT/SmallVector.h"
-#include <cerrno>
-#include <cstdarg>
using namespace lldb;
using namespace lldb_private;
{
}
-//----------------------------------------------------------------------
-// Default constructor
-//----------------------------------------------------------------------
Error::Error(ValueType err, ErrorType type) :
m_code (err),
m_type (type),
{
}
-Error::Error (const Error &rhs) :
- m_code (rhs.m_code),
- m_type (rhs.m_type),
- m_string (rhs.m_string)
-{
-}
+Error::Error(const Error &rhs) = default;
Error::Error (const char* format, ...):
m_code (0),
return *this;
}
-
//----------------------------------------------------------------------
// Assignment operator
//----------------------------------------------------------------------
return *this;
}
-Error::~Error()
-{
-}
+Error::~Error() = default;
//----------------------------------------------------------------------
// Get the error value as a NULL C string. The error string will be
Error::AsCString(const char *default_error_str) const
{
if (Success())
- return NULL;
+ return nullptr;
if (m_string.empty())
{
- const char *s = NULL;
+ const char *s = nullptr;
switch (m_type)
{
case eErrorTypeMachKernel:
default:
break;
}
- if (s)
+ if (s != nullptr)
m_string.assign(s);
}
if (m_string.empty())
if (default_error_str)
m_string.assign(default_error_str);
else
- return NULL; // User wanted a NULL string back...
+ return nullptr; // User wanted a nullptr string back...
}
return m_string.c_str();
}
-
//----------------------------------------------------------------------
// Clear the error and any cached error string that it might contain.
//----------------------------------------------------------------------
void
Error::PutToLog (Log *log, const char *format, ...)
{
- char *arg_msg = NULL;
+ char *arg_msg = nullptr;
va_list args;
va_start (args, format);
::vasprintf (&arg_msg, format, args);
va_end (args);
- if (arg_msg != NULL)
+ if (arg_msg != nullptr)
{
if (Fail())
{
const char *err_str = AsCString();
- if (err_str == NULL)
+ if (err_str == nullptr)
err_str = "???";
SetErrorStringWithFormat("error: %s err = %s (0x%8.8x)", arg_msg, err_str, m_code);
- if (log)
+ if (log != nullptr)
log->Error("%s", m_string.c_str());
}
else
{
- if (log)
+ if (log != nullptr)
log->Printf("%s err = 0x%8.8x", arg_msg, m_code);
}
::free (arg_msg);
{
if (Fail())
{
- char *arg_msg = NULL;
+ char *arg_msg = nullptr;
va_list args;
va_start (args, format);
::vasprintf (&arg_msg, format, args);
va_end (args);
- if (arg_msg != NULL)
+ if (arg_msg != nullptr)
{
const char *err_str = AsCString();
- if (err_str == NULL)
+ if (err_str == nullptr)
err_str = "???";
SetErrorStringWithFormat("%s err = %s (0x%8.8x)", arg_msg, err_str, m_code);
- if (log)
+ if (log != nullptr)
log->Error("%s", m_string.c_str());
::free (arg_msg);
{
int length = 0;
- if (format && format[0])
+ if (format != nullptr && format[0])
{
va_list args;
va_start (args, format);
void
Error::SetErrorString (const char *err_str)
{
- if (err_str && err_str[0])
+ if (err_str != nullptr && err_str[0])
{
// If we have an error string, we should always at least have
// an error set to a generic value.
int
Error::SetErrorStringWithFormat (const char *format, ...)
{
- if (format && format[0])
+ if (format != nullptr && format[0])
{
va_list args;
va_start (args, format);
int
Error::SetErrorStringWithVarArg (const char *format, va_list args)
{
- if (format && format[0])
+ if (format != nullptr && format[0])
{
// If we have an error string, we should always at least have
// an error set to a generic value.
return 0;
}
-
//----------------------------------------------------------------------
// Returns true if the error code in this object is considered a
// successful return value.
bool
Error::WasInterrupted() const
{
- if (m_type == eErrorTypePOSIX && m_code == EINTR)
- return true;
- else
- return false;
+ return (m_type == eErrorTypePOSIX && m_code == EINTR);
}
-
// C Includes
// C++ Includes
+#include <algorithm>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Event.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/Endian.h"
#include "lldb/Target/Process.h"
-#include <algorithm>
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
-// Event constructor
-//----------------------------------------------------------------------
Event::Event (Broadcaster *broadcaster, uint32_t event_type, EventData *data) :
m_broadcaster_wp (broadcaster->GetBroadcasterImpl()),
m_type (event_type),
{
}
-
-//----------------------------------------------------------------------
-// Event destructor
-//----------------------------------------------------------------------
-Event::~Event ()
-{
-}
+Event::~Event() = default;
void
Event::Dump (Stream *s) const
s->Printf("%p Event: broadcaster = NULL, type = 0x%8.8x, data = ",
static_cast<const void*>(this), m_type);
- if (m_data_ap.get() == NULL)
- s->Printf ("<NULL>");
- else
+ if (m_data_ap)
{
s->PutChar('{');
m_data_ap->Dump (s);
s->PutChar('}');
}
+ else
+ s->Printf ("<NULL>");
}
void
Event::DoOnRemoval ()
{
- if (m_data_ap.get())
+ if (m_data_ap)
m_data_ap->DoOnRemoval (this);
}
-EventData::EventData()
-{
-}
+EventData::EventData() = default;
-EventData::~EventData()
-{
-}
+EventData::~EventData() = default;
void
EventData::Dump (Stream *s) const
SetBytes (src, src_len);
}
-EventDataBytes::~EventDataBytes()
-{
-}
+EventDataBytes::~EventDataBytes() = default;
const ConstString &
EventDataBytes::GetFlavorString ()
{
s->Printf("\"%s\"", m_bytes.c_str());
}
- else if (m_bytes.size() > 0)
+ else if (!m_bytes.empty())
{
DataExtractor data;
- data.SetData(&m_bytes[0], m_bytes.size(), endian::InlHostByteOrder());
+ data.SetData(m_bytes.data(), m_bytes.size(), endian::InlHostByteOrder());
data.Dump(s, 0, eFormatBytes, 1, m_bytes.size(), 32, LLDB_INVALID_ADDRESS, 0, 0);
}
}
const void *
EventDataBytes::GetBytes() const
{
- if (m_bytes.empty())
- return NULL;
- return &m_bytes[0];
+ return (m_bytes.empty() ? nullptr : m_bytes.data());
}
size_t
void
EventDataBytes::SetBytes (const void *src, size_t src_len)
{
- if (src && src_len > 0)
+ if (src != nullptr && src_len > 0)
m_bytes.assign ((const char *)src, src_len);
else
m_bytes.clear();
void
EventDataBytes::SetBytesFromCString (const char *cstr)
{
- if (cstr && cstr[0])
+ if (cstr != nullptr && cstr[0])
m_bytes.assign (cstr);
else
m_bytes.clear();
}
-
const void *
EventDataBytes::GetBytesFromEvent (const Event *event_ptr)
{
const EventDataBytes *e = GetEventDataFromEvent (event_ptr);
- if (e)
+ if (e != nullptr)
return e->GetBytes();
- return NULL;
+ return nullptr;
}
size_t
EventDataBytes::GetByteSizeFromEvent (const Event *event_ptr)
{
const EventDataBytes *e = GetEventDataFromEvent (event_ptr);
- if (e)
+ if (e != nullptr)
return e->GetByteSize();
return 0;
}
const EventDataBytes *
EventDataBytes::GetEventDataFromEvent (const Event *event_ptr)
{
- if (event_ptr)
+ if (event_ptr != nullptr)
{
const EventData *event_data = event_ptr->GetData();
if (event_data && event_data->GetFlavor() == EventDataBytes::GetFlavorString())
return static_cast <const EventDataBytes *> (event_data);
}
- return NULL;
+ return nullptr;
}
void
{
m_bytes.swap (new_bytes);
}
-
-
#include "lldb/Core/FormatEntity.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+// Project includes
#include "lldb/Core/Address.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
using namespace lldb;
using namespace lldb_private;
-
enum FileKind
{
FileError = 0,
Fullpath
};
-#define ENTRY(n,t,f) { n, NULL, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, 0,0,NULL, false}
-#define ENTRY_VALUE(n,t,f,v) { n, NULL, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, v,0,NULL, false}
-#define ENTRY_CHILDREN(n,t,f,c) { n, NULL, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, 0,llvm::array_lengthof(c),c, false}
-#define ENTRY_CHILDREN_KEEP_SEP(n,t,f,c) { n, NULL, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, 0,llvm::array_lengthof(c),c, true}
-#define ENTRY_STRING(n,s) { n, s, FormatEntity::Entry::Type::InsertString, FormatEntity::Entry::FormatType::None, 0,0, NULL, false}
+#define ENTRY(n,t,f) { n, nullptr, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, 0, 0, nullptr, false}
+#define ENTRY_VALUE(n,t,f,v) { n, nullptr, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, v, 0, nullptr, false}
+#define ENTRY_CHILDREN(n,t,f,c) { n, nullptr, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, false}
+#define ENTRY_CHILDREN_KEEP_SEP(n,t,f,c) { n, nullptr, FormatEntity::Entry::Type::t, FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, true}
+#define ENTRY_STRING(n,s) { n, s, FormatEntity::Entry::Type::InsertString, FormatEntity::Entry::FormatType::None, 0, 0, nullptr, false}
static FormatEntity::Entry::Definition g_string_entry[] =
{
ENTRY("*", ParentString, None)
static FormatEntity::Entry::Definition g_frame_child_entries[] =
{
-
ENTRY ("index", FrameIndex , UInt32),
ENTRY ("pc" , FrameRegisterPC , UInt64),
ENTRY ("fp" , FrameRegisterFP , UInt64),
ENTRY_STRING ( "negative" , ANSI_ESC_START _TO_STR(ANSI_CTRL_IMAGE_NEGATIVE) ANSI_ESC_END),
ENTRY_STRING ( "conceal" , ANSI_ESC_START _TO_STR(ANSI_CTRL_CONCEAL) ANSI_ESC_END),
ENTRY_STRING ( "crossed-out" , ANSI_ESC_START _TO_STR(ANSI_CTRL_CROSSED_OUT) ANSI_ESC_END),
-
};
static FormatEntity::Entry::Definition g_script_child_entries[] =
static FormatEntity::Entry::Definition g_root = ENTRY_CHILDREN ("<root>", Root, None, g_top_level_entries);
-
FormatEntity::Entry::Entry (llvm::StringRef s) :
string (s.data(), s.size()),
printf_format (),
children (),
- definition (NULL),
+ definition(nullptr),
type (Type::String),
fmt (lldb::eFormatDefault),
number (0),
string (1, ch),
printf_format (),
children (),
- definition (NULL),
+ definition(nullptr),
type (Type::String),
fmt (lldb::eFormatDefault),
number (0),
return AppendText (llvm::StringRef(cstr));
}
-
Error
FormatEntity::Parse (const llvm::StringRef &format_str, Entry &entry)
{
}
}
-
template <typename T>
static bool RunScriptFormatKeyword(Stream &s,
const SymbolContext *sc,
addr_width = 16;
if (print_file_addr_or_load_addr)
{
- ExecutionContextScope *exe_scope = NULL;
+ ExecutionContextScope *exe_scope = nullptr;
if (exe_ctx)
exe_scope = exe_ctx->GetBestExecutionContextScope();
addr.Dump (&s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, 0);
if (separator_index == llvm::StringRef::npos)
{
const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
- index_lower = ::strtoul (index_lower_cstr, NULL, 0);
+ index_lower = ::strtoul(index_lower_cstr, nullptr, 0);
index_higher = index_lower;
if (log)
log->Printf("[ScanBracketedRange] [%" PRId64 "] detected, high index is same", index_lower);
{
const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
const char *index_higher_cstr = subpath.data() + separator_index + 1;
- index_lower = ::strtoul (index_lower_cstr, NULL, 0);
- index_higher = ::strtoul (index_higher_cstr, NULL, 0);
+ index_lower = ::strtoul(index_lower_cstr, nullptr, 0);
+ index_higher = ::strtoul(index_higher_cstr, nullptr, 0);
if (log)
log->Printf("[ScanBracketedRange] [%" PRId64 "-%" PRId64 "] detected", index_lower, index_higher);
}
return false;
}
-
static ValueObjectSP
ExpandIndexedExpression (ValueObject* valobj,
size_t index,
const FormatEntity::Entry &entry,
ValueObject *valobj)
{
- if (valobj == NULL)
+ if (valobj == nullptr)
return false;
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
return false;
}
- if (valobj == NULL)
+ if (valobj == nullptr)
return false;
ValueObject::ExpressionPathAftermath what_next = (do_deref_pointer ?
ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing);
ValueObject::GetValueForExpressionPathOptions options;
options.DontCheckDotVsArrowSyntax().DoAllowBitfieldSyntax().DoAllowFragileIVar().SetSyntheticChildrenTraversal(ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal::Both);
- ValueObject* target = NULL;
- const char* var_name_final_if_array_range = NULL;
+ ValueObject* target = nullptr;
+ const char* var_name_final_if_array_range = nullptr;
size_t close_bracket_index = llvm::StringRef::npos;
int64_t index_lower = -1;
int64_t index_higher = -1;
}
}
-
is_array_range = (final_value_type == ValueObject::eExpressionPathEndResultTypeBoundedRange ||
final_value_type == ValueObject::eExpressionPathEndResultTypeUnboundedRange);
}
// TODO use flags for these
- const uint32_t type_info_flags = target->GetCompilerType().GetTypeInfo(NULL);
+ const uint32_t type_info_flags = target->GetCompilerType().GetTypeInfo(nullptr);
bool is_array = (type_info_flags & eTypeIsArray) != 0;
bool is_pointer = (type_info_flags & eTypeIsPointer) != 0;
bool is_aggregate = target->GetCompilerType().IsAggregateType();
}
else
{
- success &= FormatEntity::FormatStringRef(special_directions, s, sc, exe_ctx, NULL, item, false, false);
+ success &= FormatEntity::FormatStringRef(special_directions, s, sc, exe_ctx, nullptr, item, false, false);
}
if (--max_num_children == 0)
s.PutChar(']');
return success;
}
-
}
static bool
StackFrame *frame,
const char *reg_name,
Format format)
-
{
if (frame)
{
StructuredData::ObjectSP value = thread_info_dictionary->GetObjectForDotSeparatedPath (path);
- if (value.get())
+ if (value)
{
if (value->GetType() == StructuredData::Type::eTypeInteger)
{
return false;
}
-
static inline bool
IsToken(const char *var_name_begin, const char *var)
{
}
}
return false;
-
}
+
bool
FormatEntity::FormatCString (const char *format,
Stream &s,
case Entry::Type::Root:
for (const auto &child : entry.children)
{
- if (Format (child,
+ if (!Format(child,
s,
sc,
exe_ctx,
addr,
valobj,
function_changed,
- initial_function) == false)
+ initial_function))
{
return false; // If any item of root fails, then the formatting fails
}
case Entry::Type::VariableSynthetic:
case Entry::Type::ScriptVariable:
case Entry::Type::ScriptVariableSynthetic:
- if (DumpValue(s, sc, exe_ctx, entry, valobj))
- return true;
- return false;
+ return DumpValue(s, sc, exe_ctx, entry, valobj);
case Entry::Type::AddressFile:
case Entry::Type::AddressLoad:
case Entry::Type::AddressLoadOrFile:
- if (addr && addr->IsValid() && DumpAddress(s, sc, exe_ctx, *addr, entry.type == Entry::Type::AddressLoadOrFile))
- return true;
- return false;
+ return (addr != nullptr && addr->IsValid() &&
+ DumpAddress(s, sc, exe_ctx, *addr, entry.type == Entry::Type::AddressLoadOrFile));
case Entry::Type::ProcessID:
if (exe_ctx)
}
return false;
-
case Entry::Type::ThreadID:
if (exe_ctx)
{
}
return false;
-
case Entry::Type::FrameRegisterByName:
if (exe_ctx)
{
}
else
{
- const char *name = NULL;
+ const char *name = nullptr;
if (sc->function)
- name = sc->function->GetName().AsCString (NULL);
+ name = sc->function->GetName().AsCString(nullptr);
else if (sc->symbol)
- name = sc->symbol->GetName().AsCString (NULL);
+ name = sc->symbol->GetName().AsCString(nullptr);
if (name)
{
s.PutCString(name);
// Print the function name with arguments in it
if (sc->function)
{
- ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL;
- const char *cstr = sc->function->GetName().AsCString (NULL);
+ ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
+ const char *cstr = sc->function->GetName().AsCString(nullptr);
if (cstr)
{
- const InlineFunctionInfo *inline_info = NULL;
+ const InlineFunctionInfo *inline_info = nullptr;
VariableListSP variable_list_sp;
bool get_function_vars = true;
if (sc->block)
var_value_sp = var_value_sp->GetQualifiedRepresentationIfAvailable(exe_scope->CalculateTarget()->TargetProperties::GetPreferDynamicValue(),
exe_scope->CalculateTarget()->TargetProperties::GetEnableSyntheticValue());
if (var_value_sp->GetCompilerType().IsAggregateType() &&
- DataVisualization::ShouldPrintAsOneLiner(*var_value_sp.get()))
+ DataVisualization::ShouldPrintAsOneLiner(*var_value_sp))
{
static StringSummaryFormat format(TypeSummaryImpl::Flags()
.SetHideItemNames(false)
}
else if (sc->symbol)
{
- const char *cstr = sc->symbol->GetName().AsCString (NULL);
+ const char *cstr = sc->symbol->GetName().AsCString(nullptr);
if (cstr)
{
s.PutCString(cstr);
return false;
case Entry::Type::FunctionLineOffset:
- if (DumpAddressOffsetFromFunction (s, sc, exe_ctx, sc->line_entry.range.GetBaseAddress(), false, false, false))
- return true;
- return false;
+ return (DumpAddressOffsetFromFunction (s, sc, exe_ctx, sc->line_entry.range.GetBaseAddress(), false, false, false));
case Entry::Type::FunctionPCOffset:
if (exe_ctx)
return false;
case Entry::Type::FunctionChanged:
- return function_changed == true;
+ return function_changed;
case Entry::Type::FunctionIsOptimized:
{
}
case Entry::Type::FunctionInitial:
- return initial_function == true;
+ return initial_function;
case Entry::Type::LineEntryFile:
if (sc && sc->line_entry.IsValid())
if (addr && exe_ctx && exe_ctx->GetFramePtr())
{
RegisterContextSP reg_ctx = exe_ctx->GetFramePtr()->GetRegisterContextSP();
- if (reg_ctx.get())
+ if (reg_ctx)
{
addr_t pc_loadaddr = reg_ctx->GetPC();
if (pc_loadaddr != LLDB_INVALID_ADDRESS)
if (parent->children)
{
const size_t n = parent->num_children;
- for (size_t i=0; i<n; ++i)
+ for (size_t i = 0; i < n; ++i)
{
if (i > 0)
s.PutCString(", ");
return false;
}
-
static Error
ParseEntry (const llvm::StringRef &format_str,
const FormatEntity::Entry::Definition *parent,
llvm::StringRef key = format_str.substr(0, sep_pos);
const size_t n = parent->num_children;
- for (size_t i=0; i<n; ++i)
+ for (size_t i = 0; i < n; ++i)
{
const FormatEntity::Entry::Definition *entry_def = parent->children + i;
if (key.equals(entry_def->name) || entry_def->name[0] == '*')
return error;
}
-
static const FormatEntity::Entry::Definition *
FindEntry (const llvm::StringRef &format_str, const FormatEntity::Entry::Definition *parent, llvm::StringRef &remainder)
{
std::pair<llvm::StringRef, llvm::StringRef> p = format_str.split('.');
const size_t n = parent->num_children;
- for (size_t i=0; i<n; ++i)
+ for (size_t i = 0; i < n; ++i)
{
const FormatEntity::Entry::Definition *entry_def = parent->children + i;
if (p.first.equals(entry_def->name) || entry_def->name[0] == '*')
char oct_str[5] = { 0, 0, 0, 0, 0 };
int i;
- for (i=0; (format[i] >= '0' && format[i] <= '7') && i<4; ++i)
+ for (i = 0; (format[i] >= '0' && format[i] <= '7') && i < 4; ++i)
oct_str[i] = format[i];
// We don't want to consume the last octal character since
// the main for loop will do this for us, so we advance p by
// one less than i (even if i is zero)
format = format.drop_front(i);
- unsigned long octal_value = ::strtoul (oct_str, NULL, 8);
+ unsigned long octal_value = ::strtoul(oct_str, nullptr, 8);
if (octal_value <= UINT8_MAX)
{
parent_entry.AppendChar((char)octal_value);
format = format.drop_front();
}
- unsigned long hex_value = strtoul (hex_str, NULL, 16);
+ unsigned long hex_value = strtoul(hex_str, nullptr, 16);
if (hex_value <= UINT8_MAX)
{
parent_entry.AppendChar((char)hex_value);
return error;
}
-
Error
FormatEntity::ExtractVariableInfo (llvm::StringRef &format_str, llvm::StringRef &variable_name, llvm::StringRef &variable_format)
{
const size_t n = def->num_children;
if (n > 0)
{
- for (size_t i=0; i<n; ++i)
+ for (size_t i = 0; i < n; ++i)
{
std::string match = prefix.str();
if (match_prefix.empty())
}
}
}
+
size_t
FormatEntity::AutoComplete (const char *s,
int match_start_point,
// C Includes
// C++ Includes
+#include <algorithm>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Event.h"
#include "lldb/Host/TimeValue.h"
-#include <algorithm>
using namespace lldb;
using namespace lldb_private;
bool operator() (const BroadcasterManagerWP input_wp) const
{
BroadcasterManagerSP input_sp = input_wp.lock();
- if (input_sp && input_sp == m_manager_sp)
- return true;
- else
- return false;
+ return (input_sp && input_sp == m_manager_sp);
}
+
BroadcasterManagerSP m_manager_sp;
};
-}
+} // anonymous namespace
Listener::Listener(const char *name) :
m_name (name),
m_cond_wait()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
- if (log)
+ if (log != nullptr)
log->Printf ("%p Listener::Listener('%s')",
static_cast<void*>(this), m_name.c_str());
}
manager_sp->RemoveListener(this);
}
- if (log)
+ if (log != nullptr)
log->Printf ("%p Listener::~Listener('%s')",
static_cast<void*>(this), m_name.c_str());
}
uint32_t acquired_mask = broadcaster->AddListener (this->shared_from_this(), event_mask);
- if (event_mask != acquired_mask)
- {
-
- }
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
- if (log)
+ if (log != nullptr)
log->Printf ("%p Listener::StartListeningForEvents (broadcaster = %p, mask = 0x%8.8x) acquired_mask = 0x%8.8x for %s",
static_cast<void*>(this),
static_cast<void*>(broadcaster), event_mask,
acquired_mask, m_name.c_str());
return acquired_mask;
-
}
return 0;
}
uint32_t acquired_mask = broadcaster->AddListener (this->shared_from_this(), event_mask);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
- if (log)
+ if (log != nullptr)
{
void **pointer = reinterpret_cast<void**>(&callback);
log->Printf ("%p Listener::StartListeningForEvents (broadcaster = %p, mask = 0x%8.8x, callback = %p, user_data = %p) acquired_mask = 0x%8.8x for %s",
if (m_events.empty())
m_cond_wait.SetValue (false, eBroadcastNever);
-
}
}
Listener::AddEvent (EventSP &event_sp)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
- if (log)
+ if (log != nullptr)
log->Printf ("%p Listener('%s')::AddEvent (event_sp = {%p})",
static_cast<void*>(this), m_name.c_str(),
static_cast<void*>(event_sp.get()));
bool operator() (const EventSP &event_sp) const
{
- if (event_sp->BroadcasterIs(m_broadcaster))
- return true;
- else
- return false;
+ return event_sp->BroadcasterIs(m_broadcaster);
}
private:
Broadcaster *m_broadcaster;
-
};
class EventMatcher
{
bool found_source = false;
const ConstString &event_broadcaster_name = event_sp->GetBroadcaster()->GetBroadcasterName();
- for (uint32_t i=0; i<m_num_broadcaster_names; ++i)
+ for (uint32_t i = 0; i < m_num_broadcaster_names; ++i)
{
if (m_broadcaster_names[i] == event_broadcaster_name)
{
const uint32_t m_event_type_mask;
};
-
bool
Listener::FindNextEventInternal
(
- Broadcaster *broadcaster, // NULL for any broadcaster
- const ConstString *broadcaster_names, // NULL for any event
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *broadcaster_names, // nullptr for any event
uint32_t num_broadcaster_names,
uint32_t event_type_mask,
EventSP &event_sp,
if (m_events.empty())
return false;
-
Listener::event_collection::iterator pos = m_events.end();
- if (broadcaster == NULL && broadcaster_names == NULL && event_type_mask == 0)
+ if (broadcaster == nullptr && broadcaster_names == nullptr && event_type_mask == 0)
{
pos = m_events.begin();
}
{
event_sp = *pos;
- if (log)
+ if (log != nullptr)
log->Printf ("%p '%s' Listener::FindNextEventInternal(broadcaster=%p, broadcaster_names=%p[%u], event_type_mask=0x%8.8x, remove=%i) event %p",
static_cast<void*>(this), GetName(),
static_cast<void*>(broadcaster),
Listener::PeekAtNextEvent ()
{
EventSP event_sp;
- if (FindNextEventInternal (NULL, NULL, 0, 0, event_sp, false))
+ if (FindNextEventInternal(nullptr, nullptr, 0, 0, event_sp, false))
return event_sp.get();
- return NULL;
+ return nullptr;
}
Event *
Listener::PeekAtNextEventForBroadcaster (Broadcaster *broadcaster)
{
EventSP event_sp;
- if (FindNextEventInternal (broadcaster, NULL, 0, 0, event_sp, false))
+ if (FindNextEventInternal(broadcaster, nullptr, 0, 0, event_sp, false))
return event_sp.get();
- return NULL;
+ return nullptr;
}
Event *
Listener::PeekAtNextEventForBroadcasterWithType (Broadcaster *broadcaster, uint32_t event_type_mask)
{
EventSP event_sp;
- if (FindNextEventInternal (broadcaster, NULL, 0, event_type_mask, event_sp, false))
+ if (FindNextEventInternal(broadcaster, nullptr, 0, event_type_mask, event_sp, false))
return event_sp.get();
- return NULL;
+ return nullptr;
}
-
bool
-Listener::GetNextEventInternal
-(
- Broadcaster *broadcaster, // NULL for any broadcaster
- const ConstString *broadcaster_names, // NULL for any event
- uint32_t num_broadcaster_names,
- uint32_t event_type_mask,
- EventSP &event_sp
-)
+Listener::GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *broadcaster_names, // nullptr for any event
+ uint32_t num_broadcaster_names,
+ uint32_t event_type_mask,
+ EventSP &event_sp)
{
return FindNextEventInternal (broadcaster, broadcaster_names, num_broadcaster_names, event_type_mask, event_sp, true);
}
bool
Listener::GetNextEvent (EventSP &event_sp)
{
- return GetNextEventInternal (NULL, NULL, 0, 0, event_sp);
+ return GetNextEventInternal(nullptr, nullptr, 0, 0, event_sp);
}
-
bool
Listener::GetNextEventForBroadcaster (Broadcaster *broadcaster, EventSP &event_sp)
{
- return GetNextEventInternal (broadcaster, NULL, 0, 0, event_sp);
+ return GetNextEventInternal(broadcaster, nullptr, 0, 0, event_sp);
}
bool
Listener::GetNextEventForBroadcasterWithType (Broadcaster *broadcaster, uint32_t event_type_mask, EventSP &event_sp)
{
- return GetNextEventInternal (broadcaster, NULL, 0, event_type_mask, event_sp);
+ return GetNextEventInternal(broadcaster, nullptr, 0, event_type_mask, event_sp);
}
-
bool
-Listener::WaitForEventsInternal
-(
- const TimeValue *timeout,
- Broadcaster *broadcaster, // NULL for any broadcaster
- const ConstString *broadcaster_names, // NULL for any event
- uint32_t num_broadcaster_names,
- uint32_t event_type_mask,
- EventSP &event_sp
-)
+Listener::WaitForEventsInternal(const TimeValue *timeout,
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *broadcaster_names, // nullptr for any event
+ uint32_t num_broadcaster_names,
+ uint32_t event_type_mask,
+ EventSP &event_sp)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
bool timed_out = false;
- if (log)
+ if (log != nullptr)
log->Printf ("%p Listener::WaitForEventsInternal (timeout = { %p }) for %s",
static_cast<void*>(this), static_cast<const void*>(timeout),
m_name.c_str());
- while (1)
+ while (true)
{
// Note, we don't want to lock the m_events_mutex in the call to GetNextEventInternal, since the DoOnRemoval
// code might require that new events be serviced. For instance, the Breakpoint Command's
else if (timed_out)
{
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS);
- if (log)
+ if (log != nullptr)
log->Printf ("%p Listener::WaitForEventsInternal() timed out for %s",
static_cast<void*>(this), m_name.c_str());
break;
else
{
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS);
- if (log)
+ if (log != nullptr)
log->Printf ("%p Listener::WaitForEventsInternal() unknown error for %s",
static_cast<void*>(this), m_name.c_str());
break;
}
bool
-Listener::WaitForEventForBroadcasterWithType
-(
- const TimeValue *timeout,
- Broadcaster *broadcaster,
- uint32_t event_type_mask,
- EventSP &event_sp
-)
+Listener::WaitForEventForBroadcasterWithType(const TimeValue *timeout,
+ Broadcaster *broadcaster,
+ uint32_t event_type_mask,
+ EventSP &event_sp)
{
- return WaitForEventsInternal (timeout, broadcaster, NULL, 0, event_type_mask, event_sp);
+ return WaitForEventsInternal(timeout, broadcaster, nullptr, 0, event_type_mask, event_sp);
}
bool
-Listener::WaitForEventForBroadcaster
-(
- const TimeValue *timeout,
- Broadcaster *broadcaster,
- EventSP &event_sp
-)
+Listener::WaitForEventForBroadcaster(const TimeValue *timeout,
+ Broadcaster *broadcaster,
+ EventSP &event_sp)
{
- return WaitForEventsInternal (timeout, broadcaster, NULL, 0, 0, event_sp);
+ return WaitForEventsInternal(timeout, broadcaster, nullptr, 0, 0, event_sp);
}
bool
Listener::WaitForEvent (const TimeValue *timeout, EventSP &event_sp)
{
- return WaitForEventsInternal (timeout, NULL, NULL, 0, 0, event_sp);
+ return WaitForEventsInternal(timeout, nullptr, nullptr, 0, 0, event_sp);
}
size_t
BroadcasterInfo info = pos->second;
if (event_sp->GetType () & info.event_mask)
{
- if (info.callback != NULL)
+ if (info.callback != nullptr)
{
info.callback (event_sp, info.callback_user_data);
++num_handled;
Mutex::Locker locker(m_broadcasters_mutex);
return manager_sp->UnregisterListenerForEvents (this->shared_from_this(), event_spec);
-
}
ListenerSP
//===----------------------------------------------------------------------===//
// C Includes
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
// C++ Includes
+#include <cstdio>
+#include <cstdarg>
+#include <cstdlib>
#include <map>
#include <string>
// Other libraries and framework includes
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Signals.h"
+
// Project includes
#include "lldb/Core/Log.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Utility/NameMatches.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/Signals.h"
using namespace lldb;
using namespace lldb_private;
{
}
-Log::~Log ()
-{
-}
+Log::~Log() = default;
Flags &
Log::GetOptions()
va_end(args);
}
-
//----------------------------------------------------------------------
// Print debug strings if and only if the global debug option is set to
// a non-zero value.
va_end(args);
}
-
//----------------------------------------------------------------------
// Log only if all of the bits are set
//----------------------------------------------------------------------
va_end(args);
}
-
void
Log::VAError(const char *format, va_list args)
{
free(arg_msg);
}
-
//----------------------------------------------------------------------
// Printing of errors that ARE fatal. Exit with ERR exit code
// immediately.
::exit(err);
}
-
//----------------------------------------------------------------------
// Printing of warnings that are not fatal only if verbose mode is
// enabled.
Printf("warning: %s", arg_msg);
free(arg_msg);
}
+
//----------------------------------------------------------------------
// Printing of warnings that are not fatal.
//----------------------------------------------------------------------
typedef std::map <ConstString, LogChannelSP> LogChannelMap;
typedef LogChannelMap::iterator LogChannelMapIter;
-
// Surround our callback map with a singleton function so we don't have any
// global initializers.
static CallbackMap &
}
void
-Log::EnableAllLogChannels
-(
- StreamSP &log_stream_sp,
- uint32_t log_options,
- const char **categories,
- Stream *feedback_strm
-)
+Log::EnableAllLogChannels(StreamSP &log_stream_sp,
+ uint32_t log_options,
+ const char **categories,
+ Stream *feedback_strm)
{
CallbackMap &callback_map = GetCallbackMap ();
CallbackMapIter pos, end = callback_map.end();
{
channel_pos->second->Enable (log_stream_sp, log_options, feedback_strm, categories);
}
-
}
void
}
else
matches.AppendString(pos_channel_name);
-
}
}
void
Log::Terminate ()
{
- DisableAllLogChannels (NULL);
+ DisableAllLogChannels(nullptr);
}
void
uint32_t idx = 0;
const char *name;
- for (idx = 0; (name = PluginManager::GetLogChannelCreateNameAtIndex (idx)) != NULL; ++idx)
+ for (idx = 0; (name = PluginManager::GetLogChannelCreateNameAtIndex (idx)) != nullptr; ++idx)
{
LogChannelSP log_channel_sp(LogChannel::FindPlugin (name));
if (log_channel_sp)
return false;
}
-
LogChannelSP
LogChannel::FindPlugin (const char *plugin_name)
{
{
}
-LogChannel::~LogChannel ()
-{
-}
-
-
+LogChannel::~LogChannel() = default;