@@ -290,28 +290,9 @@ bool Variable::IsInScope(StackFrame *frame) {
290290 // this variable was defined in is currently
291291 Block *deepest_frame_block =
292292 frame->GetSymbolContext (eSymbolContextBlock).block ;
293- if (deepest_frame_block) {
294- SymbolContext variable_sc;
295- CalculateSymbolContext (&variable_sc);
296-
297- // Check for static or global variable defined at the compile unit
298- // level that wasn't defined in a block
299- if (variable_sc.block == nullptr )
300- return true ;
301-
302- // Check if the variable is valid in the current block
303- if (variable_sc.block != deepest_frame_block &&
304- !variable_sc.block ->Contains (deepest_frame_block))
305- return false ;
306-
307- // If no scope range is specified then it means that the scope is the
308- // same as the scope of the enclosing lexical block.
309- if (m_scope_range.IsEmpty ())
310- return true ;
311-
312- addr_t file_address = frame->GetFrameCodeAddress ().GetFileAddress ();
313- return m_scope_range.FindEntryThatContains (file_address) != nullptr ;
314- }
293+ Address frame_addr = frame->GetFrameCodeAddress ();
294+ if (deepest_frame_block)
295+ return IsInScope (*deepest_frame_block, frame_addr);
315296 }
316297 break ;
317298
@@ -321,6 +302,27 @@ bool Variable::IsInScope(StackFrame *frame) {
321302 return false ;
322303}
323304
305+ bool Variable::IsInScope (const Block &block, const Address &addr) {
306+ SymbolContext variable_sc;
307+ CalculateSymbolContext (&variable_sc);
308+
309+ // Check for static or global variable defined at the compile unit
310+ // level that wasn't defined in a block
311+ if (variable_sc.block == nullptr )
312+ return true ;
313+
314+ // Check if the variable is valid in the current block
315+ if (variable_sc.block != &block && !variable_sc.block ->Contains (&block))
316+ return false ;
317+
318+ // If no scope range is specified then it means that the scope is the
319+ // same as the scope of the enclosing lexical block.
320+ if (m_scope_range.IsEmpty ())
321+ return true ;
322+
323+ return m_scope_range.FindEntryThatContains (addr.GetFileAddress ()) != nullptr ;
324+ }
325+
324326Status Variable::GetValuesForVariableExpressionPath (
325327 llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
326328 GetVariableCallback callback, void *baton, VariableList &variable_list,
0 commit comments