debugging - How to attach erlang dbg to a running process? -
how attach debugger running erlang process (rabbitmq)? have source code of same rabbit version that's running. set breakpoint on source line, , attach debugger running rabbit instance. i'm not sure if erlang requires debug symbols async_dirty.
in perfect world, able both locally , remotely.
i'm such erlang beginner, wouldn't i'm new erlang. i'm trying learn debug rabbitmq plugin.
from you're saying, don't need run debugger. erlang vm's concurrency model doesn't fit concept of stop-everything-and-inspect-style debugging.
on other hand, vm has great, built-in tracing capabilities. dbg
module exposed, module's interface quite difficult use, if you're beginner. i'd recommend using recon_trace
view what's going on process: http://ferd.github.io/recon/recon_trace.html.
if don't feel installing recon, start program erlang shell, , in shell, type:
%enable tracing capabilities 1> dbg:tracer(). % trace pattern local-scope % (tell tracer trace every call in yourmodule, unexported functions). 2> dbg:tpl(yourmodule, x). % tell dbg print calls processes calling module. 3> dbg:p(all,call). % run traced module 4> yourmodule:somefun(). % should see nice(?) traces of inputs, outputs, , % exceptions in shell
check out following session, fumble around not knowing how use queue
module:
eshell v6.3 (abort ^g) 1> dbg:tracer(), dbg:tpl(queue, x), dbg:p(all, call). {ok,[{matched,nonode@nohost,26}]} 2> x = queue:new(). (<0.33.0>) call queue:new() (<0.33.0>) returned queue:new/0 -> {[],[]} {[],[]} 3> x = queue:cons(1). ** exception error: undefined function queue:cons/1 4> x = queue:cons(x,1). (<0.39.0>) call queue:cons({[],[]},1) (<0.39.0>) call queue:in_r({[],[]},1) (<0.39.0>) exception_from {queue,in_r,2} {error,badarg} (<0.39.0>) exception_from {queue,cons,2} {error,badarg} ** exception error: bad argument in function queue:in_r/2 called queue:in_r({[],[]},1) 5> x = queue:cons(1,x). (<0.41.0>) call queue:cons(1,{[],[]}) (<0.41.0>) call queue:in_r(1,{[],[]}) (<0.41.0>) returned queue:in_r/2 -> {[],[1]} (<0.41.0>) returned queue:cons/2 -> {[],[1]} ** exception error: no match of right hand side value {[],[1]} 6> x1 = queue:cons(1,x). (<0.43.0>) call queue:cons(1,{[],[]}) (<0.43.0>) call queue:in_r(1,{[],[]}) (<0.43.0>) returned queue:in_r/2 -> {[],[1]} (<0.43.0>) returned queue:cons/2 -> {[],[1]} {[],[1]}
hope helps started.
if want see how erlang wizards it, see this presentation.
Comments
Post a Comment