Updated the IRInterpreter to work with an

IRMemoryMap rather than through its own memory
abstraction.  This considerably simplifies the
code, and makes it possible to run the
IRInterpreter multiple times on an already-parsed
expression in the absence of a ClangExpressionDeclMap.

Changes include:

  - ClangExpressionDeclMap's interface methods
    for the IRInterpreter now take IRMemoryMap
    arguments.  They are not long for this world,
    however, since the IRInterpreter will soon be
    working with materialized variables.

  - As mentioned above, removed the Memory class
    from the IR interpreter altogether.  It had a
    few functions that remain useful, such as
    keeping track of Values that have been placed
    in memory, so I moved those into methods on
    InterpreterStackFrame.

  - Changed IRInterpreter to work with lldb::addr_t
    rather than Memory::Region as its primary
    currency.

  - Fixed a bug in the IRMemoryMap where it did not
    report correct address byte size and byte order
    if no process was present, because it was using
    Target::GetDefaultArchitecture() rather than
    Target::GetArchitecture().

  - Made IRMemoryMap methods clear the Errors they
    receive before running.  Having to do this by
    hand is just annoying.

The testsuite seems happy with these changes, but
please let me know if you see problems (especially
in use cases without a process).

llvm-svn: 179675
This commit is contained in:
Sean Callanan
2013-04-17 07:50:58 +00:00
parent e8df5bd92b
commit 08052afa2d
4 changed files with 485 additions and 614 deletions

View File

@@ -379,7 +379,8 @@ ClangExpressionDeclMap::ResultIsReference (const ConstString &name)
}
bool
ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj,
ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj,
IRMemoryMap &map,
lldb_private::Value &value,
const ConstString &name,
lldb_private::TypeFromParser type,
@@ -425,7 +426,7 @@ ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP
const size_t pvar_byte_size = pvar_sp->GetByteSize();
uint8_t *pvar_data = pvar_sp->GetValueBytes();
if (!ReadTarget(pvar_data, value, pvar_byte_size))
if (!ReadTarget(map, pvar_data, value, pvar_byte_size))
return false;
pvar_sp->m_flags &= ~(ClangExpressionVariable::EVNeedsFreezeDry);
@@ -928,7 +929,8 @@ ClangExpressionDeclMap::WrapBareAddress (lldb::addr_t addr)
}
bool
ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
ClangExpressionDeclMap::WriteTarget (lldb_private::IRMemoryMap &map,
lldb_private::Value &value,
const uint8_t *data,
size_t length)
{
@@ -976,7 +978,7 @@ ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
lldb::addr_t load_addr = file_addr.GetLoadAddress(target);
Error err;
process->WriteMemory(load_addr, data, length, err);
map.WriteMemory(load_addr, data, length, err);
return err.Success();
}
@@ -986,7 +988,7 @@ ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
return false;
Error err;
process->WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
map.WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
return err.Success();
}
@@ -1004,7 +1006,8 @@ ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
}
bool
ClangExpressionDeclMap::ReadTarget (uint8_t *data,
ClangExpressionDeclMap::ReadTarget (IRMemoryMap &map,
uint8_t *data,
lldb_private::Value &value,
size_t length)
{
@@ -1057,11 +1060,8 @@ ClangExpressionDeclMap::ReadTarget (uint8_t *data,
}
case Value::eValueTypeLoadAddress:
{
if (!process)
return false;
Error err;
process->ReadMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
map.ReadMemory(data, (lldb::addr_t)value.GetScalar().ULongLong(), length, err);
return err.Success();
}