changeset 3370547fa302 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=3370547fa302
description:
        syscall_emul: add extra debug support for syscalls

        Breaks the debug output from system calls into two levels: Base and 
Verbose.
        A macro is added specifically for system calls which allows developers 
to
        easily add new debug messages in a consistent manner. The macro also 
contains
        a field to print thread IDs along with the CPU ID.

diffstat:

 src/sim/SConscript      |   3 +++
 src/sim/syscall_emul.cc |  27 ++++++++++++++++-----------
 src/sim/syscall_emul.hh |  11 ++++++++++-
 3 files changed, 29 insertions(+), 12 deletions(-)

diffs (115 lines):

diff -r bfe4c2a8ad36 -r 3370547fa302 src/sim/SConscript
--- a/src/sim/SConscript        Thu Mar 17 10:22:39 2016 -0700
+++ b/src/sim/SConscript        Thu Mar 17 10:22:39 2016 -0700
@@ -91,6 +91,7 @@
 DebugFlag('Loader')
 DebugFlag('PseudoInst')
 DebugFlag('Stack')
+DebugFlag('SyscallBase')
 DebugFlag('SyscallVerbose')
 DebugFlag('TimeSync')
 DebugFlag('Thread')
@@ -100,3 +101,5 @@
 DebugFlag('ClockDomain')
 DebugFlag('VoltageDomain')
 DebugFlag('DVFS')
+
+CompoundFlag('SyscallAll', [ 'SyscallBase', 'SyscallVerbose'])
diff -r bfe4c2a8ad36 -r 3370547fa302 src/sim/syscall_emul.cc
--- a/src/sim/syscall_emul.cc   Thu Mar 17 10:22:39 2016 -0700
+++ b/src/sim/syscall_emul.cc   Thu Mar 17 10:22:39 2016 -0700
@@ -42,6 +42,7 @@
 #include "config/the_isa.hh"
 #include "cpu/base.hh"
 #include "cpu/thread_context.hh"
+#include "debug/SyscallBase.hh"
 #include "debug/SyscallVerbose.hh"
 #include "mem/page_table.hh"
 #include "sim/process.hh"
@@ -55,28 +56,31 @@
 void
 SyscallDesc::doSyscall(int callnum, LiveProcess *process, ThreadContext *tc)
 {
-    if (DTRACE(SyscallVerbose)) {
+    if (DTRACE(SyscallBase)) {
         int index = 0;
-        IntReg arg[4] M5_VAR_USED;
+        IntReg arg[6] M5_VAR_USED;
 
         // we can't just put the calls to getSyscallArg() in the
         // DPRINTF arg list, because C++ doesn't guarantee their order
-        for (int i = 0; i < 4; ++i)
+        for (int i = 0; i < 6; ++i)
             arg[i] = 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]);
+        // Linux supports up to six system call arguments through registers
+        // so we want to print all six. Check to the relevant man page to
+        // verify how many are actually used by a given system call.
+        DPRINTF_SYSCALL(Base,
+                        "%s called w/arguments %d, %d, %d, %d, %d, %d\n",
+                        name, arg[0], arg[1], arg[2], arg[3], arg[4],
+                        arg[5]);
     }
 
     SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
 
     if (retval.needsRetry()) {
-        DPRINTFS(SyscallVerbose, tc->getCpuPtr(), "syscall %s needs retry\n",
-                 name);
+        DPRINTF_SYSCALL(Base, "%s needs retry\n", name);
     } else {
-        DPRINTFS(SyscallVerbose, tc->getCpuPtr(), "syscall %s returns %d\n",
-                 name, retval.encodedValue());
+        DPRINTF_SYSCALL(Base, "%s returns %d\n", name,
+                        retval.encodedValue());
     }
 
     if (!(flags & SyscallDesc::SuppressReturnValue) && !retval.needsRetry())
@@ -201,7 +205,8 @@
     }
 
     p->brk_point = new_brk;
-    DPRINTF(SyscallVerbose, "Break Point changed to: %#X\n", p->brk_point);
+    DPRINTF_SYSCALL(Verbose, "brk: break point changed to: %#X\n",
+                    p->brk_point);
     return p->brk_point;
 }
 
diff -r bfe4c2a8ad36 -r 3370547fa302 src/sim/syscall_emul.hh
--- a/src/sim/syscall_emul.hh   Thu Mar 17 10:22:39 2016 -0700
+++ b/src/sim/syscall_emul.hh   Thu Mar 17 10:22:39 2016 -0700
@@ -74,6 +74,7 @@
 #include "config/the_isa.hh"
 #include "cpu/base.hh"
 #include "cpu/thread_context.hh"
+#include "debug/SyscallBase.hh"
 #include "debug/SyscallVerbose.hh"
 #include "mem/page_table.hh"
 #include "sim/byteswap.hh"
@@ -83,6 +84,14 @@
 #include "sim/syscallreturn.hh"
 #include "sim/system.hh"
 
+// This wrapper macro helps out with readability a bit. FLAGEXT specifies
+// the verbosity and FMT is the message to be appended to the syscall
+// header information. The syscall header information contains the cpuid
+// and thread id.
+#define DPRINTF_SYSCALL(FLAGEXT, FMT, ...)                                  \
+    DPRINTFS(Syscall##FLAGEXT, tc->getCpuPtr(), "T%d : syscall " FMT,       \
+             tc->threadId(), __VA_ARGS__)
+
 ///
 /// System call descriptor.
 ///
@@ -1100,7 +1109,7 @@
     int tgt_fd = process->getSyscallArg(tc, index);
     Addr bufPtr = process->getSyscallArg(tc, index);
 
-    DPRINTF(SyscallVerbose, "fstat(%d, ...)\n", tgt_fd);
+    DPRINTF_SYSCALL(Verbose, "fstat(%d, ...)\n", tgt_fd);
 
     int sim_fd = process->getSimFD(tgt_fd);
     if (sim_fd < 0)
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to