Previoously the expression parser had to rely on the

JIT when printing the values of registers (e.g.,
"expr $pc").  Now the expression parser can do this
in the IR interpreter without running code in the
inferior process.

llvm-svn: 150554
This commit is contained in:
Sean Callanan 2012-02-15 01:40:39 +00:00
parent 84f454ec5c
commit f673e769a6
4 changed files with 47 additions and 6 deletions

View File

@ -434,11 +434,15 @@ public:
/// @param[in] decl
/// The Decl whose value is to be found.
///
/// @param[out] flags
/// The flags for the found variable.
///
/// @return
/// The value, or NULL.
//------------------------------------------------------------------
lldb_private::Value
LookupDecl (clang::NamedDecl *decl);
LookupDecl (clang::NamedDecl *decl,
ClangExpressionVariable::FlagType &flags);
//------------------------------------------------------------------
/// [Used by IRInterpreter] Get the Value for "this", "self", or

View File

@ -235,10 +235,13 @@ public:
EVNeedsFreezeDry = 1 << 4, ///< Copy from m_live_sp to m_frozen_sp during dematerialization
EVKeepInTarget = 1 << 5, ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it
EVTypeIsReference = 1 << 6, ///< The original type of this variable is a reference, so materialize the value rather than the location
EVUnknownType = 1 << 7 ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete
EVUnknownType = 1 << 7, ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete
EVBareRegister = 1 << 8 ///< This variable is a direct reference to $pc or some other entity.
};
uint16_t m_flags; // takes elements of Flags
typedef uint16_t FlagType;
FlagType m_flags; // takes elements of Flags
lldb::ValueObjectSP m_frozen_sp;
lldb::ValueObjectSP m_live_sp;

View File

@ -992,7 +992,7 @@ ClangExpressionDeclMap::ReadTarget (uint8_t *data,
}
lldb_private::Value
ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl)
ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl, ClangExpressionVariable::FlagType &flags)
{
assert (m_parser_vars.get());
@ -1001,6 +1001,8 @@ ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl)
if (expr_var_sp)
{
flags = expr_var_sp->m_flags;
if (!expr_var_sp->m_parser_vars.get())
return Value();
@ -1048,6 +1050,28 @@ ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl)
return ret;
}
else if (RegisterInfo *reg_info = expr_var_sp->GetRegisterInfo())
{
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
if (!frame)
return Value();
RegisterContextSP reg_context_sp(frame->GetRegisterContextSP());
RegisterValue reg_value;
if (!reg_context_sp->ReadRegister(reg_info, reg_value))
return Value();
Value ret;
ret.SetContext(Value::eContextTypeRegisterInfo, reg_info);
if (!reg_value.GetScalarValue(ret.GetScalar()))
return Value();
return ret;
}
else
{
return Value();
@ -1055,6 +1079,8 @@ ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl)
}
else if (persistent_var_sp)
{
flags = persistent_var_sp->m_flags;
if ((persistent_var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference ||
persistent_var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) &&
persistent_var_sp->m_live_sp &&
@ -3024,8 +3050,9 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
entity->m_parser_vars->m_named_decl = var_decl;
entity->m_parser_vars->m_llvm_value = NULL;
entity->m_parser_vars->m_lldb_value = NULL;
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
if (log && log->GetVerbose())
if (log)
{
ASTDumper ast_dumper(var_decl);
log->Printf(" CEDM::FEVD[%d] Added register %s, returned %s", current_id, context.m_decl_name.getAsString().c_str(), ast_dumper.GetCString());

View File

@ -11,6 +11,7 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Expression/ClangExpressionDeclMap.h"
#include "lldb/Expression/ClangExpressionVariable.h"
#include "lldb/Expression/IRForTarget.h"
#include "lldb/Expression/IRInterpreter.h"
@ -633,6 +634,7 @@ public:
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
lldb_private::Value resolved_value;
lldb_private::ClangExpressionVariable::FlagType flags;
if (global_value)
{
@ -649,7 +651,7 @@ public:
return Memory::Region();
}
resolved_value = m_decl_map.LookupDecl(decl);
resolved_value = m_decl_map.LookupDecl(decl, flags);
}
else
{
@ -669,6 +671,11 @@ public:
{
if (resolved_value.GetContextType() == lldb_private::Value::eContextTypeRegisterInfo)
{
bool bare_register = (flags & lldb_private::ClangExpressionVariable::EVBareRegister);
if (bare_register)
indirect_variable = false;
Memory::Region data_region = m_memory.Malloc(value->getType());
data_region.m_allocation->m_origin = resolved_value;
Memory::Region ref_region = m_memory.Malloc(value->getType());