QNX Topics

This appendix presents information specific to GNAT for QNX cross configurations.

Getting Started

This section is a starting point for using GNAT to develop and execute Ada programs for Blackberry’s QNX target environment. We assume that you know how to use GNAT in a native environment and how to start an ssh or other login session to connect to your board running QNX.

We also assume that you have installed the QNX Software Development platform.

To compile code for a QNX target using GNAT Pro, you will need to first set up your environment from the QNX Software Development platform. For example:

$ source ~/qnx-install/qnxsdp-env.sh

With GNAT, the easiest way to build the basic Hello World program is with gprbuild. For the aarch64 QNX target this would look like:

$ gprbuild --target=aarch64-nto-qnx hello
using project file .../_default.gpr
Compile
   [Ada]          hello.adb
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
 Link
   [link]         hello.adb

(The first line is the command entered by the user – the subsequent three are the programs run by gprbuild.)

This creates the executable hello, which you then need to load on the board to run it.

Integration with Momentics

The GNAT Pro toolchain can be integrated with the Momentics development environment by installing the GNATbench plugin. Once installed, comprehensive documentation on how to use GNATbench with QNX is available in the help menu.

Known Issues

Debugger Unable to Locate Source File (QNX 7.1)

After having inserted a breakpoint and resumed the program’s execution, the Debugger sometimes reports an error about not being able to find the breakpoint’s associated source file, with the error message showing that the debugger is trying to locate the source file using the wrong directory.

This issue has been reported to QNX, and in the meantime, you can work around it by using GDB’s dir command to indicate where to find your sources. For instance:

(gdb) dir /path/to/sources

You can use as many dir commands are you have source directories you would like to add.

Stack Size insufficient causing Storage Error or memory fault

The default stack size is determined by the system build, but sometimes this is inadequate. To increase the default size use the linker switches –stack <size> and optionally –lazy-stack (which will cause the stack to be allocated in 4K chunks rather than all at once). For example:

$ gprbuild --target=arm-qnx bigstack -largs -Wl,--stack -Wl,<size> -Wl,--lazy-stack

Alternatively, these linker switches could be put into a project file in the Linker section. See the gprbuild project file documentation for details.