Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rrcall to get current time #2827

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/preload/rrcalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@
* process tree, such that it may run without seccomp.
*/
#define SYS_rrcall_detach_teleport (RR_CALL_BASE + 9)
/**
* Requests the current rr tick.
*/
#define SYS_rrcall_current_time (RR_CALL_BASE + 10)
13 changes: 13 additions & 0 deletions src/record_syscall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4771,6 +4771,19 @@ static Switchable rec_prepare_syscall_arch(RecordTask* t,

return ALLOW_SWITCH;
}
case SYS_rrcall_current_time: {
// Since this is "user" facing, we follow best practices for regular
// syscalls and make sure that unused arguments (in this case all of them)
// are zero.
bool arguments_are_zero = true;
Registers r = t->regs();
for (int i = 1; i <= 6; ++i) {
arguments_are_zero &= r.arg(i) == 0;
}
syscall_state.emulate_result(arguments_are_zero ? t->trace_time() : (uintptr_t)-EINVAL);
syscall_state.expect_errno = ENOSYS;
return PREVENT_SWITCH;
}

case Arch::brk:
case Arch::munmap:
Expand Down
4 changes: 4 additions & 0 deletions src/test/util_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ void rr_detach_teleport(void) {
test_assert(err == 0);
}

int rr_current_time(void) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is something supposed to use this function?

return syscall(SYS_rrcall_current_time, 0, 0, 0, 0, 0, 0);
}

#endif /* RRUTIL_INTERNAL_H */