@@ -290,28 +290,9 @@ bool Variable::IsInScope(StackFrame *frame) {
290
290
// this variable was defined in is currently
291
291
Block *deepest_frame_block =
292
292
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);
315
296
}
316
297
break ;
317
298
@@ -321,6 +302,27 @@ bool Variable::IsInScope(StackFrame *frame) {
321
302
return false ;
322
303
}
323
304
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
+
324
326
Status Variable::GetValuesForVariableExpressionPath (
325
327
llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
326
328
GetVariableCallback callback, void *baton, VariableList &variable_list,
0 commit comments