X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fcalibrate.c;h=81eadbfd2b6d54499fd7d657e49a051361ac0c8b;hp=ee2c76af1bb9ab879163c2e2450b1db4ab8425b9;hb=679b4943c3b0f451e7f4fbcd804dd8a7a679e253;hpb=c399183f4b3257c43915f3d81f44befd23165ad9 diff --git a/src/bin/lttng/commands/calibrate.c b/src/bin/lttng/commands/calibrate.c index ee2c76af1..81eadbfd2 100644 --- a/src/bin/lttng/commands/calibrate.c +++ b/src/bin/lttng/commands/calibrate.c @@ -32,10 +32,12 @@ static int opt_event_type; static char *opt_kernel; -static int opt_pid_all; static int opt_userspace; +#if 0 +/* Not implemented yet */ static char *opt_cmd_name; static pid_t opt_pid; +#endif enum { OPT_HELP = 1, @@ -46,6 +48,7 @@ enum { OPT_FUNCTION_ENTRY, OPT_SYSCALL, OPT_USERSPACE, + OPT_LIST_OPTIONS, }; static struct lttng_handle *handle; @@ -54,13 +57,17 @@ static struct poptOption long_options[] = { /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0}, +#if 0 + /* Not implemented yet */ {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0}, - {"all", 0, POPT_ARG_VAL, &opt_pid_all, 1, 0, 0}, {"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0}, {"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0}, {"marker", 0, POPT_ARG_NONE, 0, OPT_MARKER, 0, 0}, {"probe", 0, POPT_ARG_NONE, 0, OPT_PROBE, 0, 0}, +#else + {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0}, {"function", 0, POPT_ARG_NONE, 0, OPT_FUNCTION, 0, 0}, +#endif #if 0 /* * Removed from options to discourage its use. Not in kernel @@ -69,6 +76,7 @@ static struct poptOption long_options[] = { {"function:entry", 0, POPT_ARG_NONE, 0, OPT_FUNCTION_ENTRY, 0, 0}, #endif {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0}, + {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, {0, 0, 0, 0, 0, 0, 0} }; @@ -80,23 +88,31 @@ static void usage(FILE *ofp) fprintf(ofp, "usage: lttng calibrate [options] [calibrate_options]\n"); fprintf(ofp, "\n"); fprintf(ofp, " -h, --help Show this help\n"); + fprintf(ofp, " --list-options Simple listing of options\n"); fprintf(ofp, " -k, --kernel Apply for the kernel tracer\n"); +#if 0 fprintf(ofp, " -u, --userspace [CMD] Apply for the user-space tracer\n"); - fprintf(ofp, " --all If -u, apply on all traceable apps\n"); - fprintf(ofp, " -p, --pid PID If -u, apply on a specific PID\n"); + fprintf(ofp, " If no CMD, the domain used is UST global\n"); + fprintf(ofp, " or else the domain is UST EXEC_NAME\n"); + fprintf(ofp, " -p, --pid PID If -u, apply to specific PID (domain: UST PID)\n"); +#else + fprintf(ofp, " -u, --userspace Apply for the user-space tracer\n"); +#endif fprintf(ofp, "\n"); fprintf(ofp, "Calibrate options:\n"); +#if 0 fprintf(ofp, " --tracepoint Tracepoint event (default)\n"); fprintf(ofp, " --probe\n"); fprintf(ofp, " Dynamic probe.\n"); - fprintf(ofp, " --function\n"); - fprintf(ofp, " Dynamic function entry/return probe.\n"); #if 0 fprintf(ofp, " --function:entry symbol\n"); fprintf(ofp, " Function tracer event\n"); #endif fprintf(ofp, " --syscall System call eventl\n"); fprintf(ofp, " --marker User-space marker (deprecated)\n"); +#else + fprintf(ofp, " --function Dynamic function entry/return probe (default)\n"); +#endif fprintf(ofp, "\n"); } @@ -114,52 +130,48 @@ static int calibrate_lttng(void) /* Create lttng domain */ if (opt_kernel) { dom.type = LTTNG_DOMAIN_KERNEL; + } else if (opt_userspace) { + dom.type = LTTNG_DOMAIN_UST; + } else { + ERR("Please specify a tracer (-k/--kernel or -u/--userspace)"); + ret = CMD_UNDEFINED; + goto error; } handle = lttng_create_handle(NULL, &dom); if (handle == NULL) { ret = -1; - goto end; + goto error; } - /* Kernel tracer action */ - if (opt_kernel) { - switch (opt_event_type) { - case LTTNG_EVENT_TRACEPOINT: - DBG("Calibrating kernel tracepoints"); - break; - case LTTNG_EVENT_PROBE: - DBG("Calibrating kernel probes"); - break; - case LTTNG_EVENT_FUNCTION: - DBG("Calibrating kernel functions"); - calibrate.type = LTTNG_CALIBRATE_FUNCTION; - ret = lttng_calibrate(handle, &calibrate); - break; - case LTTNG_EVENT_FUNCTION_ENTRY: - DBG("Calibrating kernel function entry"); - break; - case LTTNG_EVENT_SYSCALL: - DBG("Calibrating kernel syscall"); - break; - default: - ret = CMD_NOT_IMPLEMENTED; - goto end; + switch (opt_event_type) { + case LTTNG_EVENT_TRACEPOINT: + DBG("Calibrating kernel tracepoints"); + break; + case LTTNG_EVENT_PROBE: + DBG("Calibrating kernel probes"); + break; + case LTTNG_EVENT_FUNCTION: + DBG("Calibrating kernel functions"); + calibrate.type = LTTNG_CALIBRATE_FUNCTION; + ret = lttng_calibrate(handle, &calibrate); + if (ret < 0) { + goto error; } - } else if (opt_userspace) { /* User-space tracer action */ - /* - * TODO: Waiting on lttng UST 2.0 - */ - if (opt_pid_all) { - } else if (opt_pid != 0) { - } - ret = CMD_NOT_IMPLEMENTED; - goto end; - } else { - ERR("Please specify a tracer (--kernel or --userspace)"); - goto end; + MSG("%s calibration done", opt_kernel ? "Kernel" : "UST"); + break; + case LTTNG_EVENT_FUNCTION_ENTRY: + DBG("Calibrating kernel function entry"); + break; + case LTTNG_EVENT_SYSCALL: + DBG("Calibrating kernel syscall"); + break; + default: + ret = CMD_UNDEFINED; + goto error; } -end: + +error: lttng_destroy_handle(handle); return ret; @@ -179,7 +191,7 @@ int cmd_calibrate(int argc, const char **argv) poptReadDefaultConfig(pc, 0); /* Default event type */ - opt_event_type = LTTNG_EVENT_TRACEPOINT; + opt_event_type = LTTNG_EVENT_FUNCTION; while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { @@ -188,26 +200,30 @@ int cmd_calibrate(int argc, const char **argv) ret = CMD_SUCCESS; goto end; case OPT_TRACEPOINT: - ret = CMD_NOT_IMPLEMENTED; - break; + ret = CMD_UNDEFINED; + goto end; case OPT_MARKER: - ret = CMD_NOT_IMPLEMENTED; + ret = CMD_UNDEFINED; goto end; case OPT_PROBE: - ret = CMD_NOT_IMPLEMENTED; + ret = CMD_UNDEFINED; break; case OPT_FUNCTION: opt_event_type = LTTNG_EVENT_FUNCTION; break; case OPT_FUNCTION_ENTRY: - ret = CMD_NOT_IMPLEMENTED; - break; + ret = CMD_UNDEFINED; + goto end; case OPT_SYSCALL: - ret = CMD_NOT_IMPLEMENTED; - break; + ret = CMD_UNDEFINED; + goto end; case OPT_USERSPACE: opt_userspace = 1; break; + case OPT_LIST_OPTIONS: + list_cmd_options(stdout, long_options); + ret = CMD_SUCCESS; + goto end; default: usage(stderr); ret = CMD_UNDEFINED;