[Lldb-commits] [lldb] r136631 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangUserExpression.cpp source/Expression/ClangUtilityFunction.cpp
Sean Callanan
scallanan at apple.com
Mon Aug 1 11:18:34 PDT 2011
Author: spyffe
Date: Mon Aug 1 13:18:33 2011
New Revision: 136631
URL: http://llvm.org/viewvc/llvm-project?rev=136631&view=rev
Log:
Added checking to make sure that the target has a
scratch AST context before attempting to parse.
Modified:
lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Expression/ClangUtilityFunction.cpp
Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=136631&r1=136630&r2=136631&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Aug 1 13:18:33 2011
@@ -82,8 +82,11 @@
/// @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);
//------------------------------------------------------------------
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=136631&r1=136630&r2=136631&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Aug 1 13:18:33 2011
@@ -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());
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=136631&r1=136630&r2=136631&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Aug 1 13:18:33 2011
@@ -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);
Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=136631&r1=136630&r2=136631&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Mon Aug 1 13:18:33 2011
@@ -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);
More information about the lldb-commits
mailing list