ruby Ruby获得当前堆栈

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby Ruby获得当前堆栈相关的知识,希望对你有一定的参考价值。

Put following text into project's root dir gdb_commands.txt
--------------------------------------------------
define redirect_stdout
  call rb_eval_string("$_old_stdout, $stdout = $stdout, File.open('/tmp/ruby-debug.' + Process.pid.to_s, 'a'); $stdout.sync = true")
end
define ruby_eval
  call(rb_p(rb_eval_string_protect($arg0,(int*)0)))
end
redirect_stdout
ruby_eval("Kernel.caller")
quit

--------------------------------------------------
run from project's dir
sudo gdb --batch-silent -x gdb_commands.txt ruby 16667
16667 - ruby  pid

以上是关于ruby Ruby获得当前堆栈的主要内容,如果未能解决你的问题,请参考以下文章