Skip to contentSkip to conversation

Add -ust to the name of UST threads of the application

RFC PATCH Sebastien Boisvert 2 participants 2 messages Jun 2, 2016 – Jun 3, 2016 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Raphaël,

Quoted 21 lines · Sebastien Boisvert

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(+)
liblttng-ust/compat.h +3 -0
index 43b2223..8d5fc77 100644
@@ -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()
+{

liblttng-ust/compat.h void lttng_ust_getprocname(char *name) · line 49

Quoted 10 lines
liblttng-ust/compat.h +10 -0
+	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");

The objects can not overlap, otherwise, the behavior is undefined:

"If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined." [1]

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/sprintf.html

Quoted 25 lines
liblttng-ust/compat.h +9 -0
+
+	(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>
liblttng-ust/lttng-ust-comm.c +0 -0
index e00a22c..a85cb21 100644

liblttng-ust/lttng-ust-comm.c void *ust_listener_thread(void *arg) · line 1302

Quoted 8 lines
liblttng-ust/lttng-ust-comm.c +2 -0
@@ -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) {

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

#3 lore raw
In reply to a message not in the archive

Hi Sebastien,

2016-06-02 9:14 GMT-04:00 Sebastien Boisvert <[email protected]>:

Quoted 8 lines
Quoted 1 line

+ sprintf(name, "%s%s", name, "-ust");

The objects can not overlap, otherwise, the behavior is undefined:

"If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined." [1]

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/sprintf.html

Thanks! Will fix that!

Raphaël
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev