Trace and debug

Logic debug

The utility GBD can be used for debugging C and C++ programs.

Timing debug

When a program uses dynamic memory allocation, it is posible introduce memory leaks. Therefore, to determine whether the heap was corrupted, the malloc debug library is available in QNX. This library provides several checking by default: allocation memory, reallocating memory and releasing memory. Moreover, the mallopt() function allows optional checks: MALLOC_CKACCESS to detect buffer overruns and underruns as a result of string operations, MALLOC_FILLAREA to detect overruns as a result of user request size, MALLOC_CKCHAIN and MALLOC_VERIFY.

Furthermore, is important to note that when the library detects a problem, a message error is generated and the program is aborted. This behavior can be change specifying a handler that determines what is done when a warning o faltal error is detected.

Finally, this library provides the malloc_dump_unreferenced() function to trace and giving results. This function suspends all threads, performs the trace operation and prints messages of all memory leaks detected.

Other tracing mechanism utility called procnto-instr is provided by QNX. This module allows monitor the system execution in real time. Moreover, the TraceEvent() call can be used to generate custom events into the trace stream.