[erlang-questions] Debugging embedded Erlang system

Fred Hebert <>
Sun Oct 23 17:37:11 CEST 2011


You might need to pause the whole VM if you don't want things to crash when
you have timers waiting. See, as an example, gen_server:call/2 has a default
timeout of 5 seconds, after which the caller dies. If you're pausing a
server to observe it through a breakpoint, then the caller will crash
(unless you're damn fast to step through the code). Now if the two processes
are linked together, you just crashed the process you were stepping through
and the debugger failed you.

It's why I said it's mostly good for sequential code. If you've got
side-effect going around and stuff inter-connected, timeouts and crashes can
hurt your ability to use the debugger. Be careful about it, tracing might be
your only option many times.

On Sun, Oct 23, 2011 at 9:41 AM, Kaiduan Xie <> wrote:

> No, we do not need to pause the entire VM to debug a process, we just
> pause the particular process.
>
> In C/C++/Java, we all can step-through an multi-thread program,
>
> On Sun, Oct 23, 2011 at 9:06 AM, Fred Hebert <> wrote:
> > Stepping through the code works okay when you've got only sequential
> code,
> > but if you have a lot of code sensitive to timers and concurrency, then
> > stepping through the code of one process will mess with all the timers
> > currently running for other processes. As far as I know, there is no
> > debugging facility letting you pause the entire VM at once.
> >
> > On Sun, Oct 23, 2011 at 1:31 AM, Kaiduan Xie <> wrote:
> >>
> >> I like and use trace, but my fellow developers are hard-cored JAVA
> >> developers, they want to be able to step through the code.
> >>
> >> /Kaiduan
> >>
> >> On Sun, Oct 23, 2011 at 1:27 AM, Chandru
> >> <> wrote:
> >> > On 21 October 2011 17:30, Kaiduan Xie <> wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> We need to debug an Erlang server running in an embedded system where
> >> >> no GUI is available. We can attach an Erlang shell to the server from
> >> >> a remote box with GUI. Can we use debugger on GUI box to remote debug
> >> >> the server on embedded system? Can someone share the experience?
> >> >>
> >> >
> >> > You can use the in built trace facilities? I personally use dbg
> whenever
> >> > I
> >> > need to look at a running system and figure out what is happening.
> Some
> >> > care
> >> > is needed on what parts of the system you trace to make sure you don't
> >> > swamp
> >> > the system with traces. I have rendered a few systems unsuable because
> >> > of
> >> > the volume of tracing if the wrong trace pattern is chosen :) I
> >> > typically
> >> > use something like this:
> >> >
> >> > dbg:tracer(port, dbg:trace_port(file, "trace_file.dbg")).
> >> > dbg:p(all,call).
> >> > dbg:tp(module, function, dbg:fun2ms(fun(_) -> return_trace() end)).
> >> >
> >> > Traces will now start to be written to the file trace_file.dbg
> >> >
> >> > Once you've collected enough traces:
> >> > dbg:ctp().
> >> > dbg:flush_trace_port().
> >> >
> >> > You can then examine the trace file (binary file) using commands in
> dbg.
> >> > I
> >> > use the attached module to convert it to plain text.
> >> >
> >> > Or you can take a look at redbug: https://code.google.com/p/eper/
> >> >
> >> > cheers
> >> > Chandru
> >> >
> >> >
> >> _______________________________________________
> >> erlang-questions mailing list
> >> 
> >> http://erlang.org/mailman/listinfo/erlang-questions
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111023/852f90cf/attachment.html>


More information about the erlang-questions mailing list