xref example file
Samuel Rivas
samuel@REDACTED
Fri May 19 14:34:10 CEST 2006
Samuel Rivas wrote:
> Torbjorn Tornkvist wrote:
> > Nice! (but I couldn't get it to work)
> >
> > Has anyone written some nice icing on top of the xref cake?
> > I mean a collection of function which setup and executes
> > some of useful metrics there are to be gathered from xref?
> > The documentation of xref is good but a little bit on the terse side...
>
> Not really a nice profiling application full of flashy metrics, but I
> have a sort of template that I use to include in my applications.
>
> Just change my_app for your application name and make my_app_app_path
> return the path to the app file, run my_app_xref:start(), wait, wait a
> little more, and run my_app_xref:all(). That <i>should</i> work :)
Well, it seems I overcommited myself, it is not that easy :). There are
some patterns that make the regexp compiler fail if you don't load certain
modules.
In custom_white_list you have to delete any reference to nonexistent
module names. An easy workaround is to delete last entries and then tune it
when everything is working (returning an empty string requires more
changes to work).
custom_white_list() ->
"\"my_app.*\":init/1 + \"my_app.*\":debug_stop/0 "
"+ \"my_app.*\":\"(re)?start_link\"/_".
There is also a reference you must change in unused_white_list. Again,
an easy workaround is deleting the offending pattern:
unused_white_list() ->
xref:forget(?XREF_SERVER, 'UWL'),
Q = lists:flatten(["UWL:=(", module_regexp(gen_servers()), $:,
function_regexp(gen_server_callbacks()), "/_) "
"+ (", module_regexp(gen_events()), $:,
function_regexp(gen_event_callbacks()), "/_) "
"+ (", module_regexp(supervisors()), $:,
function_regexp(supervisor_callbacks()), "/_) "
"+ (", application_module(), $:,
function_regexp(application_callbacks()), "/_) "
"+ ", custom_white_list()]),
{ok, _} = xref:q(?XREF_SERVER,Q),
ok.
After that it ... should work?
Regards
--
Samuel
More information about the erlang-questions
mailing list