Implement event fields listing
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index c5887fe65ead21a41f637aafa3adc10d60e0eb45..96a54f881c8e5df2b9225bed57997be0c4339cda 100644 (file)
@@ -5,19 +5,18 @@
  *
  * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
  *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #define _GNU_SOURCE
@@ -41,6 +40,18 @@ static char sessiond_sock_path[PATH_MAX];
 static char *tracing_group;
 static int connected;
 
+/* Global */
+
+/*
+ * Those two variables are used by error.h to silent or control the verbosity of
+ * error message. They are global to the library so application linking with it
+ * are able to compile correctly and also control verbosity of the library.
+ *
+ * Note that it is *not* possible to silent ERR() and PERROR() macros.
+ */
+int lttng_opt_quiet;
+int lttng_opt_verbose;
+
 /*
  * Copy string from src to dst and enforce null terminated byte.
  */
@@ -669,6 +680,33 @@ int lttng_list_tracepoints(struct lttng_handle *handle,
        return ret / sizeof(struct lttng_event);
 }
 
+/*
+ *  Lists all available tracepoint fields of domain.
+ *  Sets the contents of the event field array.
+ *  Returns the number of lttng_event_field entries in events;
+ *  on error, returns a negative value.
+ */
+int lttng_list_tracepoint_fields(struct lttng_handle *handle,
+               struct lttng_event_field **fields)
+{
+       int ret;
+       struct lttcomm_session_msg lsm;
+
+       if (handle == NULL) {
+               return -1;
+       }
+
+       lsm.cmd_type = LTTNG_LIST_TRACEPOINT_FIELDS;
+       copy_lttng_domain(&lsm.domain, &handle->domain);
+
+       ret = ask_sessiond(&lsm, (void **) fields);
+       if (ret < 0) {
+               return ret;
+       }
+
+       return ret / sizeof(struct lttng_event_field);
+}
+
 /*
  *  Returns a human readable string describing
  *  the error code (a negative value).
This page took 0.02433 seconds and 4 git commands to generate.