Added a SetData() method to ValueObject. This

lets a ValueObject's contents be set from raw
data.  This has certain limitations (notably,
registers can only be set to data that is as
large as the register) but will be useful for
the new Materializer.

I also exposed this interface through SBValue.
I have added a testcase that exercises various
special cases of SBValue::SetData().

llvm-svn: 179437
This commit is contained in:
Sean Callanan
2013-04-13 01:21:23 +00:00
parent 53a6558771
commit 389823e995
13 changed files with 369 additions and 0 deletions

View File

@@ -1880,6 +1880,65 @@ SBValue::GetData ()
return sb_data;
}
bool
SBValue::SetData (lldb::SBData &data, SBError &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::ValueObjectSP value_sp(GetSP());
bool ret = true;
if (value_sp)
{
ProcessSP process_sp(value_sp->GetProcessSP());
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
if (log)
log->Printf ("SBValue(%p)::SetData() => error: process is running", value_sp.get());
error.SetErrorString("Process is running");
ret = false;
}
else
{
DataExtractor *data_extractor = data.get();
if (!data_extractor)
{
if (log)
log->Printf ("SBValue(%p)::SetData() => error: no data to set", value_sp.get());
error.SetErrorString("No data to set");
ret = false;
}
else
{
Error set_error;
value_sp->SetData(*data_extractor, set_error);
if (!set_error.Success())
{
error.SetErrorStringWithFormat("Couldn't set data: %s", set_error.AsCString());
ret = false;
}
}
}
}
else
{
error.SetErrorString("Couldn't set data: invalid SBValue");
ret = false;
}
if (log)
log->Printf ("SBValue(%p)::SetData (%p) => %s",
value_sp.get(),
data.get(),
ret ? "true" : "false");
return ret;
}
lldb::SBDeclaration
SBValue::GetDeclaration ()
{