|
Added
Link Here
|
| 1 |
package org.eclipse.cdt.debug.mi.core.command.factories.macos; |
| 2 |
|
| 3 |
import java.util.Arrays; |
| 4 |
|
| 5 |
import org.eclipse.cdt.debug.mi.core.output.CLIInfoThreadsInfo; |
| 6 |
import org.eclipse.cdt.debug.mi.core.output.MIConst; |
| 7 |
import org.eclipse.cdt.debug.mi.core.output.MIOutput; |
| 8 |
import org.eclipse.cdt.debug.mi.core.output.MIResult; |
| 9 |
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord; |
| 10 |
import org.eclipse.cdt.debug.mi.core.output.MITuple; |
| 11 |
import org.eclipse.cdt.debug.mi.core.output.MIValue; |
| 12 |
|
| 13 |
/** |
| 14 |
* This class actually parses -thread-list-ids and converts it to the |
| 15 |
* CLIInfoThreadsInfo 'format' |
| 16 |
*/ |
| 17 |
class MacOsCLIInfoThreadsInfo extends CLIInfoThreadsInfo { |
| 18 |
|
| 19 |
public MacOsCLIInfoThreadsInfo(MIOutput out) { |
| 20 |
super(out); |
| 21 |
} |
| 22 |
|
| 23 |
protected void parse() { |
| 24 |
if (isDone()) { |
| 25 |
MIOutput out = getMIOutput(); |
| 26 |
MIResultRecord rr = out.getMIResultRecord(); |
| 27 |
if (rr != null) { |
| 28 |
MIResult[] results = rr.getMIResults(); |
| 29 |
for (int i = 0; i < results.length; i++) { |
| 30 |
String var = results[i].getVariable(); |
| 31 |
if (var.equals("thread-ids")) { //$NON-NLS-1$ |
| 32 |
MIValue val = results[i].getMIValue(); |
| 33 |
if (val instanceof MITuple) { |
| 34 |
parseThreadIds((MITuple) val); |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
if (threadIds == null) { |
| 41 |
threadIds = new int[0]; |
| 42 |
} |
| 43 |
Arrays.sort(threadIds); |
| 44 |
|
| 45 |
// -thread-list-ids doesn't provide the current thread id so we |
| 46 |
// set currentThreadId to a dumb value. This has the effect of falling |
| 47 |
// back to the thread id provided by the stopped event. See EventManager::processSuspendedEvent |
| 48 |
currentThreadId = -1; |
| 49 |
} |
| 50 |
|
| 51 |
void parseThreadIds(MITuple tuple) { |
| 52 |
MIResult[] results = tuple.getMIResults(); |
| 53 |
threadIds = new int[results.length]; |
| 54 |
for (int i = 0; i < results.length; i++) { |
| 55 |
String var = results[i].getVariable(); |
| 56 |
if (var.equals("thread-id")) { //$NON-NLS-1$ |
| 57 |
MIValue value = results[i].getMIValue(); |
| 58 |
if (value instanceof MIConst) { |
| 59 |
String str = ((MIConst) value).getCString(); |
| 60 |
try { |
| 61 |
threadIds[i] = Integer.parseInt(str.trim()); |
| 62 |
} catch (NumberFormatException e) { |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
} |