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; |
| 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. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 43 | SYS_FUNC(execve) |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 44 | { |
| 45 | if (entering(tcp)) { |
| 46 | printpath(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame^] | 47 | tprints(", "); |
| 48 | |
| 49 | if (!tcp->u_arg[1] || !verbose(tcp)) |
| 50 | printaddr(tcp->u_arg[1]); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 51 | else { |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame^] | 52 | tprints("["); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 53 | printargv(tcp, tcp->u_arg[1]); |
| 54 | tprints("]"); |
| 55 | } |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame^] | 56 | tprints(", "); |
| 57 | |
| 58 | if (!tcp->u_arg[2] || !verbose(tcp)) |
| 59 | printaddr(tcp->u_arg[2]); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 60 | else if (abbrev(tcp)) |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame^] | 61 | printargc("[/* %d var%s */]", tcp, tcp->u_arg[2]); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 62 | else { |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame^] | 63 | tprints("["); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 64 | printargv(tcp, tcp->u_arg[2]); |
| 65 | tprints("]"); |
| 66 | } |
| 67 | } |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | #if defined(SPARC) || defined(SPARC64) |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 72 | SYS_FUNC(execv) |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 73 | { |
| 74 | if (entering(tcp)) { |
| 75 | printpath(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame^] | 76 | tprints(", "); |
| 77 | if (!tcp->u_arg[1] || !verbose(tcp)) |
| 78 | printaddr(tcp->u_arg[1]); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 79 | else { |
Dmitry V. Levin | ad18132 | 2015-07-20 15:17:24 +0000 | [diff] [blame^] | 80 | tprints("["); |
Dmitry V. Levin | 7be2318 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 81 | printargv(tcp, tcp->u_arg[1]); |
| 82 | tprints("]"); |
| 83 | } |
| 84 | } |
| 85 | return 0; |
| 86 | } |
| 87 | #endif /* SPARC || SPARC64 */ |