-
Notifications
You must be signed in to change notification settings - Fork 160
/
block.py
46 lines (41 loc) · 1.46 KB
/
block.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
## Block
Represents a scope.
https://sourceware.org/gdb/onlinedocs/gdb/Blocks-In-Python.html
## Symbol
https://sourceware.org/gdb/onlinedocs/gdb/Symbols-In-Python.html
"""
gdb.execute('file block_py.out', to_string=True)
# Inner block.
gdb.execute('break 37', to_string=True)
gdb.execute('run', to_string=True)
frame = gdb.selected_frame()
block = frame.block()
while block:
print(32 * '=')
print('function = ' + str(block.function))
print('is_valid() = ' + str(block.is_valid()))
print('start = ' + str(block.start))
print('end = ' + str(block.end))
print('is_global = ' + str(block.is_global))
print('is_static = ' + str(block.is_static))
print()
for symbol in block:
print('name = ' + str(symbol.name))
# gdb.SYMBOL_LOC_XXX constants.
print('addr_class = ' + str(symbol.addr_class))
print('linkage_name = ' + str(symbol.linkage_name))
print('print_name = ' + str(symbol.print_name))
print('type = ' + str(symbol.type))
print('line = ' + str(symbol.line))
print('is_argument = ' + str(symbol.is_argument))
print('is_constant = ' + str(symbol.is_constant))
print('is_function = ' + str(symbol.is_function))
print('is_variable = ' + str(symbol.is_variable))
print('needs_frame = ' + str(symbol.needs_frame))
try:
print('value = ' + str(symbol.value(frame)))
except:
pass
print()
block = block.superblock