~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIDataListRegisterNamesInfo.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
7
 
 *
8
 
 * Contributors:
9
 
 *     QNX Software Systems - Initial API and implementation
10
 
 *     Wind River Systems   - Modified for new DSF Reference Implementation
11
 
 *******************************************************************************/
12
 
 
13
 
package org.eclipse.cdt.dsf.mi.service.command.output;
14
 
 
15
 
import java.util.ArrayList;
16
 
import java.util.List;
17
 
 
18
 
/**
19
 
 * GDB/MI data list regiter names response extraction.
20
 
 */
21
 
public class MIDataListRegisterNamesInfo extends MIInfo {
22
 
 
23
 
    String[] names;
24
 
    protected int realNameCount = 0;
25
 
 
26
 
    public MIDataListRegisterNamesInfo(MIOutput rr) {
27
 
        super(rr);
28
 
        names = null;
29
 
        List<String> aList = new ArrayList<String>();
30
 
        if (isDone()) {
31
 
            MIOutput out = getMIOutput();
32
 
            MIResultRecord outr = out.getMIResultRecord();
33
 
            if (outr != null) {
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);
41
 
                        }
42
 
                    }
43
 
                }
44
 
            }
45
 
        }
46
 
        names = aList.toArray(new String[aList.size()]);
47
 
    }
48
 
 
49
 
    /*
50
 
     * Returns the register names. 
51
 
     */
52
 
    public String[] getRegisterNames() {
53
 
        
54
 
        /*
55
 
         * The expectation is that we return an empty list. The
56
 
         * constructor quarantees this so we are good here.
57
 
         */
58
 
        return names;
59
 
    }
60
 
 
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();
66
 
 
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) {
71
 
                    realNameCount++;
72
 
                    aList.add(str);
73
 
                } else {
74
 
                    aList.add(""); //$NON-NLS-1$
75
 
                }
76
 
            }
77
 
        }
78
 
    }
79
 
}