[erlang-questions] What are the debugging possibilities with a C port
Wed Nov 26 17:43:10 CET 2014
On Wed, Nov 26, 2014 at 04:59:45PM +0100, Erik Axling wrote:
> Im currently writing an erlang port of a C library. I can start the port
> but when sending commands to it it fails. What are the debugging option
> here. Can i use GDB in some way even though the port isn't a shared library
> like a nif?
> Can i write to stdout or will those not be seen as the port communicates
> over stdin and stdout?
> Thanks for any help.
Sure, ports are easy to debug. For gdb, just run the port normally and
attach to the PID. So if the port is the priv/port and the PID is 1234:
gdb priv/port 1234
If you want to add some debug printf's, you can either use stderr or if
you're using the stderr_to_stdout option to open_port/2, open and write
to a file.
More information about the erlang-questions