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; |
| 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 |
| 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 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 45 | SYS_FUNC(execve) |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 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) |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 70 | SYS_FUNC(execv) |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 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 */ |