Adding the process procname to the statedump allows users to disable
procname context in scenario for which the data and serialization overhead
of the procname process is problematic. Users can stitch information in
post-processing based on other contexts (pid).
Users can skip this statedump via the
LTTNG_UST_WITHOUT_PROCNAME_STATEDUMP env variable.
Note that the procname statedump value is the procname seen at
application start (lttng_ust_init). Subsequent calls to pthread_setname_np
or equivalent have no effect on this value.
Since we cannot use the current thread name due to the
lttng_pthread_setname_np call in ust_listener_thread, we store the
process name inside the sock_info struct before the call to
lttng_pthread_setname_np. This data structure is already present as the
"owner" object in the statedump mechanism. During the statedump, we fetch
the procname from the "owner" object.
Use LTTNG_HIDDEN to reduce visibility of lttng_ust_sockinfo_get_procname.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|Debug link file name.
|===
|Debug link file name.
|===
+`lttng_ust_statedump:procname`::
+ The process procname at process start.
++
+Fields:
++
+[options="header"]
+|===
+|Field name |Description
+
+|`procname`
+|The process name.
+
+|===
+
[[ust-lib]]
Shared library load/unload tracking
[[ust-lib]]
Shared library load/unload tracking
If set, prevents `liblttng-ust` from performing a base address state
dump (see the <<state-dump,LTTng-UST state dump>> section above).
If set, prevents `liblttng-ust` from performing a base address state
dump (see the <<state-dump,LTTng-UST state dump>> section above).
+`LTTNG_UST_WITHOUT_PROCNAME_STATEDUMP`::
+ If set, prevents `liblttng-ust` from performing a procname state
+ dump (see the <<state-dump,LTTng-UST state dump>> section above).
+
include::common-footer.txt[]
include::common-footer.txt[]
#define LTTNG_UST_CALLER_IP() __builtin_return_address(0)
#endif /* #else #if defined(__PPC__) && !defined(__PPC64__) */
#define LTTNG_UST_CALLER_IP() __builtin_return_address(0)
#endif /* #else #if defined(__PPC__) && !defined(__PPC64__) */
+/*
+ * LTTNG_HIDDEN: set the hidden attribute for internal functions
+ * On Windows, symbols are local unless explicitly exported,
+ * see https://gcc.gnu.org/wiki/Visibility
+ */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define LTTNG_HIDDEN
+#else
+#define LTTNG_HIDDEN __attribute__((visibility("hidden")))
+#endif
+
#endif /* _LTTNG_UST_HELPER_H */
#endif /* _LTTNG_UST_HELPER_H */
#include <lttng/bug.h>
#include <lttng/ringbuffer-config.h>
#include <usterr-signal-safe.h>
#include <lttng/bug.h>
#include <lttng/ringbuffer-config.h>
#include <usterr-signal-safe.h>
/*
* The longuest possible namespace proc path is with the cgroup ns
/*
* The longuest possible namespace proc path is with the cgroup ns
int lttng_get_notify_socket(void *owner);
int lttng_get_notify_socket(void *owner);
+LTTNG_HIDDEN
+char* lttng_ust_sockinfo_get_procname(void *owner);
+
void lttng_ust_sockinfo_session_enabled(void *owner);
void lttng_ust_malloc_wrapper_init(void);
void lttng_ust_sockinfo_session_enabled(void *owner);
void lttng_ust_malloc_wrapper_init(void);
/* Keep track of lazy state dump not performed yet. */
int statedump_pending;
int initial_statedump_done;
/* Keep track of lazy state dump not performed yet. */
int statedump_pending;
int initial_statedump_done;
+ /* Keep procname for statedump */
+ char procname[LTTNG_UST_PROCNAME_LEN];
};
/* Socket from app (connect) to session daemon (listen) for communication */
};
/* Socket from app (connect) to session daemon (listen) for communication */
.statedump_pending = 0,
.initial_statedump_done = 0,
.statedump_pending = 0,
.initial_statedump_done = 0,
};
/* TODO: allow global_apps_sock_path override */
};
/* TODO: allow global_apps_sock_path override */
.statedump_pending = 0,
.initial_statedump_done = 0,
.statedump_pending = 0,
.initial_statedump_done = 0,
};
static int wait_poll_fallback;
};
static int wait_poll_fallback;
return info->notify_socket;
}
return info->notify_socket;
}
+
+LTTNG_HIDDEN
+char* lttng_ust_sockinfo_get_procname(void *owner)
+{
+ struct sock_info *info = owner;
+
+ return info->procname;
+}
+
static
void print_cmd(int cmd, int handle)
{
static
void print_cmd(int cmd, int handle)
{
}
global_apps.allowed = 1;
}
global_apps.allowed = 1;
+ lttng_ust_getprocname(global_apps.procname);
+
+ lttng_ust_getprocname(local_apps.procname);
#include <stdint.h>
#include <unistd.h>
#include <lttng/ust-events.h>
#include <stdint.h>
#include <unistd.h>
#include <lttng/ust-events.h>
#define LTTNG_UST_STATEDUMP_PROVIDER
#include <lttng/tracepoint.h>
#define LTTNG_UST_STATEDUMP_PROVIDER
#include <lttng/tracepoint.h>
+TRACEPOINT_EVENT(lttng_ust_statedump, procname,
+ TP_ARGS(
+ struct lttng_session *, session,
+ char *, name
+ ),
+ TP_FIELDS(
+ ctf_array_text(char, procname, name, LTTNG_UST_PROCNAME_LEN)
+ )
+)
+
TRACEPOINT_EVENT(lttng_ust_statedump, end,
TP_ARGS(struct lttng_session *, session),
TP_FIELDS()
TRACEPOINT_EVENT(lttng_ust_statedump, end,
TP_ARGS(struct lttng_session *, session),
TP_FIELDS()
#include "lttng-ust-statedump.h"
#include "jhash.h"
#include "getenv.h"
#include "lttng-ust-statedump.h"
#include "jhash.h"
#include "getenv.h"
#define TRACEPOINT_DEFINE
#include "ust_lib.h" /* Only define. */
#define TRACEPOINT_DEFINE
#include "ust_lib.h" /* Only define. */
bin_data->dbg_file, bin_data->crc);
}
bin_data->dbg_file, bin_data->crc);
}
+static
+void procname_cb(struct lttng_session *session, void *priv)
+{
+ char *procname = (char *) priv;
+ tracepoint(lttng_ust_statedump, procname, session, procname);
+}
+
static
void trace_start_cb(struct lttng_session *session, void *priv)
{
static
void trace_start_cb(struct lttng_session *session, void *priv)
{
+static
+int do_procname_statedump(void *owner)
+{
+ if (lttng_getenv("LTTNG_UST_WITHOUT_PROCNAME_STATEDUMP"))
+ return 0;
+
+ trace_statedump_event(procname_cb, owner, lttng_ust_sockinfo_get_procname(owner));
+ return 0;
+}
+
/*
* Generate a statedump of a given traced application. A statedump is
* delimited by start and end events. For a given (process, session)
/*
* Generate a statedump of a given traced application. A statedump is
* delimited by start and end events. For a given (process, session)
trace_statedump_start(owner);
ust_unlock();
trace_statedump_start(owner);
ust_unlock();
+ do_procname_statedump(owner);
do_baddr_statedump(owner);
ust_lock_nocheck();
do_baddr_statedump(owner);
ust_lock_nocheck();