blob: 31e80a696e5f811d097f31a779e2ba5f54ad0e60 [file] [log] [blame]
Dmitry V. Levin7be23182014-12-11 19:25:02 +00001#include "defs.h"
2
3static void
4printargv(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
33static void
34printargc(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
45int
46sys_execve(struct tcb *tcp)
47{
48 if (entering(tcp)) {
49 printpath(tcp, tcp->u_arg[0]);
50 if (!verbose(tcp))
51 tprintf(", %#lx", tcp->u_arg[1]);
52 else {
53 tprints(", [");
54 printargv(tcp, tcp->u_arg[1]);
55 tprints("]");
56 }
57 if (!verbose(tcp))
58 tprintf(", %#lx", tcp->u_arg[2]);
59 else if (abbrev(tcp))
60 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
61 else {
62 tprints(", [");
63 printargv(tcp, tcp->u_arg[2]);
64 tprints("]");
65 }
66 }
67 return 0;
68}
69
70#if defined(SPARC) || defined(SPARC64)
71int
72sys_execv(struct tcb *tcp)
73{
74 if (entering(tcp)) {
75 printpath(tcp, tcp->u_arg[0]);
76 if (!verbose(tcp))
77 tprintf(", %#lx", tcp->u_arg[1]);
78 else {
79 tprints(", [");
80 printargv(tcp, tcp->u_arg[1]);
81 tprints("]");
82 }
83 }
84 return 0;
85}
86#endif /* SPARC || SPARC64 */