When developers compile, build, and run their applications, they may encounter runtime errors or other problems. There are several methods to debug different issues on the compute module.

Additional debug information can be found in these topics:

Establishing a Serial Connection

The expansion board includes a Serial to USB bridge which provides a the channel to receive runtime message and send commands.

See the serial terminal setup guide.

Application Debugging

GDB on device usage

As the preferred debugger on Linux systems, GNU Debugger (GDB) is included with the Ref-OS-IoT image. GDB is free software protected by the GNU General Public License.

Note: For more information on GDB, visit: https://sourceware.org/gdb/current/onlinedocs/gdb.html.

Example:

Add the -g flag to include appropriate debug information on the generated binary to debug the native C application with GDB. You can compile it directly on the target module or cross-compile on a host and deploy to the target device after.

$CC -g -o helloworld hello_world.c

Start debugging and run the application with the following:

root@intel-5xx-64:~# gdb helloworld
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-refos-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from helloworld...done.
(gdb) run
Starting program: /home/root/helloworld
Hello world![Inferior 1 (process 1003) exited normally]

GDB remote usage

Pre-requirement:

By default, gdbserver is not included into the image, so you need to build your own custom image by adding the following line to local.conf:

REFKIT_IMAGE_EXTRA_FEATURES += “tools-debug”

When developing native applications, you will use a host machine to cross-compile the application and deploy it on the remote development board. To enable remote debugging, start gdbserver so that developers can debug binaries from the host machine remotely.

On the Intel® Joule™ module, open port 2345 and start gdbserver on it:

root@intel-5xx-64:~# iptables -A INPUT -p tcp --dport 2345 -j ACCEPT
root@intel-5xx-64:~# gdbserver :2345 helloworld
Process helloworld created; pid = 948
Listening on port 2345

On the host machine, run gdb, then connect target device using “target <target_ip>:<port>” command and run with “continue” as shown below:

$ gdb
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote 10.237.55.40:2345
^C10.237.55.40:2345: Interrupted system call.
(gdb) target remote 10.237.55.40:2345
Remote debugging using 10.237.55.40:2345
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0x00000038f4800c40 in ?? ()
(gdb) continue
Continuing.
[Inferior 1 (process 925) exited normally]
(gdb)

 

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.