Added checking to make sure that the target has a
scratch AST context before attempting to parse.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@136631 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 4f21fc0..ebcaa01 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -64,12 +64,12 @@
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 @@
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 @@
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());
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index d8d65bc..9bc4188 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -241,7 +241,11 @@
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);
diff --git a/source/Expression/ClangUtilityFunction.cpp b/source/Expression/ClangUtilityFunction.cpp
index aec3088..72c6888 100644
--- a/source/Expression/ClangUtilityFunction.cpp
+++ b/source/Expression/ClangUtilityFunction.cpp
@@ -103,7 +103,11 @@
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);