Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | static void |
| 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; |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame] | 13 | const unsigned wordsize = current_wordsize; |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 14 | |
| 15 | cp.p64 = 1; |
| 16 | for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) { |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame] | 17 | if (umoven_or_printaddr(tcp, addr, wordsize, cp.data)) |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 18 | return; |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 19 | 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 | |
| 31 | static void |
| 32 | printargc(const char *fmt, struct tcb *tcp, long addr) |
| 33 | { |
| 34 | int count; |
Dmitry V. Levin | 4ff687b | 2015-07-27 10:02:33 +0000 | [diff] [blame] | 35 | char *cp = NULL; |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 36 | |
Dmitry V. Levin | 4ff687b | 2015-07-27 10:02:33 +0000 | [diff] [blame] | 37 | for (count = 0; !umoven(tcp, addr, current_wordsize, &cp) && cp; count++) { |
| 38 | addr += current_wordsize; |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 39 | } |
| 40 | tprintf(fmt, count, count == 1 ? "" : "s"); |
| 41 | } |
| 42 | |
Dmitry V. Levin | 7c22101 | 2015-07-26 11:06:53 +0000 | [diff] [blame] | 43 | static void |
| 44 | decode_execve(struct tcb *tcp, const unsigned int index) |
| 45 | { |
| 46 | printpath(tcp, tcp->u_arg[index + 0]); |
| 47 | tprints(", "); |
| 48 | |
| 49 | if (!tcp->u_arg[index + 1] || !verbose(tcp)) |
| 50 | printaddr(tcp->u_arg[index + 1]); |
| 51 | else { |
| 52 | tprints("["); |
| 53 | printargv(tcp, tcp->u_arg[index + 1]); |
| 54 | tprints("]"); |
| 55 | } |
| 56 | tprints(", "); |
| 57 | |
| 58 | if (!tcp->u_arg[index + 2] || !verbose(tcp)) |
| 59 | printaddr(tcp->u_arg[index + 2]); |
| 60 | else if (abbrev(tcp)) |
| 61 | printargc("[/* %d var%s */]", tcp, tcp->u_arg[index + 2]); |
| 62 | else { |
| 63 | tprints("["); |
| 64 | printargv(tcp, tcp->u_arg[index + 2]); |
| 65 | tprints("]"); |
| 66 | } |
| 67 | } |
| 68 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 69 | SYS_FUNC(execve) |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 70 | { |
Dmitry V. Levin | 7c22101 | 2015-07-26 11:06:53 +0000 | [diff] [blame] | 71 | decode_execve(tcp, 0); |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame] | 72 | |
Dmitry V. Levin | 7c22101 | 2015-07-26 11:06:53 +0000 | [diff] [blame] | 73 | return RVAL_DECODED; |
| 74 | } |
Dmitry V. Levin | 7e56b4e | 2015-07-20 15:20:46 +0000 | [diff] [blame] | 75 | |
Dmitry V. Levin | 7c22101 | 2015-07-26 11:06:53 +0000 | [diff] [blame] | 76 | SYS_FUNC(execveat) |
| 77 | { |
| 78 | print_dirfd(tcp, tcp->u_arg[0]); |
| 79 | decode_execve(tcp, 1); |
| 80 | tprints(", "); |
| 81 | printflags(at_flags, tcp->u_arg[4], "AT_???"); |
Dmitry V. Levin | 7e56b4e | 2015-07-20 15:20:46 +0000 | [diff] [blame] | 82 | |
| 83 | return RVAL_DECODED; |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | #if defined(SPARC) || defined(SPARC64) |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 87 | SYS_FUNC(execv) |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 88 | { |
Dmitry V. Levin | 7e56b4e | 2015-07-20 15:20:46 +0000 | [diff] [blame] | 89 | printpath(tcp, tcp->u_arg[0]); |
| 90 | tprints(", "); |
| 91 | if (!tcp->u_arg[1] || !verbose(tcp)) |
| 92 | printaddr(tcp->u_arg[1]); |
| 93 | else { |
| 94 | tprints("["); |
| 95 | printargv(tcp, tcp->u_arg[1]); |
| 96 | tprints("]"); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 97 | } |
Dmitry V. Levin | 7e56b4e | 2015-07-20 15:20:46 +0000 | [diff] [blame] | 98 | |
| 99 | return RVAL_DECODED; |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 100 | } |
| 101 | #endif /* SPARC || SPARC64 */ |