如何更改基于CDT的eclipse调试器中线程组显示中的文本?

DP_*_*DP_ 5 java eclipse eclipse-cdt eclipse-rcp

我有一个基于CDT的调试器,并希望在线程节点中的字母中添加一些信息.我希望红色矩形包围的字母显示一些额外的信息(见下面的截图).

截图

AFAIR,此标签的格式字符串ThreadVMNode_No_columns__text_format在文件中的属性中设置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}})
Run Code Online (Sandbox Code Playgroud)

此格式字符串用于方法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}),
Run Code Online (Sandbox Code Playgroud)

AFAIK为了向显示器添加新的信息是必要的

  1. 覆盖格式字符串MessagesForGdbLaunchVM.properties
  2. 在对构造函数的调用中将新字符串添加到字符串数组中GdbExecutionContextLabelText.

执行这两项操作的最佳方法是什么(最好不要更改Eclipse/CDT核心类的代码)?

更新1(12.09.2014 19:56 MSK):试图通过添加扩展来使用自定义调试表示模型,但该类MyCompanyDebugModelPresentation不称为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>
Run Code Online (Sandbox Code Playgroud)

DP_*_*DP_ 1

为了修改上面显示的文本,您需要修改许多文件和设置,如下面的矩阵所示。

形态矩阵

您可以按如下方式阅读此图像:

  1. 在您的项目中,指定扩展点org.eclipse.core.run.adapters(红线的起点),使其指向
  2. 你的子类GdbAdapterFactory.
  3. 修改该类,使其返回您的GdbViewModelAdapter等的子类。

您遍历该链,直到到达类ThreadVMNode(或您的子类),这决定了树中显示的值。