This is easiest done with a processor with built-in trace, the design of the board that provides the trace port, and a suitable hardware debugger and associated software. For example, many Cortex-M-based devices include an integrated ARM microprocessor chip (ETM), and this is supported by the Keil uVision IDE and ULINK-Pro debugger to provide code coverage and command / source level tracking, as well as real-time profiling. Hardware tracing has the advantage that it is not intrusive - the code works in real time.
If you do not have hardware support, you may have to resort to a simulation. Many tool chains include an instruction level simulator that will perform tracing, code coverage, and profiling, but you may have to create debug scripts or code stubs to simulate hardware to force all paths to be executed.
A third alternative is to create code on a desktop platform with stubs to replace target hardware dependencies and perform testing and code coverage. You must believe that the target C compiler and the test system compiler translate the source with identical semantics. The advantage here is that affordable debugging tools often outperform those available for embedded systems. You can also test most of your code before any hardware is available, and in most cases run the code much faster, possibly allowing for more extensive testing.
Having no POSIX API does not preclude the use of GCC, it simply eliminates the use of the GNU C library. On embedded systems without POSIX, alternative C libraries such as Newlib are used. Newlib has a system transfer layer in which I / O and database management operations are implemented.
Clifford
source share