/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; only version 2
- * of the License.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 only,
+ * as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _GNU_SOURCE
#include <common/common.h>
#include <common/defaults.h>
+#include "consumer.h"
#include "trace-kernel.h"
/*
lks->channel_count = 0;
lks->stream_count_global = 0;
lks->metadata = NULL;
- lks->consumer_fd = -1;
CDS_INIT_LIST_HEAD(&lks->channel_list.head);
+ /* Create default consumer output object */
+ lks->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
+ if (lks->consumer == NULL) {
+ goto error;
+ }
+
+ /*
+ * The tmp_consumer stays NULL until a set_consumer_uri command is
+ * executed. At this point, the consumer should be nullify until an
+ * enable_consumer command. This assignment is symbolic since we've zmalloc
+ * the struct.
+ */
+ lks->tmp_consumer = NULL;
+
+ /* Use the default consumer output which is the tracing session path. */
+ ret = snprintf(lks->consumer->dst.trace_path, PATH_MAX, "%s/kernel", path);
+ if (ret < 0) {
+ PERROR("snprintf consumer trace path");
+ goto error;
+ }
+
/* Set session path */
ret = asprintf(&lks->trace_path, "%s/kernel", path);
if (ret < 0) {
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *chan, char *path)
+struct ltt_kernel_channel *trace_kernel_create_channel(
+ struct lttng_channel *chan, char *path)
{
- int ret;
struct ltt_kernel_channel *lkc;
lkc = zmalloc(sizeof(struct ltt_kernel_channel));
/* Init linked list */
CDS_INIT_LIST_HEAD(&lkc->events_list.head);
CDS_INIT_LIST_HEAD(&lkc->stream_list.head);
- /* Set default trace output path */
- ret = asprintf(&lkc->pathname, "%s", path);
- if (ret < 0) {
- PERROR("asprintf kernel create channel");
- goto error;
- }
return lkc;
return lke;
error:
+ free(lke);
+ free(attr);
return NULL;
}
*/
struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path)
{
- int ret;
struct ltt_kernel_metadata *lkm;
struct lttng_channel *chan;
/* Init metadata */
lkm->fd = -1;
lkm->conf = chan;
- /* Set default metadata path */
- ret = asprintf(&lkm->pathname, "%s/metadata", path);
- if (ret < 0) {
- PERROR("asprintf kernel metadata");
- goto error;
- }
return lkm;
error:
+ free(lkm);
+ free(chan);
return NULL;
}
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_stream *trace_kernel_create_stream(void)
+struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
+ unsigned int count)
{
+ int ret;
struct ltt_kernel_stream *lks;
lks = zmalloc(sizeof(struct ltt_kernel_stream));
goto error;
}
+ /* Set name */
+ ret = snprintf(lks->name, sizeof(lks->name), "%s_%d", name, count);
+ if (ret < 0) {
+ PERROR("snprintf stream name");
+ goto error;
+ }
+ lks->name[sizeof(lks->name) - 1] = '\0';
+
/* Init stream */
lks->fd = -1;
- lks->pathname = NULL;
lks->state = 0;
return lks;
/* Remove from stream list */
cds_list_del(&stream->list);
- free(stream->pathname);
free(stream);
}
/* Remove from channel list */
cds_list_del(&channel->list);
- free(channel->pathname);
free(channel->channel);
free(channel->ctx);
free(channel);
}
free(metadata->conf);
- free(metadata->pathname);
free(metadata);
}
trace_kernel_destroy_channel(channel);
}
+ /* Wipe consumer output object */
+ consumer_destroy_output(session->consumer);
+ consumer_destroy_output(session->tmp_consumer);
+
free(session->trace_path);
free(session);
}