Add a lttng-ctl header to facilitate code separation

In order for lttng-ctl.c not to grow into an uncontrollable monster of
code, add this helper header and remove static declaration of some
functions to be exported out of the C file and set them hidden.

Future work on snapshot and trigger will use it in order to better split
the code into different files.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Move multiple URLs parsing fct from lttng-ctl to uri.c

Just move some functions around so we can use the multiple URLs parsing
to URIs function outside of liblttng-ctl.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Add consumer-stream.c/.h in libconsumer

These new files contain relevant calls to a lttng_consumer_stream object
and for now breaks down consumer_del_stream() from consumer.c that got
out of hand in terms of size and can not be used if the stream was not
previously successfully sent to a thread making difficult the deletion
of a stream in some error path or in no monitor mode (future mode for
streams with snapshots) outside of this use case.

It helps also modularize the consumer object and makes the code easier
to maintain and to better evolve.

At this commit, no components use this yet. Future work will
incrementaly move every consumer stream specific actions to that
seperate API.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Use the consumer stream API in consumer_del_stream()

Signed-off-by: David Goulet <dgoulet@efficios.com>
Initial import of the snapshot ABI/API in lttng-ctl

Nothing on the session daemon side as been added except the command
values added to the process client command subsystem.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Add snapshot command to lttng UI

Signed-off-by: David Goulet <dgoulet@efficios.com>
Implement snapshot commands in lttng-sessiond

Basic functionalities are implemented in the session daemon so handle
snapshots and send the command to the consumer but note that at this
commit the consumer does not handle snapshot.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Support flight recorder mode for a session

This adds the --no-output option to the lttng UI which will flag a
session to not set an output destination meaning that tracing will be in
overwrite mode in the buffers.

This is also the only way for now to snapshot a session, it's to put it
in no output mode.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Add kernel snapshot support

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: consumer handling of metadata for relayd

This patch sends the metadata stream to relayd and close it once done.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: set hidden attribute to utils_* calls

Signed-off-by: David Goulet <dgoulet@efficios.com>
Add utils function to format current time as a string

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: snapshot path

Signed-off-by: David Goulet <dgoulet@efficios.com>
Update URCU detection to correctly check for a 0.7 version

Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
Fix: consumer double-close on error

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: send per-pid session id in channel creation

The registry indexing for per-pid sessions is done with a per-pid
session id. So for per-pid buffers, we need to send the per-pid session
id as well as the global session id to the consumer in order to give it
enough information if it needs to request metadata later.

This patch adds the session_id_per_pid to the channel creation message
and to the consumer. When the sessiond receives a metadata_request,
depending on the buffer type (per-pid or per-uid), it selects the right
id to do the registry lookup.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>

Conflicts:
	src/bin/lttng-sessiond/consumer.c
	src/bin/lttng-sessiond/consumer.h
	src/bin/lttng-sessiond/ust-consumer.c
	src/common/consumer.c
	src/common/consumer.h
	src/common/kernel-consumer/kernel-consumer.c
	src/common/sessiond-comm/sessiond-comm.h
	src/common/ust-consumer/ust-consumer.c
Fix UST channel/stream output assignation

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: consumer: 64-bit index for relayd rather than 32-bit (v2)

Relayd "unique" ids wrap every 32-bit, and in some cases, negative
values are considered as error.

Change this to make the error value specifically -1ULL, use a direct
comparison (since we use an unsigned 64-bit integer, comparison with 0
becomes incorrect).

Since we now use a 64-bit ID, it is assumed to _never_ wrap-around
(remember, value -1ULL is an _error_). Therefore,
consumer_add_relayd_socket() can become much more strict than it was:
instead of accepting re-use of net_seq_idx, we can now assert that upon
LTTNG_STREAM_CONTROL socket, we have indeed allocated a relayd object,
and upon LTTNG_STREAM_DATA, we have found a relayd object.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: periodical flush check trace before stop

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: use snapshot consumer output for kernel

Signed-off-by: David Goulet <dgoulet@efficios.com>