Skip to content

Instantly share code, notes, and snippets.

@SpringMT
Last active December 25, 2016 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpringMT/dc1494e70479875ea983e70d1ca3864b to your computer and use it in GitHub Desktop.
Save SpringMT/dc1494e70479875ea983e70d1ca3864b to your computer and use it in GitHub Desktop.
Ruby 2.4.0 for gdbinit
set print pretty on
set pagination off
define ruby_thread
set $ruby_thread = ruby_current_vm->running_thread
printf "running_thread set $ruby_thread \n"
end
define vm_cfp_cnt
printf "cfp_cnt %d \n", ((rb_control_frame_t *)(($arg0)->stack + ($arg0)->stack_size) - (rb_control_frame_t *)($arg1))
end
document vm_cfp_cnt
cfp_cnt ruby_thread and cfp(from https://github.com/ruby/ruby/blob/202bbda2bf5f25343e286099140fb9282880ecba/vm_dump.c#L24)
end
# https://github.com/ruby/ruby/blob/1407e52ba4915ed7f251dec548b5e68f2a5a6a6e/vm_core.h#L1026
define vm_frame_type
printf "vm_frame_type %x ", (((rb_control_frame_t *)($arg0))->ep[0] & 0xffff0001)
set $cfp_flag = (((rb_control_frame_t *)($arg0))->ep[0] & 0xffff0001)
if $cfp_flag == 0x44440001
printf " %s \n", "TOP"
else
if $cfp_flag == 0x11110001
printf " %s \n", "METHOD"
else
if $cfp_flag == 0x33330001
printf " %s \n", "CLASS"
else
if $cfp_flag == 0x22220001
printf " %s \n", "BLOCK"
else
if $cfp_flag == 0x55550001
printf " %s \n", "CFUNC"
else
if $cfp_flag == 0x66660001
printf " %s \n", "PROC"
else
if $cfp_flag == 0x99990001
printf " %s \n", "LAMBDA"
else
if $cfp_flag == 0x77770001
printf " %s \n", "IFUNC"
else
if $cfp_flag == 0x88880001
printf " %s \n", "EVAL"
else
if $cfp_flag == 0xaaaa0001
printf " %s \n", "RESCUE"
else
if $cfp_flag == 0
printf " %s \n", "------"
else
printf " %s \n", "(none)"
end
end
end
end
end
end
end
end
end
end
end
end
document vm_frame_type
vm_frame_type cfp
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment