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>
David Goulet [Thu, 12 Jan 2012 18:04:51 +0000 (13:04 -0500)]
Fix out of order channel insert in hash table
The channel, ust-app side, was added to the hash table of the session
even if the creation failed on the tracer side. When enabling event for
that channel, a segfault was hit since the channel did not exist on the
tracer side and channel_data was NULL at this point.
Now the channel insertion in the hash table is done *after* enabling it
on the tracer side.
Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Thu, 12 Jan 2012 15:47:13 +0000 (10:47 -0500)]
Fix trace UST destroy channel
The trace_ust_destroy_channel call was iterating over the internal
events hash table and destroying the complete hash table at each event
which makes no sense at all. This caused a major segfault in the hash
table data structure when destroying a session.
Reported-by: Tan Dung Le Tran<tan.dung.le.tran@ericsson.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
lttng-sessiond: do not call ustctl_register_done()
When lttng-ust support is not enabled, compilation might fail with:
lttng-tools.git/lttng-sessiond/main.c:1167: undefined reference to
`ustctl_register_done'
Actually when HAVE_LIBLTTNG_UST_CTL is not defined, the function call is
normally optimized out by the compiler because ust_app_register() is a
static inline alway returning a negative value, leaving the call within
unreachable code.
Depending on the compiler version and optimization flags, this may
however not always happen, leading to the above error.
Therefore replace ustctl_register_done() with ustapp_register_done(),
which calls the original function when lttng-ust is enabled, and returns
an error otherwise (it is unreachable code anyway).
Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Fri, 16 Dec 2011 22:14:21 +0000 (17:14 -0500)]
Add and support the new hash table library
liblttng-ht/ is the library introduced for hash table management.
This library uses the URCU ht-shrink branch (not yet upstream) making
the lib completely lockless. Import git head URCU hashtables at commit: 91a75cc579698814e47877cc8927fcae1f573739
Note that urcu hash table files are copied from the urcu git ree to this
git tree waiting for them to be upstream and stable.
Old hash table files are removed from libcommon.
Signed-off-by: David Goulet <dgoulet@efficios.com>
Having to clone the vma each time runas is executed brings a significant
slowdown to the "start" operation when done with attached application,
and to the file creation needed when an application is attaching to the
sessiond. Use CLONE_VM flag to speed this up.
Calling exit() from the cloned process is a bad idea, because we share
file descriptors with the parent, and exit() has side-effects (anyway,
more than the low-level _exit()).
Only seteuid/setegid if they differ from current values
According to seteuid(2):
According to POSIX.1, seteuid() (setegid()) need not permit euid (egid)
to be the same value as the current effective user (group) ID, and some
implementations do not permit this.
Create all trace directories and files with client user credentials
Keep the client user credentials that created a session along with the
session. Use exactly those credentials to chown the created directories
and files.
David Goulet [Fri, 16 Dec 2011 17:15:28 +0000 (12:15 -0500)]
Support creds passing between lttng and sessiond
From now on, the lttng command line sends it's credential at each
command along with the regular communication data.
The tracing output directory is set to those credentials (uid/gid) if
the session daemon is running as a regular user (even if the user is in
the tracing group). So *no* tracing group is ever set if the session
daemon is not running as a non-root user.
If the sessiond is running as root, the tracing group is set (if exist)
and the uid of the calling user is used.
This fixes the triple enable-channel/event needed to trace UST
applications with a non-root session daemon. This was reported by
Yannick Brosseau <yannick.brosseau@polymtl.ca>.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Fri, 16 Dec 2011 17:12:35 +0000 (12:12 -0500)]
Add support for passing credentials over Unix sock
Add lttcomm_* functions for sending, receiving and setting socket option
to pass credentials over a Unix socket. Those functions allowed normal
data to be pass as well.
First commit of a series to enable credentials passing between the lttng
command line client and the session daemon.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Tue, 13 Dec 2011 20:50:16 +0000 (15:50 -0500)]
Fix register consumer fd test on registration
When a kernel session is created, a consumer is immediately spawned. So,
using two sessions, the second one was not able to register it's own
consumer since the consumer_fd is set because there is a running kernel
consumer from the first created session. The flag consumer_fds_sent is
now used to test if the kernel consumer is already consuming buffers.
Reported-by: Julien Desfossez <julien.desfossez@polymtl.ca> Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Thu, 8 Dec 2011 20:49:02 +0000 (15:49 -0500)]
Add non-root support for UST tracing
User-space tracing can now be used without root access meaning that the
session daemon can run with the user credentials and trace his own
applications.
This adds the LTTNG_HOME_RUNDIR which is located, under non privileged
user, in $HOME/.lttng. It contains all the control and consumers
sockets. It is cleanup when lttng-sessiond dies.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Wed, 7 Dec 2011 23:24:49 +0000 (18:24 -0500)]
Multiple fixes for enable/disable UST support
Makes the enable/disable command inside the main.c uses the event.c
functions. For this, the disable tracepoint functions (single and all)
for UST are added to event.c
Also fix the goto error path in event.c for disable/enable functions
where the UST event was removed from the hashtable if the event already
exist on the tracer side.
Fix the wrong hashtable being used for events lookup in ust_app.c for
enable/disable event for UST global domain.
Adds the disable event per PID function call in ust_app.c
Use the consumerd_bin variables for kernel consumers too
Right now the sessiond will only look in its own directory for
the consumerd when starting a kernel trace. This patch makes it
check for consumerd32_bin and consumerd64_bin too.
The _path suffix was confusing as to whether it would include the
filename at the end or not. In fact it should (to allow greater
flexibility in moving/renaming the consumerd executable).
Rename all configure options, env vars and substition variables to
consumerd32/64_bin instead, and expect the user to pass a complete
basename + filename to those.
- memcpy data _after_ reallocation (corruption fix),
- fix off-by-one in size check (corruption fix),
- multiply size by 2 each time size increase is needed (optimisation).
After careful review of popt cvs tree, after cross-correlation of CHANGE
file with source code POPT_ARGFLAG_OPTIONAL updates, identified that the
updates to this part of the code end at 1.13.