Fri Dec 9 17:20:21 2011 UTC ()
Enhance printing of system callss


(reinoud)
diff -r1.11 -r1.12 src/sys/arch/usermode/usermode/syscall.c

cvs diff -r1.11 -r1.12 src/sys/arch/usermode/usermode/syscall.c (expand / switch to unified diff)

--- src/sys/arch/usermode/usermode/syscall.c 2011/11/27 21:38:17 1.11
+++ src/sys/arch/usermode/usermode/syscall.c 2011/12/09 17:20:21 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: syscall.c,v 1.11 2011/11/27 21:38:17 reinoud Exp $ */ 1/* $NetBSD: syscall.c,v 1.12 2011/12/09 17:20:21 reinoud Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.11 2011/11/27 21:38:17 reinoud Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.12 2011/12/09 17:20:21 reinoud Exp $");
31 31
32#include <sys/types.h> 32#include <sys/types.h>
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/systm.h> 34#include <sys/systm.h>
35#include <sys/proc.h> 35#include <sys/proc.h>
36#include <sys/lwp.h> 36#include <sys/lwp.h>
37#include <sys/sched.h> 37#include <sys/sched.h>
38#include <sys/ktrace.h> 38#include <sys/ktrace.h>
39#include <sys/syscall.h> 39#include <sys/syscall.h>
40#include <sys/syscallvar.h> 40#include <sys/syscallvar.h>
41#include <sys/syscallargs.h> 41#include <sys/syscallargs.h>
42 42
43#include <sys/userret.h> 43#include <sys/userret.h>
@@ -96,42 +96,56 @@ syscall(void) @@ -96,42 +96,56 @@ syscall(void)
96 code &= (SYS_NSYSENT -1); 96 code &= (SYS_NSYSENT -1);
97 97
98 callp = p->p_emul->e_sysent + code; 98 callp = p->p_emul->e_sysent + code;
99 nargs = callp->sy_narg; 99 nargs = callp->sy_narg;
100 argsize = callp->sy_argsize; 100 argsize = callp->sy_argsize;
101 101
102 args = copyargs; 102 args = copyargs;
103 rval[0] = rval[1] = 0; 103 rval[0] = rval[1] = 0;
104 error = md_syscall_getargs(l, ucp, nargs, argsize, args); 104 error = md_syscall_getargs(l, ucp, nargs, argsize, args);
105 105
106 if (code != 4) { 106 if (code != 4) {
107 printf("code %3d, nargs %d, argsize %3d\t%s(",  107 printf("code %3d, nargs %d, argsize %3d\t%s(",
108 code, nargs, argsize, syscallnames[code]); 108 code, nargs, argsize, syscallnames[code]);
109 for (int i = 0; i < nargs; i++) 109 switch (code) {
110 printf("%"PRIx32", ", (uint) args[i]); 110 case 5:
111 if (nargs) 111 printf("\"%s\", %"PRIx32", %"PRIx32"", (char *) (args[0]), (uint) args[1], (uint) args[2]);
112 printf("\b\b"); 112 break;
 113 case 33:
 114 printf("\"%s\", %"PRIx32"", (char *) (args[0]), (uint) args[1]);
 115 break;
 116 case 50:
 117 printf("\"%s\"", (char *) (args[0]));
 118 break;
 119 case 58:
 120 printf("\"%s\", %"PRIx32", %"PRIx32"", (char *) (args[0]), (uint) (args[1]), (uint) args[2]);
 121 default:
 122 for (int i = 0; i < nargs; i++)
 123 printf("%"PRIx32", ", (uint) args[i]);
 124 if (nargs)
 125 printf("\b\b");
 126 }
113 printf(") "); 127 printf(") ");
114 } 128 }
115#if 0 129#if 0
116 aprint_debug("syscall no. %d, ", code); 130 aprint_debug("syscall no. %d, ", code);
117 aprint_debug("nargs %d, argsize %d => ", nargs, argsize); 131 aprint_debug("nargs %d, argsize %d => ", nargs, argsize);
118 dprintf_debug("syscall no. %d, ", code); 132 dprintf_debug("syscall no. %d, ", code);
119 dprintf_debug("nargs %d, argsize %d => ", nargs, argsize); 133 dprintf_debug("nargs %d, argsize %d => ", nargs, argsize);
120#endif 134#endif
121#if 0 135#if 1
122 if ((code == 4)) { 136 if ((code == 4)) {
123 dprintf_debug("[us] %s", (char *) args[1]); 137 dprintf_debug("[us] %s", (char *) args[1]);
124 printf("[us] %s", (char *) args[1]); 138// printf("[us] %s", (char *) args[1]);
125 } 139 }
126#endif 140#endif
127 if (code == 440) 141 if (code == 440)
128 printf("stat(%d, %p) ", (uint32_t) args[0], 142 printf("stat(%d, %p) ", (uint32_t) args[0],
129 (void *) args[1]); 143 (void *) args[1]);
130 144
131 md_syscall_inc_pc(ucp, opcode); 145 md_syscall_inc_pc(ucp, opcode);
132 146
133 if (!error)  147 if (!error)
134 error = (*callp->sy_call)(l, args, rval); 148 error = (*callp->sy_call)(l, args, rval);
135 149
136 if (code != 4) 150 if (code != 4)
137 printf("=> %s: %d, (%"PRIx32", %"PRIx32")\n", 151 printf("=> %s: %d, (%"PRIx32", %"PRIx32")\n",