2011-06-30 31 views
0

關於erlang使用翅膀3d shell(windows 7 pro,翅膀3d 1.4.1)的新手問題。當我寫命令來讀取記錄。定義:Erlang rr()返回missing_chunk

rr(wings). 

我總是得到一個錯誤:

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

我做錯了嗎?

+0

這必須是PATHS問題。 D:或d:上的.hrl文件是否區分大小寫。 –

回答

2

rr/1「從模塊的BEAM文件中讀取記錄定義。如果BEAM文件中沒有記錄定義,則會找到並讀取源文件。

我的猜測是抽象表單沒有被包含在.BEAM文件中,而且在你的安裝中源文件不可用。

UPDATE:挖入shell:read_file_records/2功能,我發現以下幾點:

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. 

它看起來像,如果「分區:Abst」塊丟失,它甚至不嘗試讀取源代碼。 beam_lib:chunks(File, [abstract_code,"CInf"])爲您回報什麼?你正在運行哪個Erlang版本?

0

rr/1需要實際的文件名或文件名的相對路徑。就像這樣:

 
rr("wings.hrl"). 

OR 

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

OR 

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

換句話說,從pwd()通過它實際的相對路徑包含定義的文件。

+0

還有一個rr/1的變體,它接受一個原子,這就是@mbr正在使用的原子。 rr(「wings.hrl」)應該允許他讀取記錄定義,但是理解爲什麼該變體不起作用會很好。 –

+0

這使得它成爲文件路徑問題。否則,這意味着函數rr/1有副作用。這可能是哪一個? –

1

我使用:

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

調用這工作正常:

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

呼叫:

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

回報:

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