开发者

Erlang rr() returns missing_chunk

Newbie question o开发者_JAVA百科n erlang using by wings 3d shell (windows 7 pro, wings 3d 1.4.1). When I write command to read records definitons:

    rr(wings).

I always get an error:

    {error,beam_lib,
      {missing_chunk,'d:/temp/erlang/lib/wings/ebin/wings.beam',"Abst"}}

What I am doing wrong?


rr/1 "reads record definitions from a module's BEAM file. If there are no record definitions in the BEAM file, the source file is located and read instead."

My guess is that the abstract form hasn't been included in the .BEAM file and that in your installation the source files are not available.

UPDATE: Digging into the shell:read_file_records/2 function, I've found the following:

read_file_records(File, Opts) ->
    case filename:extension(File) of
        ".beam" ->
            case beam_lib:chunks(File, [abstract_code,"CInf"]) of
                {ok,{_Mod,[{abstract_code,{Version,Forms}},{"CInf",CB}]}} ->
                    case record_attrs(Forms) of
                        [] when Version =:= raw_abstract_v1 ->
                            [];
                        [] -> 
                            %% If the version is raw_X, then this test
                            %% is unnecessary.
                            try_source(File, CB);
                        Records -> 
                            Records
                    end;
                {ok,{_Mod,[{abstract_code,no_abstract_code},{"CInf",CB}]}} ->
                    try_source(File, CB);
                Error ->
                    %% Could be that the "Abst" chunk is missing (pre R6).
                    Error
            end;
        _ ->
            parse_file(File, Opts)
    end.

It looks like, if the "Abst" chunk is missing, it doesn't even try to read the source code. What does beam_lib:chunks(File, [abstract_code,"CInf"]) return for you? Which Erlang version are you running?


I am using:

Erlang R14B01 (erts-5.8.2) [rq:1] [async-threads:0]
Eshell V5.8.2  (abort with ^G)

Calling this works fine:

    rr("d:/temp/erlang/src/wings.hrl").

Calling:

    beam_lib:chunks("wings", [abstract_code,"CInf"]).

returns:

    {error,beam_lib,{file_error,"wings.beam",enoent}}


rr/1 requires the actual file name or the relative PATH to the file name. Like this:

rr("wings.hrl").

OR

rr("./apps/MYAPP-1.0/include/my_include_file.hrl").

OR

rr("./src/wings.erl").

In other words, pass it the actual relative PATH from your pwd() to the file which contains the definitions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