Changes between Version 13 and Version 14 of ErlangShellInterface


Ignore:
Timestamp:
Apr 24, 2012, 12:08:25 PM (13 years ago)
Author:
daniel_h
Comment:

dependency analysis via ri

Legend:

Unmodified
Added
Removed
Modified
  • ErlangShellInterface

    v13 v14  
    298298 
    299299There is a [[SemanticQuery|semantic queries]] page, where you can learn more about this topic. 
     300 
     301== Dependency analysis == 
     302 
     303The two interface functions are: 
     304 
     3051. For drawing: 
     306{{{#!erlang 
     307ri:draw_dep/1 
     308}}} 
     3092. For printing the result to stdout: 
     310{{{#!erlang 
     311ri:print_dep/1 
     312}}} 
     313 
     314=== Options === 
     315 
     316The parameter of the interface functions is a proplist setting the options of the analysis. The available options are: 
     317 
     318 * {{{level (mod | func)}}} 
     319    The level of the dependency query (module or function). 
     320 * {{{type (all | cycles)}}} 
     321    Whether the investigation should be done on the whole graph, or just on the cyclic part (if exists). When printing out the cycles, type {{{all}}} returns graph nodes, while {{{cycles}}} returns names. 
     322 * {{{otp (true | false)}}} 
     323    Whether Erlang/OTP standard modules should be included in the analysis or not. 
     324 * {{{gnode}}} 
     325    Entity or entities that should be the starting point of the analysis. 
     326 * exception 
     327    List of entities excluded from the analysis. 
     328 * leaves 
     329    List of those entities which should be included in the analysis, but their children should not (and consequently the children become exceptions). 
     330 * {{{dot}}} 
     331    The file path of the generated {{{.dot}}} graph description. Unless it is a non-existing absolute path, the graph will be placed into the {{{./dep_files}}} directory. This option is only available when using {{{draw_dep}}}. 
     332 
     333You can specify entities either with graph nodes (such as {{{{'$gn', func, 123}}}}) or with their identifier. Modules can be specified with their names as atoms (e.g. 'mnesia'), while functions are specified by their MFA descriptor as a string (e.g. "io:format/2") 
     334 
     335=== Examples for listing results === 
     336 
     337* Checking for cycles in module level. 
     338{{{#!erlang 
     339ri:print_dep([{level, mod}, {type, all}]). 
     340}}} 
     341   
     342 
     343* Checking for cycles in function level, and printing out names of the functions (Module:Function/Arity). 
     344{{{#!erlang 
     345ri:print_dep([{level, func}, {type, cycles}]). 
     346}}} 
     347{{{#!erlang 
     348  [['foo:fv4/1','foo:fv4/1'], 
     349  ['test3:p/1','test:fv6/1','test3:p/1'], 
     350  ['cycle4:f4/1','cycle3:f3/1','cycle4:f4/1'], 
     351  ['cycle2:fv2/1','cycle1:fv1/0','cycle2:fv2/1'], 
     352  ['test:fv5/1','test:fv4/2','test:fv5/1'], 
     353  ['cycle4:f5/1','cycle3:f6/1','cycle4:f5/1']] 
     354}}} 
     355 
     356 
     357* Checking for cycles in function level, and printing out the graph nodes of the functions. 
     358{{{#!erlang 
     359ri:print_dep([{level, func}, {type, all}]). 
     360}}} 
     361{{{#!erlang 
     362  {"6 cycle(s)", 
     363  {[[{'$gn',func,28},{'$gn',func,28}],  
     364  [{'$gn',func,29},{'$gn',func,37},{'$gn',func,29}], 
     365  [{'$gn',func,7},{'$gn',func,9},{'$gn',func,7}], 
     366  [{'$gn',func,2},{'$gn',func,1},{'$gn',func,2}], 
     367  [{'$gn',func,36},{'$gn',func,35},{'$gn',func,36}], 
     368  [{'$gn',func,8},{'$gn',func,6},{'$gn',func,8}]]} 
     369}}} 
     370 
     371* Checking for cycles in module level from a given node 
     372{{{#!erlang 
     373ri:print_dep([{level, mod}, {gnode, {'$gn', module, 24}}]).  
     374}}} 
     375{{{#!erlang 
     376  {true,[[{'$gn',module,24}, 
     377          {'$gn',module,25}, 
     378          {'$gn',module,24}]]} 
     379}}} 
     380 
     381* Checking for cycles in function level from a node given with its identifier 
     382{{{#!erlang 
     383ri:print_dep([{level, func}, {gnode, "cycle4:f5/1"}]). 
     384}}} 
    300385 
    301386== Server management command list ==