Cleanup: remove trailing whitespace in README

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
cleanup: fix typo in syscall instrumentation header

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change mode of lttng-syscalls-generate-headers.sh to 755

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add MIPS system call support

[ Edit by Mathieu: currently missing: update of arch-independent headers
  to include the MIPS headers to complete system call support. ]

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: vppid context should test for current nsproxy

Triggers a NULL pointer exception with tracing scheduling events with
vppid context activated.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: ensure userspace accesses are done with _inatomic

Otherwise, triggers scheduling while atomic (might_sleep()) warnings,
since we call those from a tracepoint probe (with preemption disabled).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: statedump: disable vm maps enumeration

We need the tasklist lock to correctly dump these, which is unavailable
to modules. Disable this feature for now.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: statedump namespaced pid, tid and ppid

Use the target process namespace to lookup the value (pid, tid or ppid),
not the current task.

[ Edit by Mathieu Desnoyers: removed extra p->nsproxy check. Already
  performed within rcu read-side critical section. ]

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Support the hostname context

This is particularly useful when tracing a machine with containers
(lxc), that way we can easily distinguish events generated inside
a container.

[ Edit by Mathieu Desnoyers: various fix. ]

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng_statedump_process_state for each PID NS

When a process is in a namespace, its pid, tid and ppid are relative to
the namespace. Since namespaces can be nested, we need to know the
representation of each process in each namespace.

This patch changes the lttng_enumerate_task_fd to iterate over each
PID namespace of a process if any, that way we generate, in the
statedump, an entry for each process in each namespace it belongs.
To know the nesting level, the field "level" is added to the
lttng_statedump_process_state event, 0 being the top-level.
For processes running on the top-level namespace, the statedump
behaviour is unchanged (except the added "level" field).

For example (no nesting, just one level of namespace) :
lttng_statedump_process_state: {
        tid = 32185, vtid = 1, pid = 32185,
        vpid = 1, ppid = 32173, vppid = 0,
        level = 1, name = "init" }
lttng_statedump_process_state: {
        tid = 32185, vtid = 32185, pid = 32185,
        vpid = 32185, ppid = 32173, vppid = 32173,
        level = 0, name = "init" }

Confirmed that the process 32173 in the top-level namespace is indeed
the lxc-start command that created the container and its namespace.

[ Edit by Mathieu Desnoyers: Minor cleanups ]

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: lttng_statedump_process_state for each PID NS has infinite loop

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add env hostname information

Approximation in case of hostname change or in case of
contextualisation, but it does the job for 95% of use-cases.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cleanup: no need to hold RCU read-side lock when reading current nsproxy

As documented in include/linux/nsproxy.h.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Document limitation of vppid and ppid context wrt eventual RCU instrumentation

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Support for linux kernels 2.6.32 through 2.6.37

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fix timestamps on architectures without CONFIG_KTIME_SCALAR

trace_clock_monotonic_wrapper() should return a u64 representing the
number of nanoseconds since system startup.
ktime_get() provides that value directly within its .tv64 field only
on those architectures defining CONFIG_KTIME_SCALAR, whereas in all
other cases (e.g. PowerPC) a ktime_to_ns() conversion (which
translates back to .tv64 when CONFIG_KTIME_SCALAR is defined)
becomes necessary.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Update version to 2.1.0-rc1

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: statedump missing check for NULL namespace

Cause kernel OOPS. statedump PID namespace support is newly introduced
in lttng-modules 2.1. Happens when iterating on a zombie process.

Reported-by: David Goulet <dgoulet@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix ring_buffer_frontend.c: missing include lttng-tracer-core.h

In lib/ringbuffer/ring_buffer_frontend.c, RING_BUFFER_ALIGN is undefined,
leading to no alignment offset being recorded after the call to
config->cb.record_header_size() in lib_ring_buffer_try_reserve_slow().

However, lttng-ring-buffer-client.h does define RING_BUFFER_ALIGN, so
the alignment offset will be produced when the packet header is written
in lttng_write_event_header().

This discrepancy may be observed on architectures that don't set
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, such as ARM, with a babeltrace
error such as:

babeltrace: ../../include/babeltrace/ctf/types.h:206: ctf_pos_get_event:
Assertion `pos->offset <= pos->content_size' failed.
Aborted

indicating that the actual content size differs from the calculated one
due to the difference in alignment.  Including the appropriate header
file in ring_buffer_frontend.c solves the problem.

Signed-off-by: Wade Farnsworth <wade_farnsworth@mentor.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix cleanup: move lttng-tracer-core.h include to lib ringbuffer config.h

This is where it is used. Add a #ifdef check for the LTTNG_TRACER_CORE_H
define to ensure that the header it depends on is always included.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>