加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 为什么ruby-debug说’保存的帧可能不完整’

发布时间:2020-12-16 23:14:34 所属栏目:百科 来源:网络整理
导读:有时我会在触发断点时得到这个.看起来堆栈帧没有被保存,所以我无法退回调用堆栈 – 真正的痛苦.请参阅下面的示例 -- #0 BatchProcess.add_failure_record(row_id#Fixnum,test#Struct::Test,message#String,...) at line server/processes/batch.rb:309Warnin
有时我会在触发断点时得到这个.看起来堆栈帧没有被保存,所以我无法退回调用堆栈 – 真正的痛苦.请参阅下面的示例
--> #0 BatchProcess.add_failure_record(row_id#Fixnum,test#Struct::Test,message#String,...) 
       at line server/processes/batch.rb:309
Warning: saved frames may be incomplete; compare with caller(0).
(rdb:1) pp caller
["./server/processes/batch.rb:309:in `run_tests'","./server/processes/common/generic_process.rb:219:in `each'","./server/processes/common/generic_process.rb:219:in `run_tests'","./server/processes/common/generic_process.rb:271:in `run_plan'","./server/processes/common/corrections.rb:19:in `each_with_index'","./server/processes/common/generic_process.rb:266:in `each'","./server/processes/common/generic_process.rb:266:in `each_with_index'","./server/processes/common/generic_process.rb:266:in `run_plan'","./server/processes/batch.rb:202:in `run_engine'","/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'","./server/processes/batch.rb:201:in `run_engine'","./server/processes/common/generic_process.rb:88:in `run_dataset'","./server/processes/batch.rb:210:in `run_dataset'","./server/processes/batch.rb:209:in `run_dataset'","./server/processes/common/generic_process.rb:159:in `run'","./server/processes/common/generic_process.rb:158:in `each'","./server/processes/common/generic_process.rb:158:in `run'","./server/processes/batch.rb:350:in `run'","./server/processes/batch.rb:349:in `run'","server/processes/test_runs/run_tests.rb:55:in `run_one_process'","server/processes/test_runs/run_tests.rb:81"]

关于如何阻止这种情况发生的任何想法?

解决方法

这意味着Ruby的caller()函数报告的调用堆栈与调试器记录的调用堆栈不匹配.

如果在调用堆栈中有多个帧时激活了调试器跟踪,则会发生这种情况.它也可能由于ruby-debug中的错误导致无法正确跟踪.一个“补救措施”是将它放在主文件中文件的最开头:
require’ruby-debug’; Debugger.start

然而,这方面的缺点是从程序开始就添加了一些额外的开销.

在Ruby代码中的某处,您必须告诉Ruby开始跟踪调用和返回.通常,这是通过Debugger.start和Debugger.stop或Debugger.start {}的组合完成的.如果您从框架运行,这些命令将在某处发布,因此在正确的位置发布的责任在于添加此代码的程序员.

最后,我将更改消息更加明确:

Warning: saved frames may be incomplete; 
compare debugger backtrace (bt) with Ruby caller(0).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读