1 #include "defs.h"
2
3 static void
printargv(struct tcb * tcp,long addr)4 printargv(struct tcb *tcp, long addr)
5 {
6 union {
7 unsigned int p32;
8 unsigned long p64;
9 char data[sizeof(long)];
10 } cp;
11 const char *sep;
12 unsigned int n = 0;
13 unsigned wordsize = current_wordsize;
14
15 cp.p64 = 1;
16 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
17 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
18 tprintf("%#lx", addr);
19 return;
20 }
21 if (wordsize == 4)
22 cp.p64 = cp.p32;
23 if (cp.p64 == 0)
24 break;
25 tprints(sep);
26 printstr(tcp, cp.p64, -1);
27 addr += wordsize;
28 }
29 if (cp.p64)
30 tprintf("%s...", sep);
31 }
32
33 static void
printargc(const char * fmt,struct tcb * tcp,long addr)34 printargc(const char *fmt, struct tcb *tcp, long addr)
35 {
36 int count;
37 char *cp;
38
39 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
40 addr += sizeof(char *);
41 }
42 tprintf(fmt, count, count == 1 ? "" : "s");
43 }
44
SYS_FUNC(execve)45 SYS_FUNC(execve)
46 {
47 if (entering(tcp)) {
48 printpath(tcp, tcp->u_arg[0]);
49 if (!verbose(tcp))
50 tprintf(", %#lx", tcp->u_arg[1]);
51 else {
52 tprints(", [");
53 printargv(tcp, tcp->u_arg[1]);
54 tprints("]");
55 }
56 if (!verbose(tcp))
57 tprintf(", %#lx", tcp->u_arg[2]);
58 else if (abbrev(tcp))
59 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
60 else {
61 tprints(", [");
62 printargv(tcp, tcp->u_arg[2]);
63 tprints("]");
64 }
65 }
66 return 0;
67 }
68
69 #if defined(SPARC) || defined(SPARC64)
SYS_FUNC(execv)70 SYS_FUNC(execv)
71 {
72 if (entering(tcp)) {
73 printpath(tcp, tcp->u_arg[0]);
74 if (!verbose(tcp))
75 tprintf(", %#lx", tcp->u_arg[1]);
76 else {
77 tprints(", [");
78 printargv(tcp, tcp->u_arg[1]);
79 tprints("]");
80 }
81 }
82 return 0;
83 }
84 #endif /* SPARC || SPARC64 */
85