syscall emulation: fix DPRINTF arg ordering bug
When we switched getSyscallArg() from explicit arg indices to the implicit method, some DPRINTF arguments were left as calls to getSyscallArg(), even though C/C++ doesn't guarantee anything about the order of invocation of these calls. As a result, the args could be printed out in arbitrary orders. Interestingly, this bug has been around since 2009: http://repo.gem5.org/gem5/rev/4842482e1bd1
This commit is contained in:
parent
59c8c454eb
commit
f5aace8300
1 changed files with 17 additions and 14 deletions
|
@ -55,16 +55,19 @@ using namespace TheISA;
|
||||||
void
|
void
|
||||||
SyscallDesc::doSyscall(int callnum, LiveProcess *process, ThreadContext *tc)
|
SyscallDesc::doSyscall(int callnum, LiveProcess *process, ThreadContext *tc)
|
||||||
{
|
{
|
||||||
#if TRACING_ON
|
if (DTRACE(SyscallVerbose)) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
#endif
|
IntReg arg[4];
|
||||||
DPRINTFR(SyscallVerbose,
|
|
||||||
"%d: %s: syscall %s called w/arguments %d,%d,%d,%d\n",
|
// we can't just put the calls to getSyscallArg() in the
|
||||||
curTick(), tc->getCpuPtr()->name(), name,
|
// DPRINTF arg list, because C++ doesn't guarantee their order
|
||||||
process->getSyscallArg(tc, index),
|
for (int i = 0; i < 4; ++i)
|
||||||
process->getSyscallArg(tc, index),
|
arg[i] = process->getSyscallArg(tc, index);
|
||||||
process->getSyscallArg(tc, index),
|
|
||||||
process->getSyscallArg(tc, index));
|
DPRINTFNR("%d: %s: syscall %s called w/arguments %d,%d,%d,%d\n",
|
||||||
|
curTick(), tc->getCpuPtr()->name(), name,
|
||||||
|
arg[0], arg[1], arg[2], arg[3]);
|
||||||
|
}
|
||||||
|
|
||||||
SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
|
SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
|
||||||
|
|
||||||
|
@ -91,8 +94,8 @@ ignoreFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
||||||
ThreadContext *tc)
|
ThreadContext *tc)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
warn("ignoring syscall %s(%d, %d, ...)", desc->name,
|
warn("ignoring syscall %s(%d, ...)", desc->name,
|
||||||
process->getSyscallArg(tc, index), process->getSyscallArg(tc, index));
|
process->getSyscallArg(tc, index));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -103,8 +106,8 @@ ignoreWarnOnceFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
||||||
ThreadContext *tc)
|
ThreadContext *tc)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
warn_once("ignoring syscall %s(%d, %d, ...)", desc->name,
|
warn_once("ignoring syscall %s(%d, ...)", desc->name,
|
||||||
process->getSyscallArg(tc, index), process->getSyscallArg(tc, index));
|
process->getSyscallArg(tc, index));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue