1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

[269306] - Implemented GDB-specific OS ID.

This commit is contained in:
Pawel Piech 2009-03-19 18:46:28 +00:00
parent 2900660608
commit 2d935d7b6e
10 changed files with 220 additions and 88 deletions

View file

@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch;
import java.util.Map;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText;
import org.eclipse.core.runtime.IStatus;
/**
* @since 2.0
*/
public class GdbExecutionContextLabelText extends ExecutionContextLabelText {
public GdbExecutionContextLabelText(String formatPattern, String[] propertyNames) {
super(formatPattern, propertyNames);
}
@Override
protected Object getPropertyValue(String propertyName, IStatus status, Map<String, Object> properties) {
if (IGdbLaunchVMConstants.PROP_OS_ID_KNOWN.equals(propertyName)) {
return properties.get(IGdbLaunchVMConstants.PROP_OS_ID) != null ? 1 : 0;
}
return super.getPropertyValue(propertyName, status, properties);
}
@Override
protected boolean checkProperty(String propertyName, IStatus status, Map<String, Object> properties) {
if (IGdbLaunchVMConstants.PROP_OS_ID_KNOWN.equals(propertyName) ||
IGdbLaunchVMConstants.PROP_OS_ID.equals(propertyName))
{
return true;
}
return super.checkProperty(propertyName, status, properties);
}
}

View file

