File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33#include " DebuggerExtensionCommand.h"
44
55#include " ReplayTask.h"
6+ #include " TraceFrame.h"
67#include " log.h"
78
89using namespace std ;
@@ -25,6 +26,17 @@ static SimpleDebuggerExtensionCommand elapsed_time(
2526 return string (" Elapsed Time (s): " ) + to_string (elapsed_time);
2627 });
2728
29+ static SimpleDebuggerExtensionCommand absolute_time (
30+ " absolute-time" ,
31+ " Print absolute time (in seconds) from the monotonic clock in the"
32+ " 'record' timeline." ,
33+ [](GdbServer&, Task* t, const vector<string>&) {
34+ auto replay_t = static_cast <ReplayTask*>(t);
35+ auto elapsed_time = replay_t ->current_trace_frame ().monotonic_time ();
36+
37+ return string (" Absolute Time (s): " ) + to_string (elapsed_time);
38+ });
39+
2840static SimpleDebuggerExtensionCommand when (
2941 " when" , " Print the number of the last completely replayed rr event." ,
3042 [](GdbServer&, Task* t, const vector<string>&) {
Original file line number Diff line number Diff line change 1+ import time
2+
13from util import *
24import re
35
6+ # Get monotonic timer value from right now
7+ monotonic_start = time.monotonic()
8+
9+ send_gdb("absolute-time")
10+ expect_gdb(re.compile(r'(?<=Absolute Time \(s\): )[0-9.]+'))
11+ absolute_time_start = float(last_match().group(0))
12+
13+ if absolute_time_start > monotonic_start:
14+ failed("ERROR ... The reported monotonic time at the start was after the test script started")
15+ if absolute_time_start < monotonic_start - 300:
16+ failed("ERROR ... The reported monotonic time at the start was over five minutes before the test script started")
17+
18+ send_gdb('elapsed-time')
19+
20+ expect_gdb(re.compile(r'(?<=Elapsed Time \(s\): )[0-9.]+'))
21+ elapsed_start = float(last_match().group(0))
22+
423# Test that the elapsed-time GDB command returns a time >= 1.0 at a breakpoint
524# after sleep(1);
625
1837 failed('ERROR ... The reported elapsed time after sleeping for ' +
1938 f'{sleep_time} (s) was {elapsed_time}')
2039
40+ send_gdb("absolute-time")
41+ expect_gdb(re.compile(r'(?<=Absolute Time \(s\): )[0-9.]+'))
42+ absolute_time_end = float(last_match().group(0))
43+
44+ sleep_time_absolute = absolute_time_end - absolute_time_start
45+ sleep_time_relative = elapsed_time - elapsed_start
46+
47+ if abs(sleep_time_absolute - sleep_time_relative) > 0.0001:
48+ failed(f"ERROR ... The sleep time reported by absolute-time vs elapsed-time was too far apart (should be as equal as double allows): {sleep_time_absolute} - {sleep_time_relative} = {sleep_time_absolute - sleep_time_relative}" )
49+
2150ok()
You can’t perform that action at this time.
0 commit comments