如何知道.beam文件是否使用debug_info编译?

Ser*_*rov 4 erlang

我看到我需要.erl使用debug_info参数编译一个文件,以便在调试器中调试它.

当我尝试在调试.beam器中调试文件时,我总是看到该文件没有调试信息,无法打开.

**无效的梁文件或无抽象代码:"/ erlang-debug/myapp.beam"

我怀疑可能是我以错误的方式编译文件.我尝试了所有可能的方式,但仍然没有运气,我觉得文件是在没有debug_info的情况下编译的.

Erlang文档页面上提到了我使用的最简单的示例之一:

% erlc +debug_info module.erl
Run Code Online (Sandbox Code Playgroud)

有没有办法知道某个特定.beam文件是否使用debug_info编译?

Pas*_*cal 6

您可以使用module_info函数访问所有编译选项.要对调试信息标志进行测试,可以使用proplists函数来提取信息:

1> O = fun(M) ->               
1> Comp = M:module_info(compile),      
1> Options = proplists:get_value(options,Comp),
1> proplists:get_value(debug_info,Options)     
1> end.                                        
#Fun<erl_eval.6.50752066>
2> c(p564).
{ok,p564}
3> O(p564).
undefined
4> c(p564,[debug_info]). 
{ok,p564}
5> O(p564).             
true
6>
Run Code Online (Sandbox Code Playgroud)