+ fprintf(fp, "Usage : lttngtop [OPTIONS] TRACE\n");
+ fprintf(fp, " TRACE Path to the trace to analyse (-r for network live tracing, nothing for mmap live streaming)\n");
+ fprintf(fp, " -h, --help This help message\n");
+ fprintf(fp, " -t, --textdump Display live events in text-only\n");
+ fprintf(fp, " -p, --pid Comma-separated list of PIDs to display\n");
+ fprintf(fp, " -f, --child Follow threads associated with selected PIDs\n");
+ fprintf(fp, " -n, --hostname Comma-separated list of hostnames to display (require hostname context in trace)\n");
+ fprintf(fp, " -a, --all In textdump mode, display all events but write in bold the processes we are interested in (-f, -p and -n)\n");
+ fprintf(fp, " -k, --kprobes Comma-separated list of kprobes to insert (same format as lttng enable-event)\n");
+ fprintf(fp, " -r, --relay-hostname Network live streaming : hostname of the lttng-relayd (default port)\n");
+ fprintf(fp, " -b, --begin Network live streaming : read the trace for the beginning of the recording\n");
+ fprintf(fp, " -o, --output <filename> In textdump, output the log in <filename>\n");
+}
+
+/*
+ * Parse probe options.
+ * Shamelessly stolen from lttng-tools :
+ * src/bin/lttng/commands/enable_events.c
+ */
+static struct kprobes *parse_probe_opts(char *opt)
+{
+ char s_hex[19];
+ char name[LTTNG_SYMBOL_NAME_LEN];
+ struct kprobes *kprobe;
+ int ret;
+
+ /*
+ kprobe->probe_addr = 0;
+ kprobe->probe_offset = 0;
+ asprintf(&kprobe->probe_name, "probe_sys_open");
+ asprintf(&kprobe->symbol_name, "sys_open");
+ */
+
+ if (opt == NULL) {
+ kprobe = NULL;
+ goto end;
+ }
+
+ kprobe = g_new0(struct kprobes, 1);
+
+ /* Check for symbol+offset */
+ ret = sscanf(opt, "%[^'+']+%s", name, s_hex);
+ if (ret == 2) {
+ ret = asprintf(&kprobe->probe_name, "probe_%s", name);
+ ret = asprintf(&kprobe->symbol_name, "%s", name);
+
+ if (strlen(s_hex) == 0) {
+ fprintf(stderr, "Invalid probe offset %s", s_hex);
+ ret = -1;
+ goto end;
+ }
+ kprobe->probe_offset = strtoul(s_hex, NULL, 0);
+ kprobe->probe_addr = 0;
+ goto end;
+ }
+
+ /* Check for symbol */
+ if (isalpha(name[0])) {
+ ret = sscanf(opt, "%s", name);
+ if (ret == 1) {
+ ret = asprintf(&kprobe->probe_name, "probe_%s", name);
+ ret = asprintf(&kprobe->symbol_name, "%s", name);
+ kprobe->probe_offset = 0;
+ kprobe->probe_addr = 0;
+ goto end;
+ }
+ }
+
+ /* Check for address */
+ ret = sscanf(opt, "%s", s_hex);
+ if (ret > 0) {
+ if (strlen(s_hex) == 0) {
+ fprintf(stderr, "Invalid probe address %s", s_hex);
+ ret = -1;
+ goto end;
+ }
+ ret = asprintf(&kprobe->probe_name, "probe_%s", s_hex);
+ kprobe->probe_offset = 0;
+ kprobe->probe_addr = strtoul(s_hex, NULL, 0);
+ goto end;
+ }
+
+ /* No match */
+ kprobe = NULL;
+
+end:
+ return kprobe;