[lttng-dev] [PATCH] calibrate.c : Enforce exactly one domain flag, adjust usage() output accordingly, setup TODOs in calibrate_lttng()
Thibault, Daniel
Daniel.Thibault at drdc-rddc.gc.ca
Thu Feb 2 11:18:47 EST 2012
>From 764ce77ee249904c7b4cb72630d86a74f62a51fc Thu, 2 Feb 2012 11:17:36 -0500
From: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
Date: Thu, 2 Feb 2012 11:17:20 -0500
Subject: [PATCH] calibrate.c : Enforce exactly one domain flag, adjust usage() output accordingly, setup TODOs in calibrate_lttng()
Signed-off-by: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
diff --git a/src/bin/lttng/commands/calibrate.c b/src/bin/lttng/commands/calibrate.c
index dc95d24..2e390ae 100644
--- a/src/bin/lttng/commands/calibrate.c
+++ b/src/bin/lttng/commands/calibrate.c
@@ -86,6 +86,7 @@
static void usage(FILE *ofp)
{
fprintf(ofp, "usage: lttng calibrate [options] [calibrate_options]\n");
+ fprintf(ofp, "Exactly one domain (-k/--kernel or -u/--userspace) must be specified.\n");
fprintf(ofp, "\n");
fprintf(ofp, " -h, --help Show this help\n");
fprintf(ofp, " --list-options Simple listing of options\n");
@@ -93,7 +94,6 @@
#if 0
fprintf(ofp, " -u, --userspace [CMD] Apply to the user-space tracer (domain: UST\n");
fprintf(ofp, " EXEC_NAME). If no CMD, the domain is UST global.\n";
- fprintf(ofp, " (-k preempts -u)\n");
fprintf(ofp, " -p, --pid PID If -u, apply to specific PID (domain: UST PID)\n");
#else
fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n");
@@ -101,17 +101,15 @@
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, " --tracepoint Tracepoint event (default)\n");
+ fprintf(ofp, " --probe Dynamic probe.\n");
#if 0
- fprintf(ofp, " --function:entry symbol\n");
- fprintf(ofp, " Function tracer event\n");
+ fprintf(ofp, " --function:entry symbol Function tracer event\n");
#endif
- fprintf(ofp, " --syscall System call eventl\n");
- fprintf(ofp, " --marker User-space marker (deprecated)\n");
+ 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");
+ fprintf(ofp, " --function Dynamic function entry/return probe (default)\n");
#endif
fprintf(ofp, "\n");
}
@@ -128,14 +126,12 @@
struct lttng_calibrate calibrate;
/* Create lttng domain */
+ /* cmd_add_context() enforces the existence of exactly one domain flag */
if (opt_kernel) {
dom.type = LTTNG_DOMAIN_KERNEL;
- } else if (opt_userspace) {
+ } else { /* if (opt_userspace) { */
dom.type = LTTNG_DOMAIN_UST;
- } else {
- ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
- ret = CMD_ERROR;
- goto error;
+ /* TODO As LTTNG_DOMAIN_* values are added, capture them here */
}
handle = lttng_create_handle(NULL, &dom);
@@ -146,9 +142,11 @@
switch (opt_event_type) {
case LTTNG_EVENT_TRACEPOINT:
+ /* TODO Calibrate kernel tracepoints */
DBG("Calibrating kernel tracepoints");
break;
case LTTNG_EVENT_PROBE:
+ /* TODO Calibrate kernel probes */
DBG("Calibrating kernel probes");
break;
case LTTNG_EVENT_FUNCTION:
@@ -156,22 +154,23 @@
calibrate.type = LTTNG_CALIBRATE_FUNCTION;
ret = lttng_calibrate(handle, &calibrate);
if (ret < 0) {
+ ret = CMD_ERROR;
goto error;
}
MSG("%s calibration done", opt_kernel ? "Kernel" : "UST");
break;
case LTTNG_EVENT_FUNCTION_ENTRY:
+ /* TODO Calibrate kernel function entry */
DBG("Calibrating kernel function entry");
break;
case LTTNG_EVENT_SYSCALL:
+ /* TODO Calibrate kernel syscall */
DBG("Calibrating kernel syscall");
break;
default:
ret = CMD_UNDEFINED;
goto error;
}
-
- ret = CMD_SUCCESS;
error:
lttng_destroy_handle(handle);
@@ -231,6 +230,18 @@
}
}
+ /* Enforce requirement for exactly one domain */
+ /* Five LTTNG_DOMAIN_* values are currently planned */
+ if (!opt_userspace && !opt_kernel) {
+ ERR("No domain specified: Use one of -k/--kernel or -u/--userspace");
+ ret = CMD_ERROR;
+ goto end;
+ } else if (opt_userspace && opt_kernel) {
+ ERR("More than one domain specified");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
ret = calibrate_lttng();
end:
------------------------------
Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
Système de systèmes (SdS) / System of Systems (SoS)
Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
2459 Boul. Pie XI Nord
Québec, QC G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC: 918V QSDJ
Gouvernement du Canada / Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/>
More information about the lttng-dev
mailing list