1
/*******************************************************************************
2
* Copyright (c) 2000, 2006 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - Initial API and implementation
10
* Ericsson AB - Modified for DSF Reference Implementation
11
*******************************************************************************/
12
package org.eclipse.cdt.dsf.mi.service.command.output;
15
* GDB/MI thread list parsing.
17
public class MIThreadListIdsInfo extends MIInfo {
20
private String[] strThreadIds;
22
public MIThreadListIdsInfo(MIOutput out) {
26
public int[] getThreadIds() {
27
if (threadIds == null) {
28
// To make sure that the threads have be parsed
29
String[] tIds = getStrThreadIds();
31
threadIds = new int[tIds.length];
32
for (int i=0; i<tIds.length; i++) {
34
threadIds[i] = Integer.parseInt(tIds[i]);
35
} catch (NumberFormatException e) {
47
public String[] getStrThreadIds() {
48
if (strThreadIds == null) {
56
MIOutput out = getMIOutput();
57
MIResultRecord rr = out.getMIResultRecord();
59
MIResult[] results = rr.getMIResults();
60
for (int i = 0; i < results.length; i++) {
61
String var = results[i].getVariable();
62
if (var.equals("thread-ids")) { //$NON-NLS-1$
63
MIValue val = results[i].getMIValue();
64
if (val instanceof MITuple) {
65
parseThreadIds((MITuple)val);
71
if (strThreadIds == null) {
72
strThreadIds = new String[0];
76
void parseThreadIds(MITuple tuple) {
77
MIResult[] results = tuple.getMIResults();
78
strThreadIds = new String[results.length];
79
for (int i = 0; i < results.length; i++) {
80
String var = results[i].getVariable();
81
if (var.equals("thread-id")) { //$NON-NLS-1$
82
MIValue value = results[i].getMIValue();
83
if (value instanceof MIConst) {
84
strThreadIds[i] = ((MIConst)value).getCString().trim();