From 4649f42a2263df0f0478b9a255e394dfe98be023 Mon Sep 17 00:00:00 2001
From: Lionel Gauthier <lionel.gauthier@eurecom.fr>
Date: Thu, 9 Apr 2015 09:12:21 +0000
Subject: [PATCH] patches13/0008-name-pthreads-easier-debugging.patch
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7054 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
common/utils/itti/intertask_interface.c | 3 +++
common/utils/itti/intertask_interface_dump.c | 2 ++
openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c | 2 ++
openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c | 1 +
.../src/com/rrc/RRCMessageHandler.cpp | 2 ++
.../src/com/rrm/RRMMessageHandler.cpp | 2 ++
targets/RT/USER/lte-softmodem.c | 13 +++++++++++--
7 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c
index adea1fe799..d86f731581 100644
--- a/common/utils/itti/intertask_interface.c
+++ b/common/utils/itti/intertask_interface.c
@@ -709,6 +709,9 @@ int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *ar
result = pthread_create (&itti_desc.threads[thread_id].task_thread, NULL, start_routine, args_p);
AssertFatal (result >= 0, "Thread creation for task %d, thread %d failed (%d)!\n", task_id, thread_id, result);
+ char name[16];
+ snprintf( name, sizeof(name), "ITTI %d", thread_id );
+ pthread_setname_np( itti_desc.threads[thread_id].task_thread, name );
itti_desc.created_tasks ++;
diff --git a/common/utils/itti/intertask_interface_dump.c b/common/utils/itti/intertask_interface_dump.c
index 4c4905db9f..7775cb6fd9 100644
--- a/common/utils/itti/intertask_interface_dump.c
+++ b/common/utils/itti/intertask_interface_dump.c
@@ -34,6 +34,7 @@
* @author Sebastien Roux <sebastien.roux@eurecom.fr>
*/
+#define _GNU_SOURCE // required for pthread_setname_np()
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
@@ -845,6 +846,7 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
if (ret < 0) {
AssertFatal (0, "pthread_create failed (%d:%s)!\n", errno, strerror(errno));
}
+ pthread_setname_np( itti_dump_queue.itti_acceptor_thread, "ITTI acceptor" );
return 0;
}
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c
index 2200c953fb..7e8360c61b 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c
@@ -38,6 +38,7 @@
* @ingroup pdcp
*/
+#define _GNU_SOURCE // required for pthread_setname_np()
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
@@ -160,6 +161,7 @@ int pdcp_netlink_init(void) {
errno, strerror(errno));
exit(EXIT_FAILURE);
}
+ pthread_setname_np( pdcp_netlink_thread, "PDCP netlink" );
}
return 0;
}
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c
index 7248be01eb..455e0ded4a 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c
@@ -133,6 +133,7 @@ int init_pdcp_thread(void) {
}
else {
LOG_I(PDCP,"Allocate PDCP thread successful\n");
+ pthread_setname_np( pdcp_thread, "PDCP" );
}
return(0);
}
diff --git a/openair2/RRM_4_RRC_LITE/src/com/rrc/RRCMessageHandler.cpp b/openair2/RRM_4_RRC_LITE/src/com/rrc/RRCMessageHandler.cpp
index 64add3536f..60cf352a9a 100755
--- a/openair2/RRM_4_RRC_LITE/src/com/rrc/RRCMessageHandler.cpp
+++ b/openair2/RRM_4_RRC_LITE/src/com/rrc/RRCMessageHandler.cpp
@@ -41,6 +41,8 @@ RRCMessageHandler::RRCMessageHandler()
if (pthread_create(&m_thread, NULL, RRCMessageHandlerThreadLoop, (void *) NULL) != 0) {
fprintf(stderr, "\nRRCMessageHandler::RRCMessageHandler() ERROR pthread_create...\n");
+ } else {
+ pthread_setname_np( m_thread, "RRCMsgHandler" );
}
}
//----------------------------------------------------------------------------
diff --git a/openair2/RRM_4_RRC_LITE/src/com/rrm/RRMMessageHandler.cpp b/openair2/RRM_4_RRC_LITE/src/com/rrm/RRMMessageHandler.cpp
index 98b44d50b1..48a3a77320 100755
--- a/openair2/RRM_4_RRC_LITE/src/com/rrm/RRMMessageHandler.cpp
+++ b/openair2/RRM_4_RRC_LITE/src/com/rrm/RRMMessageHandler.cpp
@@ -41,6 +41,8 @@ RRMMessageHandler::RRMMessageHandler()
if (pthread_create(&m_thread, NULL, RRMMessageHandlerThreadLoop, (void *) NULL) != 0) {
fprintf(stderr, "\nRRMMessageHandler::RRMMessageHandler() ERROR pthread_create...\n");
+ } else {
+ pthread_setname_np( m_thread, "RRMMsgHandler" );
}
}
//----------------------------------------------------------------------------
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index b6452bc221..b9ea96e43b 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -1241,6 +1241,11 @@ void init_eNB_proc(void)
pthread_cond_init( &PHY_vars_eNB_g[0][CC_id]->proc[i].cond_rx, NULL);
pthread_create( &PHY_vars_eNB_g[0][CC_id]->proc[i].pthread_tx, NULL, eNB_thread_tx, &PHY_vars_eNB_g[0][CC_id]->proc[i] );
pthread_create( &PHY_vars_eNB_g[0][CC_id]->proc[i].pthread_rx, NULL, eNB_thread_rx, &PHY_vars_eNB_g[0][CC_id]->proc[i] );
+ char name[16];
+ snprintf( name, sizeof(name), "TX %d", i );
+ pthread_setname_np( PHY_vars_eNB_g[0][CC_id]->proc[i].pthread_tx, name );
+ snprintf( name, sizeof(name), "RX %d", i );
+ pthread_setname_np( PHY_vars_eNB_g[0][CC_id]->proc[i].pthread_rx, name );
PHY_vars_eNB_g[0][CC_id]->proc[i].frame_tx = 0;
PHY_vars_eNB_g[0][CC_id]->proc[i].frame_rx = 0;
#ifdef EXMIMO
@@ -2800,6 +2805,8 @@ int main( int argc, char **argv )
}
ret = pthread_create(&forms_thread, NULL, scope_thread, NULL);
+ if (ret == 0)
+ pthread_setname_np( forms_thread, "xforms" );
printf("Scope thread created, ret=%d\n",ret);
}
#endif
@@ -2850,7 +2857,8 @@ int main( int argc, char **argv )
return(error_code);
}
else {
- LOG_D(HW,"[lte-softmodem.c] Allocate UE_thread successful\n");
+ LOG_D( HW, "[lte-softmodem.c] Allocate UE_thread successful\n" );
+ pthread_setname_np( main_ue_thread, "main UE" );
}
#endif
printf("UE threads created\n");
@@ -2872,7 +2880,8 @@ int main( int argc, char **argv )
return(error_code);
}
else {
- LOG_D(HW,"[lte-softmodem.c] Allocate eNB_thread successful\n");
+ LOG_D( HW, "[lte-softmodem.c] Allocate eNB_thread successful\n" );
+ pthread_setname_np( main_eNB_thread, "main eNB" );
}
#endif
}
--
GitLab