| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 1 | #include "config.h" |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 2 | |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 3 | #include <sys/ioctl.h> |
| Petr Machata | 2b46cfc | 2012-02-18 11:17:29 +0100 | [diff] [blame] | 4 | #include <assert.h> |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 5 | #include <errno.h> |
| 6 | #include <error.h> |
| 7 | #include <fcntl.h> |
| 8 | #include <getopt.h> |
| 9 | #include <limits.h> |
| 10 | #include <stdlib.h> |
| 11 | #include <string.h> |
| 12 | #include <unistd.h> |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 13 | |
| Juan Cespedes | f728123 | 2009-06-25 16:11:21 +0200 | [diff] [blame] | 14 | #include "common.h" |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 15 | #include "filter.h" |
| 16 | #include "glob.h" |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 17 | |
| Steve Fink | 58c73a7 | 2006-07-17 23:18:35 +0200 | [diff] [blame] | 18 | #ifndef SYSCONFDIR |
| 19 | #define SYSCONFDIR "/etc" |
| 20 | #endif |
| 21 | |
| Olaf Hering | e948e58 | 2006-10-12 23:53:44 +0200 | [diff] [blame] | 22 | #define SYSTEM_CONFIG_FILE SYSCONFDIR "/ltrace.conf" |
| Steve Fink | 58c73a7 | 2006-07-17 23:18:35 +0200 | [diff] [blame] | 23 | #define USER_CONFIG_FILE "~/.ltrace.conf" |
| 24 | |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 25 | struct options_t options = { |
| Juan Cespedes | da9b953 | 2009-04-07 15:33:50 +0200 | [diff] [blame] | 26 | .align = DEFAULT_ALIGN, /* alignment column for results */ |
| 27 | .user = NULL, /* username to run command as */ |
| 28 | .syscalls = 0, /* display syscalls */ |
| 29 | .libcalls = 1, /* display library calls */ |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 30 | #ifdef USE_DEMANGLE |
| Juan Cespedes | da9b953 | 2009-04-07 15:33:50 +0200 | [diff] [blame] | 31 | .demangle = 0, /* Demangle low-level symbol names */ |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 32 | #endif |
| Juan Cespedes | da9b953 | 2009-04-07 15:33:50 +0200 | [diff] [blame] | 33 | .indent = 0, /* indent output according to program flow */ |
| 34 | .output = NULL, /* output to a specific file */ |
| Juan Cespedes | cc813cd | 2009-04-07 15:45:53 +0200 | [diff] [blame] | 35 | .summary = 0, /* Report a summary on program exit */ |
| 36 | .debug = 0, /* debug */ |
| 37 | .arraylen = DEFAULT_ARRAYLEN, /* maximum # array elements to print */ |
| 38 | .strlen = DEFAULT_STRLEN, /* maximum # of bytes printed in strings */ |
| 39 | .follow = 0, /* trace child processes */ |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 40 | }; |
| 41 | |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 42 | static char *progname; /* Program name (`ltrace') */ |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 43 | int opt_i = 0; /* instruction pointer */ |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 44 | int opt_r = 0; /* print relative timestamp */ |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 45 | int opt_t = 0; /* print absolute timestamp */ |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 46 | int opt_T = 0; /* show the time spent inside each call */ |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 47 | |
| 48 | /* List of pids given to option -p: */ |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 49 | struct opt_p_t *opt_p = NULL; /* attach to process with a given pid */ |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 50 | |
| Steve Fink | 58c73a7 | 2006-07-17 23:18:35 +0200 | [diff] [blame] | 51 | /* List of filenames give to option -F: */ |
| 52 | struct opt_F_t *opt_F = NULL; /* alternate configuration file(s) */ |
| 53 | |
| Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 54 | #ifdef PLT_REINITALISATION_BP |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 55 | /* Set a break on the routine named here in order to re-initialize breakpoints |
| 56 | after all the PLTs have been initialzed */ |
| Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 57 | char *PLTs_initialized_by_here = PLT_REINITALISATION_BP; |
| 58 | #endif |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 59 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 60 | static void |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 61 | err_usage(void) { |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 62 | fprintf(stderr, "Try `%s --help' for more information\n", progname); |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 63 | exit(1); |
| 64 | } |
| 65 | |
| 66 | static void |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 67 | usage(void) { |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 68 | fprintf(stdout, "Usage: %s [option ...] [command [arg ...]]\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 69 | "Trace library calls of a given program.\n\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 70 | " -a, --align=COLUMN align return values in a secific column.\n" |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 71 | " -A ARRAYLEN maximum number of array elements to print.\n" |
| Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 72 | " -b, --no-signals don't print signals.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 73 | " -c count time and calls, and report a summary on exit.\n" |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 74 | # ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 75 | " -C, --demangle decode low-level symbol names into user-level names.\n" |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 76 | # endif |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 77 | " -D, --debug=LEVEL enable debugging (see -Dh or --debug=help).\n" |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 78 | " -Dh, --debug=help show help on debugging.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 79 | " -e expr modify which events to trace.\n" |
| Juan Cespedes | c4e53a9 | 2009-05-06 20:36:42 +0200 | [diff] [blame] | 80 | " -f trace children (fork() and clone()).\n" |
| Juan Cespedes | cc813cd | 2009-04-07 15:45:53 +0200 | [diff] [blame] | 81 | " -F, --config=FILE load alternate configuration file (may be repeated).\n" |
| Joe Damato | fa2aefc | 2010-10-30 19:56:50 -0700 | [diff] [blame] | 82 | " -g, --no-plt disable breakpoints on PLT entries.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 83 | " -h, --help display this help and exit.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 84 | " -i print instruction pointer at time of library call.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 85 | " -l, --library=FILE print library calls from this library only.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 86 | " -L do NOT display library calls.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 87 | " -n, --indent=NR indent output by NR spaces for each call level nesting.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 88 | " -o, --output=FILE write the trace output to that file.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 89 | " -p PID attach to the process with the process ID pid.\n" |
| 90 | " -r print relative timestamps.\n" |
| 91 | " -s STRLEN specify the maximum string size to print.\n" |
| 92 | " -S display system calls.\n" |
| 93 | " -t, -tt, -ttt print absolute timestamps.\n" |
| 94 | " -T show the time spent inside each call.\n" |
| 95 | " -u USERNAME run command with the userid, groupid of username.\n" |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 96 | " -V, --version output version information and exit.\n" |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 97 | #if defined(HAVE_LIBUNWIND) |
| 98 | " -w=NR, --where=NR print backtrace showing NR stack frames at most.\n" |
| 99 | #endif /* defined(HAVE_LIBUNWIND) */ |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 100 | " -x NAME treat the global NAME like a library subroutine.\n" |
| Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 101 | #ifdef PLT_REINITALISATION_BP |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 102 | " -X NAME same as -x; and PLT's will be initialized by here.\n" |
| Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 103 | #endif |
| 104 | "\nReport bugs to ltrace-devel@lists.alioth.debian.org\n", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 105 | progname); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 106 | } |
| 107 | |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 108 | static void |
| 109 | usage_debug(void) { |
| 110 | fprintf(stdout, "%s debugging option, --debug=<octal> or -D<octal>:\n", progname); |
| 111 | fprintf(stdout, |
| 112 | "\n" |
| 113 | " number ref. in source description\n" |
| 114 | " 1 general Generally helpful progress information\n" |
| 115 | " 10 event Shows every event received by a traced process\n" |
| 116 | " 20 process Shows actions carried upon a traced processes\n" |
| 117 | " 40 function Shows every entry to internal functions\n" |
| 118 | "\n" |
| 119 | "Debugging options are mixed using bitwise-or.\n" |
| 120 | "Note that the meanings and values are subject to change.\n" |
| 121 | ); |
| 122 | } |
| 123 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 124 | static char * |
| 125 | search_for_command(char *filename) { |
| Juan Cespedes | f1bfe20 | 2002-03-27 00:22:23 +0100 | [diff] [blame] | 126 | static char pathname[PATH_MAX]; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 127 | char *path; |
| 128 | int m, n; |
| 129 | |
| 130 | if (strchr(filename, '/')) { |
| 131 | return filename; |
| 132 | } |
| 133 | for (path = getenv("PATH"); path && *path; path += m) { |
| 134 | if (strchr(path, ':')) { |
| 135 | n = strchr(path, ':') - path; |
| 136 | m = n + 1; |
| 137 | } else { |
| 138 | m = n = strlen(path); |
| 139 | } |
| Juan Cespedes | f1bfe20 | 2002-03-27 00:22:23 +0100 | [diff] [blame] | 140 | if (n + strlen(filename) + 1 >= PATH_MAX) { |
| 141 | fprintf(stderr, "Error: filename too long\n"); |
| 142 | exit(1); |
| 143 | } |
| 144 | strncpy(pathname, path, n); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 145 | if (n && pathname[n - 1] != '/') { |
| 146 | pathname[n++] = '/'; |
| 147 | } |
| 148 | strcpy(pathname + n, filename); |
| 149 | if (!access(pathname, X_OK)) { |
| 150 | return pathname; |
| 151 | } |
| 152 | } |
| 153 | return filename; |
| 154 | } |
| 155 | |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 156 | static void |
| 157 | guess_cols(void) { |
| 158 | struct winsize ws; |
| 159 | char *c; |
| 160 | |
| 161 | options.align = DEFAULT_ALIGN; |
| 162 | c = getenv("COLUMNS"); |
| 163 | if (c && *c) { |
| 164 | char *endptr; |
| 165 | int cols; |
| 166 | cols = strtol(c, &endptr, 0); |
| 167 | if (cols > 0 && !*endptr) { |
| 168 | options.align = cols * 5 / 8; |
| 169 | } |
| 170 | } else if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col > 0) { |
| 171 | options.align = ws.ws_col * 5 / 8; |
| Juan Cespedes | 43739a6 | 2009-04-07 13:10:08 +0200 | [diff] [blame] | 172 | } else if (ioctl(2, TIOCGWINSZ, &ws) != -1 && ws.ws_col > 0) { |
| 173 | options.align = ws.ws_col * 5 / 8; |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 177 | static void |
| 178 | add_filter_rule(struct filter *filt, const char *expr, |
| 179 | enum filter_rule_type type, |
| 180 | const char *sym, int sym_re_p, |
| 181 | const char *lib, int lib_re_p) |
| 182 | { |
| 183 | fprintf(stderr, "add_filter_rule, type = %d\n", type); |
| 184 | fprintf(stderr, "+ symname = %s (re=%d)\n", sym, sym_re_p); |
| 185 | fprintf(stderr, "+ libname = %s (re=%d)\n", lib, lib_re_p); |
| 186 | struct filter_rule *rule = malloc(sizeof(*rule)); |
| 187 | struct filter_lib_matcher *matcher = malloc(sizeof(*matcher)); |
| 188 | |
| 189 | if (rule == NULL || matcher == NULL) { |
| 190 | error(0, errno, "rule near '%s' will be ignored", expr); |
| 191 | fail: |
| 192 | free(rule); |
| 193 | free(matcher); |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | regex_t symbol_re; |
| 198 | int status = (sym_re_p ? regcomp : globcomp)(&symbol_re, sym, 0); |
| 199 | if (status != 0) { |
| 200 | char buf[100]; |
| 201 | regerror(status, &symbol_re, buf, sizeof buf); |
| 202 | error(0, 0, "rule near '%s' will be ignored: %s", expr, buf); |
| 203 | goto fail; |
| 204 | } |
| 205 | |
| Petr Machata | 0b55b58 | 2012-04-02 00:38:46 +0200 | [diff] [blame] | 206 | if (strcmp(lib, "MAIN") == 0) { |
| 207 | filter_lib_matcher_main_init(matcher); |
| 208 | } else { |
| 209 | enum filter_lib_matcher_type type |
| 210 | = lib[0] == '/' ? FLM_PATHNAME : FLM_SONAME; |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 211 | |
| Petr Machata | 0b55b58 | 2012-04-02 00:38:46 +0200 | [diff] [blame] | 212 | regex_t lib_re; |
| 213 | status = (lib_re_p ? regcomp : globcomp)(&lib_re, lib, 0); |
| 214 | if (status != 0) { |
| 215 | char buf[100]; |
| 216 | regerror(status, &lib_re, buf, sizeof buf); |
| 217 | error(0, 0, "rule near '%s' will be ignored: %s", |
| 218 | expr, buf); |
| 219 | |
| 220 | regfree(&symbol_re); |
| 221 | goto fail; |
| 222 | } |
| 223 | filter_lib_matcher_name_init(matcher, type, lib_re); |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 224 | } |
| 225 | |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 226 | filter_rule_init(rule, type, matcher, symbol_re); |
| Petr Machata | e0973cb | 2012-04-01 19:36:41 +0200 | [diff] [blame] | 227 | filter_add_rule(filt, rule); |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | static int |
| 231 | parse_filter(struct filter *filt, char *expr) |
| 232 | { |
| 233 | fprintf(stderr, "filter '%s'\n", expr); |
| 234 | |
| 235 | /* Filter is a chain of sym@lib rules separated by '-'. If |
| 236 | * the filter expression starts with '-', the missing initial |
| 237 | * rule is implicitly *@*. */ |
| 238 | |
| 239 | enum filter_rule_type type = FR_ADD; |
| 240 | |
| 241 | while (*expr != 0) { |
| 242 | size_t s = strcspn(expr, "@-"); |
| 243 | char *symname = expr; |
| 244 | char *libname; |
| 245 | char *next = expr + s + 1; |
| 246 | enum filter_rule_type this_type = type; |
| 247 | |
| 248 | if (expr[s] == 0) { |
| 249 | libname = "*"; |
| 250 | expr = next - 1; |
| 251 | |
| 252 | } else if (expr[s] == '-') { |
| 253 | libname = "*"; |
| 254 | expr = next; |
| 255 | type = FR_SUBTRACT; |
| 256 | |
| 257 | } else { |
| 258 | assert(expr[s] == '@'); |
| 259 | expr[s] = 0; |
| 260 | s = strcspn(next, "-"); |
| 261 | if (s == 0) { |
| 262 | libname = "*"; |
| 263 | expr = next; |
| 264 | } else if (next[s] == 0) { |
| 265 | expr = next + s; |
| 266 | libname = next; |
| 267 | |
| 268 | } else { |
| 269 | assert(next[s] == '-'); |
| 270 | type = FR_SUBTRACT; |
| 271 | next[s] = 0; |
| 272 | expr = next + s + 1; |
| 273 | libname = next; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | assert(*libname != 0); |
| 278 | char *symend = symname + strlen(symname) - 1; |
| 279 | char *libend = libname + strlen(libname) - 1; |
| 280 | int sym_is_re = 0; |
| 281 | int lib_is_re = 0; |
| 282 | |
| 283 | /* |
| 284 | * /xxx/@... and ...@/xxx/ means that xxx are regular |
| 285 | * expressions. They are globs otherwise. |
| 286 | * |
| 287 | * /xxx@yyy/ is the same as /xxx/@/yyy/ |
| 288 | * |
| 289 | * @/xxx matches library path name |
| 290 | * @.xxx matches library relative path name |
| 291 | */ |
| 292 | if (symname[0] == '/') { |
| 293 | if (symname != symend && symend[0] == '/') { |
| 294 | ++symname; |
| 295 | *symend-- = 0; |
| 296 | sym_is_re = 1; |
| 297 | |
| 298 | } else { |
| 299 | sym_is_re = 1; |
| 300 | lib_is_re = 1; |
| 301 | ++symname; |
| 302 | |
| 303 | /* /XXX@YYY/ is the same as |
| 304 | * /XXX/@/YYY/. */ |
| 305 | if (libend[0] != '/') |
| 306 | error(0, 0, "unmatched '/'" |
| 307 | " in symbol name"); |
| 308 | else |
| 309 | *libend-- = 0; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | /* If libname ends in '/', then we expect '/' in the |
| 314 | * beginning too. Otherwise the initial '/' is part |
| 315 | * of absolute file name. */ |
| 316 | if (!lib_is_re && libend[0] == '/') { |
| 317 | lib_is_re = 1; |
| 318 | *libend-- = 0; |
| 319 | if (libname != libend && libname[0] == '/') |
| 320 | ++libname; |
| 321 | else |
| 322 | error(0, 0, "unmatched '/' in library name"); |
| 323 | } |
| 324 | |
| 325 | if (*symname == 0) /* /@AA/ */ |
| 326 | symname = "*"; |
| 327 | if (*libname == 0) /* /aa@/ */ |
| 328 | libname = "*"; |
| 329 | |
| 330 | add_filter_rule(filt, expr, this_type, |
| 331 | symname, sym_is_re, |
| 332 | libname, lib_is_re); |
| 333 | } |
| 334 | |
| 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | static struct filter * |
| 339 | recursive_parse_chain(char *expr) |
| 340 | { |
| 341 | /* Event expression grammar: |
| 342 | * |
| 343 | * Chain ::= Filter FilterList |
| 344 | * FilterList ::= eps | ',' Filter FilterList |
| 345 | * Filter ::= Rule RuleList |
| 346 | * RuleList ::= eps | '-' Rule RuleList |
| 347 | * Rule ::= eps | Glob Soname |
| 348 | * Soname ::= eps | '@' Glob | '@' '/' Filename |
| 349 | * Glob ::= '/' Regex '/' |
| 350 | */ |
| 351 | |
| 352 | struct filter *filt = malloc(sizeof(*filt)); |
| 353 | if (filt == NULL) { |
| 354 | error(0, errno, "(part of) filter will be ignored: '%s'", expr); |
| 355 | return NULL; |
| 356 | } |
| 357 | |
| Petr Machata | 35c8814 | 2012-04-04 00:54:43 +0200 | [diff] [blame] | 358 | filter_init(filt); |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 359 | struct filter *next = NULL; |
| 360 | char *it; |
| 361 | int escape = 0; |
| 362 | for (it = expr; ; ++it) { |
| 363 | if (*it == 0) |
| 364 | goto done; |
| 365 | |
| 366 | if (escape) { |
| 367 | escape = 0; |
| 368 | continue; |
| 369 | } |
| 370 | |
| 371 | if (*it == '\\') { |
| 372 | escape = 1; |
| 373 | |
| 374 | } else if (*it == ',') { |
| 375 | *it = 0; |
| 376 | next = recursive_parse_chain(it + 1); |
| 377 | done: |
| 378 | filt->next = next; |
| 379 | if (parse_filter(filt, expr) < 0) { |
| 380 | fprintf(stderr, |
| 381 | "Filter '%s' will be ignored.\n", expr); |
| 382 | free(filt); |
| 383 | filt = next; |
| 384 | } |
| 385 | return filt; |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | static void |
| Petr Machata | b5f80ac | 2012-04-04 01:46:18 +0200 | [diff] [blame] | 391 | parse_filter_chain(const char *expr, struct filter **retp) |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 392 | { |
| 393 | char *str = strdup(expr); |
| 394 | if (str == NULL) { |
| 395 | error(0, errno, "filter '%s' will be ignored", expr); |
| 396 | return; |
| 397 | } |
| Petr Machata | b5f80ac | 2012-04-04 01:46:18 +0200 | [diff] [blame] | 398 | *retp = recursive_parse_chain(str); |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 399 | } |
| 400 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 401 | char ** |
| 402 | process_options(int argc, char **argv) { |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 403 | progname = argv[0]; |
| Juan Cespedes | b65bdc5 | 2008-12-16 19:50:16 +0100 | [diff] [blame] | 404 | options.output = stderr; |
| Joe Damato | fa2aefc | 2010-10-30 19:56:50 -0700 | [diff] [blame] | 405 | options.no_plt = 0; |
| Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 406 | options.no_signals = 0; |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 407 | #if defined(HAVE_LIBUNWIND) |
| 408 | options.bt_depth = -1; |
| 409 | #endif /* defined(HAVE_LIBUNWIND) */ |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 410 | |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 411 | guess_cols(); |
| 412 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 413 | while (1) { |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 414 | int c; |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 415 | char *p; |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 416 | int option_index = 0; |
| 417 | static struct option long_options[] = { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 418 | {"align", 1, 0, 'a'}, |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 419 | {"config", 1, 0, 'F'}, |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 420 | {"debug", 1, 0, 'D'}, |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 421 | # ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 422 | {"demangle", 0, 0, 'C'}, |
| Juan Cespedes | 8e3e082 | 1998-09-24 13:49:55 +0200 | [diff] [blame] | 423 | #endif |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 424 | {"indent", 1, 0, 'n'}, |
| 425 | {"help", 0, 0, 'h'}, |
| 426 | {"library", 1, 0, 'l'}, |
| 427 | {"output", 1, 0, 'o'}, |
| 428 | {"version", 0, 0, 'V'}, |
| Joe Damato | fa2aefc | 2010-10-30 19:56:50 -0700 | [diff] [blame] | 429 | {"no-plt", 0, 0, 'g'}, |
| Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 430 | {"no-signals", 0, 0, 'b'}, |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 431 | #if defined(HAVE_LIBUNWIND) |
| 432 | {"where", 1, 0, 'w'}, |
| 433 | #endif /* defined(HAVE_LIBUNWIND) */ |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 434 | {0, 0, 0, 0} |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 435 | }; |
| Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 436 | c = getopt_long(argc, argv, "+cfhiLrStTVgb" |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 437 | # ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 438 | "C" |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 439 | # endif |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 440 | #if defined(HAVE_LIBUNWIND) |
| 441 | "a:A:D:e:F:l:n:o:p:s:u:x:X:w:", long_options, |
| 442 | #else /* !defined(HAVE_LIBUNWIND) */ |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 443 | "a:A:D:e:F:l:n:o:p:s:u:x:X:", long_options, |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 444 | #endif |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 445 | &option_index); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 446 | if (c == -1) { |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 447 | break; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 448 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 449 | switch (c) { |
| 450 | case 'a': |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 451 | options.align = atoi(optarg); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 452 | break; |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 453 | case 'A': |
| Juan Cespedes | da9b953 | 2009-04-07 15:33:50 +0200 | [diff] [blame] | 454 | options.arraylen = atoi(optarg); |
| Steve Fink | 1150bc4 | 2006-08-07 06:04:43 +0200 | [diff] [blame] | 455 | break; |
| Joe Damato | 535e738 | 2010-11-08 15:47:43 -0800 | [diff] [blame] | 456 | case 'b': |
| 457 | options.no_signals = 1; |
| 458 | break; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 459 | case 'c': |
| Juan Cespedes | da9b953 | 2009-04-07 15:33:50 +0200 | [diff] [blame] | 460 | options.summary++; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 461 | break; |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 462 | #ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 463 | case 'C': |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 464 | options.demangle++; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 465 | break; |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 466 | #endif |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 467 | case 'D': |
| 468 | if (optarg[0]=='h') { |
| 469 | usage_debug(); |
| 470 | exit(0); |
| 471 | } |
| 472 | options.debug = strtoul(optarg,&p,8); |
| 473 | if (*p) { |
| 474 | fprintf(stderr, "%s: --debug requires an octal argument\n", progname); |
| 475 | err_usage(); |
| 476 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 477 | break; |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 478 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 479 | case 'e': |
| Petr Machata | b5f80ac | 2012-04-04 01:46:18 +0200 | [diff] [blame] | 480 | parse_filter_chain(optarg, &options.plt_filter); |
| Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 481 | break; |
| 482 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 483 | case 'f': |
| Juan Cespedes | cc813cd | 2009-04-07 15:45:53 +0200 | [diff] [blame] | 484 | options.follow = 1; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 485 | break; |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 486 | case 'F': |
| 487 | { |
| 488 | struct opt_F_t *tmp = malloc(sizeof(struct opt_F_t)); |
| 489 | if (!tmp) { |
| 490 | perror("ltrace: malloc"); |
| 491 | exit(1); |
| 492 | } |
| 493 | tmp->filename = strdup(optarg); |
| 494 | tmp->next = opt_F; |
| 495 | opt_F = tmp; |
| 496 | break; |
| 497 | } |
| Joe Damato | fa2aefc | 2010-10-30 19:56:50 -0700 | [diff] [blame] | 498 | case 'g': |
| 499 | options.no_plt = 1; |
| 500 | break; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 501 | case 'h': |
| 502 | usage(); |
| 503 | exit(0); |
| 504 | case 'i': |
| 505 | opt_i++; |
| 506 | break; |
| 507 | case 'l': |
| Petr Machata | 2b46cfc | 2012-02-18 11:17:29 +0100 | [diff] [blame] | 508 | assert(!"-l support not yet implemented"); |
| 509 | abort(); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 510 | break; |
| 511 | case 'L': |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 512 | options.libcalls = 0; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 513 | break; |
| 514 | case 'n': |
| Juan Cespedes | b65bdc5 | 2008-12-16 19:50:16 +0100 | [diff] [blame] | 515 | options.indent = atoi(optarg); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 516 | break; |
| 517 | case 'o': |
| Juan Cespedes | b65bdc5 | 2008-12-16 19:50:16 +0100 | [diff] [blame] | 518 | options.output = fopen(optarg, "w"); |
| 519 | if (!options.output) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 520 | fprintf(stderr, |
| 521 | "Can't open %s for output: %s\n", |
| 522 | optarg, strerror(errno)); |
| 523 | exit(1); |
| 524 | } |
| Juan Cespedes | b65bdc5 | 2008-12-16 19:50:16 +0100 | [diff] [blame] | 525 | setvbuf(options.output, (char *)NULL, _IOLBF, 0); |
| 526 | fcntl(fileno(options.output), F_SETFD, FD_CLOEXEC); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 527 | break; |
| 528 | case 'p': |
| 529 | { |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 530 | struct opt_p_t *tmp = malloc(sizeof(struct opt_p_t)); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 531 | if (!tmp) { |
| 532 | perror("ltrace: malloc"); |
| 533 | exit(1); |
| 534 | } |
| 535 | tmp->pid = atoi(optarg); |
| 536 | tmp->next = opt_p; |
| 537 | opt_p = tmp; |
| 538 | break; |
| 539 | } |
| 540 | case 'r': |
| 541 | opt_r++; |
| 542 | break; |
| 543 | case 's': |
| Juan Cespedes | cc813cd | 2009-04-07 15:45:53 +0200 | [diff] [blame] | 544 | options.strlen = atoi(optarg); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 545 | break; |
| 546 | case 'S': |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 547 | options.syscalls = 1; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 548 | break; |
| 549 | case 't': |
| 550 | opt_t++; |
| 551 | break; |
| 552 | case 'T': |
| 553 | opt_T++; |
| 554 | break; |
| 555 | case 'u': |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 556 | options.user = optarg; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 557 | break; |
| 558 | case 'V': |
| 559 | printf("ltrace version " PACKAGE_VERSION ".\n" |
| Juan Cespedes | 1423f08 | 2009-04-07 00:45:33 +0200 | [diff] [blame] | 560 | "Copyright (C) 1997-2009 Juan Cespedes <cespedes@debian.org>.\n" |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 561 | "This is free software; see the GNU General Public Licence\n" |
| 562 | "version 2 or later for copying conditions. There is NO warranty.\n"); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 563 | exit(0); |
| Joe Damato | fa2aefc | 2010-10-30 19:56:50 -0700 | [diff] [blame] | 564 | break; |
| Joe Damato | 535e738 | 2010-11-08 15:47:43 -0800 | [diff] [blame] | 565 | #if defined(HAVE_LIBUNWIND) |
| 566 | case 'w': |
| 567 | options.bt_depth = atoi(optarg); |
| Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 568 | break; |
| Joe Damato | 535e738 | 2010-11-08 15:47:43 -0800 | [diff] [blame] | 569 | #endif /* defined(HAVE_LIBUNWIND) */ |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 570 | case 'X': |
| Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 571 | #ifdef PLT_REINITALISATION_BP |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 572 | PLTs_initialized_by_here = optarg; |
| Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 573 | #else |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 574 | fprintf(stderr, "WARNING: \"-X\" not used for this " |
| Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 575 | "architecture: assuming you meant \"-x\"\n"); |
| 576 | #endif |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 577 | /* Fall Thru */ |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 578 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 579 | case 'x': |
| Petr Machata | da3edbf | 2012-04-04 02:20:21 +0200 | [diff] [blame^] | 580 | parse_filter_chain(optarg, &options.static_filter); |
| 581 | break; |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 582 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 583 | default: |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 584 | err_usage(); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 585 | } |
| 586 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 587 | argc -= optind; |
| 588 | argv += optind; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 589 | |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 590 | if (!opt_F) { |
| 591 | opt_F = malloc(sizeof(struct opt_F_t)); |
| 592 | opt_F->next = malloc(sizeof(struct opt_F_t)); |
| 593 | opt_F->next->next = NULL; |
| 594 | opt_F->filename = USER_CONFIG_FILE; |
| 595 | opt_F->next->filename = SYSTEM_CONFIG_FILE; |
| 596 | } |
| Steve Fink | 58c73a7 | 2006-07-17 23:18:35 +0200 | [diff] [blame] | 597 | /* Reverse the config file list since it was built by |
| 598 | * prepending, and it would make more sense to process the |
| 599 | * files in the order they were given. Probably it would make |
| 600 | * more sense to keep a tail pointer instead? */ |
| 601 | { |
| Juan Cespedes | aee0931 | 2007-08-31 18:49:48 +0200 | [diff] [blame] | 602 | struct opt_F_t *egg = NULL; |
| 603 | struct opt_F_t *chicken; |
| 604 | while (opt_F) { |
| 605 | chicken = opt_F->next; |
| 606 | opt_F->next = egg; |
| 607 | egg = opt_F; |
| 608 | opt_F = chicken; |
| 609 | } |
| 610 | opt_F = egg; |
| Steve Fink | 58c73a7 | 2006-07-17 23:18:35 +0200 | [diff] [blame] | 611 | } |
| 612 | |
| Petr Machata | 0b55b58 | 2012-04-02 00:38:46 +0200 | [diff] [blame] | 613 | /* Set default filter. Use @MAIN for now, as that's what |
| 614 | * ltrace used to have in the past. XXX Maybe we should make |
| 615 | * this "*" instead. */ |
| Petr Machata | b5f80ac | 2012-04-04 01:46:18 +0200 | [diff] [blame] | 616 | if (options.plt_filter == NULL) { |
| 617 | parse_filter_chain("@MAIN", &options.plt_filter); |
| Petr Machata | 0367389 | 2012-04-03 13:51:09 +0200 | [diff] [blame] | 618 | options.hide_caller = 1; |
| 619 | } |
| Petr Machata | e0973cb | 2012-04-01 19:36:41 +0200 | [diff] [blame] | 620 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 621 | if (!opt_p && argc < 1) { |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 622 | fprintf(stderr, "%s: too few arguments\n", progname); |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 623 | err_usage(); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 624 | } |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 625 | if (opt_r && opt_t) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 626 | fprintf(stderr, "%s: Incompatible options -r and -t\n", |
| 627 | progname); |
| Juan Cespedes | c5c744a | 2009-07-23 18:22:58 +0200 | [diff] [blame] | 628 | err_usage(); |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 629 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 630 | if (argc > 0) { |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 631 | command = search_for_command(argv[0]); |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 632 | } |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 633 | return &argv[0]; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 634 | } |