Added checks to the expresssion parser which make
searching for variables and symbols in the target
more robust. These checks prevent variables from
being reported as existing if they cannot actually
be evaluated in the current context.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@134656 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 453f4b1..cfe2d00 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -552,6 +552,9 @@
else
return false;
+ if (!func_so_addr || !func_so_addr->IsValid())
+ return false;
+
func_addr = func_so_addr->GetCallableLoadAddress (m_parser_vars->m_exe_ctx->target);
return true;
@@ -573,6 +576,10 @@
sc_list.GetContextAtIndex(i, sym_ctx);
const Address *sym_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
+
+ if (!sym_address || !sym_address->IsValid())
+ return LLDB_INVALID_ADDRESS;
+
if (sym_address)
{
switch (sym_ctx.symbol->GetType())
@@ -1261,7 +1268,7 @@
NULL));
}
else if (sym)
- {
+ {
location_value.reset(new Value);
addr_t location_load_addr = GetSymbolAddress(*exe_ctx.target, name);
@@ -1591,6 +1598,11 @@
var_sp = program_globals.GetVariableAtIndex (0);
}
}
+
+ if (!var_sp ||
+ !var_sp->IsInScope(&frame) ||
+ !var_sp->LocationIsValidForFrame (&frame))
+ return lldb::VariableSP();
if (var_sp && type)
{