Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 115804

Summary: Enable thread name display
Product: [Tools] CDT Reporter: Norbert Plött <norbert.ploett>
Component: cdt-debugAssignee: cdt-debug-inbox <cdt-debug-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: cdtdoug
Version: 3.0   
Target Milestone: 3.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 114793    
Bug Blocks:    
Attachments:
Description Flags
Implements CLIInfoThreadsInfo cdtdoug: iplog+

Description Norbert Plött CLA 2005-11-10 08:21:20 EST
A colleague of mine was wondering why the debug view does not display
thread names when the gdb debugger does return them when queried with
"info threads":

===================
[1.123.068.100.723] 16 info threads
[1.123.068.100.723] (gdb)
[1.123.068.100.723] ~"info threads\n"
[1.123.068.100.793] ~"  5 Thread 8 ( Name: TIMERThread, State: sleeping,
Priority: 14 )  "
[1.123.068.100.843] ~"  4 Thread 3 ( Name: Network support, State:
sleeping, Priority: 7 )  "
[1.123.068.100.893] ~"  3 Thread 2 ( Name: Network alarm support, State:
sleeping, Priority: 6 )  "
[1.123.068.100.953] ~"  2 Thread 1 ( Name: Idle Thread, State: ready,
Priority:31 )  "
[1.123.068.100.993] ~"* 1 Thread 9 ( Name: pthread.00000800, State:
running, Priority: 15 )  "
===================

I looked into it and found the follwing:

- org.eclipse.cdt.debug.mi.core.output.CLIInfoThreadsInfo analyzes the
gdb output.
- CLIInfoThreadsInfo.getThreadNames() currently simply returns null. So 
displaying threadnames is already provisioned for, it is just not implemented.
- CLIInfoThreadsInfo.parseThreadInfo(String, List) currently only parses
for the thread number.
- It is easy to augment parseThreadInfo(String, List) so that it
retrieves the thread name along with the number and then properly
implement getThreadNames(). This is sufficient for getting the thread
names displayed in the debug view.

Subsequent discussion (see cdt-dev of 2005-08-08, "OT: Setting thread names 
(was: Displaying thread namesin debug view)") showed that thread naming is not 
supported e.g. on POSIX, still it will certainly useful on those platforms 
which do support it. I therefore suggest an implementation which handle 
platforms without thread names transparently, but will provide the names for 
those platforms which do have names. 

The patch will be attached. We have tested the behavior with Windows / Cygwin 
(does not have thread names), VxWorks (does have thread names) and RMOS 
(Siemens proprietary, does have thread names). I hope it will be approved :-)
Comment 1 Norbert Plött CLA 2005-11-10 08:24:08 EST
Created attachment 29693 [details]
Implements CLIInfoThreadsInfo

This patch supplies the code to properly implement
CLIInfoThreadsInfo.getThreadNames().
Note that the implemenation handles threads without names gracefully but does
extract the name for those threads which do have a thread name set.
Comment 2 Nobody - feel free to take it CLA 2005-11-10 17:15:41 EST
Norbert,
The patch looks good on the platforms I have access to, but it may break 
something else. 
The best solution for this problem is to provide an extension point to allow 
the contributions of command factories. By doing this we will solve the 
problems we have with the gdb backend specific commands like "info 
threads", "info shared", etc.
So, you would be able to contribute your own plugin that contains a command 
factory (a simple extension of the existing one) and select Siemens gdb in the 
launch configuration.
I am planning to propose this feature for the next release (3.1 or 3.2, 
whatever it is). 
So, my question is: do you need it to 3.0.2 or you can wait for 3.1(3.2)?
Comment 3 Norbert Plött CLA 2005-11-11 02:37:07 EST
Thanks Mikhail, I can go by distributing the patched plug-in for in-house use. 
Would have been nice to have it contributed but ... I can wait.

So what will you do? Move the target milestone or something?
Comment 4 Nobody - feel free to take it CLA 2005-11-11 10:16:35 EST
(In reply to comment #3)
> Thanks Mikhail, I can go by distributing the patched plug-in for in-house 
use. 
> Would have been nice to have it contributed but ... I can wait.
> So what will you do? Move the target milestone or something?

Currently I am working on the plan proposals which include the mentioned 
feature. If the feature is approved, I will create an enhancement request and 
mark this bug as dependent on the new request. 
Comment 5 Norbert Plött CLA 2006-01-02 03:12:37 EST
[from Stefan Bylund]

Hi Norbert,


I was the one who added the support for optionally displaying thread
names in the CDT debug view. This feature was added in the patch
http://dev.eclipse.org/mhonarc/lists/cdt-patch/msg02506.html and
described in the corresponding bug report
https://bugs.eclipse.org/bugs/show_bug.cgi?id=69711.


This patch was initiated by a discussion of this issue found here:
http://dev.eclipse.org/mhonarc/lists/cdt-debug-dev/msg00462.html


The conclusion was that there is no reliable way to retrieve thread
names and other thread metadata from the output of the "info threads"
command in a platform-independent manner. Instead, we choose to only
provide the foundation for a third party to do this.


Your patch seems to assume that thread names from the output of "info
threads" are in the form "Name: <name>", which is not true on all
platforms.


Until there is an MI-version of the "info threads" command that reports
thread metadata in a strict form, I think that we should leave parsing
thread names to third party extensions using the foundation provided by
the patch 69711.


Regards,
/Stefan
Comment 6 Norbert Plött CLA 2006-01-02 03:13:34 EST
> Your patch seems to assume that thread names from the output of "info
> threads" are in the form "Name: <name>", which is not true on all
> platforms.

Yes, my pragmatic rationale was 
- Provide a solution that works on the platforms I know of
- Take care that things don't get worse for other platforms (I trust that my code will just nicely return the empty string for platforms which don't have the same pattern for encoding the name, it won't throw exceptions or do other nasty stuff)

and leave improvements for more platforms to others who need it.

As it is now I'll go by patching CDT until the extension point that Mikhail mentioned is in place, then I'll contribute my modified command factory.
Comment 7 Norbert Plött CLA 2006-02-17 03:10:55 EST
Bug fixed through the solution made possible by 114793 (see comment #2)