Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the text in the thread group display in CDT-based eclipse debugger?

I have a CDT-based debugger and want to add some information into the lettering in the thread node. I want the lettering surrounded by the red rectangle to display some additional information (see screenshot below).

Screenshot

AFAIR, the format string for this label is set in the property ThreadVMNode_No_columns__text_format in file C:\Users\...\workspace\org.eclipse.cdt.dsf.gdb.ui\src\org\eclipse\cdt\dsf\gdb\internal\ui\viewmodel\launch\MessagesForGdbLaunchVM.properties.

# {0} - name available, 0=not available/1=available
# {1} - name
# {2} - ID available, 0=not available/1=available
# {3} - ID
# {4} - OS Thread ID available, 0=not available/1=available
# {5} - OS Thread ID
# {6} - Core available, 0=not available/1=available
# {7} - Core 
# {8} - 0=running/1=suspended
# {9} - state change reason available, 0=not available/1=available
# {10} - state change reason
# {11} - state change details available, 0=not available/1=available
# {12} - state change details
ThreadVMNode_No_columns__text_format={0,choice,0#Thread|1#{1}}{2,choice,0#|1# [{3}]}{4,choice,0#|1# {5}}{6,choice,0#|1# [core: {7}]} ({8,choice,0#Running|1#Suspended}{9,choice,0#|1# : {10}}{11,choice,0#|1# : {12}})

This format string is used in method org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.ThreadVMNode.createLabelProvider():

public class ThreadVMNode extends AbstractThreadVMNode 
    implements IElementLabelProvider, IElementMementoProvider
{
    [...]

    @Override
    protected IElementLabelProvider createLabelProvider() {
        PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider();

        provider.setColumnInfo(
            PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS, 
            new LabelColumnInfo(new LabelAttribute[] { 
                // Text is made of the thread name followed by its state and state change reason. 
                new GdbExecutionContextLabelText(
                    MessagesForGdbLaunchVM.ThreadVMNode_No_columns__text_format,
                    new String[] { 
                        ExecutionContextLabelText.PROP_NAME_KNOWN, 
                        PROP_NAME, 
                        ExecutionContextLabelText.PROP_ID_KNOWN, 
                        ILaunchVMConstants.PROP_ID, 
                        IGdbLaunchVMConstants.PROP_OS_ID_KNOWN, 
                        IGdbLaunchVMConstants.PROP_OS_ID, 
                        IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN, 
                        IGdbLaunchVMConstants.PROP_CORES_ID,
                        ILaunchVMConstants.PROP_IS_SUSPENDED,
                        ExecutionContextLabelText.PROP_STATE_CHANGE_REASON_KNOWN, 
                        ILaunchVMConstants.PROP_STATE_CHANGE_REASON,
                        ExecutionContextLabelText.PROP_STATE_CHANGE_DETAILS_KNOWN,
                        ILaunchVMConstants.PROP_STATE_CHANGE_DETAILS}),

AFAIK in order to add a new piece of information to the display it is necessary to

  1. override the format string MessagesForGdbLaunchVM.properties and
  2. add the new string into the string array in the call to the constructor GdbExecutionContextLabelText.

What is the best way to do both these things (preferably not changing the code of the Eclipse/CDT core classes) ?

Update 1 (12.09.2014 19:56 MSK): Tried to use a custom debug presentation model by adding an extension, but the class MyCompanyDebugModelPresentation is not called anyhwere.

   <extension
         point="org.eclipse.debug.ui.debugModelPresentations">
      <debugModelPresentation
            class="com.mycompany.internal.debug.ui.model.MyCompanyDebugModelPresentation"
            id="com.mycompany.internal.debug.ui.model.MyCompanyDebugModelPresentation">
      </debugModelPresentation>
   </extension>
like image 571
Dmitrii Pisarenko Avatar asked Nov 11 '22 01:11

Dmitrii Pisarenko


1 Answers

In order to modify the text shown above, you need to modify a number of files and settings, which are shown in the matrix below.

Morphology matrix

You can read this image as follows:

  1. In your project, specify the extension point org.eclipse.core.run.adapters (start of the red line) so that it points to
  2. your subclass of GdbAdapterFactory.
  3. Modify that class so that it returns your subclass of GdbViewModelAdapter etc.

You go through that chain until you arrive at the ThreadVMNode class (or your subclass), which determines what values are shown in the tree.

like image 115
Dmitrii Pisarenko Avatar answered Nov 14 '22 22:11

Dmitrii Pisarenko