9 #ifndef STAP_SCRIPT_FILENAME
10 #error "STAP_SCRIPT_FILENAME is required"
13 #define STRINGIFY1(lit) #lit
14 #define STRINGIFY(lit) STRINGIFY1 (lit)
15 #define _(x) gettext (x)
17 static int opt_d, opt_f, opt_q, opt_p;
19 /* Script filename. */
20 static char *opt_Z = STRINGIFY (STAP_SCRIPT_FILENAME);
25 void *retval = malloc (size);
28 error (EXIT_FAILURE, errno, _("memory allocation of %zu bytes"), size);
37 usage: staptrace [-dfq] [-o file] [-p pid] [command [arg ...]]\n\
47 dump_args (char **args)
51 for (argp = args; *argp; argp++)
55 fprintf (stderr, "'%s'", *argp);
61 main (int argc, char **argv)
65 args = xmalloc (sizeof (*args) * argc * 2);
73 i = getopt (argc, argv, "+dfqo:p:hZ:");
83 error (EXIT_FAILURE, 0, _("-ff is unsupported"));
106 usage (EXIT_SUCCESS);
108 usage (EXIT_FAILURE);
112 if ((optind == argc) == !opt_p)
113 usage (EXIT_FAILURE);
125 for (i = optind; i < argc; i++)
126 len += 3 + strlen (argv[i]) * 4;
128 d = *argp++ = xmalloc (len);
129 d = stpcpy (d, "(exec");
130 for (i = optind; i < argc; i++)
134 for (s = argv[optind]; *s; s++)
138 d = stpcpy (d, "'\\''");
156 execvp ("stap", args);
160 error (EXIT_FAILURE, errno, "Error executing stap");