1
/*******************************************************************************
2
* Copyright (c) 2000, 2007 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
* Wind River Systems - Modified for new DSF Reference Implementation
11
*******************************************************************************/
13
package org.eclipse.cdt.dsf.mi.service.command.output;
15
import java.util.ArrayList;
16
import java.util.List;
19
* GDB/MI data list regiter names response extraction.
21
public class MIDataListRegisterNamesInfo extends MIInfo {
24
protected int realNameCount = 0;
26
public MIDataListRegisterNamesInfo(MIOutput rr) {
29
List<String> aList = new ArrayList<String>();
31
MIOutput out = getMIOutput();
32
MIResultRecord outr = out.getMIResultRecord();
34
MIResult[] results = outr.getMIResults();
35
for (int i = 0; i < results.length; i++) {
36
String var = results[i].getVariable();
37
if (var.equals("register-names")) { //$NON-NLS-1$
38
MIValue value = results[i].getMIValue();
39
if (value instanceof MIList) {
40
parseRegisters((MIList) value, aList);
46
names = aList.toArray(new String[aList.size()]);
50
* Returns the register names.
52
public String[] getRegisterNames() {
55
* The expectation is that we return an empty list. The
56
* constructor quarantees this so we are good here.
61
private void parseRegisters(MIList list, List<String> aList) {
62
MIValue[] values = list.getMIValues();
63
for (int i = 0; i < values.length; i++) {
64
if (values[i] instanceof MIConst) {
65
String str = ((MIConst) values[i]).getCString();
67
/* this cannot filter nulls because index is critical in retreival
68
* and index is assigned in the layers above. The MI spec allows
69
* empty returns, for some register names. */
70
if (str != null && str.length() > 0) {
74
aList.add(""); //$NON-NLS-1$