[Lldb-commits] [lldb] r150554 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangExpressionVariable.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRInterpreter.cpp
Sean Callanan
scallanan at apple.com
Tue Feb 14 17:40:39 PST 2012
Author: spyffe
Date: Tue Feb 14 19:40:39 2012
New Revision: 150554
URL: http://llvm.org/viewvc/llvm-project?rev=150554&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Expression/IRInterpreter.cpp
Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=150554&r1=150553&r2=150554&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Feb 14 19:40:39 2012
@@ -434,11 +434,15 @@
/// @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
Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=150554&r1=150553&r2=150554&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Tue Feb 14 19:40:39 2012
@@ -235,10 +235,13 @@
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;
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=150554&r1=150553&r2=150554&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Feb 14 19:40:39 2012
@@ -992,7 +992,7 @@
}
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 @@
if (expr_var_sp)
{
+ flags = expr_var_sp->m_flags;
+
if (!expr_var_sp->m_parser_vars.get())
return Value();
@@ -1048,6 +1050,28 @@
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 @@
}
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 @@
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());
Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=150554&r1=150553&r2=150554&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Tue Feb 14 19:40:39 2012
@@ -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 @@
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 @@
return Memory::Region();
}
- resolved_value = m_decl_map.LookupDecl(decl);
+ resolved_value = m_decl_map.LookupDecl(decl, flags);
}
else
{
@@ -669,6 +671,11 @@
{
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());
More information about the lldb-commits
mailing list