Fix: function definition and declaration mismatch

Fixes #476

Signed-off-by: David Goulet <dgoulet@efficios.com>
Move ust channel registry inside session registry

This is more logical with the way we do locking where a channel can not
exist without a session so accessing a channel implies the session lock.

Also, this patch makes the session registry a pointer that we allocate
and free on destroy.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Support per UID buffers

This is a rather large commit. It adds the support for per UID buffers
for the user space tracer.

The --buffers-uid option is added to the lttng enable-channel command
which will set the session to use per UID buffers. So, all other channel
in that session MUST be set with the same buffer type or else an error
will be returned. For instance, here is an invalid use case:

$ lttng create
$ lttng enable-channel -u --buffers-uid chan1
$ lttng enable-channel -u chan2

The default is per PID (--buffers-pid). With no buffer type option, the
per PID is used for the UST tracer and global buffers for the kernel
being the only supported type for it (--buffers-global).

The tracing directory path are also changed to support this. For per UID
buffers, the path is now:

	~/lttng-traces/ust/uid/1000/64-bit/*

For per PID buffers:

	~/lttng-traces/<session_name>-<date>-<time>/ust/pid/ \
		<app-name>-<pid>-<date>-<time>/

So basically, for UID, traces are stored per UID/ABI and for PID is
simply stored with the app name and pid. The kernel traces are untouched
and are still in kernel/.

Tests are also added for per UID buffers.

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: wrong header path when compiling without UST support

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Memory leak on error paths of relay_add_stream

On error paths the memory allocated for stream is never freed.

Also, fix undefined behavior on asprintf alloc failure. According to
asprintf(3), the content of the pointer passed to it is undefined if an
alloc failure occurs, so we could end up freeing a pointer in an
undefined state. Force its value to NULL.

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Memory leaks on error paths in config_read_session_name

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Memory leaks on error paths when exporting consumerd libdir in env

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Memory leaks on unknown hashtable type error handling

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Memory leaks when calling get_cmdline_by_pid

Callers of get_cmdline_by_pid must free(3) the returned string.

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Memory leak when zmalloc fail on kernel channel allocation

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Use after free on spawn_sessiond error path in check_sessiond

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Add with-sessiond-bin configure option

I also cleaned up the little check_sessiond function. The check using
access(2) was only done for the command line option, but I think it is a
good idea to do it wherever the path comes from.

Closes #441

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Allow enable-channel to work with metadata channel

This makes the enable-channel command to support setting the metadata
channel attributes. Now, with the lttng UI and API, the metadata
attributes can be set.

$ lttng enable-channel metadata -u ...

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: handle error if metadata fails to be created

Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: change expected number of event for test uid

With UST commit d970f72ef97cd5f1e5e0152ce48a4c6b28eccfb2, enabling the
same events in two different channels make write them two times instead
of once.

This commit changes the number of expected events in one test for per
UID buffers.

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