我正在使用 ocamldebug(使用 OCaml 4.02.1),并且试图在特定模块内的某处设置断点,但我得到的只是一条有用的错误消息:Can't find any event there.
例如,这是我想设置断点的函数 1 的摘录,如 ocamldebug 所列:
(ocd) list Value.Eval_slevel 79 83
79
80 let slevel stmt = match slevel with
81 | Per_stmt_slevel.Global i -> i
82 | Per_stmt_slevel.PerStmt f -> f stmt
83
我尝试了
break
的几种变体命令,但我每次都得到相同的结果:(ocd) break @ Value.Eval_slevel 80 // module + line number
Can't find any event there.
(ocd) break @ Value.Eval_slevel 80 21 // module + line + column
Can't find any event there.
(ocd) break @ Value.Eval_slevel # 3335 // module + character number
Can't find any event there.
我还尝试了附近的源代码行(以检查可能的行不匹配),并且我还尝试使用模块同义词(例如
Eval_slevel
, eval_slevel
),但无济于事。请注意,如果我手动执行程序直到它到达此函数,则表明第 80 行确实有一个事件:
Time: 17447400 - pc: 3865360 - module Value.Eval_slevel
80 let slevel stmt = <|b|>match slevel with
而且,在这种情况下,我可以手动设置本地断点:
(ocd) break
Breakpoint 1 at 3865360: file src/value/eval_slevel.ml, line 80,
characters 22-119
但显然这个想法是能够做到这一点,而不必手动找到它。
如果我尝试使用函数名称设置断点,则 ocamldebug 看不到它。即使在通过该事件运行程序之后,标识符似乎对 ocamldebug 不可见:
(ocd) break Value.Eval_slevel.slevel
Unbound identifier Value.Eval_slevel.slevel
这就是我无法设置断点的原因吗?如果是这样,是否有解决方法?否则,还有其他方法可以设置这些断点吗?
备注
以下是我尝试做的其他一些事情,以及一些观察结果:
Can't find any event there.
, 但有些文件可以在其中工作。 No source file for <module>
. Position out of range.
The module path <module> is not yet initialized. Please run program forward until its initialization code is executed.
1 这个例子来自 Frama-C,它是可重现的,以防有人感兴趣。但是,我无法在该代码库之外生成最小示例。
最佳答案
您是否有机会通过 dynlink 加载 Value 模块?我知道this issue已经开放了一段时间,肯定会适用于 OCAML 4.02.1。如果是这种情况,您必须禁用 dynlink 并静态链接才能让 ocamldebug 与该模块一起工作。
关于debugging - 无法在 ocamldebug : "Can' t find any event there. 中设置断点“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30399730/