@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch;
/**
* @since 2.0
*/
public interface IGdbLaunchVMConstants {
public static final String PROP_OS_ID = "os_id"; //$NON-NLS-1$
/**
* Value <code>0</code> means it's not known. Value <code>1</code>, means it's known.
*/
public static final String PROP_OS_ID_KNOWN = "os_id_known"; //$NON-NLS-1$
}

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch;
import org.eclipse.osgi.util.NLS;
/**
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class MessagesForGdbLaunchVM extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.messages"; //$NON-NLS-1$
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, MessagesForGdbLaunchVM.class);
}
private MessagesForGdbLaunchVM() {
}
public static String ThreadVMNode_No_columns__text_format;
public static String ThreadVMNode_No_columns__Error__label;
}

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractThreadVMNode;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
@ -27,11 +28,19 @@ import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelAttribute;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelColumnInfo;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMDelegatingPropertiesUpdate;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.ui.IMemento;
@ -48,6 +57,40 @@ public class ThreadVMNode extends AbstractThreadVMNode
return "ThreadVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
@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,
ILaunchVMConstants.PROP_IS_SUSPENDED,
ExecutionContextLabelText.PROP_STATE_CHANGE_REASON_KNOWN,
ILaunchVMConstants.PROP_STATE_CHANGE_REASON }),
new LabelText(MessagesForGdbLaunchVM.ThreadVMNode_No_columns__Error__label, new String[0]),
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING)) {
{ setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); }
@Override
public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
return !((Boolean)properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED)).booleanValue();
};
},
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED)),
}));
return provider;
}
@Override
protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) {
IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length];
@ -63,33 +106,37 @@ public class ThreadVMNode extends AbstractThreadVMNode
// standard container properties.
parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm);
count++;
IMIExecutionDMContext execDmc = findDmcInPath(
update.getViewerInput(), update.getElementPath(), IMIExecutionDMContext.class);
if (execDmc != null) {
update.setProperty(ILaunchVMConstants.PROP_ID, Integer.toString(execDmc.getThreadId()));
}
IProcesses processService = getServicesTracker().getService(IProcesses.class);
final IThreadDMContext threadDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IThreadDMContext.class);
if (processService == null || threadDmc == null) {
update.setStatus(DsfUIPlugin.newErrorStatus(IDsfStatusConstants.INVALID_HANDLE, "Service or handle invalid", null)); //$NON-NLS-1$
} else {
processService.getExecutionData(
threadDmc,
new ViewerDataRequestMonitor<IThreadDMData>(getExecutor(), update) {
@Override
public void handleCompleted() {
if (isSuccess()) {
fillThreadDataProperties(update, getData());
} else {
final IMIExecutionDMContext execDmc = findDmcInPath(
update.getViewerInput(), update.getElementPath(), IMIExecutionDMContext.class);
if (execDmc != null) {
update.setProperty(ILaunchVMConstants.PROP_ID, Integer.toString(execDmc.getThreadId()));
} else {
update.setStatus(getStatus());
}
if (update.getProperties().contains(PROP_NAME) ||
update.getProperties().contains(IGdbLaunchVMConstants.PROP_OS_ID))
{
//
if (processService == null || threadDmc == null) {
update.setStatus(DsfUIPlugin.newErrorStatus(IDsfStatusConstants.INVALID_HANDLE, "Service or handle invalid", null)); //$NON-NLS-1$
} else {
processService.getExecutionData(
threadDmc,
new ViewerDataRequestMonitor<IThreadDMData>(getExecutor(), update) {
@Override
public void handleCompleted() {
if (isSuccess()) {
fillThreadDataProperties(update, getData());
}
update.setStatus(getStatus());
countringRm.done();
}
countringRm.done();
}
});
count++;
});
count++;
}
}
countringRm.setDoneCount(count);
@ -101,13 +148,7 @@ public class ThreadVMNode extends AbstractThreadVMNode
if (data.getName() != null && data.getName().length() > 0) {
update.setProperty(PROP_NAME, data.getName());
}
IMIExecutionDMContext execDmc = findDmcInPath(
update.getViewerInput(), update.getElementPath(), IMIExecutionDMContext.class);
if (execDmc != null) {
update.setProperty(ILaunchVMConstants.PROP_ID, Integer.toString(execDmc.getThreadId()));
}
update.setProperty(ILaunchVMConstants.PROP_ID2, data.getId());
update.setProperty(IGdbLaunchVMConstants.PROP_OS_ID, data.getId());
}
private String produceThreadElementName(String viewName, IMIExecutionDMContext execCtx) {

View file

@ -0,0 +1,24 @@
###############################################################################
# Copyright (c) 2007, 2009 Wind River Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Wind River Systems - initial API and implementation
###############################################################################
# {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} - 0=running/1=suspended
# {7} - state change reason available, 0=not available/1=available
# {8} - state change reason
ThreadVMNode_No_columns__text_format={0,choice,0#Thread|1#{1}}{2,choice,0#|1# [{3}]}{4,choice,0#|1# {5}} ({6,choice,0#Running|1#Suspended}{7,choice,0#|1# : {8}})
ThreadVMNode_No_columns__Error__label=<unavailable>

View file

@ -12,7 +12,6 @@
package org.eclipse.cdt.dsf.debug.ui.viewmodel.launch;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
@ -105,30 +104,9 @@ public abstract class AbstractThreadVMNode extends AbstractDMVMNode
PROP_NAME,
ExecutionContextLabelText.PROP_ID_KNOWN,
ILaunchVMConstants.PROP_ID,
ExecutionContextLabelText.PROP_ID2_KNOWN,
ILaunchVMConstants.PROP_ID2,
ILaunchVMConstants.PROP_IS_SUSPENDED,
ILaunchVMConstants.PROP_STATE_CHANGE_REASON })
{
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
String reason = (String)properties.get(ILaunchVMConstants.PROP_STATE_CHANGE_REASON);
return
reason != null && reason.length() != 0 &&
!StateChangeReason.UNKNOWN.equals(reason);
}
},
// If no state change reason is available compose a string without it.
new ExecutionContextLabelText(
MessagesForLaunchVM.AbstractThreadVMNode_No_columns__No_reason__text_format,
new String[] {
ExecutionContextLabelText.PROP_NAME_KNOWN,
PROP_NAME,
ExecutionContextLabelText.PROP_ID_KNOWN,
ILaunchVMConstants.PROP_ID,
ExecutionContextLabelText.PROP_ID2_KNOWN,
ILaunchVMConstants.PROP_ID2,
ILaunchVMConstants.PROP_IS_SUSPENDED }),
ExecutionContextLabelText.PROP_STATE_CHANGE_REASON_KNOWN,
ILaunchVMConstants.PROP_STATE_CHANGE_REASON }),
new LabelText(MessagesForLaunchVM.AbstractThreadVMNode_No_columns__Error__label, new String[0]),
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING)) {
{ setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); }

View file

@ -17,33 +17,34 @@ import org.eclipse.cdt.dsf.ui.viewmodel.properties.IElementPropertiesProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText;
import org.eclipse.core.runtime.IStatus;
class ExecutionContextLabelText extends LabelText {
/**
* @since 2.0
*/
public class ExecutionContextLabelText extends LabelText {
/**
* Value <code>0</code> means it's not known. Value <code>1</code>, means it's known.
*/
public static final String PROP_STATE_CHANGE_REASON_KNOWN = "state_change_reason_known"; //$NON-NLS-1$
/**
* Value <code>0</code> means it's not known. Value <code>1</code>, means it's known.
*/
public static final String PROP_ID_KNOWN = "id_known"; //$NON-NLS-1$
/**
* A second ID, such as the OS Id for a thread.
*
* Value <code>0</code> means it's not known. Value <code>1</code>, means it's known.
*/
public static final String PROP_ID2_KNOWN = "id2_known"; //$NON-NLS-1$
/**
* Value <code>0</code> means it's not known. Value <code>1</code>, means it's known.
*/
public static final String PROP_NAME_KNOWN = "name_known"; //$NON-NLS-1$
protected ExecutionContextLabelText(String formatPattern, String[] propertyNames) {
public ExecutionContextLabelText(String formatPattern, String[] propertyNames) {
super(formatPattern, propertyNames);
}
@Override
protected Object getPropertyValue(String propertyName, IStatus status, Map<String, Object> properties) {
if ( ILaunchVMConstants.PROP_STATE_CHANGE_REASON.equals(propertyName) ) {
String reason = (String)properties.get(propertyName);
String reason = (String)properties.get(ILaunchVMConstants.PROP_STATE_CHANGE_REASON);
String reasonLabel = "invalid reason"; //$NON-NLS-1$
if (StateChangeReason.BREAKPOINT.name().equals(reason)) {
reasonLabel = MessagesForLaunchVM.State_change_reason__Breakpoint__label;
@ -70,6 +71,9 @@ class ExecutionContextLabelText extends LabelText {
} else if ( ILaunchVMConstants.PROP_IS_SUSPENDED.equals(propertyName) ) {
Boolean suspended = (Boolean)properties.get(propertyName);
return suspended ? 1 : 0;
} else if ( PROP_STATE_CHANGE_REASON_KNOWN.equals(propertyName) ) {
String reason = (String)properties.get(ILaunchVMConstants.PROP_STATE_CHANGE_REASON);
return (reason != null && !StateChangeReason.UNKNOWN.name().equals(reason)) ? 1 : 0;
} else if (PROP_NAME_KNOWN.equals(propertyName)) {
return properties.get(IElementPropertiesProvider.PROP_NAME) != null ? 1 : 0;
} else if (IElementPropertiesProvider.PROP_NAME.equals(propertyName)) {
@ -77,14 +81,9 @@ class ExecutionContextLabelText extends LabelText {
return val != null ? val : ""; //$NON-NLS-1$
} else if (PROP_ID_KNOWN.equals(propertyName)) {
return properties.get(ILaunchVMConstants.PROP_ID) != null ? 1 : 0;
} else if (PROP_ID2_KNOWN.equals(propertyName)) {
return properties.get(ILaunchVMConstants.PROP_ID2) != null ? 1 : 0;
} else if (ILaunchVMConstants.PROP_ID.equals(propertyName)) {
Object val = properties.get(ILaunchVMConstants.PROP_ID);
return val != null ? val : ""; //$NON-NLS-1$
} else if (ILaunchVMConstants.PROP_ID2.equals(propertyName)) {
Object val = properties.get(ILaunchVMConstants.PROP_ID2);
return val != null ? val : ""; //$NON-NLS-1$
}
return super.getPropertyValue(propertyName, status, properties);
}
@ -93,10 +92,10 @@ class ExecutionContextLabelText extends LabelText {
protected boolean checkProperty(String propertyName, IStatus status, Map<String, Object> properties) {
if (PROP_NAME_KNOWN.equals(propertyName) ||
IElementPropertiesProvider.PROP_NAME.equals(propertyName) ||
PROP_STATE_CHANGE_REASON_KNOWN.equals(propertyName) ||
ILaunchVMConstants.PROP_STATE_CHANGE_REASON.equals(propertyName) ||
PROP_ID_KNOWN.equals(propertyName) ||
ILaunchVMConstants.PROP_ID.equals(propertyName) ||
PROP_ID2_KNOWN.equals(propertyName) ||
ILaunchVMConstants.PROP_ID2.equals(propertyName))
ILaunchVMConstants.PROP_ID.equals(propertyName))
{
return true;
}

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel.launch;
public interface ILaunchVMConstants {
public static final String PROP_ID = "id"; //$NON-NLS-1$
public static final String PROP_ID2 = "id2"; //$NON-NLS-1$
public static final String PROP_IS_SUSPENDED = "is_suspended"; //$NON-NLS-1$

View file

@ -38,7 +38,6 @@ public class MessagesForLaunchVM extends NLS {
public static String AbstractContainerVMNode_No_columns__Error__label;
public static String AbstractThreadVMNode_No_columns__text_format;
public static String AbstractThreadVMNode_No_columns__No_reason__text_format;
public static String AbstractThreadVMNode_No_columns__Error__label;
public static String State_change_reason__Unknown__label;

View file

@ -47,20 +47,10 @@ AbstractContainerVMNode_No_columns__Error__label=<unavailable>
# {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} - 0=running/1=suspended
# {7} - state change reason
AbstractThreadVMNode_No_columns__text_format={0,choice,0#Thread|1#{1}}{2,choice,0#|1# [{3}]}{4,choice,0#|1# {5}} ({6,choice,0#Running|1#Suspended} : {7})
# {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} - 0=running/1=suspended
AbstractThreadVMNode_No_columns__No_reason__text_format={0,choice,0#Thread|1#{1}}{2,choice,0#|1# [{3}]}{4,choice,0#|1# {5}} ({6,choice,0#Running|1#Suspended})
# {4} - 0=running/1=suspended
# {5} - state change reason available, 0=not available/1=available
# {6} - state change reason
AbstractThreadVMNode_No_columns__text_format={0,choice,0#Thread|1#{1}}{2,choice,0#|1# [{3}]} ({4,choice,0#Running|1#Suspended}{5,choice,0#|1# : {6}})
AbstractThreadVMNode_No_columns__Error__label=<unavailable>