[erlang-questions] how can I debug errors in linked-in drivers or nif loaded as shared library?

Kevin A. Smith kevin@REDACTED
Fri Dec 24 14:59:56 CET 2010

I've edited the erl script which comes with the standard Erlang release to allow easy use of GDB for just such situations:

if [ ! -z "$USE_GDB" ]; then
gdb $BINDIR/erlexec --args $BINDIR/erlexec ${1+"$@"}
exec $BINDIR/erlexec ${1+"$@"}

#exec $BINDIR/erlexec ${1+"$@"}

Define the env var "USE_GDB" before launching Erlang and you'll get a debugger prompt when your NIF/driver crashes. GDB's backtrace command is especially helpful :-)

Credit to Dave Smith @ Basho for originally suggesting this approach.


On Dec 24, 2010, at 4:09 AM, caox wrote:

> hi
> 	I got a segmentation fault and a core.dump file when tested my linked-in driver. How could I debug it with gdb?
> 	For an executable c file, we can just call 'gdb a.out core.dump'. How can I do this for a .so file loaded by erlang?
>        Thanks.
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED

More information about the erlang-questions mailing list