In the design and analysis of real-time systems, accurate timing measurement of various events in the system is required for validation purposes. In this paper, we present the design and implementation of a time-tracing hardware that gathers timing information on the execution of programs including the operating system. The hardware traces the timing behavior of programs including the total execution times, the time consumed in the system calls of the operating system, the time spent by the scheduler, etc. The results show that the hardware measures the execution times of programs with a resolution of 50 ns, while incurring only a small amount of overhead in the execution time. The timing information that this hardware provides can be used for validating various aspects of real-time systems such as worst case execution time analysis and schedulability analysis.