зеркало из https://github.com/github/ruby.git
misc/gdb.py: Allow overriding stack_size [ci skip]
This commit is contained in:
Родитель
210caa777b
Коммит
8d9a25a6d7
34
misc/gdb.py
34
misc/gdb.py
|
@ -1,8 +1,17 @@
|
||||||
|
import argparse
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
# Usage:
|
# usage: [-h] [-s STACK_SIZE] [uplevel]
|
||||||
# cfp: Dump the current cfp
|
#
|
||||||
# cfp 1: Dump the caller cfp
|
# Dump a control frame
|
||||||
|
#
|
||||||
|
# positional arguments:
|
||||||
|
# uplevel CFP offset from the stack top
|
||||||
|
#
|
||||||
|
# options:
|
||||||
|
# -h, --help show this help message and exit
|
||||||
|
# -s STACK_SIZE, --stack-size STACK_SIZE
|
||||||
|
# override stack_size (useful for JIT frames)
|
||||||
class CFP(gdb.Command):
|
class CFP(gdb.Command):
|
||||||
FRAME_MAGICS = [
|
FRAME_MAGICS = [
|
||||||
# frame types
|
# frame types
|
||||||
|
@ -35,10 +44,16 @@ class CFP(gdb.Command):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(CFP, self).__init__('cfp', gdb.COMMAND_USER)
|
super(CFP, self).__init__('cfp', gdb.COMMAND_USER)
|
||||||
|
|
||||||
def invoke(self, offset, from_tty):
|
self.parser = argparse.ArgumentParser(description='Dump a control frame')
|
||||||
if not offset:
|
self.parser.add_argument('uplevel', type=int, nargs='?', default=0, help='CFP offset from the stack top')
|
||||||
offset = '0'
|
self.parser.add_argument('-s', '--stack-size', type=int, help='override stack_size (useful for JIT frames)')
|
||||||
cfp = f'(ruby_current_ec->cfp + ({offset}))'
|
|
||||||
|
def invoke(self, args, from_tty):
|
||||||
|
try:
|
||||||
|
args = self.parser.parse_args(args.split())
|
||||||
|
except SystemExit:
|
||||||
|
return
|
||||||
|
cfp = f'(ruby_current_ec->cfp + ({args.uplevel}))'
|
||||||
|
|
||||||
end_cfp = self.get_int('ruby_current_ec->vm_stack + ruby_current_ec->vm_stack_size')
|
end_cfp = self.get_int('ruby_current_ec->vm_stack + ruby_current_ec->vm_stack_size')
|
||||||
cfp_count = int((end_cfp - self.get_int('ruby_current_ec->cfp')) / self.get_int('sizeof(rb_control_frame_t)'))
|
cfp_count = int((end_cfp - self.get_int('ruby_current_ec->cfp')) / self.get_int('sizeof(rb_control_frame_t)'))
|
||||||
|
@ -65,7 +80,10 @@ class CFP(gdb.Command):
|
||||||
self.print_stack(cfp, -1, self.frame_types(cfp, -1))
|
self.print_stack(cfp, -1, self.frame_types(cfp, -1))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
stack_size = int((self.get_int(f'{cfp}->sp') - self.get_int(f'vm_base_ptr({cfp})')) / 8)
|
if args.stack_size is not None:
|
||||||
|
stack_size = args.stack_size
|
||||||
|
else:
|
||||||
|
stack_size = int((self.get_int(f'{cfp}->sp') - self.get_int(f'vm_base_ptr({cfp})')) / 8)
|
||||||
print(f'Stack (size={stack_size}):')
|
print(f'Stack (size={stack_size}):')
|
||||||
for i in range(0, stack_size):
|
for i in range(0, stack_size):
|
||||||
self.print_stack(cfp, i, self.rp(cfp, i))
|
self.print_stack(cfp, i, self.rp(cfp, i))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче