Skip to content

Commit e3b027b

Browse files
authored
Merge pull request #2370 from mitza-oci/thread-names
Support thread names on Windows and Integrity
2 parents 5ba4a19 + 473396d commit e3b027b

20 files changed

Lines changed: 115 additions & 88 deletions

ACE/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ USER VISIBLE CHANGES BETWEEN ACE-8.0.2 and ACE-8.0.3
2121
. Updated support for Green Hills INTEGRITY and INTEGRITY-178 tuMP RTOS.
2222
Tested on INTEGRITY 11.4.6 and INTEGRITY-178 5.0.0.
2323

24+
. Thread names given to ACE_OS::thr_create are now passed down to the OS
25+
on Windows and on INTEGRITY.
26+
2427
USER VISIBLE CHANGES BETWEEN ACE-8.0.1 and ACE-8.0.2
2528
====================================================
2629

ACE/ace/OS_NS_Thread.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,7 +3455,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
34553455
void *stack,
34563456
size_t stacksize,
34573457
ACE_Base_Thread_Adapter *thread_adapter,
3458-
const char** thr_name)
3458+
const char **thr_name)
34593459
{
34603460
ACE_OS_TRACE ("ACE_OS::thr_create");
34613461

@@ -3882,6 +3882,11 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
38823882
flags,
38833883
thr_id);
38843884

3885+
if (thr_name && *thr_name && *thr_handle)
3886+
{
3887+
SetThreadDescription (*thr_handle, ACE_Ascii_To_Wide (*thr_name).wchar_rep ());
3888+
}
3889+
38853890
if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0)
38863891
{
38873892
// Set the priority of the new thread and then let it
@@ -3937,7 +3942,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
39373942
// The call below to ::taskSpawn () causes VxWorks to assign a
39383943
// unique task name of the form: "t" + an integer, because the
39393944
// first argument is 0.
3940-
tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char*> (*thr_name) : 0,
3945+
tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char *> (*thr_name) : 0,
39413946
priority,
39423947
(int) flags,
39433948
stacksize,
@@ -3957,7 +3962,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
39573962

39583963
// The TID is defined to be the address of the TCB.
39593964
int status = ::taskInit (tcb,
3960-
thr_name && *thr_name ? const_cast <char*>(*thr_name) : 0,
3965+
thr_name && *thr_name ? const_cast <char *> (*thr_name) : 0,
39613966
priority,
39623967
(int) flags,
39633968
(char *) stack + sizeof (WIND_TCB),
@@ -4023,17 +4028,20 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
40234028

40244029
// Don't let this Task run immediately; we have to set its entrypoint's argument below.
40254030
err_code = ::SetupTask (AddressSpaceObjectNumber (1), priority /* priority */, 0 /* weight */, 0 /* timeslice */,
4026-
(Address) stack /* stack */, (Address) stacksize /* stackLength */, true /* enableClibrary */,
4027-
true /* allocTLS */, (Address) &integrity_task_adapter, false /* startIt */, 0 /* name */,
4028-
0 /* symbolFile */, thr_handle /* newTask */, 0 /* newActivity */);
4031+
(Address) stack /* stack */, (Address) stacksize /* stackLength */, true /* enableClibrary */,
4032+
true /* allocTLS */, (Address) &integrity_task_adapter, false /* startIt */,
4033+
thr_name ? const_cast<char *> (*thr_name) : nullptr /* name */,
4034+
0 /* symbolFile */, thr_handle /* newTask */, 0 /* newActivity */);
40294035

40304036
# else
40314037
ACE_UNUSED_ARG (stack);
40324038
// INTEGRITY has kernel calls in which we can pass argument for the new Task's entry point,
40334039
// e.g. CommonCreateTaskWithArgument.
40344040
// However, we are imitating INTEGRITY-178 and the call without entrypoint's argument is used.
40354041
err_code = ::CommonCreateTask (priority, (Address) &integrity_task_adapter /* entrypoint */,
4036-
(Address) stacksize, 0 /* name */, thr_handle /* newtask */);
4042+
(Address) stacksize,
4043+
thr_name ? const_cast<char *> (*thr_name) : nullptr /* name */,
4044+
thr_handle /* newtask */);
40374045
# endif
40384046

