Attachment 'in-scope.py'
Download 1 class InScope (gdb.Function):
2 """Check if all the given variables or macros are in scope.
3 Receives as argument a list of names separated by whitespace."""
4
5 def __init__ (self):
6 super (InScope, self).__init__ ("in_scope")
7
8 def invoke (self, var):
9 vars = set (var.string().split())
10 found = set ()
11 block = gdb.get_block_for_pc (gdb.get_selected_frame ().get_pc ())
12 while block:
13 for sym in block:
14 if (sym.is_argument () or sym.is_constant ()
15 or sym.is_function () or sym.is_variable ()):
16 sym_name = sym.get_print_name ()
17 if sym_name in vars:
18 found.add (sym_name)
19 block = block.get_superblock ()
20
21 return vars == found
22
23 InScope ()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.