summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Flags.cpp122
-rw-r--r--lldb/source/Core/Log.cpp22
-rw-r--r--lldb/source/Core/Section.cpp2
-rw-r--r--lldb/source/Core/Stream.cpp37
-rw-r--r--lldb/source/Core/ValueObject.cpp117
5 files changed, 124 insertions, 176 deletions
diff --git a/lldb/source/Core/Flags.cpp b/lldb/source/Core/Flags.cpp
deleted file mode 100644
index 13cbd85915b..00000000000
--- a/lldb/source/Core/Flags.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-//===-- Flags.cpp -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/Flags.h"
-
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// Default Constructor
-//----------------------------------------------------------------------
-Flags::Flags (ValueType flags) :
- m_flags(flags)
-{
-}
-
-//----------------------------------------------------------------------
-// Copy Constructor
-//----------------------------------------------------------------------
-Flags::Flags (const Flags& rhs) :
- m_flags(rhs.m_flags)
-{
-}
-
-//----------------------------------------------------------------------
-// Virtual destructor in case anyone inherits from this class.
-//----------------------------------------------------------------------
-Flags::~Flags ()
-{
-}
-
-//----------------------------------------------------------------------
-// Get accessor for all of the current flag bits.
-//----------------------------------------------------------------------
-Flags::ValueType
-Flags::GetAllFlagBits () const
-{
- return m_flags;
-}
-
-size_t
-Flags::GetBitSize() const
-{
- return sizeof (ValueType) * 8;
-}
-
-//----------------------------------------------------------------------
-// Set accessor for all of the current flag bits.
-//----------------------------------------------------------------------
-void
-Flags::SetAllFlagBits (ValueType flags)
-{
- m_flags = flags;
-}
-
-//----------------------------------------------------------------------
-// Clear one or more bits in our flag bits
-//----------------------------------------------------------------------
-Flags::ValueType
-Flags::Clear (ValueType bits)
-{
- m_flags &= ~bits;
- return m_flags;
-}
-
-//----------------------------------------------------------------------
-// Set one or more bits in our flag bits
-//----------------------------------------------------------------------
-Flags::ValueType
-Flags::Set (ValueType bits)
-{
- m_flags |= bits;
- return m_flags;
-}
-
-//----------------------------------------------------------------------
-// Returns true if any flag bits in "bits" are set
-//----------------------------------------------------------------------
-bool
-Flags::IsSet (ValueType bits) const
-{
- return (m_flags & bits) != 0;
-}
-
-//----------------------------------------------------------------------
-// Returns true if all flag bits in "bits" are clear
-//----------------------------------------------------------------------
-bool
-Flags::IsClear (ValueType bits) const
-{
- return (m_flags & bits) == 0;
-}
-
-
-size_t
-Flags::SetCount () const
-{
- size_t count = 0;
- for (ValueType mask = m_flags; mask; mask >>= 1)
- {
- if (mask & 1)
- ++count;
- }
- return count;
-}
-
-size_t
-Flags::ClearCount () const
-{
- size_t count = 0;
- for (ValueType shift = 0; shift < sizeof(ValueType)*8; ++shift)
- {
- if ((m_flags & (1u << shift)) == 0)
- ++count;
- }
- return count;
-}
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index 7bbbf4f11c3..a612b6500cf 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -91,29 +91,27 @@ Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args)
Mutex::Locker locker;
- uint32_t log_options = m_options.GetAllFlagBits();
-
// Lock the threaded logging mutex if we are doing thread safe logging
- if (log_options & LLDB_LOG_OPTION_THREADSAFE)
+ if (m_options.Test (LLDB_LOG_OPTION_THREADSAFE))
locker.Reset(g_LogThreadedMutex.GetMutex());
// Add a sequence ID if requested
- if (log_options & LLDB_LOG_OPTION_PREPEND_SEQUENCE)
+ if (m_options.Test (LLDB_LOG_OPTION_PREPEND_SEQUENCE))
header.Printf ("%u ", ++g_sequence_id);
// Timestamp if requested
- if (log_options & LLDB_LOG_OPTION_PREPEND_TIMESTAMP)
+ if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
{
struct timeval tv = TimeValue::Now().GetAsTimeVal();
header.Printf ("%9llu.%6.6llu ", tv.tv_sec, tv.tv_usec);
}
// Add the process and thread if requested
- if (log_options & LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD)
+ if (m_options.Test (LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD))
header.Printf ("[%4.4x/%4.4x]: ", getpid(), Host::GetCurrentThreadID());
// Add the process and thread if requested
- if (log_options & LLDB_LOG_OPTION_PREPEND_THREAD_NAME)
+ if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME))
{
const char *thread_name_str = Host::GetThreadName (getpid(), Host::GetCurrentThreadID());
if (thread_name_str)
@@ -171,7 +169,7 @@ Log::PrintfWithFlags (uint32_t flags, const char *format, ...)
void
Log::Debug (const char *format, ...)
{
- if (GetOptions().IsSet(LLDB_LOG_OPTION_DEBUG))
+ if (GetOptions().Test(LLDB_LOG_OPTION_DEBUG))
{
va_list args;
va_start (args, format);
@@ -188,7 +186,7 @@ Log::Debug (const char *format, ...)
void
Log::DebugVerbose (const char *format, ...)
{
- if (GetOptions().IsSet(LLDB_LOG_OPTION_DEBUG) && GetOptions().IsSet(LLDB_LOG_OPTION_VERBOSE))
+ if (GetOptions().AllSet (LLDB_LOG_OPTION_DEBUG | LLDB_LOG_OPTION_VERBOSE))
{
va_list args;
va_start (args, format);
@@ -204,7 +202,7 @@ Log::DebugVerbose (const char *format, ...)
void
Log::LogIf (uint32_t bits, const char *format, ...)
{
- if ((bits & m_options.GetAllFlagBits()) == bits)
+ if (m_options.AllSet (bits))
{
va_list args;
va_start (args, format);
@@ -262,7 +260,7 @@ Log::FatalError (int err, const char *format, ...)
void
Log::Verbose (const char *format, ...)
{
- if (m_options.IsSet(LLDB_LOG_OPTION_VERBOSE))
+ if (m_options.Test(LLDB_LOG_OPTION_VERBOSE))
{
va_list args;
va_start (args, format);
@@ -278,7 +276,7 @@ Log::Verbose (const char *format, ...)
void
Log::WarningVerbose (const char *format, ...)
{
- if (m_options.IsSet(LLDB_LOG_OPTION_VERBOSE))
+ if (m_options.Test(LLDB_LOG_OPTION_VERBOSE))
{
char *arg_msg = NULL;
va_list args;
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 3dae577c5c8..28935b2249c 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -248,7 +248,7 @@ Section::Dump (Stream *s, Target *target) const
range.Dump (s, 0);
}
- s->Printf("%c 0x%8.8llx 0x%8.8llx 0x%8.8x ", resolved ? ' ' : '*', m_file_offset, m_file_size, GetAllFlagBits());
+ s->Printf("%c 0x%8.8llx 0x%8.8llx 0x%8.8x ", resolved ? ' ' : '*', m_file_offset, m_file_size, Get());
DumpName (s);
diff --git a/lldb/source/Core/Stream.cpp b/lldb/source/Core/Stream.cpp
index 9beec35c8f7..f971a4178df 100644
--- a/lldb/source/Core/Stream.cpp
+++ b/lldb/source/Core/Stream.cpp
@@ -64,7 +64,7 @@ int
Stream::PutSLEB128 (int64_t sval)
{
int bytes_written = 0;
- if (m_flags.IsSet(eBinary))
+ if (m_flags.Test(eBinary))
{
bool more = true;
while (more)
@@ -98,7 +98,7 @@ int
Stream::PutULEB128 (uint64_t uval)
{
int bytes_written = 0;
- if (m_flags.IsSet(eBinary))
+ if (m_flags.Test(eBinary))
{
do
{
@@ -129,7 +129,7 @@ Stream::PutCString (const char *cstr)
{
int cstr_len = strlen(cstr);
// when in binary mode, emit the NULL terminator
- if (m_flags.IsSet(eBinary))
+ if (m_flags.Test(eBinary))
++cstr_len;
return Write (cstr, cstr_len);
}
@@ -212,7 +212,7 @@ Stream::PrintfVarArg (const char *format, va_list args)
{
va_end (args);
// Include the NULL termination byte for binary output
- if (m_flags.IsSet(eBinary))
+ if (m_flags.Test(eBinary))
length += 1;
// The formatted string fit into our stack based buffer, so we can just
// append that to our packet
@@ -227,7 +227,7 @@ Stream::PrintfVarArg (const char *format, va_list args)
if (str_ptr)
{
// Include the NULL termination byte for binary output
- if (m_flags.IsSet(eBinary))
+ if (m_flags.Test(eBinary))
length += 1;
bytes_written = Write (str_ptr, length);
::free (str_ptr);
@@ -429,7 +429,7 @@ Stream::SetAddressByteSize(uint8_t addr_size)
bool
Stream::GetVerbose() const
{
- return m_flags.IsSet(eVerbose);
+ return m_flags.Test(eVerbose);
}
//------------------------------------------------------------------
@@ -438,7 +438,7 @@ Stream::GetVerbose() const
bool
Stream::GetDebug() const
{
- return m_flags.IsSet(eDebug);
+ return m_flags.Test(eDebug);
}
//------------------------------------------------------------------
@@ -512,7 +512,7 @@ Stream::PutNHex8 (size_t n, uint8_t uvalue)
{
int bytes_written = 0;
for (size_t i=0; i<n; ++i)
- bytes_written += _PutHex8 (uvalue, m_flags.IsSet(eAddPrefix));
+ bytes_written += _PutHex8 (uvalue, m_flags.Test(eAddPrefix));
return bytes_written;
}
@@ -520,7 +520,7 @@ int
Stream::_PutHex8 (uint8_t uvalue, bool add_prefix)
{
int bytes_written = 0;
- if (m_flags.IsSet(eBinary))
+ if (m_flags.Test(eBinary))
{
bytes_written = Write (&uvalue, 1);
}
@@ -541,7 +541,7 @@ Stream::_PutHex8 (uint8_t uvalue, bool add_prefix)
int
Stream::PutHex8 (uint8_t uvalue)
{
- return _PutHex8 (uvalue, m_flags.IsSet(eAddPrefix));
+ return _PutHex8 (uvalue, m_flags.Test(eAddPrefix));
}
int
@@ -550,7 +550,7 @@ Stream::PutHex16 (uint16_t uvalue, ByteOrder byte_order)
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- bool add_prefix = m_flags.IsSet(eAddPrefix);
+ bool add_prefix = m_flags.Test(eAddPrefix);
int bytes_written = 0;
if (byte_order == eByteOrderLittle)
{
@@ -571,7 +571,7 @@ Stream::PutHex32(uint32_t uvalue, ByteOrder byte_order)
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- bool add_prefix = m_flags.IsSet(eAddPrefix);
+ bool add_prefix = m_flags.Test(eAddPrefix);
int bytes_written = 0;
if (byte_order == eByteOrderLittle)
{
@@ -592,7 +592,7 @@ Stream::PutHex64(uint64_t uvalue, ByteOrder byte_order)
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- bool add_prefix = m_flags.IsSet(eAddPrefix);
+ bool add_prefix = m_flags.Test(eAddPrefix);
int bytes_written = 0;
if (byte_order == eByteOrderLittle)
{
@@ -669,8 +669,9 @@ Stream::PutRawBytes (const void *s, size_t src_len, ByteOrder src_byte_order, By
int bytes_written = 0;
const uint8_t *src = (const uint8_t *)s;
- bool binary_is_clear = m_flags.IsClear (eBinary);
- m_flags.Set (eBinary);
+ bool binary_was_set = m_flags.Test (eBinary);
+ if (!binary_was_set)
+ m_flags.Set (eBinary);
if (src_byte_order == dst_byte_order)
{
for (size_t i = 0; i < src_len; ++i)
@@ -681,7 +682,7 @@ Stream::PutRawBytes (const void *s, size_t src_len, ByteOrder src_byte_order, By
for (size_t i = src_len-1; i < src_len; --i)
bytes_written += _PutHex8 (src[i], false);
}
- if (binary_is_clear)
+ if (!binary_was_set)
m_flags.Clear (eBinary);
return bytes_written;
@@ -698,7 +699,7 @@ Stream::PutBytesAsRawHex8 (const void *s, size_t src_len, ByteOrder src_byte_ord
int bytes_written = 0;
const uint8_t *src = (const uint8_t *)s;
- bool binary_is_set = m_flags.IsSet(eBinary);
+ bool binary_is_set = m_flags.Test(eBinary);
m_flags.Clear(eBinary);
if (src_byte_order == dst_byte_order)
{
@@ -720,7 +721,7 @@ int
Stream::PutCStringAsRawHex8 (const char *s)
{
int bytes_written = 0;
- bool binary_is_set = m_flags.IsSet(eBinary);
+ bool binary_is_set = m_flags.Test(eBinary);
m_flags.Clear(eBinary);
do
{
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 4345eecea18..d10bf064c08 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -358,8 +358,8 @@ ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int3
bool child_is_base_class = false;
const bool transparent_pointers = synthetic_array_member == false;
clang::ASTContext *clang_ast = GetClangAST();
- void *clang_type = GetClangType();
- void *child_clang_type;
+ clang_type_t clang_type = GetClangType();
+ clang_type_t child_clang_type;
child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast,
GetName().AsCString(),
clang_type,
@@ -401,22 +401,38 @@ ValueObject::GetSummaryAsCString (ExecutionContextScope *exe_scope)
{
if (m_summary_str.empty())
{
- void *clang_type = GetClangType();
+ clang_type_t clang_type = GetClangType();
// See if this is a pointer to a C string?
- uint32_t fixed_length = 0;
if (clang_type)
{
StreamString sstr;
+ clang_type_t elem_or_pointee_clang_type;
+ const Flags type_flags (ClangASTContext::GetTypeInfo (clang_type,
+ GetClangAST(),
+ &elem_or_pointee_clang_type));
- if (ClangASTContext::IsCStringType (clang_type, fixed_length))
+ if (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) &&
+ ClangASTContext::IsCharType (elem_or_pointee_clang_type))
{
Process *process = exe_scope->CalculateProcess();
if (process != NULL)
{
+ lldb::addr_t cstr_address = LLDB_INVALID_ADDRESS;
lldb::AddressType cstr_address_type = eAddressTypeInvalid;
- lldb::addr_t cstr_address = GetPointerValue (cstr_address_type, true);
+ size_t cstr_len = 0;
+ if (type_flags.Test (ClangASTContext::eTypeIsArray))
+ {
+ // We have an array
+ cstr_len = ClangASTContext::GetArraySize (clang_type);
+ cstr_address = GetAddressOf (cstr_address_type, true);
+ }
+ else
+ {
+ // We have a pointer
+ cstr_address = GetPointerValue (cstr_address_type, true);
+ }
if (cstr_address != LLDB_INVALID_ADDRESS)
{
DataExtractor data;
@@ -425,14 +441,14 @@ ValueObject::GetSummaryAsCString (ExecutionContextScope *exe_scope)
std::vector<char> cstr_buffer;
size_t cstr_length;
Error error;
- if (fixed_length > 0)
+ if (cstr_len > 0)
{
- data_buffer.resize(fixed_length);
+ data_buffer.resize(cstr_len);
// Resize the formatted buffer in case every character
// uses the "\xXX" format and one extra byte for a NULL
cstr_buffer.resize(data_buffer.size() * 4 + 1);
data.SetData (&data_buffer.front(), data_buffer.size(), eByteOrderHost);
- bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), fixed_length, error);
+ bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), cstr_len, error);
if (bytes_read > 0)
{
sstr << '"';
@@ -590,7 +606,7 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope)
case Value::eContextTypeDCType:
case Value::eContextTypeDCVariable:
{
- void *clang_type = GetClangType ();
+ clang_type_t clang_type = GetClangType ();
if (clang_type)
{
StreamString sstr;
@@ -644,11 +660,37 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope)
}
addr_t
+ValueObject::GetAddressOf (lldb::AddressType &address_type, bool scalar_is_load_address)
+{
+ switch (m_value.GetValueType())
+ {
+ case Value::eValueTypeScalar:
+ if (scalar_is_load_address)
+ {
+ address_type = eAddressTypeLoad;
+ return m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+ }
+ break;
+
+ case Value::eValueTypeLoadAddress:
+ case Value::eValueTypeFileAddress:
+ case Value::eValueTypeHostAddress:
+ {
+ address_type = m_value.GetValueAddressType ();
+ return m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+ }
+ break;
+ }
+ address_type = eAddressTypeInvalid;
+ return LLDB_INVALID_ADDRESS;
+}
+
+addr_t
ValueObject::GetPointerValue (lldb::AddressType &address_type, bool scalar_is_load_address)
{
lldb::addr_t address = LLDB_INVALID_ADDRESS;
address_type = eAddressTypeInvalid;
- switch (GetValue().GetValueType())
+ switch (m_value.GetValueType())
{
case Value::eValueTypeScalar:
if (scalar_is_load_address)
@@ -773,7 +815,7 @@ ValueObject::Write ()
lldb::LanguageType
ValueObject::GetObjectRuntimeLanguage ()
{
- void *opaque_qual_type = GetClangType();
+ clang_type_t opaque_qual_type = GetClangType();
if (opaque_qual_type == NULL)
return lldb::eLanguageTypeC;
@@ -825,6 +867,8 @@ ValueObject::IsPointerType ()
return ClangASTContext::IsPointerType (GetClangType());
}
+
+
bool
ValueObject::IsPointerOrReferenceType ()
{
@@ -909,7 +953,6 @@ ValueObject::GetExpressionPath (Stream &s)
}
}
-
void
ValueObject::DumpValueObject
(
@@ -929,13 +972,12 @@ ValueObject::DumpValueObject
{
if (valobj)
{
- //const char *loc_cstr = valobj->GetLocationAsCString();
clang_type_t clang_type = valobj->GetClangType();
- const Flags type_info_flags (ClangASTContext::GetTypeInfoMask (clang_type));
+ const Flags type_flags (ClangASTContext::GetTypeInfo (clang_type, NULL, NULL));
const char *err_cstr = NULL;
- const bool has_children = type_info_flags.IsSet (ClangASTContext::eTypeHasChildren);
- const bool has_value = type_info_flags.IsSet (ClangASTContext::eTypeHasValue);
+ const bool has_children = type_flags.Test (ClangASTContext::eTypeHasChildren);
+ const bool has_value = type_flags.Test (ClangASTContext::eTypeHasValue);
const bool print_valobj = flat_output == false || has_value;
@@ -983,6 +1025,7 @@ ValueObject::DumpValueObject
}
else
{
+ const bool is_ref = type_flags.Test (ClangASTContext::eTypeIsReference);
if (print_valobj)
{
const char *sum_cstr = valobj->GetSummaryAsCString(exe_scope);
@@ -1006,9 +1049,39 @@ ValueObject::DumpValueObject
if (curr_depth < max_depth)
{
- bool is_ptr_or_ref = type_info_flags.IsSet (ClangASTContext::eTypeIsPointer | ClangASTContext::eTypeIsReference);
+ // We will show children for all concrete types. We won't show
+ // pointer contents unless a pointer depth has been specified.
+ // We won't reference contents unless the reference is the
+ // root object (depth of zero).
+ bool print_children = true;
+
+ // Use a new temporary pointer depth in case we override the
+ // current pointer depth below...
+ uint32_t curr_ptr_depth = ptr_depth;
+
+ const bool is_ptr = type_flags.Test (ClangASTContext::eTypeIsPointer);
+ if (is_ptr || is_ref)
+ {
+ // We have a pointer or reference whose value is an address.
+ // Make sure that address is not NULL
+ lldb::AddressType ptr_address_type;
+ if (valobj->GetPointerValue (ptr_address_type, true) == 0)
+ print_children = false;
+
+ else if (is_ref && curr_depth == 0)
+ {
+ // If this is the root object (depth is zero) that we are showing
+ // and it is a reference, and no pointer depth has been supplied
+ // print out what it references. Don't do this at deeper depths
+ // otherwise we can end up with infinite recursion...
+ curr_ptr_depth = 1;
+ }
+
+ if (curr_ptr_depth == 0)
+ print_children = false;
+ }
- if (!is_ptr_or_ref || ptr_depth > 0)
+ if (print_children)
{
const uint32_t num_children = valobj->GetNumChildren();
if (num_children)
@@ -1034,7 +1107,7 @@ ValueObject::DumpValueObject
exe_scope,
child_sp.get(),
NULL,
- is_ptr_or_ref ? ptr_depth - 1 : ptr_depth,
+ (is_ptr || is_ref) ? curr_ptr_depth - 1 : curr_ptr_depth,
curr_depth + 1,
max_depth,
show_types,
@@ -1055,7 +1128,7 @@ ValueObject::DumpValueObject
{
// Aggregate, no children...
if (print_valobj)
- s.PutCString("{}\n");
+ s.PutCString(" {}\n");
}
else
{
@@ -1066,8 +1139,6 @@ ValueObject::DumpValueObject
}
else
{
- // We printed a pointer, but we are stopping and not printing
- // and children of this pointer...
s.EOL();
}
}
OpenPOWER on IntegriCloud