David Goulet [Thu, 2 Feb 2012 16:47:37 +0000 (11:47 -0500)]
Fix EEXIST handling on epoll_ctl add
Creating a second channel on the kernel tracer triggers a
update_kernel_poll which iterates over all channels and add the file
descriptors to the epoll set. Collision occurs with the first previously
added channel so EEXIST is acceptable and we simply do not perror() to
keep the session daemon stderr clean.
Signed-off-by: David Goulet <dgoulet@efficios.com>
The create_session function was changed making the session name not
having the date and time append to it anymore. This completely broke the
default behavior of automatic session creation. Only one possible
session name was 'auto'.
Signed-off-by: David Goulet <dgoulet@efficios.com>
Thibault, Daniel [Mon, 30 Jan 2012 21:58:22 +0000 (16:58 -0500)]
Fixing memory leaks in add-context command
Besides enforcing the return values and outputting --help to stdout, the
problem lay with the instances of struct ctx_type *type being created
but not assigned to the doubly-linked list under various error
conditions.
Signed-off-by: Daniel U. Thibault <daniel.thibault@drdc-rddc.gc.ca> Signed-off-by: David Goulet <dgoulet@efficios.com>
Thibault, Daniel [Mon, 30 Jan 2012 21:26:34 +0000 (16:26 -0500)]
Rewrites lttng-ctl's set_session_daemon_path
This fifth patch rewrites lttng-ctl's set_session_daemon_path() to avoid
duplicating snippets of code. It also fixes the snprintf return value
test so the code works with both GNU C < 2.1 and >= 2.1. With GNU C <
2.1, snprintf returns -1 if the target buffer is too small; with GNU C
>= 2.1, snprintf returns the required size (excluding the closing null)
under the same conditions.
Signed-off-by: Daniel U. Thibault <daniel.thibault@drdc-rddc.gc.ca> Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Fri, 27 Jan 2012 17:43:54 +0000 (12:43 -0500)]
Add CMD_WARNING error code
The CMD_WARNING is returned if at least one command went wrong and at
least one succeeded. This shoudl tell the user that there is an error
message on stderr but the rest of the command went well.
One use case for that is the multiple -t of add_context. If one of them
fails, this code is returned.
This error code is added at the end of the enum so the previous CMD code
are not changed.
Also, if the tracer (-k/-u) is not specified, CMD_ERROR is returned
instead of CMD_UNDEFINED which makes way more sense.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Fri, 27 Jan 2012 15:37:45 +0000 (10:37 -0500)]
Fix comments and enforce expected return values
Improve calibrate and add_context usage() printout. Document and enforce
the expected return values for the cmd_calibrate/cmd_addcontext chain of
functions.
Fix add_context usage()
Add documentation in liblttng-ctl.
Signed-off-by: Daniel Thibault <daniel.thibault@drdc-rddc.gc.ca> Signed-off-by: David Goulet <dgoulet@efficios.com>
If the child is scheduled before the parent, using "pause()" in the
parent could be executed after the signal has been handled: that's
entirely racy. Use a proper signal handler and flag to handle this
racelessly.
- strncmp should compare up to and _include_ the \0 (was off by one).
Instead of 2 for "-h", it should be 3. Use "sizeof("-h")" instead of
hardcoding 3.
- strncmp logic was reversed for the --list-options check.
Simon Marchi [Tue, 24 Jan 2012 16:28:04 +0000 (11:28 -0500)]
Add a '--list-options' option to each command.
This is intended to be used for programmable Bash completion.
Modified from previous version:
- Changed '\0' to 0 to match current coding style.
Changes made by David Goulet:
- Check args for --list-options in lttng cli to stop auto execution of
the session daemon.
- Adds --list-options to all help. (Hidding command is bad :P)
- Fix uninitialized ret value in enable channel
Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Tue, 24 Jan 2012 16:49:49 +0000 (11:49 -0500)]
Check kernel version for tests
Test using the session daemon must be done on a kernel version 2.6.27 or
higher for lttng-tools and lttng-ust requirements. Before starting a
session daemon, tests validate the kernel version and stop them if the
kernel is too old.
This is *really* important for launchpad build system which compile and
run our tests on 2.6.24 kernel.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Tue, 24 Jan 2012 15:17:30 +0000 (10:17 -0500)]
Add MSG_WAITALL to recvmsg of sessiond-comm
Get the complete message on receive. We do not handle receiving split
data with the lttcomm_recv_unix_sock which is *not* good but for now we
will simply add this flag since every call should block anyway and does
not require any other funky flags.
This issue was detected with the kernel events listing failing by
sending half of the data half the time.
Reported-by: Daniel Thibault <daniel.thibault@drdc-rddc.gc.ca> Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Mon, 23 Jan 2012 19:12:46 +0000 (14:12 -0500)]
Change SIGCHLD to SIGUSR1 when lttng waiting on sessiond
Using lttng cli, if the session daemon dies after exec(), a SIGCHLD is
returned. It was catched but not handled to cleanly quit and inform the
user that the session daemon failed.
We now use SIGUSR1 to signal the lttng cli that the session daemon is
ready to receive command.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Mon, 23 Jan 2012 17:01:35 +0000 (12:01 -0500)]
Add UST version validation
Upon registration of an UST app, we now check the version compatibility
with the session daemon and set a compatible bit. Only the major version
is validated since major version bump implies ABI/API breakage.
For now, every action on the application list check the app compatible
bit before executing it. We are too close from a stable release so hard
*not standard* check is done across the map for ust-app. The downside is
that the client will not get informed of any incompatible app upon any
action on the tracer using lttng cli.
If the version is NOT compatible, the register done is sent and the app
is kept in the registry. We can't close the socket or deny the
registration because if the env. var LTTNG_UST_REGISTER_TIMEOUT=-1 is
set on the app side, infinite loop will occur and possibly stall the
app.
New sessiond comm. version error added but not use at this commit.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Sun, 22 Jan 2012 21:11:11 +0000 (16:11 -0500)]
Add kernel module version validation
The session daemon now checks if the kernel modules are compatible
whenever it tries to load them.
Introduce modprobe.c/.h and kern-modules.h that contains the lttng
modules information and function to load/remove them. Also add a call to
kernel.c for kernel version validation.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Fri, 20 Jan 2012 21:30:23 +0000 (16:30 -0500)]
Split and remove lttng-share header file
This header is split into two files: defaults.h and macros.h.
A third header is introduce here which is common.h including runas.h and
macros.h which are part of the common library. Since the defaults.h
contains only defaults values, it seems ok to keep it seperate from the
common library having only macros and function calls.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Fri, 20 Jan 2012 18:17:16 +0000 (13:17 -0500)]
Complete change of the source directory tree
For the sake of clearness and awesomeness :P, this change was needed for
better semantic across the code and better organization of source files.
src/
--> Contains source files of the project
bin/
--> Contains every binaries this git tree builds (lttng,
lttng-sessiond and lttng-consumerd).
lib/
--> Contains exported libraries (lttng-ctl).
common/
--> Contains shared code for the entire project. (internal
libraries mostly)
Every internal headers are moved from include/ to src/common. The
include directory only contains exported public headers now
(lttng/lttng.h). The -I$(top_srcdir)/src is also added for all
Makefiles.
The consumerd APIs are not exported anymore. The reason is that the
consumer will get completely re-engineered in the next months. It's our
safety net for the APIs breakage of the coming year concerning the
consumerd library.
Renaming is done also on some internal libraries to follow the naming
convention. The public library liblttngctl is renamed to liblttng-ctl
making it linkable now with "-llttng-ctl" deprecating the old
"-llttngctl".
No code is changed with this commit except #include statements
added/removed/renamed. This is why there is yet files and internal API
calls that does not follow the naming convention (Ex: lttngerr.h,
lttng-share.h in src/common).
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Thu, 19 Jan 2012 18:43:57 +0000 (13:43 -0500)]
Don't init kernel tracer if not root (UID=0)
No point of trying to init kernel tracer if the session daemon is not
root. At this time, only UID=0 can load kernel modules and interact with
the lttng kernel tracer.
Reported-by: Daniel Thibault <daniel.thibault@drdc-rddc.gc.ca> Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Tue, 17 Jan 2012 22:05:10 +0000 (17:05 -0500)]
Fix double free and out of order delete session
Failing to create metadata, the data structure was freed but the pointer
was not set to NULL. When deleting the metadata of that session (that
has failed), the pointer was not NULL creating a "valid" pointer for the
check and creating a double free error. This failure happens when the
session daemon reached the maximum number of open files.
Also, on destroy trace, the ust app session was freed and deref. just
after creating an invalid pointer access.
Finally, set the started flag of a ust app session to 0 when stopping
the session.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Mon, 16 Jan 2012 22:25:49 +0000 (17:25 -0500)]
Add UST test for n events using validation
ust-nevents tests an instrumented application generating 100 events and
validating that those events are found using babeltrace (need to be
installed).
Adds the tests/utils.sh which is a family of function used to interact
with lttng cli. There is also a trace_matches function which uses
babeltrace to find string patterns.
Also, the session daemon is spawned at the beginning of runall.sh and
killed at the end. This means that all tests are done on a single
session daemon instance. Thus, session name across tests have to be
unique! From now on, each test should use the file name as a unique
identifier for the session name.
Finally, fixed the session name for all tests. At this commit, "make
check" or "sudo make check" should pass.
Signed-off-by: David Goulet <dgoulet@efficios.com>