9 #ifndef STAP_SCRIPT_FILENAME
10 #error "STAP_SCRIPT_FILENAME is required"
13 #define STRINGIFY(lit) #lit
14 #define _(x) gettext (x)
16 static int opt_d, opt_f, opt_q, opt_p;
18 /* Script filename. */
19 static char *opt_Z = STRINGIFY (STAP_SCRIPT_FILENAME);
24 void *retval = malloc (size);
27 error (EXIT_FAILURE, errno, _("memory allocation of %zu bytes"), size);
36 usage: staptrace [-dfq] [-o file] [-p pid] [command [arg ...]]\n\
46 dump_args (char **args)
50 for (argp = args; *argp; argp++)
54 fprintf (stderr, "'%s'", *argp);
60 main (int argc, char **argv)
64 args = xmalloc (sizeof (*args) * argc * 2);
72 i = getopt (argc, argv, "+dfqo:p:hZ:");
82 error (EXIT_FAILURE, 0, _("-ff is unsupported"));
105 usage (EXIT_SUCCESS);
107 error (0, 0, _("Invalid option '%c'"), i);
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, "'\\''");
155 execvp ("stap", args);
159 error (EXIT_FAILURE, errno, "Error executing stap");