From: raphael.beamonte@gmail.com (Raphaël Beamonte)
Subject: [lttng-dev] [RFC PATCH 1/2] Add -ust to the name of UST threads of the application
Date: Thu, 21 Apr 2016 16:50:32 -0400 [thread overview]
Message-ID: <0b9164b53c42d51798ee886f33479cee6d6576bd.1461269886.git.raphael.beamonte@gmail.com> (raw)
In-Reply-To: <cover.1461269886.git.raphael.beamonte@gmail.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]
Add the required functions to change the thread name of the UST
threads and add the -ust string at its end. This will help to
identify LTTng-UST processes when analyzing the trace of a process.
Signed-off-by: Raphaël Beamonte <raphael.beamonte at gmail.com>
---
liblttng-ust/compat.h | 22 ++++++++++++++++++++++
liblttng-ust/lttng-ust-comm.c | 2 ++
2 files changed, 24 insertions(+)
diff --git a/liblttng-ust/compat.h b/liblttng-ust/compat.h
index 43b2223..8d5fc77 100644
--- a/liblttng-ust/compat.h
+++ b/liblttng-ust/compat.h
@@ -34,6 +34,23 @@ void lttng_ust_getprocname(char *name)
(void) prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0);
}
+static inline
+void lttng_ust_setustprocname()
+{
+ char name[LTTNG_UST_PROCNAME_LEN];
+ int limit = LTTNG_UST_PROCNAME_LEN - 4;
+
+ lttng_ust_getprocname(name);
+
+ if (strlen(name) >= limit) {
+ name[limit] = 0;
+ }
+
+ sprintf(name, "%s%s", name, "-ust");
+
+ (void) prctl(PR_SET_NAME, name, 0, 0, 0);
+}
+
#elif defined(__FreeBSD__)
#include <stdlib.h>
#include <string.h>
@@ -59,6 +76,11 @@ void lttng_ust_getprocname(char *name)
strncpy(name, bsd_name, LTTNG_UST_PROCNAME_LEN - 1);
}
+static inline
+void lttng_ust_setustprocname()
+{
+}
+
#endif
#include <errno.h>
diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
index e00a22c..a85cb21 100644
--- a/liblttng-ust/lttng-ust-comm.c
+++ b/liblttng-ust/lttng-ust-comm.c
@@ -1295,6 +1295,8 @@ void *ust_listener_thread(void *arg)
int sock, ret, prev_connect_failed = 0, has_waited = 0;
long timeout;
+ lttng_ust_setustprocname();
+
/* Restart trying to connect to the session daemon */
restart:
if (prev_connect_failed) {
--
2.1.4
next prev parent reply other threads:[~2016-04-21 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 20:50 [lttng-dev] [RFC PATCH 0/2] Identify UST threads by changing thread names Raphaël Beamonte
2016-04-21 20:50 ` Raphaël Beamonte [this message]
2016-04-21 20:50 ` [lttng-dev] [RFC PATCH 2/2] Add -ust to the name of UST threads of the application Raphaël Beamonte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0b9164b53c42d51798ee886f33479cee6d6576bd.1461269886.git.raphael.beamonte@gmail.com \
--to=raphael.beamonte@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox