mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
* cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java
* cdi/org/eclipse/cdt/debug/mi/core/cdi/ThreadManager.java
This commit is contained in:
parent
f87836aa5e
commit
be18a50d17
3 changed files with 142 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-07-02 Alain Magloire
|
||||
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/ThreadManager.java
|
||||
|
||||
2004-06-29 Alain Magloire
|
||||
|
||||
When selecting threads gdb can reset the current
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessManager extends Manager { //implements ICDIProcessManager {
|
||||
|
||||
static final ICDITarget[] noProcess = new Target[0];
|
||||
|
||||
HashMap processMap;
|
||||
|
||||
class ProcessSet {
|
||||
ICDITarget[] currentProcs;
|
||||
int currentProcessId;
|
||||
ProcessSet(ICDITarget[] procs, int id) {
|
||||
currentProcs = procs;
|
||||
currentProcessId = id;
|
||||
}
|
||||
}
|
||||
|
||||
public ProcessManager(Session session) {
|
||||
super(session, true);
|
||||
processMap = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIProcessManager#getProcesses()
|
||||
*/
|
||||
public ICDITarget[] getProcesses(ICDISession session) throws CDIException {
|
||||
ProcessSet set = (ProcessSet)processMap.get(session);
|
||||
if (set == null) {
|
||||
set = getCProcesses(session);
|
||||
processMap.put(session, set);
|
||||
}
|
||||
return set.currentProcs;
|
||||
}
|
||||
|
||||
public ProcessSet getCProcesses(ICDISession session) throws CDIException {
|
||||
ICDITarget[] cprocs = new Target[] {new Target((Session)session)};
|
||||
return new ProcessSet(cprocs, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.derug.core.cdi.ICDIManager#update()
|
||||
*/
|
||||
public void update() throws CDIException {
|
||||
}
|
||||
|
||||
}
|
|
@ -10,17 +10,38 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIInfoThreads;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfoThreadsInfo;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ThreadManager extends Manager { //implements ICDIThreadManager {
|
||||
|
||||
static final Thread[] noThreads = new Thread[0];
|
||||
HashMap threadMap;
|
||||
|
||||
class ThreadSet {
|
||||
ICDIThread[] currentThreads;
|
||||
int currentThreadId;
|
||||
ThreadSet(ICDIThread[] threads, int id) {
|
||||
currentThreads = threads;
|
||||
currentThreadId = id;
|
||||
}
|
||||
}
|
||||
|
||||
public ThreadManager(Session session) {
|
||||
super(session, true);
|
||||
threadMap = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +52,62 @@ public class ThreadManager extends Manager { //implements ICDIThreadManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIThreadManager#update()
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIThreadManager#getThreads()
|
||||
*/
|
||||
public ICDIThread[] getThreads(ICDITarget process) throws CDIException {
|
||||
ThreadSet set = (ThreadSet)threadMap.get(process);
|
||||
if (set == null) {
|
||||
set = getCThreads(process);
|
||||
threadMap.put(process, set);
|
||||
}
|
||||
return set.currentThreads;
|
||||
}
|
||||
|
||||
public ThreadSet getCThreads(ICDITarget process) throws CDIException {
|
||||
Thread[] cthreads = noThreads;
|
||||
int currentThreadId = 0;
|
||||
MISession mi = ((Session)getSession()).getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
try {
|
||||
// HACK/FIXME: gdb/mi thread-list-ids does not
|
||||
// show any newly create thread, we workaround by
|
||||
// issuing "info threads" instead.
|
||||
//MIThreadListIds tids = factory.createMIThreadListIds();
|
||||
//MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo();
|
||||
|
||||
MIInfoThreads tids = factory.createMIInfoThreads();
|
||||
mi.postCommand(tids);
|
||||
MIInfoThreadsInfo info = tids.getMIInfoThreadsInfo();
|
||||
int [] ids;
|
||||
if (info == null) {
|
||||
ids = new int[0];
|
||||
} else {
|
||||
ids = info.getThreadIds();
|
||||
}
|
||||
if (ids != null && ids.length > 0) {
|
||||
cthreads = new Thread[ids.length];
|
||||
// Ok that means it is a multiThreaded.
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
cthreads[i] = new Thread(process, ids[i]);
|
||||
}
|
||||
} else {
|
||||
// Provide a dummy.
|
||||
cthreads = new Thread[]{new Thread(process, 0)};
|
||||
}
|
||||
currentThreadId = info.getCurrentThread();
|
||||
//FIX: When attaching there is no thread selected
|
||||
// We will choose the first one as a workaround.
|
||||
if (currentThreadId == 0 && cthreads.length > 0) {
|
||||
currentThreadId = cthreads[0].getId();
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.getMessage());
|
||||
}
|
||||
return new ThreadSet(cthreads, currentThreadId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.derug.core.cdi.ICDIThreadManager#update()
|
||||
*/
|
||||
public void update() throws CDIException {
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue