[ZeroBrane Studio] Re: debug lua on an embedded micro

  • From: Paul K <paul@xxxxxxxxxxxxx>
  • To: "zerobrane@xxxxxxxxxxxxx" <zerobrane@xxxxxxxxxxxxx>
  • Date: Tue, 16 Sep 2014 11:01:15 -0700

Hi Steve,

> Is there a correct procedure for stopping a debug session.  I was mid
debugging a Lua function call run() but when I stop debugging (Shift+F5) or
stop the server in ZB, my application crashes.  I think Lua is calling
os_exit() and causing my app to quit unceremoniously (which I can probably
tidy up).  But why would Lua try to quit?

Yes, starting from v0.70 ZBS includes "Project | Detach process" (also on
the toolbar on the right side next to Stop). This will stop debugging, but
will continue the process without "killing" it.

Another option that I use for environments like this is to set "os.exit =
require('mobdebug').done" in your application after "require('mobdebug')",
which will have the same effect as described above when you hit "Stop
debugging" in the IDE.

In a similar way you can change os.exit to some more complex code that will
stop debugging (using done() and then do whatever graceful shutdown you
need to do in your application).

Paul.

Other related posts: