[erlang-questions] How do I trace by module name?

45 views
Skip to first unread message

Alex Shneyderman

unread,
Oct 27, 2012, 6:16:03 AM10/27/12
to erlang-q...@erlang.org
I am trying to use dbg. Here is what I did:

Erlang R15B (erts-5.9) [source] [64-bit] [smp:8:8] [async-threads:0]
[hipe] [kernel-poll:false]

Eshell V5.9 (abort with ^G)
1> compile:file("fib.erl",[debug_info]).
{ok,fib}
2> dbg:tracer().
{ok,<0.38.0>}
3> dbg:tpl(fib,c).
{ok,[{matched,nonode@nohost,3},{saved,c}]}
4> fib:fib(21).
231
5> dbg:ltp().
c: [{'_',[],[{message,{caller}}]}]
caller_exception_trace: cx
caller_trace: c
cx: [{'_',[],[{exception_trace},{message,{caller}}]}]
exception_trace: x
x: [{'_',[],[{exception_trace}]}]
ok

Or something is amiss with my code, dbg or something else? Any ideas?
Or can I even trace by module. I tried to trace by process and that worked
fine.

Cheers,
Alex.
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Yang Liu

unread,
Oct 27, 2012, 7:28:50 AM10/27/12
to Alex Shneyderman, erlang-q...@erlang.org

I always use this, i call it at start, then it trace every call on the module

open_tracer(Module) ->
     dbg:tracer(),
     dbg:p(all, [call]),
     dbg:tpl(Module, [{'_', [], [{return_trace}]}]).

Alex Shneyderman

unread,
Oct 27, 2012, 11:24:24 AM10/27/12
to Yang Liu, erlang-q...@erlang.org
(one more time to the list):

great this works!

Is there any way to redirect traces to a file? I mean with
specialized handler ...

Yang Liu

unread,
Oct 27, 2012, 8:40:47 PM10/27/12
to Alex Shneyderman, erlang-q...@erlang.org

dbg:tracer
(port,dbg:trace_
port(file,{"/log/
trace",wrap,atom_
to_list(node
()),50000000,12})).
like at the function trace_port, and there is a discusstion i found
stackoverflow.com/questions/1954894/using-trace-and-dbg-in-erlang

在 2012-10-27 晚上11:24,"Alex Shneyderman" <a.shne...@gmail.com>写道:

Joseph Wayne Norton

unread,
Oct 27, 2012, 10:22:39 PM10/27/12
to Alex Shneyderman, erlang-q...@erlang.org
Alex -

I'd recommend taking a look at the redbug tool.  It provides nice features for tracing. (https://github.com/massemanet/eper/blob/master/src/redbug.erl)

Joe N.
Reply all
Reply to author
Forward
0 new messages