Fix: Include child loggers in the output of "lttng list"
The case where a parent logger has an handler attached but the
tracepoint comes from a child logger is not correctly handled
by the "lttng list -j/-l" command.
For example, if the logger "org.myapp" has a LTTng handler
attached, its child logger "org.myapp.mycomponent" would be
absent from the lttng list output even if it exists.
When checking for events to list, search through the parent
tree of each logger to find a potential LTTng handler.
This should also fix the problem of "lttng list" always
returning empty when the deprecated, but still supported,
LTTngAgent API was used, since that one attaches only one
handler to the root logger.
Fix: Handle both agent config files pointing to same port
The expected locations for the user and root agent sessiond
configuration files are ~/.lttng/agent.port and
/var/run/lttng/agent.port, respectively. These files indicate
which port an agent should connect to to reach its respective
sessiond.
If by some bad luck both files indicate the same port, then
both Java TCP clients would end up connecting to the same
sessiond, resulting in weird results, like "lttng list" listing
all events twice.
Make sure the target ports are different, and avoid duplicate
connections in case there are not.
The LTTngAgent#dispose method is static on purpose (see commit 9355f049), and will remain so as long as this agent will be
supported, so we can suppress the compiler warning telling
us the method can be made static.
There can be up to 4 TCP clients running at the same time
(for all combinations of user/root and jul/log4j), the
logging should differentiate between them.
Jonathan Rajotte [Thu, 26 May 2016 22:05:12 +0000 (18:05 -0400)]
Fix: log4j example: set logger level to prevent unexpected level inheritance
BSF or other jars can ship with log4j.properties file embedded. This
causes problem when launching application with a general class path (e.g
/usr/share/java/*) since log4j will look for a property file in all
loaded jars. If any contains directive for the root logger it will
affect any logger with no level who are directly under the root logger.
This could result in an unexpected behaviour (e.g no events triggered
etc.).
Link: https://issues.apache.org/jira/browse/BSF-24 Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: initialize RCU callbacks with mixed LGPL/non-LGPL objects
Linking both _LGPL_SOURCE and non-_LGPL_SOURCE objects into the same
module may result in having the RCU callbacks left to NULL, which
prevents tracing for tracepoints and/or probes which sit in the non-LGPL
compile unit.
This happens if the contructor of the LGPL compile unit is executed
first, thus incrementing the __tracepoint_registered counter, which will
prevent later execution of that same constructor in the non-LGPL compile
unit to initialize the RCU callbacks in __tracepoint__init_urcu_sym().
Fix: incorrect structure layout with mixed LGPL/non-LGPL objects
Linking both _LGPL_SOURCE and non-_LGPL_SOURCE objects into the same
module may result in corruption. If the tracepoint_dlopen object used is
the one declared by a LGPL compile unit, a non-LGPL compile unit may try
to initialize fields beyond the end of the structure.
Fix: don't call __builtin_return_address(0) on 32-bit powerpc
Invoking __builtin_return_address(0) corrupts the stack, as previously
noticed for the "ip" context. Disable its use on 32-bit powerpc
everywhere else in the lttng-ust code base.
Fix: update debug message about weak-hidden symbols
We actually deal OK with compilers that treats weak-hidden symbols as
different addresses between compile units part of the same module.
Simply report this without statement on whether or not the compiler
producing this code is broken.
Fix: work-around gcc optimisation oddness on 32-bit powerpc
Deal with gcc O1 optimisation issues with weak hidden symbols. gcc 4.8
and prior does not have the same behavior for symbol scoping on 32-bit
powerpc depending on the object size: symbols for objects of 8 bytes or
less have the same address throughout a module, whereas they have
different addresses between compile units for objects larger than 8
bytes. Add this pointer indirection to ensure that the symbol scoping
match that of the other weak hidden symbols found in tracepoint.h.
On many architectures (arm32, arm64, powerpc64) gcc chooses to assign
different addresses to weak-hidden symbols from different compile units
within the same module.
This is unfortunate, but still OK with respect to tracepoints.
The real issue is on 32-bit powerpc, where gcc (in O1 or more) assigns
different addresses only for objects larger than 8 bytes, but same
addresses for objects of 8 bytes or less (int and pointers).
test: add test for gcc issue with weak hidden symbol on powerpc
On Ubuntu 32-bit powerpc, gcc 4.4, 4.6, 4.8, gcc -O1 (and O2) causes
weak hidden symbols to have different addresses within the same module.
It seems to be fixed in gcc 4.9 on powerpc.
This issue causes some tracepoints to be silently hidden from LTTng.
Restrict Java context retriever names to a set of valid characters
Since the context/retriever names end up as-is as part of the
metadata, only alphanumerical characters, periods "." and
underscores "_" should be accepted. The names must also not
start with a number.
Refuse registration of retriever names that do not respect these
conditions, so that the problem is reported right away to the
application.
Fix: Correctly compute Java agent list loggers response size
The code was assuming that (number of characters == number of bytes),
which is not always the case!
The notions of number of bytes and data sizes only make sense when
the strings are encoded into byte arrays. The response's getBytes()
method should the only one handling these concepts.
Commit 9355f049 changed the dispose() back to non-static. However,
"static synchronized" and "synchronized" are not the same thing!
The latter synchronizes on the instance, but the former synchronizes
on the class object.
In this case we need to synchronize on the class object manually.
Fix: Verify number of bytes contained in sessiond agent commands
The command header indicates the number of bytes in the payload.
Make sure those bytes were really present on the socket, and throw
an error if they were not.
Michael Jeanson [Wed, 18 May 2016 19:18:05 +0000 (15:18 -0400)]
Fix: merge tap tests stdout and stderr
This makes the output and error statement ordered in the log
file and ensure that the first line is the tap test plan. Some tap
parser are confused if the test plan is not on the first line.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Thu, 12 May 2016 15:01:18 +0000 (11:01 -0400)]
Tests: Replace prove by autotools tap runner
This patch removes the dependency on the prove perl script
to run the TAP test suite. It replaces it with the autotools
shell TAP driver that only requires a shell and awk.
Custom arguments can be passed to the test runner with
env variables as follow:
env LOG_DRIVER_FLAGS='--comments --ignore-exit' \
TESTS='foo.test baz.test' make -e check
This tap driver also creates a log file for each test that
can then be used by another system to build a test report.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
"make distcheck" marks each source file on the srcdir in the extracted
dist tarball read-only. The examples copy from the srcdir into the
builddir before running the "make" examples, but this keeps the
read-only flag on the builddir directories, which fails the build
because the resulting objects cannot be created.
Fix this by ensuring the copied target directory for each example is
user-writeable.
Those underscore-prefixed symbols are only used internally within the
tracepoint provider. Declare them as static symbols, thus removing
unneeded global symbols which are not meant to be used by applications.
Antoine Busque [Mon, 9 May 2016 21:54:44 +0000 (17:54 -0400)]
Fix: erroneous computation of ELF in-memory size
The current algorithm for computation of ELF in-memory size computed
values using the `p_align` field from program headers to align loaded
segments, when in fact `p_align` is only used to describe the
relationship between a segment's offset in the ELF file and its
virtual address once loaded in memory (`p_vaddr`), not the alignment
between segments. (Refer to the ELF specification version 1.1 at pages
2-2 and 2-8 for more details.)
This implementation instead uses the `p_memsz` and `p_vaddr` fields to
compute the highest virtual address of the executable, and uses the
difference from its base address as the in-memory size.
Signed-off-by: Antoine Busque <abusque@efficios.com>
Antoine Busque [Mon, 9 May 2016 20:33:29 +0000 (16:33 -0400)]
Fix: remove NULL check of nonnull parameter in dlclose
The `handle` parameter of `dlclose`, as defined in
`include/lttng/ust-dlfcn.h` is marked `__nonnull`. GCC starting with
version 6.1 emits warnings for comparisons of nonnull arguments
against NULL by default (see -Wnonnull-compare).
Therefore, this removes a superfluous NULL check on `handle`, for
which GCC emitted a warning.
Signed-off-by: Antoine Busque <abusque@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
We need to byteswap integers passed to the filter when they are tagged
as being in an endianness which differs from the architecture
endianness, so the integer comparisons make sense in terms of value
rather than raw bytes for those fields.
Antoine Busque [Wed, 20 Apr 2016 17:09:07 +0000 (13:09 -0400)]
Rename statedump and dl events and fields
The current names of the `lttng_ust_statedump:soinfo` event, as well
as its field `sopath` both refer exclusively to shared objects (so),
although the event applies to any executables, including
position-independent executables (PIE), as well as shared objects.
Thus, this patch changes the name of the event to `bin_info` and the
field to `path`, to avoid any confusion.
For consistency, the `sopath` field in the `lttng_ust_dl:dlopen` event
is also renamed to `path`, although dlopen only applies to shared
objects.
Signed-off-by: Antoine Busque <abusque@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Antoine Busque [Fri, 15 Apr 2016 17:18:04 +0000 (13:18 -0400)]
Tests: add tests for lttng_ust_elf_is_pic
This adds tests for the lttng_ust_elf_is_pic function used to tell
whether an executable is position independent code or not. Three
sample executables are used, one non-PIC executable, one PIE, and a
PIC shared object.
Signed-off-by: Antoine Busque <abusque@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Antoine Busque [Wed, 13 Apr 2016 21:31:57 +0000 (17:31 -0400)]
Add is_pic field to statedump soinfo event
This field indicates whether the executable or library is position
independent code (PIC). The field is not added to the similar dlopen
event from liblttng-ust-dl because in that case all dlopened libraries
are necessarily PIC.
This allows a posteriori analyses to be performed without having to
read the executable file to know whether adresses are relative to the
base address or absolute.
Signed-off-by: Antoine Busque <abusque@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: rename liblttng-ust-agent to lttng-ust-agent-all
Rename liblttng-ust-agent to lttng-ust-agent-all to respect the new
jar file naming scheme, but keep a symbolic link from liblttng-ust-agent
to lttng-ust-agent-all to keep backwards compatibility.
The UST 2.7 java agent LTTngAgent class has a non-static dispose method.
This class is kept in 2.8 for backwards compatibility purposes. Keep
this API unchanged.
The built troff man pages should be distributed in a release
tarball. When building from a release tarball, the tools (asciidoc
and xmlto) are not strictly needed, unless a man page source is
modified/removed, in which case:
if the tools existed at configure time:
rebuild/update man page
otherwise:
show an error message which indicates why the target
cannot be built because the tools are missing
When building from the Git repository, and when --enable-man-pages
is used, the tools are required at configure time.
The incentive for this change is to make the man pages easier to
write and maintain, AsciiDoc being far more easy to read and write
than pure troff, as well as enable rich HTML man page generation
from the intermediate DocBook XML file to publish man pages with
working internal/external links and style improvements on the
LTTng website. This also makes LTTng-UST man pages conform to the
LTTng-tools ones which use the same mechanism.
The following "redirection" man pages are also added:
They all redirect to lttng-ust(3). They are always distributed,
but only installed when lttng-ust(3) is also installed (which is
when --enable-man-page exists at configure time).
See the new doc/man/README.md file for more details about the
new files and macros to use in the AsciiDoc man page source files.
This patch also contains various content fixes and updates of the
LTTng-UST man pages. Some new content is based on the online LTTng
documentation.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
This has been detected in the lttng-modules port of the filter
interpreter by Coverity. The intent of the code in UST is similar, and
we can find the same dead code, although Coverity may not see it as dead
code because it cannot prove that the string is not modified between the
two uses. Since we know it is not modified, remove the dead code.
will print a range of 0 ... -1 in the generated CTF metadata, which does
not reflect signedness of the values.
Also, struct ustctl_enum_entry is missing a LTTNG_PACKED attribute,
which is against our protocol rules.
This change needs to be pushed in locked-step into lttng-tools and
lttng-ust, since it breaks the protocol between the two when UST uses
the new enumeration type (introduced in 2.8.0-rc1).
Assertions in the lttng-ust-comm init function are slightly too harsh
for their own good. In situations involving incoherent seccomp profiles
(e.g. accepting futex, poll, nanosleep, clock_nanosleep, but not
restart_syscall), unexpected errno values can be returned by
sem_timedwait.
Print an error in those situations, but let the application proceed.
Calling this function from an instrumented program allows disabling
tracepoint destructors. This allows threads to continue calling
tracepoint code even after the tracepoint destructors have run. This is
needed for applications that exit without joining all their threads.
Fix: handle backward probe compatibility for application contexts
Fix segmentation fault of applications built against lttng-ust 2.7,
linked against lttng-ust 2.8-pre when tracing is active. We need to
consider backward ABI compability here, which can be done by using
a dummy context in place of an application context when recording an
event. Basically, application contexts won't be saved into events
generated by a lttng-ust 2.7 probe provider: those will appear as empty
contexts.