40394047
if (err_code != Success)

ACE/ace/OS_NS_Thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ namespace ACE_OS {
16401640
void *stack = 0,
16411641
size_t stacksize = ACE_DEFAULT_THREAD_STACKSIZE,
16421642
ACE_Base_Thread_Adapter *thread_adapter = 0,
1643-
const char** thr_name = 0);
1643+
const char **thr_name = 0);
16441644

16451645
ACE_NAMESPACE_INLINE_FUNCTION
16461646
int thr_equal (ACE_thread_t t1, ACE_thread_t t2);

ACE/ace/OS_NS_Thread.inl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,9 @@ ACE_OS::sigwait (sigset_t *sset, int *sig)
23792379
// means forever.
23802380
*sig = ::sigtimedwait (sset, 0, 0);
23812381
return *sig;
2382+
# else
2383+
ACE_UNUSED_ARG (sset);
2384+
ACE_NOTSUP_RETURN (-1);
23822385
# endif /* ACE_HAS_WTHREADS || ACE_LACKS_SIGWAIT */
23832386
#else
23842387
ACE_UNUSED_ARG (sset);
@@ -2843,18 +2846,14 @@ ACE_OS::thr_self ()
28432846
#endif /* ACE_HAS_THREADS */
28442847
}
28452848

2846-
ACE_INLINE const char*
2849+
ACE_INLINE const char *
28472850
ACE_OS::thr_name ()
28482851
{
2849-
#if defined (ACE_HAS_THREADS)
2850-
#if defined (ACE_HAS_VXTHREADS)
2852+
#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_VXTHREADS)
28512853
return ::taskName (ACE_OS::thr_self ());
28522854
#else
28532855
ACE_NOTSUP_RETURN (0);
28542856
#endif
2855-
#else
2856-
ACE_NOTSUP_RETURN (0);
2857-
#endif
28582857
}
28592858

28602859
ACE_INLINE void

ACE/ace/Sock_Connect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,10 @@ ACE::count_interfaces (ACE_HANDLE handle, size_t &how_many)
841841
{
842842
#if defined (SIOCGIFNUM)
843843
# if defined (SIOCGLIFNUM)
844-
int cmd = SIOCGLIFNUM;
844+
ACE_IOCTL_TYPE_ARG2 cmd = SIOCGLIFNUM;
845845
struct lifnum if_num = {AF_UNSPEC,0,0};
846846
# else
847-
int cmd = SIOCGIFNUM;
847+
ACE_IOCTL_TYPE_ARG2 cmd = SIOCGIFNUM;
848848
int if_num = 0;
849849
# endif /* SIOCGLIFNUM */
850850
if (ACE_OS::ioctl (handle, cmd, (caddr_t)&if_num) == -1)

ACE/ace/Stack_Trace.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ ACE_Stack_Trace::c_str () const
4848
return &this->buf_[0];
4949
}
5050

51+
#if defined(__GLIBC__) || defined(ACE_HAS_EXECINFO_H) || defined(VXWORKS) || \
52+
(defined(ACE_WIN32) && !defined (__MINGW32__) && !defined(__BORLANDC__))
5153
static inline size_t
5254
determine_starting_frame (ssize_t initial_frame, ssize_t offset)
5355
{
5456
return (std::max)( initial_frame + offset, static_cast<ssize_t>(0));
5557
}
58+
#endif
5659

5760
#if defined(ACE_FACE_SAFETY_BASE) && !defined(ACE_FACE_DEV)
5861
void

