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