summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-07-07 01:59:51 +0000
committerGreg Clayton <gclayton@apple.com>2011-07-07 01:59:51 +0000
commit644247c1dc56106a06afbf8ac25fa4e07f46dd88 (patch)
treef318a596a16b71724e40d6ae52564b263b5baa10 /lldb/source/Core
parenta3c122db7e4883129bb35558becd6fe8c4722295 (diff)
downloadbcm5719-llvm-644247c1dc56106a06afbf8ac25fa4e07f46dd88.tar.gz
bcm5719-llvm-644247c1dc56106a06afbf8ac25fa4e07f46dd88.zip
Added "target variable" command that allows introspection of global
variables prior to running your binary. Zero filled sections now get section data correctly filled with zeroes when Target::ReadMemory reads from the object file section data. Added new option groups and option values for file lists. I still need to hook up all of the options to "target variable" to allow more complete introspection by file and shlib. Added the ability for ValueObjectVariable objects to be created with only the target as the execution context. This allows them to be read from the object files through Target::ReadMemory(...). Added a "virtual Module * GetModule()" function to the ValueObject class. By default it will look to the parent variable object and return its module. The module is needed when we have global variables that have file addresses (virtual addresses that are specific to module object files) and in turn allows global variables to be displayed prior to running. Removed all of the unused proxy object support that bit rotted in lldb_private::Value. Replaced a lot of places that used "FileSpec::Compare (lhs, rhs) == 0" code with the more efficient "FileSpec::Equal (lhs, rhs)". Improved logging in GDB remote plug-in. llvm-svn: 134579
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Broadcaster.cpp7
-rw-r--r--lldb/source/Core/Communication.cpp5
-rw-r--r--lldb/source/Core/FileSpecList.cpp10
-rw-r--r--lldb/source/Core/Module.cpp32
-rw-r--r--lldb/source/Core/ModuleList.cpp20
-rw-r--r--lldb/source/Core/SearchFilter.cpp2
-rw-r--r--lldb/source/Core/Section.cpp21
-rw-r--r--lldb/source/Core/SourceManager.cpp2
-rw-r--r--lldb/source/Core/Value.cpp425
-rw-r--r--lldb/source/Core/ValueObject.cpp6
-rw-r--r--lldb/source/Core/ValueObjectChild.cpp2
-rw-r--r--lldb/source/Core/ValueObjectDynamicValue.cpp4
-rw-r--r--lldb/source/Core/ValueObjectMemory.cpp12
-rw-r--r--lldb/source/Core/ValueObjectVariable.cpp22
14 files changed, 238 insertions, 332 deletions
diff --git a/lldb/source/Core/Broadcaster.cpp b/lldb/source/Core/Broadcaster.cpp
index 647367e17c2..fe1b7164d5d 100644
--- a/lldb/source/Core/Broadcaster.cpp
+++ b/lldb/source/Core/Broadcaster.cpp
@@ -239,13 +239,6 @@ Broadcaster::PrivateBroadcastEvent (EventSP &event_sp, bool unique)
if (hijacking_listener)
{
- // FIXME: REMOVE THIS EXTRA LOGGING
- LogSP log_process(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS));
- if (log_process)
- log_process->Printf ("Hijacking event delivery for Broadcaster(\"%s\") to Listener(\"%s\").",
- m_broadcaster_name.AsCString(""),
- hijacking_listener->GetName());
-
if (unique && hijacking_listener->PeekAtNextEventForBroadcasterWithType (this, event_type))
return;
hijacking_listener->AddEvent (event_sp);
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index 81c1bce30f2..a43ed2e929d 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -368,7 +368,10 @@ Communication::ReadThread (void *p)
case eConnectionStatusError: // Check GetError() for details
case eConnectionStatusTimedOut: // Request timed out
if (log)
- error.LogIfError(log.get(), "%p Communication::ReadFromConnection () => status = %i", p, status);
+ error.LogIfError(log.get(),
+ "%p Communication::ReadFromConnection () => status = %s",
+ p,
+ Communication::ConnectionStatusAsCString (status));
break;
}
}
diff --git a/lldb/source/Core/FileSpecList.cpp b/lldb/source/Core/FileSpecList.cpp
index fdf54b5ed76..3ad4c6b7923 100644
--- a/lldb/source/Core/FileSpecList.cpp
+++ b/lldb/source/Core/FileSpecList.cpp
@@ -88,9 +88,15 @@ FileSpecList::Clear()
// Dumps the file list to the supplied stream pointer "s".
//------------------------------------------------------------------
void
-FileSpecList::Dump(Stream *s) const
+FileSpecList::Dump(Stream *s, const char *separator_cstr) const
{
- for_each (m_files.begin(), m_files.end(), bind2nd(mem_fun_ref(&FileSpec::Dump),s));
+ collection::const_iterator pos, end = m_files.end();
+ for (pos = m_files.begin(); pos != end; ++pos)
+ {
+ pos->Dump(s);
+ if (separator_cstr)
+ s->PutCString(separator_cstr);
+ }
}
//------------------------------------------------------------------
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 026950e03db..8b07a76eead 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -193,16 +193,6 @@ Module::GetCompileUnitAtIndex (uint32_t index)
return cu_sp;
}
-//CompUnitSP
-//Module::FindCompUnit(lldb::user_id_t uid)
-//{
-// CompUnitSP cu_sp;
-// SymbolVendor *symbols = GetSymbolVendor ();
-// if (symbols)
-// cu_sp = symbols->FindCompUnit(uid);
-// return cu_sp;
-//}
-
bool
Module::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
{
@@ -323,6 +313,28 @@ Module::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_
}
uint32_t
+Module::FindCompileUnits (const FileSpec &path,
+ bool append,
+ SymbolContextList &sc_list)
+{
+ if (!append)
+ sc_list.Clear();
+
+ const uint32_t start_size = sc_list.GetSize();
+ const uint32_t num_compile_units = GetNumCompileUnits();
+ SymbolContext sc;
+ sc.module_sp = GetSP();
+ const bool compare_directory = path.GetDirectory();
+ for (uint32_t i=0; i<num_compile_units; ++i)
+ {
+ sc.comp_unit = GetCompileUnitAtIndex(i).get();
+ if (FileSpec::Equal (*sc.comp_unit, path, compare_directory))
+ sc_list.Append(sc);
+ }
+ return sc_list.GetSize() - start_size;
+}
+
+uint32_t
Module::FindFunctions (const ConstString &name,
uint32_t name_type_mask,
bool include_symbols,
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 18f3bbf5bc7..49ec7c96191 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -150,7 +150,7 @@ ModuleList::GetModuleAtIndex(uint32_t idx)
return module_sp;
}
-size_t
+uint32_t
ModuleList::FindFunctions (const ConstString &name,
uint32_t name_type_mask,
bool include_symbols,
@@ -171,6 +171,24 @@ ModuleList::FindFunctions (const ConstString &name,
}
uint32_t
+ModuleList::FindCompileUnits (const FileSpec &path,
+ bool append,
+ SymbolContextList &sc_list)
+{
+ if (!append)
+ sc_list.Clear();
+
+ Mutex::Locker locker(m_modules_mutex);
+ collection::const_iterator pos, end = m_modules.end();
+ for (pos = m_modules.begin(); pos != end; ++pos)
+ {
+ (*pos)->FindCompileUnits (path, true, sc_list);
+ }
+
+ return sc_list.GetSize();
+}
+
+uint32_t
ModuleList::FindGlobalVariables (const ConstString &name,
bool append,
uint32_t max_matches,
diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp
index cc0a8d5034f..b0934b45d5c 100644
--- a/lldb/source/Core/SearchFilter.cpp
+++ b/lldb/source/Core/SearchFilter.cpp
@@ -326,7 +326,7 @@ SearchFilterByModule::~SearchFilterByModule()
bool
SearchFilterByModule::ModulePasses (const ModuleSP &module_sp)
{
- if (module_sp && FileSpec::Compare (module_sp->GetFileSpec(), m_module_spec, false) == 0)
+ if (module_sp && FileSpec::Equal(module_sp->GetFileSpec(), m_module_spec, false))
return true;
else
return false;
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 0765c546384..f32c72bdba4 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -331,8 +331,25 @@ Section::ReadSectionDataFromObjectFile (const ObjectFile* objfile, off_t section
if (file)
{
- off_t section_file_offset = GetFileOffset() + objfile->GetOffset() + section_offset;
- return file.ReadFileContents (section_file_offset, dst, dst_len);
+ size_t bytes_left = dst_len;
+ size_t bytes_read = 0;
+ const uint64_t file_size = GetFileSize();
+ if (section_offset < file_size)
+ {
+ off_t section_file_offset = objfile->GetOffset() + GetFileOffset() + section_offset;
+ bytes_read = file.ReadFileContents (section_file_offset, dst, dst_len);
+ if (bytes_read >= dst_len)
+ return bytes_read;
+ bytes_left -= bytes_read;
+ }
+
+ const uint64_t byte_size = GetByteSize();
+ if (section_offset + bytes_read < byte_size)
+ {
+ memset ((uint8_t*)dst + bytes_read, 0, bytes_left);
+ bytes_read += bytes_left;
+ }
+ return bytes_read;
}
}
return 0;
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index ecea72daeec..5ceeee365d7 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -279,7 +279,7 @@ SourceManager::File::DisplaySourceLines (uint32_t line, uint32_t context_before,
bool
SourceManager::File::FileSpecMatches (const FileSpec &file_spec)
{
- return FileSpec::Compare (m_file_spec, file_spec, false) == 0;
+ return FileSpec::Equal (m_file_spec, file_spec, false);
}
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 2ba490ebb0a..897ab8cb59d 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -31,98 +31,30 @@ using namespace lldb;
using namespace lldb_private;
Value::Value() :
- m_value(),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
+ m_value (),
+ m_value_type (eValueTypeScalar),
+ m_context (NULL),
+ m_context_type (eContextTypeInvalid),
+ m_data_buffer ()
{
}
Value::Value(const Scalar& scalar) :
- m_value(scalar),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
+ m_value (scalar),
+ m_value_type (eValueTypeScalar),
+ m_context (NULL),
+ m_context_type (eContextTypeInvalid),
+ m_data_buffer ()
{
}
-Value::Value(int v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(unsigned int v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(long v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(unsigned long v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(long long v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(unsigned long long v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(float v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(double v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
-
-Value::Value(long double v) :
- m_value(v),
- m_value_type(eValueTypeScalar),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
-{
-}
Value::Value(const uint8_t *bytes, int len) :
- m_value(),
- m_value_type(eValueTypeHostAddress),
- m_context(NULL),
- m_context_type(eContextTypeInvalid)
+ m_value (),
+ m_value_type (eValueTypeHostAddress),
+ m_context (NULL),
+ m_context_type (eContextTypeInvalid),
+ m_data_buffer ()
{
m_data_buffer.CopyData(bytes, len);
m_value = (uintptr_t)m_data_buffer.GetBytes();
@@ -163,35 +95,9 @@ Value::operator=(const Value &rhs)
return *this;
}
-Value *
-Value::CreateProxy()
-{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->CreateProxy ();
-
- Value *ret = new Value;
- ret->SetContext(eContextTypeValue, this);
- return ret;
-}
-
-Value *
-Value::GetProxyTarget()
-{
- if (m_context_type == eContextTypeValue)
- return (Value*)m_context;
- else
- return NULL;
-}
-
void
Value::Dump (Stream* strm)
{
- if (m_context_type == eContextTypeValue)
- {
- ((Value*)m_context)->Dump (strm);
- return;
- }
-
m_value.GetValue (strm, true);
strm->Printf(", value_type = %s, context = %p, context_type = %s",
Value::GetValueTypeAsCString(m_value_type),
@@ -202,18 +108,12 @@ Value::Dump (Stream* strm)
Value::ValueType
Value::GetValueType() const
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetValueType ();
-
return m_value_type;
}
AddressType
Value::GetValueAddressType () const
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetValueAddressType ();
-
switch (m_value_type)
{
default:
@@ -226,60 +126,9 @@ Value::GetValueAddressType () const
return eAddressTypeInvalid;
}
-
-Value::ContextType
-Value::GetContextType() const
-{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetContextType ();
-
- return m_context_type;
-}
-
-void
-Value::SetValueType (Value::ValueType value_type)
-{
- if (m_context_type == eContextTypeValue)
- {
- ((Value*)m_context)->SetValueType(value_type);
- return;
- }
-
- m_value_type = value_type;
-}
-
-void
-Value::ClearContext ()
-{
- if (m_context_type == eContextTypeValue)
- {
- ((Value*)m_context)->ClearContext();
- return;
- }
-
- m_context = NULL;
- m_context_type = eContextTypeInvalid;
-}
-
-void
-Value::SetContext (Value::ContextType context_type, void *p)
-{
- if (m_context_type == eContextTypeValue)
- {
- ((Value*)m_context)->SetContext(context_type, p);
- return;
- }
-
- m_context_type = context_type;
- m_context = p;
-}
-
RegisterInfo *
Value::GetRegisterInfo()
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetRegisterInfo();
-
if (m_context_type == eContextTypeRegisterInfo)
return static_cast<RegisterInfo *> (m_context);
return NULL;
@@ -288,32 +137,14 @@ Value::GetRegisterInfo()
Type *
Value::GetType()
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetType();
-
if (m_context_type == eContextTypeLLDBType)
return static_cast<Type *> (m_context);
return NULL;
}
-Scalar &
-Value::GetScalar()
-{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetScalar();
-
- return m_value;
-}
-
void
Value::ResizeData(int len)
{
- if (m_context_type == eContextTypeValue)
- {
- ((Value*)m_context)->ResizeData(len);
- return;
- }
-
m_value_type = eValueTypeHostAddress;
m_data_buffer.SetByteSize(len);
m_value = (uintptr_t)m_data_buffer.GetBytes();
@@ -322,19 +153,16 @@ Value::ResizeData(int len)
bool
Value::ValueOf(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->ValueOf(exe_ctx, ast_context);
-
switch (m_context_type)
{
default:
case eContextTypeInvalid:
- case eContextTypeClangType: // clang::Type *
- case eContextTypeRegisterInfo: // RegisterInfo *
- case eContextTypeLLDBType: // Type *
+ case eContextTypeClangType: // clang::Type *
+ case eContextTypeRegisterInfo: // RegisterInfo *
+ case eContextTypeLLDBType: // Type *
break;
- case eContextTypeVariable: // Variable *
+ case eContextTypeVariable: // Variable *
ResolveValue(exe_ctx, ast_context);
return true;
}
@@ -344,9 +172,6 @@ Value::ValueOf(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
size_t
Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr)
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetValueByteSize(ast_context, error_ptr);
-
size_t byte_size = 0;
switch (m_context_type)
@@ -412,9 +237,6 @@ Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr)
clang_type_t
Value::GetClangType ()
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetClangType();
-
switch (m_context_type)
{
default:
@@ -444,9 +266,6 @@ Value::GetClangType ()
lldb::Format
Value::GetValueDefaultFormat ()
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetValueDefaultFormat();
-
switch (m_context_type)
{
default:
@@ -506,11 +325,12 @@ Value::GetData (DataExtractor &data)
}
Error
-Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context, DataExtractor &data, uint32_t data_offset)
+Value::GetValueAsData (ExecutionContext *exe_ctx,
+ clang::ASTContext *ast_context,
+ DataExtractor &data,
+ uint32_t data_offset,
+ Module *module)
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetValueAsData(exe_ctx, ast_context, data, data_offset);
-
data.Clear();
Error error;
@@ -544,16 +364,20 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
{
error.SetErrorString ("can't read load address (no execution context)");
}
- else if (exe_ctx->process == NULL)
+ else
{
- error.SetErrorString ("can't read load address (invalid process)");
- }
- else
- {
- address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
- address_type = eAddressTypeLoad;
- data.SetByteOrder(exe_ctx->process->GetTarget().GetArchitecture().GetByteOrder());
- data.SetAddressByteSize(exe_ctx->process->GetTarget().GetArchitecture().GetAddressByteSize());
+ Process *process = exe_ctx->GetProcess();
+ if (process == NULL)
+ {
+ error.SetErrorString ("can't read load address (invalid process)");
+ }
+ else
+ {
+ address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+ address_type = eAddressTypeLoad;
+ data.SetByteOrder(process->GetTarget().GetArchitecture().GetByteOrder());
+ data.SetAddressByteSize(process->GetTarget().GetArchitecture().GetAddressByteSize());
+ }
}
break;
@@ -568,71 +392,91 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
}
else
{
- // The only thing we can currently lock down to a module so that
- // we can resolve a file address, is a variable.
- Variable *variable = GetVariable();
-
- if (GetVariable())
+ address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+ if (address == LLDB_INVALID_ADDRESS)
{
- address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
- if (address != LLDB_INVALID_ADDRESS)
+ error.SetErrorString ("invalid file address");
+ }
+ else
+ {
+ if (module == NULL)
+ {
+ // The only thing we can currently lock down to a module so that
+ // we can resolve a file address, is a variable.
+ Variable *variable = GetVariable();
+ if (variable)
+ {
+ SymbolContext var_sc;
+ variable->CalculateSymbolContext(&var_sc);
+ module = var_sc.module_sp.get();
+ }
+ }
+
+ if (module)
{
bool resolved = false;
- SymbolContext var_sc;
- variable->CalculateSymbolContext(&var_sc);
- if (var_sc.module_sp)
+ ObjectFile *objfile = module->GetObjectFile();
+ if (objfile)
{
- ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
- if (objfile)
+ Address so_addr(address, objfile->GetSectionList());
+ addr_t load_address = so_addr.GetLoadAddress (exe_ctx->target);
+ if (load_address != LLDB_INVALID_ADDRESS)
{
- Address so_addr(address, objfile->GetSectionList());
- addr_t load_address = so_addr.GetLoadAddress (exe_ctx->target);
- if (load_address != LLDB_INVALID_ADDRESS)
+ resolved = true;
+ address = load_address;
+ address_type = eAddressTypeLoad;
+ data.SetByteOrder(exe_ctx->target->GetArchitecture().GetByteOrder());
+ data.SetAddressByteSize(exe_ctx->target->GetArchitecture().GetAddressByteSize());
+ }
+ else
+ {
+ if (so_addr.IsSectionOffset())
{
resolved = true;
- address = load_address;
- address_type = eAddressTypeLoad;
- data.SetByteOrder(exe_ctx->target->GetArchitecture().GetByteOrder());
- data.SetAddressByteSize(exe_ctx->target->GetArchitecture().GetAddressByteSize());
- }
- else
- {
- if (so_addr.IsSectionOffset())
- {
- resolved = true;
- file_so_addr = so_addr;
- data.SetByteOrder(objfile->GetByteOrder());
- data.SetAddressByteSize(objfile->GetAddressByteSize());
- }
+ file_so_addr = so_addr;
+ data.SetByteOrder(objfile->GetByteOrder());
+ data.SetAddressByteSize(objfile->GetAddressByteSize());
}
}
}
if (!resolved)
{
- if (var_sc.module_sp)
- error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s' in %s%s%s",
- address,
- variable->GetName().AsCString(""),
- var_sc.module_sp->GetFileSpec().GetDirectory().GetCString(),
- var_sc.module_sp->GetFileSpec().GetDirectory() ? "/" : "",
- var_sc.module_sp->GetFileSpec().GetFilename().GetCString());
+ Variable *variable = GetVariable();
+
+ if (module)
+ {
+ if (variable)
+ error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s' in %s%s%s",
+ address,
+ variable->GetName().AsCString(""),
+ module->GetFileSpec().GetDirectory().GetCString(),
+ module->GetFileSpec().GetDirectory() ? "/" : "",
+ module->GetFileSpec().GetFilename().GetCString());
+ else
+ error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx in %s%s%s",
+ address,
+ module->GetFileSpec().GetDirectory().GetCString(),
+ module->GetFileSpec().GetDirectory() ? "/" : "",
+ module->GetFileSpec().GetFilename().GetCString());
+ }
else
- error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s'",
- address,
- variable->GetName().AsCString(""));
+ {
+ if (variable)
+ error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s'",
+ address,
+ variable->GetName().AsCString(""));
+ else
+ error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx", address);
+ }
}
}
else
{
- error.SetErrorString ("invalid file address");
+ // Can't convert a file address to anything valid without more
+ // context (which Module it came from)
+ error.SetErrorString ("can't read memory from file address without more context");
}
}
- else
- {
- // Can't convert a file address to anything valid without more
- // context (which Module it came from)
- error.SetErrorString ("can't read memory from file address without more context");
- }
}
break;
@@ -695,9 +539,24 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
}
else
{
- if (exe_ctx->process->ReadMemory(address, dst, byte_size, error) != byte_size)
+ // The execution context might have a NULL process, but it
+ // might have a valid process in the exe_ctx->target, so use
+ // the ExecutionContext::GetProcess accessor to ensure we
+ // get the process if there is one.
+ Process *process = exe_ctx->GetProcess();
+
+ if (process)
{
- error.SetErrorStringWithFormat("read memory from 0x%llx failed", (uint64_t)address);
+ const size_t bytes_read = process->ReadMemory(address, dst, byte_size, error);
+ if (bytes_read != byte_size)
+ error.SetErrorStringWithFormat("read memory from 0x%llx failed (%u of %u bytes read)",
+ (uint64_t)address,
+ (uint32_t)bytes_read,
+ (uint32_t)byte_size);
+ }
+ else
+ {
+ error.SetErrorStringWithFormat("read memory from 0x%llx failed (invalid process)", (uint64_t)address);
}
}
}
@@ -717,30 +576,9 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
Scalar &
Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
{
- Scalar scalar;
- if (m_context_type == eContextTypeValue)
+ void *opaque_clang_qual_type = GetClangType();
+ if (opaque_clang_qual_type)
{
- // Resolve the proxy
-
- Value * rhs = (Value*)m_context;
-
- m_value = rhs->m_value;
- m_value_type = rhs->m_value_type;
- m_context = rhs->m_context;
- m_context_type = rhs->m_context_type;
-
- if ((uintptr_t)rhs->m_value.ULongLong(LLDB_INVALID_ADDRESS) == (uintptr_t)rhs->m_data_buffer.GetBytes())
- {
- m_data_buffer.CopyData(rhs->m_data_buffer.GetBytes(),
- rhs->m_data_buffer.GetByteSize());
-
- m_value = (uintptr_t)m_data_buffer.GetBytes();
- }
- }
-
- if (m_context_type == eContextTypeClangType)
- {
- void *opaque_clang_qual_type = GetClangType();
switch (m_value_type)
{
case eValueTypeScalar: // raw scalar value
@@ -759,6 +597,7 @@ Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
DataExtractor data;
if (ClangASTType::ReadFromMemory (ast_context, opaque_clang_qual_type, exe_ctx, addr, address_type, data))
{
+ Scalar scalar;
if (ClangASTType::GetValueAsScalar (ast_context, opaque_clang_qual_type, data, 0, data.GetByteSize(), scalar))
{
m_value = scalar;
@@ -784,8 +623,6 @@ Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
}
break;
}
-
-
}
return m_value;
}
@@ -793,16 +630,11 @@ Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
Variable *
Value::GetVariable()
{
- if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetVariable();
-
if (m_context_type == eContextTypeVariable)
return static_cast<Variable *> (m_context);
return NULL;
}
-
-
const char *
Value::GetValueTypeAsCString (ValueType value_type)
{
@@ -821,12 +653,11 @@ Value::GetContextTypeAsCString (ContextType context_type)
{
switch (context_type)
{
- case eContextTypeInvalid: return "invalid";
- case eContextTypeClangType: return "clang::Type *";
- case eContextTypeRegisterInfo: return "RegisterInfo *";
- case eContextTypeLLDBType: return "Type *";
- case eContextTypeVariable: return "Variable *";
- case eContextTypeValue: return "Value"; // TODO: Sean, more description here?
+ case eContextTypeInvalid: return "invalid";
+ case eContextTypeClangType: return "clang::Type *";
+ case eContextTypeRegisterInfo: return "RegisterInfo *";
+ case eContextTypeLLDBType: return "Type *";
+ case eContextTypeVariable: return "Variable *";
};
return "???";
}
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index e721bd60425..918be0923c3 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -973,7 +973,7 @@ ValueObject::SetValueFromCString (const char *value_str)
unsigned long long ull_val = strtoull(value_str, &end, 0);
if (end && *end != '\0')
return false;
- m_value = ull_val;
+ m_value.GetScalar() = ull_val;
// Limit the bytes in our m_data appropriately.
m_value.GetScalar().GetData (m_data, byte_size);
}
@@ -989,7 +989,7 @@ ValueObject::SetValueFromCString (const char *value_str)
long long sll_val = strtoll(value_str, &end, 0);
if (end && *end != '\0')
return false;
- m_value = sll_val;
+ m_value.GetScalar() = sll_val;
// Limit the bytes in our m_data appropriately.
m_value.GetScalar().GetData (m_data, byte_size);
}
@@ -1612,7 +1612,7 @@ ValueObject::CreateConstantValue (const ConstString &name)
data.SetByteOrder (m_data.GetByteOrder());
data.SetAddressByteSize(m_data.GetAddressByteSize());
- m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0);
+ m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0, GetModule());
valobj_sp = ValueObjectConstResult::Create (exe_scope,
ast,
diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp
index dcbb90a99ea..8ddf195b51f 100644
--- a/lldb/source/Core/ValueObjectChild.cpp
+++ b/lldb/source/Core/ValueObjectChild.cpp
@@ -169,7 +169,7 @@ ValueObjectChild::UpdateValue ()
if (m_error.Success())
{
ExecutionContext exe_ctx (GetExecutionContextScope());
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST (), m_data, 0);
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST (), m_data, 0, GetModule());
}
}
else
diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp
index e0d94f7e22a..c80fd9d592f 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -177,7 +177,7 @@ ValueObjectDynamicValue::UpdateValue ()
if (m_type_sp)
SetValueDidChange(true);
m_value = m_parent->GetValue();
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0);
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
return m_error.Success();
}
@@ -225,7 +225,7 @@ ValueObjectDynamicValue::UpdateValue ()
{
// The variable value is in the Scalar value inside the m_value.
// We can point our m_data right to it.
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0);
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
if (m_error.Success())
{
if (ClangASTContext::IsAggregateType (GetClangType()))
diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp
index 900d27fbb1a..bfa58378911 100644
--- a/lldb/source/Core/ValueObjectMemory.cpp
+++ b/lldb/source/Core/ValueObjectMemory.cpp
@@ -205,7 +205,7 @@ ValueObjectMemory::UpdateValue ()
case Value::eValueTypeScalar:
// The variable value is in the Scalar value inside the m_value.
// We can point our m_data right to it.
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0);
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
break;
case Value::eValueTypeFileAddress:
@@ -247,7 +247,7 @@ ValueObjectMemory::UpdateValue ()
else
value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType());
- m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0);
+ m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule());
}
break;
}
@@ -267,3 +267,11 @@ ValueObjectMemory::IsInScope ()
return true;
}
+
+Module *
+ValueObjectMemory::GetModule()
+{
+ return m_address.GetModule();
+}
+
+
diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index 79692a023a8..2b381d7cb6b 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -20,6 +20,7 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/Variable.h"
@@ -154,7 +155,7 @@ ValueObjectVariable::UpdateValue ()
case Value::eValueTypeScalar:
// The variable value is in the Scalar value inside the m_value.
// We can point our m_data right to it.
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0);
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
break;
case Value::eValueTypeFileAddress:
@@ -206,7 +207,7 @@ ValueObjectVariable::UpdateValue ()
// so it can extract read its value into m_data appropriately
Value value(m_value);
value.SetContext(Value::eContextTypeVariable, variable);
- m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0);
+ m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule());
}
break;
}
@@ -233,3 +234,20 @@ ValueObjectVariable::IsInScope ()
return m_variable_sp->IsInScope (frame);
}
+Module *
+ValueObjectVariable::GetModule()
+{
+ if (m_variable_sp)
+ {
+ SymbolContextScope *sc_scope = m_variable_sp->GetSymbolContextScope();
+ if (sc_scope)
+ {
+ SymbolContext sc;
+ sc_scope->CalculateSymbolContext (&sc);
+ return sc.module_sp.get();
+ }
+ }
+ return NULL;
+}
+
+
OpenPOWER on IntegriCloud