1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-27 02:45:32 +02:00

Generics.

This commit is contained in:
Sergey Prigogin 2010-12-09 01:16:31 +00:00
parent c42dcb755b
commit 82e06db2d9

View file

@ -147,7 +147,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* When a thread starts it is added to the list.
* When a thread ends it is removed from the list.
*/
private ArrayList fThreads;
private ArrayList<CThread> fThreads;
/**
* Associated inferior process, or <code>null</code> if not available.
@ -240,7 +240,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private IAddressFactory fAddressFactory;
/**
* Support for the memory retrival on this target.
* Support for the memory retrieval on this target.
*/
private CMemoryBlockRetrievalExtension fMemoryBlockRetrieval;
@ -266,7 +266,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
setState(CDebugElementState.SUSPENDED);
initializePreferences();
setConfiguration(cdiTarget.getConfiguration());
setThreadList( new ArrayList( 5 ) );
setThreadList(new ArrayList<CThread>(5));
createDisassembly();
setModuleManager(new CModuleManager(this));
setSignalManager(new CSignalManager(this));
@ -283,7 +283,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
protected void initialize() {
initializeSourceLookupPath();
ArrayList debugEvents = new ArrayList( 1 );
ArrayList<DebugEvent> debugEvents = new ArrayList<DebugEvent>(1);
debugEvents.add(createCreateEvent());
initializeThreads(debugEvents);
initializeBreakpoints();
@ -292,7 +292,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
initializeModuleManager();
initializeMemoryBlocks();
getLaunch().addDebugTarget(this);
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
fireEventSet(debugEvents.toArray(new DebugEvent[debugEvents.size()]));
}
private void initializeBreakpoints() {
@ -323,7 +323,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
/**
* Adds all of the pre-existing threads to this debug target.
*/
protected void initializeThreads( List debugEvents ) {
protected void initializeThreads(List<DebugEvent> debugEvents) {
final ICDITarget cdiTarget = getCDITarget();
if (cdiTarget == null) {
return;
@ -332,8 +332,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
ICDIThread[] cdiThreads = new ICDIThread[0];
try {
cdiThreads = cdiTarget.getThreads();
}
catch( CDIException e ) {
} catch (CDIException e) {
// ignore
}
DebugEvent suspendEvent = null;
@ -345,8 +344,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
// Use BREAKPOINT as a detail to force perspective switch
suspendEvent = thread.createSuspendEvent(DebugEvent.BREAKPOINT);
}
}
catch( CDIException e ) {
} catch (CDIException e) {
// ignore
}
}
@ -396,17 +394,16 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
ICDISharedLibrary[] slibs = new ICDISharedLibrary[0];
try {
slibs = cdiTarget.getSharedLibraries();
}
catch( CDIException e ) {
} catch (CDIException e) {
DebugPlugin.log(e);
}
ICModule[] modules = null;
if (getExecFile() != null) {
modules = new ICModule[slibs.length + 1];
modules[0] = CModule.createExecutable(this, getExecFile().getPath());
}
else
} else {
modules = new ICModule[slibs.length];
}
for (int i = 0; i < slibs.length; ++i) {
modules[i + 1] = CModule.createSharedLibrary(this, slibs[i]);
}
@ -441,8 +438,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
*/
public IThread[] getThreads() {
List threads = getThreadList();
return (IThread[])threads.toArray( new IThread[threads.size()] );
List<CThread> threads = getThreadList();
return threads.toArray(new IThread[threads.size()]);
}
/*
@ -535,8 +532,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (cdiTarget != null) {
cdiTarget.terminate();
}
}
catch( CDIException e ) {
} catch (CDIException e) {
if (getState() == newState) {
restoreOldState();
}
@ -590,8 +586,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (cdiTarget != null) {
cdiTarget.resume(false);
}
}
catch( CDIException e ) {
} catch (CDIException e) {
if (getState() == newState) {
restoreOldState();
}
@ -612,8 +607,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (cdiTarget != null) {
cdiTarget.suspend();
}
}
catch( CDIException e ) {
} catch (CDIException e) {
if (getState() == newState) {
restoreOldState();
}
@ -629,17 +623,16 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* Notifies threads that the target has been suspended.
*/
protected void suspendThreads(ICDISuspendedEvent event) {
Iterator it = getThreadList().iterator();
Iterator<CThread> it = getThreadList().iterator();
while (it.hasNext()) {
CThread thread = (CThread)it.next();
CThread thread = it.next();
ICDIThread suspensionThread = null;
try {
final ICDITarget cdiTarget = getCDITarget();
if (cdiTarget != null) {
suspensionThread = cdiTarget.getCurrentThread();
}
}
catch( CDIException e ) {
} catch (CDIException e) {
// ignore
}
thread.suspendByTarget(event.getReason(), suspensionThread);
@ -649,11 +642,11 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
/**
* Refreshes the thread list.
*/
protected synchronized List refreshThreads() {
ArrayList newThreads = new ArrayList( 5 );
ArrayList list = new ArrayList( 5 );
ArrayList debugEvents = new ArrayList( 5 );
List oldList = (List)getThreadList().clone();
protected synchronized List<CThread> refreshThreads() {
ArrayList<CThread> newThreads = new ArrayList<CThread>(5);
ArrayList<CThread> list = new ArrayList<CThread>(5);
ArrayList<DebugEvent> debugEvents = new ArrayList<DebugEvent>(5);
List<CThread> oldList = (List<CThread>)getThreadList().clone();
ICDIThread[] cdiThreads = new ICDIThread[0];
ICDIThread currentCDIThread = null;
try {
@ -662,8 +655,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
cdiThreads = cdiTarget.getThreads();
currentCDIThread = cdiTarget.getCurrentThread();
}
}
catch( CDIException e ) {
} catch (CDIException e) {
}
for (int i = 0; i < cdiThreads.length; ++i) {
CThread thread = findThread(oldList, cdiThreads[i]);
@ -677,29 +669,29 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
thread.setCurrent(cdiThreads[i].equals(currentCDIThread));
list.add(thread);
}
Iterator it = oldList.iterator();
Iterator<CThread> it = oldList.iterator();
while (it.hasNext()) {
CThread thread = (CThread)it.next();
CThread thread = it.next();
thread.terminated();
debugEvents.add(thread.createTerminateEvent());
}
setThreadList(list);
it = newThreads.iterator();
while (it.hasNext()) {
debugEvents.add( ((CThread)it.next()).createCreateEvent() );
debugEvents.add(it.next().createCreateEvent());
}
if (debugEvents.size() > 0)
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
fireEventSet(debugEvents.toArray(new DebugEvent[debugEvents.size()]));
return newThreads;
}
/**
* Notifies threads that the target has been resumed.
*/
protected synchronized void resumeThreads( List debugEvents, int detail ) {
Iterator it = getThreadList().iterator();
protected synchronized void resumeThreads(List<DebugEvent> debugEvents, int detail) {
Iterator<CThread> it = getThreadList().iterator();
while (it.hasNext()) {
((CThread)it.next()).resumedByTarget( detail, debugEvents );
it.next().resumedByTarget(detail, debugEvents);
}
}
@ -760,8 +752,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (cdiTarget != null) {
cdiTarget.disconnect();
}
}
catch( CDIException e ) {
} catch (CDIException e) {
if (getState() == newState) {
restoreOldState();
}
@ -812,7 +803,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*
* @return list of threads
*/
protected ArrayList getThreadList() {
protected ArrayList<CThread> getThreadList() {
return fThreads;
}
@ -822,7 +813,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*
* @param threads empty list
*/
private void setThreadList( ArrayList threads ) {
private void setThreadList(ArrayList<CThread> threads) {
fThreads = threads;
}
@ -834,7 +825,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@Override
public Object getAdapter( Class adapter ) {
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
if (adapter.equals(ICDebugElement.class))
return this;
if (adapter.equals(CDebugElement.class))
@ -978,8 +969,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
setInternalTemporaryBreakpoint(location);
}
}
catch( CoreException e ) {
} catch (CoreException e) {
requestFailed(e.getMessage(), e);
}
@ -987,8 +977,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
changeState(newState);
try {
cdiTarget.restart();
}
catch( CDIException e ) {
} catch (CDIException e) {
if (getState() == newState) {
restoreOldState();
}
@ -1087,16 +1076,16 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* Removes all threads from this target's collection of threads, firing a terminate event for each.
*/
protected void removeAllThreads() {
List threads = getThreadList();
setThreadList( new ArrayList( 0 ) );
ArrayList debugEvents = new ArrayList( threads.size() );
Iterator it = threads.iterator();
List<CThread> threads = getThreadList();
setThreadList(new ArrayList<CThread>(0));
ArrayList<DebugEvent> debugEvents = new ArrayList<DebugEvent>(threads.size());
Iterator<CThread> it = threads.iterator();
while (it.hasNext()) {
CThread thread = (CThread)it.next();
CThread thread = it.next();
thread.terminated();
debugEvents.add(thread.createTerminateEvent());
}
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
fireEventSet(debugEvents.toArray(new DebugEvent[debugEvents.size()]));
}
/**
@ -1132,14 +1121,13 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
// Reset the registers that have errors.
getRegisterManager().targetSuspended();
getBreakpointManager().skipBreakpoints(false);
List newThreads = refreshThreads();
List<CThread> newThreads = refreshThreads();
if (event.getSource() instanceof ICDITarget) {
if (!(this.getConfiguration() instanceof ICDITargetConfiguration2) || !((ICDITargetConfiguration2)this.getConfiguration()).supportsThreadControl())
suspendThreads(event);
}
} else if (event.getSource() instanceof ICDIThread) {
// We need this for debuggers that don't have notifications
// for newly created threads.
else if ( event.getSource() instanceof ICDIThread ) {
CThread thread = findThread((ICDIThread)event.getSource());
if (thread != null && newThreads.contains(thread)) {
ICDIEvent[] evts = new ICDIEvent[]{ event };
@ -1179,7 +1167,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
setState(CDebugElementState.RESUMED);
setCurrentStateInfo(null);
resetStatus();
ArrayList debugEvents = new ArrayList( 10 );
ArrayList<DebugEvent> debugEvents = new ArrayList<DebugEvent>(10);
int detail = DebugEvent.UNSPECIFIED;
switch(event.getType()) {
case ICDIResumedEvent.CONTINUE:
@ -1202,7 +1190,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (!(this.getConfiguration() instanceof ICDITargetConfiguration2) || !((ICDITargetConfiguration2)this.getConfiguration()).supportsThreadControl())
resumeThreads(debugEvents, detail);
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
fireEventSet(debugEvents.toArray(new DebugEvent[debugEvents.size()]));
}
private void handleEndSteppingRange(ICDIEndSteppingRange endSteppingRange) {
@ -1287,10 +1275,10 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private void handleThreadTerminatedEvent(ICDIDestroyedEvent event) {
ICDIThread cdiThread = (ICDIThread)event.getSource();
List threads = getThreadList();
List<CThread> threads = getThreadList();
List<CThread> threadsToRemove = new ArrayList<CThread>(1);
for (int i = 0; i < threads.size(); i++) {
CThread cthread = (CThread)threads.get(i);
CThread cthread = threads.get(i);
// It's possible CThread has handled the thread-terminated event
// before us (by appearing first in the EventManager)
// and has disassociated itself from the ICDIThread.
@ -1319,9 +1307,9 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return findThread(getThreadList(), cdiThread);
}
public CThread findThread( List threads, ICDIThread cdiThread ) {
public CThread findThread(List<CThread> threads, ICDIThread cdiThread) {
for (int i = 0; i < threads.size(); i++) {
CThread t = (CThread)threads.get( i );
CThread t = threads.get(i);
ICDIThread thisCdiThread = t.getCDIThread();
if (thisCdiThread != null && thisCdiThread.equals(cdiThread))
return t;
@ -1388,8 +1376,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
// ???
targetRequestFailed("not_a_location", null); //$NON-NLS-1$
}
}
catch( CDIException e ) {
} catch (CDIException e) {
targetRequestFailed(e.getMessage(), null);
}
}
@ -1422,7 +1409,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return fIsLittleEndian.booleanValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IExecFileInfo#getExecFile()
*/
@ -1454,32 +1440,29 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
IGlobalVariableDescriptor[] globals = new IGlobalVariableDescriptor[0];
// If the backend can give us the globals...
boolean hasCDIGlobals = false;
ArrayList list = new ArrayList();
if (cdiTarget instanceof ICDITarget2)
{
ArrayList<IGlobalVariableDescriptor> list = new ArrayList<IGlobalVariableDescriptor>();
if (cdiTarget instanceof ICDITarget2) {
ICDIGlobalVariableDescriptor[] cdiGlobals = ((ICDITarget2) cdiTarget).getGlobalVariables();
hasCDIGlobals = cdiGlobals != null;
if (hasCDIGlobals)
{
if (hasCDIGlobals) {
for (int i = 0; i < cdiGlobals.length; i++) {
list.add(CVariableFactory.createGlobalVariableDescriptor(cdiGlobals[i].getName(), null));
}
}
}
// otherwise ask the binary
if (!hasCDIGlobals)
{
if (!hasCDIGlobals) {
IBinaryObject file = getBinaryFile();
if (file != null) {
list.addAll(getCFileGlobals(file));
}
}
globals = (IGlobalVariableDescriptor[])list.toArray( new IGlobalVariableDescriptor[list.size()] );
globals = list.toArray(new IGlobalVariableDescriptor[list.size()]);
return globals;
}
private List getCFileGlobals( IBinaryObject file ) {
ArrayList list = new ArrayList();
private List<IGlobalVariableDescriptor> getCFileGlobals(IBinaryObject file) {
ArrayList<IGlobalVariableDescriptor> list = new ArrayList<IGlobalVariableDescriptor>();
ISymbol[] symbols = file.getSymbols();
for (int i = 0; i < symbols.length; ++i) {
if (symbols[i].getType() == ISymbol.VARIABLE) {
@ -1555,8 +1538,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (cdiTarget != null) {
cdiTarget.resume(false);
}
}
catch( CDIException e ) {
} catch (CDIException e) {
if (getState() == newState) {
restoreOldState();
}
@ -1629,8 +1611,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
String result = ""; //$NON-NLS-1$
try {
result = getName();
}
catch( DebugException e ) {
} catch (DebugException e) {
}
return result;
}
@ -1794,17 +1775,17 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private void changeState(CDebugElementState state) {
setState(state);
Iterator it = getThreadList().iterator();
Iterator<CThread> it = getThreadList().iterator();
while (it.hasNext()) {
((CThread)it.next()).setState( state );
it.next().setState(state);
}
}
protected void restoreOldState() {
restoreState();
Iterator it = getThreadList().iterator();
Iterator<CThread> it = getThreadList().iterator();
while (it.hasNext()) {
((CThread)it.next()).restoreState();
it.next().restoreState();
}
}
@ -1819,8 +1800,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (cdiTarget != null) {
vo = cdiTarget.getGlobalVariableDescriptors(info.getPath().lastSegment(), null, info.getName());
}
}
catch( CDIException e ) {
} catch (CDIException e) {
throw new DebugException(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getMessage(), null));
}
return CVariableFactory.createGlobalVariable(this, info, vo);
@ -1841,8 +1821,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (cdiTarget != null) {
cdiTarget.setSourcePaths(list.toArray(new String[list.size()]));
}
}
catch( CDIException e ) {
} catch (CDIException e) {
CDebugCorePlugin.log(e);
}
}
@ -1855,14 +1834,12 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
IProject project = ((ProjectSourceContainer) container).getProject();
if (project != null && project.exists())
pathToAdd = project.getLocation().toPortableString();
}
if ( container instanceof FolderSourceContainer ) {
} else if (container instanceof FolderSourceContainer) {
IContainer folderContainer = ((FolderSourceContainer) container).getContainer();
if (folderContainer != null && folderContainer.exists()) {
pathToAdd = folderContainer.getLocation().toPortableString();
}
}
if ( container instanceof DirectorySourceContainer ) {
} if (container instanceof DirectorySourceContainer) {
File dir = ((DirectorySourceContainer) container).getDirectory();
if (dir != null && dir.exists()) {
IPath path = new Path(dir.getAbsolutePath());
@ -1882,8 +1859,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if (container.isComposite()) {
try {
getSourceLookupPath(list, container.getSourceContainers());
}
catch( CoreException e ) {
} catch (CoreException e) {
CDebugCorePlugin.log(e.getStatus());
}
}
@ -1937,8 +1913,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private void stopAtLocation(ICDILocation location, String stopExpression) throws DebugException {
try {
setInternalTemporaryBreakpoint(location);
}
catch( CoreException e ) {
} catch (CoreException e) {
final ICDITarget cdiTarget = getCDITarget();
boolean isTerminated = cdiTarget != null && cdiTarget.isTerminated();
if (isTerminated) {
@ -1980,8 +1955,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
ICDILocation location = cdiTarget.createFunctionLocation("", mainSymbol); //$NON-NLS-1$
setInternalTemporaryBreakpoint(location);
}
}
catch( CoreException e ) {
} catch (CoreException e) {
String message = MessageFormat.format(CoreModelMessages.getString("CDebugTarget.2"), new String[]{ mainSymbol, e.getStatus().getMessage() }); //$NON-NLS-1$
IStatus newStatus = new Status(IStatus.WARNING, e.getStatus().getPlugin(), ICDebugInternalConstants.STATUS_CODE_QUESTION, message, null);
if (!CDebugUtils.question(newStatus, this)) {