Comparing guest and host timelines

You can use information from trace events to compare timelines of events in the guest and the host.

The following is an example of trace event output that can be used to compare the guest and host at timestamp counts (TSCs) when a specific event occurs:

t:0x2ebe7b16b CPU:00 QVM :GUEST_ENTER guest_ip:0x00000000fe087700
t:0x2ebe7c20c CPU:00 QVM :CYCLES
at_entry:0x0000000068ed5b7f
at_exit:0x0000000068ed620e
t:0x2ebe7c6f7 CPU:00 QVM :GUEST_EXIT
status:0x00000000
hw_reason:0x07e00000
clockcycles_offset:0xfffffffd7d05a4eb
guest_ip:0x00000000fc4047f0
payload:0x0000000000000000

where:

The host necessarily begins counting before the guest, so the host timestamp count will always be greater than the guest timestamp.

To obtain values that can be used for a meaningful comparison of when an event occured for the guest with when it occured for the host, you need to:

  1. Construct a timeline for the guest with at_entry/at_exit event pairs.
  2. Construct a timeline for the host with the same at_entry/at_exit event pairs, combined with the value in clockcycles_offset at the guest exit.

    As you construct your host timeline, note which event pair in the host corresponds to which event pair in the guest.

Anything that occurs between an at_entry and at_exit event pair in the guest will have occured between the corresponding event pair in the host. For example, an event that occured between the at_entry and at_exit event pair in the output above will have occured in the host between:

(0x0000000068ed5b7f - 0xfffffffd7d05a4eb) = 0x2ebe7b694

and:

(0x0000000068ed620e - 0xfffffffd7d05a4eb) = 0x2ebe7bd23
Note:

Remember that:

  • The value of clockcycles_offset will vary due to time drift.
  • Any ClockCycles() value outside the at_entry/at_exit intervals will never be observed by a guest.

See Time in the Understanding QNX Virtual Environments chapter, and Finding the current time drift in this chapter.