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
*******************************************************************************/
11
package org.eclipse.cdt.debug.mi.core.output;
13
import java.util.ArrayList;
14
import java.util.List;
17
* GDB/MI var-list-children
18
* -var-list-children var2
19
* ^done,numchild="6",children={child={name="var2.0",exp="0",numchild="0",type="char"},child={name="var2.1",exp="1",numchild="0",type="char"},child={name="var2.2",exp="2",numchild="0",type="char"},child={name="var2.3",exp="3",numchild="0",type="char"},child={name="var2.4",exp="4",numchild="0",type="char"},child={name="var2.5",exp="5",numchild="0",type="char"}}
22
public class MIVarListChildrenInfo extends MIInfo {
27
public MIVarListChildrenInfo(MIOutput record) {
32
public MIVar[] getMIVars() {
37
List aList = new ArrayList();
39
MIOutput out = getMIOutput();
40
MIResultRecord rr = out.getMIResultRecord();
42
MIResult[] results = rr.getMIResults();
43
for (int i = 0; i < results.length; i++) {
44
String var = results[i].getVariable();
45
MIValue value = results[i].getMIValue();
47
if (var.equals("numchild")) { //$NON-NLS-1$
48
if (value instanceof MIConst) {
49
String str = ((MIConst)value).getString();
51
numchild = Integer.parseInt(str.trim());
52
} catch (NumberFormatException e) {
55
} else if (var.equals("children")) { //$NON-NLS-1$
56
parseChildren(value, aList);
61
children = (MIVar[])aList.toArray(new MIVar[aList.size()]);
65
* Some gdb MacOSX do not return a MITuple so we have
66
* to check for different format.
69
void parseChildren(MIValue val, List aList) {
70
MIResult[] results = null;
71
if (val instanceof MITuple) {
72
results = ((MITuple)val).getMIResults();
73
} else if (val instanceof MIList) {
74
results = ((MIList)val).getMIResults();
76
if (results != null) {
77
for (int i = 0; i < results.length; i++) {
78
String var = results[i].getVariable();
79
if (var.equals("child")) { //$NON-NLS-1$
80
MIValue value = results[i].getMIValue();
81
if (value instanceof MITuple) {
82
aList.add(new MIVar((MITuple)value));