blob: c2f3c0e8e886bb7210fe472e3166908c18d096dd [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;
Dmitry V. Levinad181322015-07-20 15:17:24 +000013 const unsigned wordsize = current_wordsize;
Dmitry V. Levin7be23182014-12-11 19:25:02 +000014
15 cp.p64 = 1;
16 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Dmitry V. Levinad181322015-07-20 15:17:24 +000017 if (umoven_or_printaddr(tcp, addr, wordsize, cp.data))
Dmitry V. Levin7be23182014-12-11 19:25:02 +000018 return;
Dmitry V. Levin7be23182014-12-11 19:25:02 +000019 if (wordsize == 4)
20 cp.p64 = cp.p32;
21 if (cp.p64 == 0)
22 break;
23 tprints(sep);
24 printstr(tcp, cp.p64, -1);
25 addr += wordsize;
26 }
27 if (cp.p64)
28 tprintf("%s...", sep);
29}
30
31static void
32printargc(const char *fmt, struct tcb *tcp, long addr)
33{
34 int count;
35 char *cp;
36
37 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
38 addr += sizeof(char *);
39 }
40 tprintf(fmt, count, count == 1 ? "" : "s");
41}
42
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000043SYS_FUNC(execve)
Dmitry V. Levin7be23182014-12-11 19:25:02 +000044{
45 if (entering(tcp)) {
46 printpath(tcp, tcp->u_arg[0]);
Dmitry V. Levinad181322015-07-20 15:17:24 +000047 tprints(", ");
48
49 if (!tcp->u_arg[1] || !verbose(tcp))
50 printaddr(tcp->u_arg[1]);
Dmitry V. Levin7be23182014-12-11 19:25:02 +000051 else {
Dmitry V. Levinad181322015-07-20 15:17:24 +000052 tprints("[");
Dmitry V. Levin7be23182014-12-11 19:25:02 +000053 printargv(tcp, tcp->u_arg[1]);
54 tprints("]");
55 }
Dmitry V. Levinad181322015-07-20 15:17:24 +000056 tprints(", ");
57
58 if (!tcp->u_arg[2] || !verbose(tcp))
59 printaddr(tcp->u_arg[2]);
Dmitry V. Levin7be23182014-12-11 19:25:02 +000060 else if (abbrev(tcp))
Dmitry V. Levinad181322015-07-20 15:17:24 +000061 printargc("[/* %d var%s */]", tcp, tcp->u_arg[2]);
Dmitry V. Levin7be23182014-12-11 19:25:02 +000062 else {
Dmitry V. Levinad181322015-07-20 15:17:24 +000063 tprints("[");
Dmitry V. Levin7be23182014-12-11 19:25:02 +000064 printargv(tcp, tcp->u_arg[2]);
65 tprints("]");
66 }
67 }
68 return 0;
69}
70
71#if defined(SPARC) || defined(SPARC64)
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000072SYS_FUNC(execv)
Dmitry V. Levin7be23182014-12-11 19:25:02 +000073{
74 if (entering(tcp)) {
75 printpath(tcp, tcp->u_arg[0]);
Dmitry V. Levinad181322015-07-20 15:17:24 +000076 tprints(", ");
77 if (!tcp->u_arg[1] || !verbose(tcp))
78 printaddr(tcp->u_arg[1]);
Dmitry V. Levin7be23182014-12-11 19:25:02 +000079 else {
Dmitry V. Levinad181322015-07-20 15:17:24 +000080 tprints("[");
Dmitry V. Levin7be23182014-12-11 19:25:02 +000081 printargv(tcp, tcp->u_arg[1]);
82 tprints("]");
83 }
84 }
85 return 0;
86}
87#endif /* SPARC || SPARC64 */