Added checking to make sure that the target has a

scratch AST context before attempting to parse.

llvm-svn: 136631
This commit is contained in:
Sean Callanan 2011-08-01 18:18:33 +00:00
parent df425dbf04
commit b995119900
4 changed files with 22 additions and 5 deletions

View File

@ -82,8 +82,11 @@ public:
/// @param[in] exe_ctx
/// The execution context to use when finding types for variables.
/// Also used to find a "scratch" AST context to store result types.
///
/// @return
/// True if parsing is possible; false if it is unsafe to continue.
//------------------------------------------------------------------
void
bool
WillParse (ExecutionContext &exe_ctx);
//------------------------------------------------------------------

View File

@ -64,12 +64,12 @@ ClangExpressionDeclMap::~ClangExpressionDeclMap()
DisableStructVars();
}
void
bool
ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx)
{
EnableParserVars();
m_parser_vars->m_exe_ctx = &exe_ctx;
if (exe_ctx.frame)
m_parser_vars->m_sym_ctx = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
else if (exe_ctx.thread)
@ -78,6 +78,11 @@ ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx)
m_parser_vars->m_sym_ctx = SymbolContext(exe_ctx.target->GetSP(), ModuleSP());
if (exe_ctx.target)
m_parser_vars->m_persistent_vars = &exe_ctx.target->GetPersistentVariables();
if (exe_ctx.target && !exe_ctx.target->GetScratchClangASTContext())
return false;
return true;
}
void
@ -133,6 +138,7 @@ ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name,
const llvm::APInt& value)
{
assert (m_parser_vars.get());
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext());

View File

@ -241,7 +241,11 @@ ClangUserExpression::Parse (Stream &error_stream,
m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory));
m_expr_decl_map->WillParse(exe_ctx);
if (!m_expr_decl_map->WillParse(exe_ctx))
{
error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
return false;
}
ClangExpressionParser parser(exe_ctx.process, *this);

View File

@ -103,7 +103,11 @@ ClangUtilityFunction::Install (Stream &error_stream,
m_data_allocator.reset(new ProcessDataAllocator(*exe_ctx.process));
m_expr_decl_map->WillParse(exe_ctx);
if (!m_expr_decl_map->WillParse(exe_ctx))
{
error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
return false;
}
ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this);