*
* 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
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.
*/
memcpy(dst, src, sizeof(struct lttng_domain));
break;
default:
+ memset(dst, 0, sizeof(struct lttng_domain));
dst->type = LTTNG_DOMAIN_KERNEL;
break;
}
/* Get GID of group 'tracing' */
grp_tracing = getgrnam(grp_name);
- if (grp_tracing == NULL) {
- /* NULL means not found also. getgrnam(3) */
- if (errno != 0) {
- perror("getgrnam");
- }
+ if (!grp_tracing) {
+ /* If grp_tracing is NULL, the group does not exist. */
goto end;
}
return -1;
}
+ memset(&lsm, 0, sizeof(lsm));
+
lsm.cmd_type = LTTNG_ADD_CONTEXT;
/* Copy channel name */
return -1;
}
+ memset(&lsm, 0, sizeof(lsm));
+
/* If no channel name, we put the default name */
if (channel_name == NULL) {
copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME,
return -1;
}
+ memset(&lsm, 0, sizeof(lsm));
+
if (channel_name) {
copy_string(lsm.u.disable.channel_name, channel_name,
sizeof(lsm.u.disable.channel_name));
return -1;
}
+ memset(&lsm, 0, sizeof(lsm));
+
memcpy(&lsm.u.channel.chan, chan, sizeof(lsm.u.channel.chan));
lsm.cmd_type = LTTNG_ENABLE_CHANNEL;
return -1;
}
+ memset(&lsm, 0, sizeof(lsm));
+
lsm.cmd_type = LTTNG_DISABLE_CHANNEL;
copy_string(lsm.u.disable.channel_name, name,
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).
/*
* Set default channel attributes.
- * If either or both of the arguments are null, nothing happens.
+ * If either or both of the arguments are null, attr content is zeroe'd.
*/
void lttng_channel_set_default_attr(struct lttng_domain *domain,
struct lttng_channel_attr *attr)
{
+ memset(attr, 0, sizeof(struct lttng_channel_attr));
+
/* Safety check */
if (attr == NULL || domain == NULL) {
return;
attr->output = DEFAULT_UST_CHANNEL_OUTPUT;
break;
default:
- /* Default behavior */
- memset(attr, 0, sizeof(struct lttng_channel_attr));
+ /* Default behavior: leave set to 0. */
break;
}
}