#include <string.h>
// C++ Includes
+#include <map>
#include <string>
#include <vector>
lldb_private::Value *m_lldb_value; ///< The value found in LLDB for this variable
lldb::VariableSP m_lldb_var; ///< The original variable for this variable
const lldb_private::Symbol *m_lldb_sym; ///< The original symbol for this variable, if it was a symbol
-
- private:
- DISALLOW_COPY_AND_ASSIGN (ParserVars);
};
+
+private:
+ typedef std::map <uint64_t, ParserVars> ParserVarMap;
+ ParserVarMap m_parser_vars;
+
+public:
//----------------------------------------------------------------------
/// Make this variable usable by the parser by allocating space for
/// parser-specific variables
//----------------------------------------------------------------------
void
- EnableParserVars()
+ EnableParserVars(uint64_t parser_id)
{
- if (!m_parser_vars.get())
- m_parser_vars.reset(new ParserVars);
+ m_parser_vars.emplace(parser_id, ParserVars());
}
//----------------------------------------------------------------------
/// Deallocate parser-specific variables
//----------------------------------------------------------------------
void
- DisableParserVars()
+ DisableParserVars(uint64_t parser_id)
+ {
+ m_parser_vars.erase(parser_id);
+ }
+
+ //----------------------------------------------------------------------
+ /// Access parser-specific variables
+ //----------------------------------------------------------------------
+ ParserVars *
+ GetParserVars(uint64_t parser_id)
{
- m_parser_vars.reset();
+ ParserVarMap::iterator i = m_parser_vars.find(parser_id);
+
+ if (i == m_parser_vars.end())
+ return NULL;
+ else
+ return &i->second;
}
//----------------------------------------------------------------------
size_t m_size; ///< The space required for the variable, in bytes
off_t m_offset; ///< The offset of the variable in the struct, in bytes
};
-
+
+private:
+ typedef std::map <uint64_t, JITVars> JITVarMap;
+ JITVarMap m_jit_vars;
+
+public:
//----------------------------------------------------------------------
/// Make this variable usable for materializing for the JIT by allocating
/// space for JIT-specific variables
//----------------------------------------------------------------------
void
- EnableJITVars()
+ EnableJITVars(uint64_t parser_id)
{
- if (!m_jit_vars.get())
- m_jit_vars.reset(new JITVars);
+ m_jit_vars.emplace(parser_id, JITVars());
}
//----------------------------------------------------------------------
/// Deallocate JIT-specific variables
//----------------------------------------------------------------------
void
- DisableJITVars()
+ DisableJITVars(uint64_t parser_id)
{
- m_jit_vars.reset();
+ m_jit_vars.erase(parser_id);
+ }
+
+ JITVars *GetJITVars(uint64_t parser_id)
+ {
+ JITVarMap::iterator i = m_jit_vars.find(parser_id);
+
+ if (i == m_jit_vars.end())
+ return NULL;
+ else
+ return &i->second;
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// Members
//----------------------------------------------------------------------
- std::auto_ptr<ParserVars> m_parser_vars;
- std::auto_ptr<JITVars> m_jit_vars;
-
enum Flags
{
EVNone = 0,
lldb::ValueObjectSP m_frozen_sp;
lldb::ValueObjectSP m_live_sp;
-private:
+
DISALLOW_COPY_AND_ASSIGN (ClangExpressionVariable);
};
/// The variable requested, or NULL if that variable is not in the list.
//----------------------------------------------------------------------
lldb::ClangExpressionVariableSP
- GetVariable (const clang::NamedDecl *decl)
+ GetVariable (const clang::NamedDecl *decl, uint64_t parser_id)
{
lldb::ClangExpressionVariableSP var_sp;
for (size_t index = 0, size = GetSize(); index < size; ++index)
{
var_sp = GetVariableAtIndex(index);
- if (var_sp->m_parser_vars.get() && var_sp->m_parser_vars->m_named_decl == decl)
+
+ ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(parser_id);
+
+ if (parser_vars && parser_vars->m_named_decl == decl)
return var_sp;
}
var_sp.reset();
ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
if (var_sp)
{
- if (var_sp->m_parser_vars.get() &&
- var_sp->m_parser_vars->m_lldb_value)
- delete var_sp->m_parser_vars->m_lldb_value;
+ ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+
+ if (parser_vars && parser_vars->m_lldb_value)
+ delete parser_vars->m_lldb_value;
- var_sp->DisableParserVars();
+ var_sp->DisableParserVars(GetParserID());
}
}
{
ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
if (pvar_sp)
- pvar_sp->DisableParserVars();
+ pvar_sp->DisableParserVars(GetParserID());
}
DisableParserVars();
ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
- ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
+ ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl, GetParserID()));
if (!var_sp)
- var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
+ var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID());
if (!var_sp)
return ClangExpressionVariableSP();
if (log)
log->Printf("Created persistent variable with flags 0x%hx", var_sp->m_flags);
- var_sp->EnableParserVars();
+ var_sp->EnableParserVars(GetParserID());
+
+ ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
- var_sp->m_parser_vars->m_named_decl = decl;
- var_sp->m_parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = decl;
+ parser_vars->m_parser_type = parser_type;
return true;
}
m_struct_vars->m_struct_laid_out = false;
- if (m_struct_members.GetVariable(decl))
+ if (m_struct_members.GetVariable(decl, GetParserID()))
return true;
- ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
+ ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl, GetParserID()));
if (!var_sp)
- var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
+ var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID());
if (!var_sp)
return false;
// We know entity->m_parser_vars is valid because we used a parser variable
// to find it
- var_sp->m_parser_vars->m_llvm_value = value;
- var_sp->EnableJITVars();
- var_sp->m_jit_vars->m_alignment = alignment;
- var_sp->m_jit_vars->m_size = size;
+ ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+
+ parser_vars->m_llvm_value = value;
+
+ var_sp->EnableJITVars(GetParserID());
+
+ ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
+
+ jit_vars->m_alignment = alignment;
+ jit_vars->m_size = size;
m_struct_members.AddVariable(var_sp);
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
if (!member_sp)
return false;
+
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
- if (!member_sp->m_jit_vars.get())
+ if (!jit_vars)
return false;
if (member_index == 0)
- m_struct_vars->m_struct_alignment = member_sp->m_jit_vars->m_alignment;
+ m_struct_vars->m_struct_alignment = jit_vars->m_alignment;
- if (cursor % member_sp->m_jit_vars->m_alignment)
- cursor += (member_sp->m_jit_vars->m_alignment - (cursor % member_sp->m_jit_vars->m_alignment));
+ if (cursor % jit_vars->m_alignment)
+ cursor += (jit_vars->m_alignment - (cursor % jit_vars->m_alignment));
- member_sp->m_jit_vars->m_offset = cursor;
- cursor += member_sp->m_jit_vars->m_size;
+ jit_vars->m_offset = cursor;
+ cursor += jit_vars->m_size;
}
m_struct_vars->m_struct_size = cursor;
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
- if (!member_sp ||
- !member_sp->m_parser_vars.get() ||
- !member_sp->m_jit_vars.get() ||
+ if (!member_sp)
+ return false;
+
+ ClangExpressionVariable::ParserVars *parser_vars = member_sp->GetParserVars(GetParserID());
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+
+ if (!parser_vars ||
+ !jit_vars ||
!member_sp->GetValueObject())
return false;
- decl = member_sp->m_parser_vars->m_named_decl;
- value = member_sp->m_parser_vars->m_llvm_value;
- offset = member_sp->m_jit_vars->m_offset;
+ decl = parser_vars->m_named_decl;
+ value = parser_vars->m_llvm_value;
+ offset = jit_vars->m_offset;
name = member_sp->GetName();
return true;
uint64_t &ptr
)
{
- ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl));
+ ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl, GetParserID()));
if (!entity_sp)
return false;
// We know m_parser_vars is valid since we searched for the variable by
// its NamedDecl
- ptr = entity_sp->m_parser_vars->m_lldb_value->GetScalar().ULongLong();
+ ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID());
+
+ ptr = parser_vars->m_lldb_value->GetScalar().ULongLong();
return true;
}
{
assert (m_parser_vars.get());
- ClangExpressionVariableSP expr_var_sp (m_found_entities.GetVariable(decl));
- ClangExpressionVariableSP persistent_var_sp (m_parser_vars->m_persistent_vars->GetVariable(decl));
+ ClangExpressionVariableSP expr_var_sp (m_found_entities.GetVariable(decl, GetParserID()));
+ ClangExpressionVariableSP persistent_var_sp (m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID()));
if (expr_var_sp)
{
flags = expr_var_sp->m_flags;
- if (!expr_var_sp->m_parser_vars.get())
+ ClangExpressionVariable::ParserVars *parser_vars = expr_var_sp->GetParserVars(GetParserID());
+
+ if (!parser_vars)
return Value();
bool is_reference = expr_var_sp->m_flags & ClangExpressionVariable::EVTypeIsReference;
- if (expr_var_sp->m_parser_vars->m_lldb_var)
+ if (parser_vars->m_lldb_var)
{
- std::auto_ptr<Value> value(GetVariableValue(expr_var_sp->m_parser_vars->m_lldb_var, NULL));
+ std::auto_ptr<Value> value(GetVariableValue(parser_vars->m_lldb_var, NULL));
if (is_reference && value.get() && value->GetValueType() == Value::eValueTypeLoadAddress)
{
else
return Value();
}
- else if (expr_var_sp->m_parser_vars->m_lldb_sym)
+ else if (parser_vars->m_lldb_sym)
{
- const Address sym_address = expr_var_sp->m_parser_vars->m_lldb_sym->GetAddress();
+ const Address sym_address = parser_vars->m_lldb_sym->GetAddress();
if (!sym_address.IsValid())
return Value();
s.Printf("[%s]\n", member_sp->GetName().GetCString());
- if (!member_sp->m_jit_vars.get())
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+
+ if (!jit_vars)
return false;
extractor.Dump (&s, // stream
- member_sp->m_jit_vars->m_offset, // offset
+ jit_vars->m_offset, // offset
lldb::eFormatBytesWithASCII, // format
1, // byte size of individual entries
- member_sp->m_jit_vars->m_size, // number of entries
+ jit_vars->m_size, // number of entries
16, // entries per line
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, // address to print
+ m_material_vars->m_materialized_location + jit_vars->m_offset, // address to print
0, // bit size (bitfields only; 0 means ignore)
0); // bit alignment (bitfields only; 0 means ignore)
{
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+
+ if (!jit_vars)
+ {
+ err.SetErrorString("Variable being materialized doesn't have JIT state");
+ return false;
+ }
+
if (m_found_entities.ContainsVariable (member_sp))
{
if (!member_sp->GetValueObject())
if (!DoMaterializeOneRegister (dematerialize,
*reg_ctx,
*reg_info,
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ m_material_vars->m_materialized_location + jit_vars->m_offset,
err))
return false;
}
else
- {
- if (!member_sp->m_jit_vars.get())
- {
- err.SetErrorString("Variable being materialized doesn't have necessary state");
- return false;
- }
-
+ {
if (!DoMaterializeOneVariable (dematerialize,
sym_ctx,
member_sp,
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ m_material_vars->m_materialized_location + jit_vars->m_offset,
err))
return false;
}
if (!DoMaterializeOnePersistentVariable (dematerialize,
member_sp,
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ m_material_vars->m_materialized_location + jit_vars->m_offset,
stack_frame_top,
stack_frame_bottom,
err))
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
+
+ ClangExpressionVariable::ParserVars *var_parser_vars = expr_var->GetParserVars(GetParserID());
- if (!frame || !process || !target || !m_parser_vars.get() || !expr_var->m_parser_vars.get())
+ if (!frame || !process || !target || !m_parser_vars.get() || !var_parser_vars)
{
err.SetErrorString("Necessary state for variable materialization isn't present");
return false;
const ConstString &name(expr_var->GetName());
TypeFromUser type(expr_var->GetTypeFromUser());
- VariableSP &var(expr_var->m_parser_vars->m_lldb_var);
- const lldb_private::Symbol *symbol = expr_var->m_parser_vars->m_lldb_sym;
+ VariableSP &var(var_parser_vars->m_lldb_var);
+ const lldb_private::Symbol *symbol = var_parser_vars->m_lldb_sym;
bool is_reference(expr_var->m_flags & ClangExpressionVariable::EVTypeIsReference);
ClangExpressionVariableSP entity(m_found_entities.CreateVariable (valobj));
assert (entity.get());
- entity->EnableParserVars();
- entity->m_parser_vars->m_parser_type = pt;
- entity->m_parser_vars->m_named_decl = var_decl;
- entity->m_parser_vars->m_llvm_value = NULL;
- entity->m_parser_vars->m_lldb_value = var_location;
- entity->m_parser_vars->m_lldb_var = var;
+ entity->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = pt;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = var_location;
+ parser_vars->m_lldb_var = var;
if (is_reference)
entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType()));
- pvar_sp->EnableParserVars();
- pvar_sp->m_parser_vars->m_parser_type = parser_type;
- pvar_sp->m_parser_vars->m_named_decl = var_decl;
- pvar_sp->m_parser_vars->m_llvm_value = NULL;
- pvar_sp->m_parser_vars->m_lldb_value = NULL;
+ pvar_sp->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = NULL;
if (log)
{
symbol_location->GetScalar() = symbol_load_addr;
symbol_location->SetValueType(Value::eValueTypeLoadAddress);
- entity->EnableParserVars();
- entity->m_parser_vars->m_parser_type = parser_type;
- entity->m_parser_vars->m_named_decl = var_decl;
- entity->m_parser_vars->m_llvm_value = NULL;
- entity->m_parser_vars->m_lldb_value = symbol_location.release();
- entity->m_parser_vars->m_lldb_sym = &symbol;
+ entity->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = symbol_location.release();
+ parser_vars->m_lldb_sym = &symbol;
if (log)
{
{
ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+
if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
{
- const NamedDecl *named_decl = entity->m_parser_vars->m_named_decl;
+ const NamedDecl *named_decl = parser_vars->m_named_decl;
const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
if (!var_decl)
TypeFromUser user_type(copied_type, scratch_ast_context);
- entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
- entity->m_parser_vars->m_parser_type = parser_type;
+ parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
+ parser_vars->m_parser_type = parser_type;
entity->SetClangAST(user_type.GetASTContext());
entity->SetClangType(user_type.GetOpaqueQualType());
std::string decl_name(context.m_decl_name.getAsString());
entity->SetName (ConstString (decl_name.c_str()));
entity->SetRegisterInfo (reg_info);
- entity->EnableParserVars();
- entity->m_parser_vars->m_parser_type = parser_type;
- 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->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = NULL;
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
if (log)
entity->SetClangType (fun_opaque_type);
entity->SetClangAST (fun_ast_context);
- entity->EnableParserVars();
- entity->m_parser_vars->m_named_decl = fun_decl;
- entity->m_parser_vars->m_llvm_value = NULL;
- entity->m_parser_vars->m_lldb_value = fun_location.release();
+ entity->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_named_decl = fun_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = fun_location.release();
if (log)
{