ACE/ace/Thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ACE_Thread::spawn_n (size_t n,
1717
void *stack[],
1818
size_t stack_size[],
1919
ACE_Thread_Adapter *thread_adapter,
20-
const char* thr_name[])
20+
const char *thr_name[])
2121
{
2222
ACE_TRACE ("ACE_Thread::spawn_n");
2323
size_t i;
@@ -53,7 +53,7 @@ ACE_Thread::spawn_n (ACE_thread_t thread_ids[],
5353
size_t stack_size[],
5454
ACE_hthread_t thread_handles[],
5555
ACE_Thread_Adapter *thread_adapter,
56-
const char* thr_name[])
56+
const char *thr_name[])
5757
{
5858
ACE_TRACE ("ACE_Thread::spawn_n");
5959
size_t i = 0;

ACE/ace/Thread.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ACE_Export ACE_Thread
8888
void *stack = 0,
8989
size_t stack_size = ACE_DEFAULT_THREAD_STACKSIZE,
9090
ACE_Thread_Adapter *thread_adapter = 0,
91-
const char** thr_name = 0);
91+
const char **thr_name = 0);
9292

9393
/**
9494
* Spawn N new threads, which execute @a func with argument @a arg (if
@@ -112,7 +112,7 @@ class ACE_Export ACE_Thread
112112
void *stack[] = 0,
113113
size_t stack_size[] = 0,
114114
ACE_Thread_Adapter *thread_adapter = 0,
115-
const char* thr_name[] = 0);
115+
const char *thr_name[] = 0);
116116

117117
/**
118118
* Spawn @a n new threads, which execute @a func with argument @a arg
@@ -142,7 +142,7 @@ class ACE_Export ACE_Thread
142142
size_t stack_size[] = 0,
143143
ACE_hthread_t thread_handles[] = 0,
144144
ACE_Thread_Adapter *thread_adapter = 0,
145-
const char* thr_name[] = 0);
145+
const char *thr_name[] = 0);
146146

147147
/**
148148
* Wait for one or more threads to exit and reap their exit status.

ACE/ace/Thread.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ ACE_Thread::spawn (ACE_THR_FUNC func,
7676
void *thr_stack,
7777
size_t thr_stack_size,
7878
ACE_Thread_Adapter *thread_adapter,
79-
const char** thr_name)
79+
const char **thr_name)
8080
{
8181
ACE_TRACE ("ACE_Thread::spawn");
8282

ACE/ace/Thread_Manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func,
577577
void *stack,
578578
size_t stack_size,
579579
ACE_Task_Base *task,
580-
const char** thr_name)
580+
const char **thr_name)
581581
{
582582
// First, threads created by Thread Manager should not be daemon threads.
583583
// Using assertion is probably a bit too strong. However, it helps
@@ -692,7 +692,7 @@ ACE_Thread_Manager::spawn (ACE_THR_FUNC func,
692692
int grp_id,
693693
void *stack,
694694
size_t stack_size,
695-
const char** thr_name)
695+
const char **thr_name)
696696
{
697697
ACE_TRACE ("ACE_Thread_Manager::spawn");
698698

@@ -733,7 +733,7 @@ ACE_Thread_Manager::spawn_n (size_t n,
733733
ACE_hthread_t thread_handles[],
734734
void *stack[],
735735
size_t stack_size[],
736-
const char* thr_name[])
736+
const char *thr_name[])
737737
{
738738
ACE_TRACE ("ACE_Thread_Manager::spawn_n");
739739
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
@@ -776,7 +776,7 @@ ACE_Thread_Manager::spawn_n (ACE_thread_t thread_ids[],
776776
size_t stack_size[],
777777
ACE_hthread_t thread_handles[],
778778
ACE_Task_Base *task,
779-
const char* thr_name[])
779+
const char *thr_name[])
780780
{
781781
ACE_TRACE ("ACE_Thread_Manager::spawn_n");
782782
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));

0 commit comments

Comments
 (0)