}
SyscallReturn
-unimplementedFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+unimplementedFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
fatal("syscall %s (#%d) unimplemented.", desc->name(), callnum);
SyscallReturn
-ignoreFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+ignoreFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
if (desc->needWarning()) {
warn("ignoring syscall %s(...)%s", desc->name(), desc->warnOnce() ?
}
static SyscallReturn
-exitImpl(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc,
- bool group)
+exitImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool group)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int status = p->getSyscallArg(tc, index);
System *sys = tc->getSystemPtr();
}
SyscallReturn
-exitFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+exitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return exitImpl(desc, callnum, p, tc, false);
+ return exitImpl(desc, callnum, tc, false);
}
SyscallReturn
-exitGroupFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+exitGroupFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return exitImpl(desc, callnum, p, tc, true);
+ return exitImpl(desc, callnum, tc, true);
}
SyscallReturn
-getpagesizeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+getpagesizeFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
return (int)PageBytes;
}
SyscallReturn
-brkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+brkFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
// change brk addr to first arg
int index = 0;
+ auto p = tc->getProcessPtr();
Addr new_brk = p->getSyscallArg(tc, index);
std::shared_ptr<MemState> mem_state = p->memState;
}
SyscallReturn
-setTidAddressFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+setTidAddressFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
uint64_t tidPtr = process->getSyscallArg(tc, index);
process->childClearTID = tidPtr;
}
SyscallReturn
-closeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+closeFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
return p->fds->closeFDEntry(tgt_fd);
}
SyscallReturn
-lseekFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+lseekFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
uint64_t offs = p->getSyscallArg(tc, index);
int whence = p->getSyscallArg(tc, index);
SyscallReturn
-_llseekFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+_llseekFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
uint64_t offset_high = p->getSyscallArg(tc, index);
uint32_t offset_low = p->getSyscallArg(tc, index);
SyscallReturn
-munmapFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+munmapFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
// With mmap more fully implemented, it might be worthwhile to bite
// the bullet and implement munmap. Should allow us to reuse simulated
const char *hostname = "m5.eecs.umich.edu";
SyscallReturn
-gethostnameFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+gethostnameFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
Addr buf_ptr = p->getSyscallArg(tc, index);
int name_len = p->getSyscallArg(tc, index);
BufferArg name(buf_ptr, name_len);
}
SyscallReturn
-getcwdFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int result = 0;
int index = 0;
+ auto p = tc->getProcessPtr();
Addr buf_ptr = p->getSyscallArg(tc, index);
unsigned long size = p->getSyscallArg(tc, index);
BufferArg buf(buf_ptr, size);
}
SyscallReturn
-readlinkFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+readlinkFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return readlinkFunc(desc, callnum, process, tc, 0);
+ return readlinkFunc(desc, callnum, tc, 0);
}
SyscallReturn
-readlinkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc,
- int index)
+readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, int index)
{
string path;
+ auto p = tc->getProcessPtr();
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
return -EFAULT;
}
SyscallReturn
-unlinkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+unlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
- return unlinkHelper(desc, num, p, tc, 0);
+ return unlinkHelper(desc, num, tc, 0);
}
SyscallReturn
-unlinkHelper(SyscallDesc *desc, int num, Process *p, ThreadContext *tc,
- int index)
+unlinkHelper(SyscallDesc *desc, int num, ThreadContext *tc, int index)
{
string path;
+ auto p = tc->getProcessPtr();
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
return -EFAULT;
}
SyscallReturn
-linkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+linkFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
string path;
string new_path;
+ auto p = tc->getProcessPtr();
int index = 0;
auto &virt_mem = tc->getMemProxy();
}
SyscallReturn
-symlinkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
string path;
string new_path;
+ auto p = tc->getProcessPtr();
int index = 0;
auto &virt_mem = tc->getMemProxy();
}
SyscallReturn
-mkdirFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
+ auto p = tc->getProcessPtr();
int index = 0;
std::string path;
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
}
SyscallReturn
-renameFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+renameFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
string old_name;
+ auto p = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(old_name, p->getSyscallArg(tc, index)))
}
SyscallReturn
-truncateFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
string path;
+ auto p = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
}
SyscallReturn
-ftruncateFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+ftruncateFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
off_t length = p->getSyscallArg(tc, index);
}
SyscallReturn
-truncate64Func(SyscallDesc *desc, int num,
- Process *process, ThreadContext *tc)
+truncate64Func(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
string path;
if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index)))
}
SyscallReturn
-ftruncate64Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
int64_t length = p->getSyscallArg(tc, index, 64);
}
SyscallReturn
-umaskFunc(SyscallDesc *desc, int num, Process *process, ThreadContext *tc)
+umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
// Letting the simulated program change the simulator's umask seems like
// a bad idea. Compromise by just returning the current umask but not
}
SyscallReturn
-chownFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+chownFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
string path;
+ auto p = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
}
SyscallReturn
-fchownFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+fchownFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
* for the fd entries that we maintain for checkpoint restoration.
*/
SyscallReturn
-dupFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+dupFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
auto old_hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*p->fds)[tgt_fd]);
}
SyscallReturn
-dup2Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+dup2Func(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
-
+ auto p = tc->getProcessPtr();
int old_tgt_fd = p->getSyscallArg(tc, index);
auto old_hbp = std::dynamic_pointer_cast<HBFDEntry>((*p->fds)[old_tgt_fd]);
if (!old_hbp)
}
SyscallReturn
-fcntlFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int arg;
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
int cmd = p->getSyscallArg(tc, index);
}
SyscallReturn
-fcntl64Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
auto hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*p->fds)[tgt_fd]);
}
SyscallReturn
-pipeImpl(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc,
- bool pseudoPipe)
+pipeImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool pseudoPipe)
{
int sim_fds[2], tgt_fds[2];
+ auto p = tc->getProcessPtr();
int pipe_retval = pipe(sim_fds);
if (pipe_retval == -1)
}
SyscallReturn
-pipePseudoFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+pipePseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return pipeImpl(desc, callnum, process, tc, true);
+ return pipeImpl(desc, callnum, tc, true);
}
SyscallReturn
-pipeFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
+pipeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return pipeImpl(desc, callnum, process, tc, false);
+ return pipeImpl(desc, callnum, tc, false);
}
SyscallReturn
-setpgidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+setpgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int pid = process->getSyscallArg(tc, index);
int pgid = process->getSyscallArg(tc, index);
}
SyscallReturn
-getpidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getpidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
// Make up a PID. There's no interprocess communication in
// fake_syscall mode, so there's no way for a process to know it's
// not getting a unique value.
+ auto process = tc->getProcessPtr();
tc->setIntReg(SyscallPseudoReturnReg, process->ppid());
return process->pid();
}
SyscallReturn
-getuidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getuidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
// Make up a UID and EUID... it shouldn't matter, and we want the
// simulation to be deterministic.
// EUID goes in r20.
+ auto process = tc->getProcessPtr();
tc->setIntReg(SyscallPseudoReturnReg, process->euid()); // EUID
return process->uid(); // UID
}
SyscallReturn
-getgidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getgidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
// Get current group ID. EGID goes in r20.
+ auto process = tc->getProcessPtr();
tc->setIntReg(SyscallPseudoReturnReg, process->egid()); // EGID
return process->gid();
}
SyscallReturn
-setuidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+setuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
// can't fathom why a benchmark would call this.
int index = 0;
+ auto process = tc->getProcessPtr();
warn("Ignoring call to setuid(%d)\n", process->getSyscallArg(tc, index));
return 0;
}
SyscallReturn
-getpidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getpidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
+ auto process = tc->getProcessPtr();
return process->tgid();
}
SyscallReturn
-gettidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+gettidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
+ auto process = tc->getProcessPtr();
return process->pid();
}
SyscallReturn
-getppidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getppidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
+ auto process = tc->getProcessPtr();
return process->ppid();
}
SyscallReturn
-getuidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
+ auto process = tc->getProcessPtr();
return process->uid(); // UID
}
SyscallReturn
-geteuidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+geteuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
+ auto process = tc->getProcessPtr();
return process->euid(); // UID
}
SyscallReturn
-getgidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
+ auto process = tc->getProcessPtr();
return process->gid();
}
SyscallReturn
-getegidFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getegidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
+ auto process = tc->getProcessPtr();
return process->egid();
}
SyscallReturn
-fallocateFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+fallocateFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
#if defined(__linux__)
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
int mode = p->getSyscallArg(tc, index);
off_t offset = p->getSyscallArg(tc, index);
}
SyscallReturn
-accessFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc,
- int index)
+accessFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int index)
{
string path;
+ auto p = tc->getProcessPtr();
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
return -EFAULT;
}
SyscallReturn
-accessFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+accessFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return accessFunc(desc, callnum, p, tc, 0);
+ return accessFunc(desc, callnum, tc, 0);
}
SyscallReturn
-mknodFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+mknodFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
+ auto p = tc->getProcessPtr();
int index = 0;
std::string path;
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
}
SyscallReturn
-chdirFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+chdirFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
+ auto p = tc->getProcessPtr();
int index = 0;
std::string path;
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
}
SyscallReturn
-rmdirFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+rmdirFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
+ auto p = tc->getProcessPtr();
int index = 0;
std::string path;
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
#if defined(SYS_getdents) || defined(SYS_getdents64)
template<typename DE, int SYS_NUM>
static SyscallReturn
-getdentsImpl(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+getdentsImpl(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr buf_ptr = p->getSyscallArg(tc, index);
unsigned count = p->getSyscallArg(tc, index);
#if defined(SYS_getdents)
SyscallReturn
-getdentsFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+getdentsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
typedef struct linux_dirent {
unsigned long d_ino;
char dname[];
} LinDent;
- return getdentsImpl<LinDent, SYS_getdents>(desc, callnum, p, tc);
+ return getdentsImpl<LinDent, SYS_getdents>(desc, callnum, tc);
}
#endif
#if defined(SYS_getdents64)
SyscallReturn
-getdents64Func(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+getdents64Func(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
typedef struct linux_dirent64 {
ino64_t d_ino;
char dname[];
} LinDent64;
- return getdentsImpl<LinDent64, SYS_getdents64>(desc, callnum, p, tc);
+ return getdentsImpl<LinDent64, SYS_getdents64>(desc, callnum, tc);
}
#endif
SyscallReturn
-shutdownFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+shutdownFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
int how = p->getSyscallArg(tc, index);
}
SyscallReturn
-bindFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+bindFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr buf_ptr = p->getSyscallArg(tc, index);
int addrlen = p->getSyscallArg(tc, index);
}
SyscallReturn
-listenFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+listenFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
int backlog = p->getSyscallArg(tc, index);
}
SyscallReturn
-connectFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+connectFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr buf_ptr = p->getSyscallArg(tc, index);
int addrlen = p->getSyscallArg(tc, index);
}
SyscallReturn
-recvfromFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+recvfromFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr bufrPtr = p->getSyscallArg(tc, index);
size_t bufrLen = p->getSyscallArg(tc, index);
}
SyscallReturn
-sendtoFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+sendtoFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr bufrPtr = p->getSyscallArg(tc, index);
size_t bufrLen = p->getSyscallArg(tc, index);
}
SyscallReturn
-recvmsgFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr msgPtr = p->getSyscallArg(tc, index);
int flags = p->getSyscallArg(tc, index);
}
SyscallReturn
-sendmsgFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr msgPtr = p->getSyscallArg(tc, index);
int flags = p->getSyscallArg(tc, index);
}
SyscallReturn
-getsockoptFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+getsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
// union of all possible return value types from getsockopt
union val {
} val;
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
int level = p->getSyscallArg(tc, index);
int optname = p->getSyscallArg(tc, index);
}
SyscallReturn
-getsocknameFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr addrPtr = p->getSyscallArg(tc, index);
Addr lenPtr = p->getSyscallArg(tc, index);
}
SyscallReturn
-getpeernameFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+getpeernameFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr sockAddrPtr = p->getSyscallArg(tc, index);
Addr addrlenPtr = p->getSyscallArg(tc, index);
}
SyscallReturn
-setsockoptFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+setsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
int level = p->getSyscallArg(tc, index);
int optname = p->getSyscallArg(tc, index);
void warnUnsupportedOS(std::string syscall_name);
/// Handler for unimplemented syscalls that we haven't thought about.
-SyscallReturn unimplementedFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn unimplementedFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Handler for unimplemented syscalls that we never intend to
/// implement (signal handling, etc.) and should not affect the correct
/// behavior of the program. Print a warning only if the appropriate
/// trace flag is enabled. Return success to the target program.
-SyscallReturn ignoreFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn ignoreFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target fallocateFunc() handler.
-SyscallReturn fallocateFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn fallocateFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target exit() handler: terminate current context.
-SyscallReturn exitFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn exitFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target exit_group() handler: terminate simulation. (exit all threads)
-SyscallReturn exitGroupFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn exitGroupFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target set_tid_address() handler.
-SyscallReturn setTidAddressFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn setTidAddressFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getpagesize() handler.
-SyscallReturn getpagesizeFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getpagesizeFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target brk() handler: set brk address.
-SyscallReturn brkFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn brkFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target close() handler.
-SyscallReturn closeFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn closeFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target lseek() handler.
-SyscallReturn lseekFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn lseekFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target _llseek() handler.
-SyscallReturn _llseekFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn _llseekFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target munmap() handler.
-SyscallReturn munmapFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn munmapFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target shutdown() handler.
-SyscallReturn shutdownFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn shutdownFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target gethostname() handler.
-SyscallReturn gethostnameFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn gethostnameFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getcwd() handler.
-SyscallReturn getcwdFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target readlink() handler.
-SyscallReturn readlinkFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc,
+SyscallReturn readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
int index = 0);
-SyscallReturn readlinkFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target unlink() handler.
-SyscallReturn unlinkHelper(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc,
+SyscallReturn unlinkHelper(SyscallDesc *desc, int num, ThreadContext *tc,
int index);
-SyscallReturn unlinkFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn unlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target link() handler
-SyscallReturn linkFunc(SyscallDesc *desc, int num, Process *p,
- ThreadContext *tc);
+SyscallReturn linkFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target symlink() handler.
-SyscallReturn symlinkFunc(SyscallDesc *desc, int num, Process *p,
- ThreadContext *tc);
+SyscallReturn symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target mkdir() handler.
-SyscallReturn mkdirFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target mknod() handler.
-SyscallReturn mknodFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn mknodFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target chdir() handler.
-SyscallReturn chdirFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn chdirFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target rmdir() handler.
-SyscallReturn rmdirFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn rmdirFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target rename() handler.
-SyscallReturn renameFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn renameFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target truncate() handler.
-SyscallReturn truncateFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target ftruncate() handler.
-SyscallReturn ftruncateFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn ftruncateFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target truncate64() handler.
-SyscallReturn truncate64Func(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn truncate64Func(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target ftruncate64() handler.
-SyscallReturn ftruncate64Func(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target umask() handler.
-SyscallReturn umaskFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target gettid() handler.
-SyscallReturn gettidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn gettidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target chown() handler.
-SyscallReturn chownFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn chownFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target setpgid() handler.
-SyscallReturn setpgidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn setpgidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target fchown() handler.
-SyscallReturn fchownFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn fchownFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target dup() handler.
-SyscallReturn dupFunc(SyscallDesc *desc, int num,
- Process *process, ThreadContext *tc);
+SyscallReturn dupFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target dup2() handler.
-SyscallReturn dup2Func(SyscallDesc *desc, int num,
- Process *process, ThreadContext *tc);
+SyscallReturn dup2Func(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target fcntl() handler.
-SyscallReturn fcntlFunc(SyscallDesc *desc, int num,
- Process *process, ThreadContext *tc);
+SyscallReturn fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target fcntl64() handler.
-SyscallReturn fcntl64Func(SyscallDesc *desc, int num,
- Process *process, ThreadContext *tc);
+SyscallReturn fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target setuid() handler.
-SyscallReturn setuidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn setuidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target pipe() handler.
-SyscallReturn pipeFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn pipeFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Internal pipe() handler.
-SyscallReturn pipeImpl(SyscallDesc *desc, int num, Process *p,
- ThreadContext *tc, bool pseudoPipe);
+SyscallReturn pipeImpl(SyscallDesc *desc, int num, ThreadContext *tc,
+ bool pseudoPipe);
/// Target getpid() handler.
-SyscallReturn getpidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getpidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target getpeername() handler.
-SyscallReturn getpeernameFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getpeernameFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target bind() handler.
-SyscallReturn bindFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn bindFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target listen() handler.
-SyscallReturn listenFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn listenFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target connect() handler.
-SyscallReturn connectFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn connectFunc(SyscallDesc *desc, int num, ThreadContext *tc);
#if defined(SYS_getdents)
// Target getdents() handler.
-SyscallReturn getdentsFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getdentsFunc(SyscallDesc *desc, int num, ThreadContext *tc);
#endif
#if defined(SYS_getdents64)
// Target getdents() handler.
-SyscallReturn getdents64Func(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getdents64Func(SyscallDesc *desc, int num, ThreadContext *tc);
#endif
// Target sendto() handler.
-SyscallReturn sendtoFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn sendtoFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target recvfrom() handler.
-SyscallReturn recvfromFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn recvfromFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target recvmsg() handler.
-SyscallReturn recvmsgFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target sendmsg() handler.
-SyscallReturn sendmsgFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target getuid() handler.
-SyscallReturn getuidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getuidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getgid() handler.
-SyscallReturn getgidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getgidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getppid() handler.
-SyscallReturn getppidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getppidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target geteuid() handler.
-SyscallReturn geteuidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn geteuidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getegid() handler.
-SyscallReturn getegidFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getegidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target access() handler
-SyscallReturn accessFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
-SyscallReturn accessFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc,
+SyscallReturn accessFunc(SyscallDesc *desc, int num, ThreadContext *tc);
+SyscallReturn accessFunc(SyscallDesc *desc, int num, ThreadContext *tc,
int index);
// Target getsockopt() handler.
-SyscallReturn getsockoptFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target setsockopt() handler.
-SyscallReturn setsockoptFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn setsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc);
// Target getsockname() handler.
-SyscallReturn getsocknameFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Futex system call
/// Implemented by Daniel Sanchez
/// Used by printf's in multi-threaded apps
template <class OS>
SyscallReturn
-futexFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+futexFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
using namespace std;
int index = 0;
+ auto process = tc->getProcessPtr();
+
Addr uaddr = process->getSyscallArg(tc, index);
int op = process->getSyscallArg(tc, index);
int val = process->getSyscallArg(tc, index);
/// Pseudo Funcs - These functions use a different return convension,
/// returning a second value in a register other than the normal return register
-SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num,
- Process *process, ThreadContext *tc);
+SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getpidPseudo() handler.
-SyscallReturn getpidPseudoFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getpidPseudoFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getuidPseudo() handler.
-SyscallReturn getuidPseudoFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getuidPseudoFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// Target getgidPseudo() handler.
-SyscallReturn getgidPseudoFunc(SyscallDesc *desc, int num,
- Process *p, ThreadContext *tc);
+SyscallReturn getgidPseudoFunc(SyscallDesc *desc, int num, ThreadContext *tc);
/// A readable name for 1,000,000, for converting microseconds to seconds.
/// not TTYs to provide repeatable results.
template <class OS>
SyscallReturn
-ioctlFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
+
int tgt_fd = p->getSyscallArg(tc, index);
unsigned req = p->getSyscallArg(tc, index);
if (dfdp) {
EmulatedDriver *emul_driver = dfdp->getDriver();
if (emul_driver)
- return emul_driver->ioctl(p, tc, req);
+ return emul_driver->ioctl(tc, req);
}
auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*p->fds)[tgt_fd]);
template <class OS>
SyscallReturn
-openImpl(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc,
- bool isopenat)
+openImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool isopenat)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_dirfd = -1;
/**
DPRINTF_SYSCALL(Verbose, "open%s: passing call to "
"driver open with path[%s]\n",
isopenat ? "at" : "", abs_path.c_str());
- return drv->open(p, tc, mode, host_flags);
+ return drv->open(tc, mode, host_flags);
}
/**
* Fall through here for pass through to host devices, such
/// Target open() handler.
template <class OS>
SyscallReturn
-openFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+openFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return openImpl<OS>(desc, callnum, process, tc, false);
+ return openImpl<OS>(desc, callnum, tc, false);
}
/// Target openat() handler.
template <class OS>
SyscallReturn
-openatFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+openatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
- return openImpl<OS>(desc, callnum, process, tc, true);
+ return openImpl<OS>(desc, callnum, tc, true);
}
/// Target unlinkat() handler.
template <class OS>
SyscallReturn
-unlinkatFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+unlinkatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int dirfd = process->getSyscallArg(tc, index);
if (dirfd != OS::TGT_AT_FDCWD)
warn("unlinkat: first argument not AT_FDCWD; unlikely to work");
- return unlinkHelper(desc, callnum, process, tc, 1);
+ return unlinkHelper(desc, callnum, tc, 1);
}
/// Target facessat() handler
template <class OS>
SyscallReturn
-faccessatFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+faccessatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int dirfd = process->getSyscallArg(tc, index);
if (dirfd != OS::TGT_AT_FDCWD)
warn("faccessat: first argument not AT_FDCWD; unlikely to work");
- return accessFunc(desc, callnum, process, tc, 1);
+ return accessFunc(desc, callnum, tc, 1);
}
/// Target readlinkat() handler
template <class OS>
SyscallReturn
-readlinkatFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+readlinkatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int dirfd = process->getSyscallArg(tc, index);
if (dirfd != OS::TGT_AT_FDCWD)
warn("openat: first argument not AT_FDCWD; unlikely to work");
- return readlinkFunc(desc, callnum, process, tc, 1);
+ return readlinkFunc(desc, callnum, tc, 1);
}
/// Target renameat() handler.
template <class OS>
SyscallReturn
-renameatFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+renameatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int olddirfd = process->getSyscallArg(tc, index);
if (olddirfd != OS::TGT_AT_FDCWD)
/// Target sysinfo() handler.
template <class OS>
SyscallReturn
-sysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+sysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
-
int index = 0;
+ auto process = tc->getProcessPtr();
+
TypedBufferArg<typename OS::tgt_sysinfo>
sysinfo(process->getSyscallArg(tc, index));
/// Target chmod() handler.
template <class OS>
SyscallReturn
-chmodFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+chmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
std::string path;
+ auto process = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path,
template <class OS>
SyscallReturn
-pollFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+pollFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
Addr fdsPtr = p->getSyscallArg(tc, index);
int nfds = p->getSyscallArg(tc, index);
int tmout = p->getSyscallArg(tc, index);
/// Target fchmod() handler.
template <class OS>
SyscallReturn
-fchmodFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+fchmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
uint32_t mode = p->getSyscallArg(tc, index);
/// Target mremap() handler.
template <class OS>
SyscallReturn
-mremapFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
+mremapFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
Addr start = process->getSyscallArg(tc, index);
uint64_t old_length = process->getSyscallArg(tc, index);
uint64_t new_length = process->getSyscallArg(tc, index);
/// Target stat() handler.
template <class OS>
SyscallReturn
-statFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+statFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
std::string path;
+ auto process = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path,
/// Target stat64() handler.
template <class OS>
SyscallReturn
-stat64Func(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+stat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
std::string path;
+ auto process = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path,
/// Target fstatat64() handler.
template <class OS>
SyscallReturn
-fstatat64Func(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+fstatat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int dirfd = process->getSyscallArg(tc, index);
if (dirfd != OS::TGT_AT_FDCWD)
warn("fstatat64: first argument not AT_FDCWD; unlikely to work");
/// Target fstat64() handler.
template <class OS>
SyscallReturn
-fstat64Func(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+fstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr bufPtr = p->getSyscallArg(tc, index);
/// Target lstat() handler.
template <class OS>
SyscallReturn
-lstatFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+lstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
std::string path;
+ auto process = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path,
/// Target lstat64() handler.
template <class OS>
SyscallReturn
-lstat64Func(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+lstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
std::string path;
+ auto process = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path,
/// Target fstat() handler.
template <class OS>
SyscallReturn
-fstatFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+fstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr bufPtr = p->getSyscallArg(tc, index);
/// Target statfs() handler.
template <class OS>
SyscallReturn
-statfsFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+statfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
#if defined(__linux__)
std::string path;
+ auto process = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path,
template <class OS>
SyscallReturn
-cloneFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
RegVal flags = p->getSyscallArg(tc, index);
RegVal newStack = p->getSyscallArg(tc, index);
Addr ptidPtr = p->getSyscallArg(tc, index);
/// Target fstatfs() handler.
template <class OS>
SyscallReturn
-fstatfsFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+fstatfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr bufPtr = p->getSyscallArg(tc, index);
/// Target readv() handler.
template <class OS>
SyscallReturn
-readvFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+readvFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
/// Target writev() handler.
template <class OS>
SyscallReturn
-writevFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+writevFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
auto hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*p->fds)[tgt_fd]);
/// Real mmap handler.
template <class OS>
SyscallReturn
-mmapImpl(SyscallDesc *desc, int num, Process *p, ThreadContext *tc,
- bool is_mmap2)
+mmapImpl(SyscallDesc *desc, int num, ThreadContext *tc, bool is_mmap2)
{
int index = 0;
+ auto p = tc->getProcessPtr();
Addr start = p->getSyscallArg(tc, index);
uint64_t length = p->getSyscallArg(tc, index);
int prot = p->getSyscallArg(tc, index);
auto dfdp = std::dynamic_pointer_cast<DeviceFDEntry>(fdep);
if (dfdp) {
EmulatedDriver *emul_driver = dfdp->getDriver();
- return emul_driver->mmap(p, tc, start, length, prot,
- tgt_flags, tgt_fd, offset);
+ return emul_driver->mmap(tc, start, length, prot, tgt_flags,
+ tgt_fd, offset);
}
auto ffdp = std::dynamic_pointer_cast<FileFDEntry>(fdep);
template <class OS>
SyscallReturn
-pwrite64Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+pwrite64Func(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr bufPtr = p->getSyscallArg(tc, index);
int nbytes = p->getSyscallArg(tc, index);
/// Target mmap() handler.
template <class OS>
SyscallReturn
-mmapFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+mmapFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
- return mmapImpl<OS>(desc, num, p, tc, false);
+ return mmapImpl<OS>(desc, num, tc, false);
}
/// Target mmap2() handler.
template <class OS>
SyscallReturn
-mmap2Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+mmap2Func(SyscallDesc *desc, int num, ThreadContext *tc)
{
- return mmapImpl<OS>(desc, num, p, tc, true);
+ return mmapImpl<OS>(desc, num, tc, true);
}
/// Target getrlimit() handler.
template <class OS>
SyscallReturn
-getrlimitFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getrlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
unsigned resource = process->getSyscallArg(tc, index);
TypedBufferArg<typename OS::rlimit> rlp(process->getSyscallArg(tc, index));
template <class OS>
SyscallReturn
-prlimitFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+prlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
if (process->getSyscallArg(tc, index) != 0)
{
warn("prlimit: ignoring rlimits for nonzero pid");
/// Target clock_gettime() function.
template <class OS>
SyscallReturn
-clock_gettimeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+clock_gettimeFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 1;
+ auto p = tc->getProcessPtr();
//int clk_id = p->getSyscallArg(tc, index);
TypedBufferArg<typename OS::timespec> tp(p->getSyscallArg(tc, index));
/// Target clock_getres() function.
template <class OS>
SyscallReturn
-clock_getresFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+clock_getresFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 1;
+ auto p = tc->getProcessPtr();
TypedBufferArg<typename OS::timespec> tp(p->getSyscallArg(tc, index));
// Set resolution at ns, which is what clock_gettime() returns
/// Target gettimeofday() handler.
template <class OS>
SyscallReturn
-gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+gettimeofdayFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
TypedBufferArg<typename OS::timeval> tp(process->getSyscallArg(tc, index));
getElapsedTimeMicro(tp->tv_sec, tp->tv_usec);
/// Target utimes() handler.
template <class OS>
SyscallReturn
-utimesFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+utimesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
std::string path;
+ auto process = tc->getProcessPtr();
int index = 0;
if (!tc->getMemProxy().tryReadString(path,
template <class OS>
SyscallReturn
-execveFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+execveFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
desc->setFlags(0);
+ auto p = tc->getProcessPtr();
int index = 0;
std::string path;
/// Target getrusage() function.
template <class OS>
SyscallReturn
-getrusageFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+getrusageFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int who = process->getSyscallArg(tc, index); // THREAD, SELF, or CHILDREN
TypedBufferArg<typename OS::rusage> rup(process->getSyscallArg(tc, index));
/// Target times() function.
template <class OS>
SyscallReturn
-timesFunc(SyscallDesc *desc, int callnum, Process *process,
- ThreadContext *tc)
+timesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
TypedBufferArg<typename OS::tms> bufp(process->getSyscallArg(tc, index));
// Fill in the time structure (in clocks)
/// Target time() function.
template <class OS>
SyscallReturn
-timeFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
+timeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
typename OS::time_t sec, usec;
getElapsedTimeMicro(sec, usec);
sec += seconds_since_epoch;
int index = 0;
+ auto process = tc->getProcessPtr();
Addr taddr = (Addr)process->getSyscallArg(tc, index);
if (taddr != 0) {
typename OS::time_t t = sec;
template <class OS>
SyscallReturn
-tgkillFunc(SyscallDesc *desc, int num, Process *process, ThreadContext *tc)
+tgkillFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto process = tc->getProcessPtr();
int tgid = process->getSyscallArg(tc, index);
int tid = process->getSyscallArg(tc, index);
int sig = process->getSyscallArg(tc, index);
return -ESRCH;
if (sig == OS::TGT_SIGABRT)
- exitGroupFunc(desc, 252, process, tc);
+ exitGroupFunc(desc, 252, tc);
return 0;
}
template <class OS>
SyscallReturn
-socketFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+socketFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int domain = p->getSyscallArg(tc, index);
int type = p->getSyscallArg(tc, index);
int prot = p->getSyscallArg(tc, index);
template <class OS>
SyscallReturn
-socketpairFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+socketpairFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int domain = p->getSyscallArg(tc, index);
int type = p->getSyscallArg(tc, index);
int prot = p->getSyscallArg(tc, index);
template <class OS>
SyscallReturn
-selectFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+selectFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
{
int retval;
int index = 0;
+ auto p = tc->getProcessPtr();
int nfds_t = p->getSyscallArg(tc, index);
Addr fds_read_ptr = p->getSyscallArg(tc, index);
Addr fds_writ_ptr = p->getSyscallArg(tc, index);
template <class OS>
SyscallReturn
-readFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+readFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr buf_ptr = p->getSyscallArg(tc, index);
int nbytes = p->getSyscallArg(tc, index);
template <class OS>
SyscallReturn
-writeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+writeFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr buf_ptr = p->getSyscallArg(tc, index);
int nbytes = p->getSyscallArg(tc, index);
template <class OS>
SyscallReturn
-wait4Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+wait4Func(SyscallDesc *desc, int num, ThreadContext *tc)
{
int index = 0;
+ auto p = tc->getProcessPtr();
pid_t pid = p->getSyscallArg(tc, index);
Addr statPtr = p->getSyscallArg(tc, index);
int options = p->getSyscallArg(tc, index);
template <class OS>
SyscallReturn
-acceptFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+acceptFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
struct sockaddr sa;
socklen_t addrLen;
int host_fd;
int index = 0;
+ auto p = tc->getProcessPtr();
int tgt_fd = p->getSyscallArg(tc, index);
Addr addrPtr = p->getSyscallArg(tc, index);
Addr lenPtr = p->getSyscallArg(tc, index);
/// Target eventfd() function.
template <class OS>
SyscallReturn
-eventfdFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+eventfdFunc(SyscallDesc *desc, int num, ThreadContext *tc)
{
#if defined(__linux__)
int index = 0;
+ auto p = tc->getProcessPtr();
unsigned initval = p->getSyscallArg(tc, index);
int in_flags = p->getSyscallArg(tc, index);