private String[] parseCores(MIList list) {
    List<String> cores = new ArrayList<String>();

    MIValue[] values = list.getMIValues();
    for (int i = 0; i < values.length; i++) {
      if (values[i] instanceof MIConst) {
        cores.add(((MIConst) values[i]).getCString());
      }
    }
    return cores.toArray(new String[cores.size()]);
  }
Beispiel #2
0
 /** Parsing a MIList of the form: [{number="1",value="0xffff"},{number="xxx",value="yyy"},..] */
 public static MIRegisterValue[] getMIRegisterValues(MIList miList) {
   List aList = new ArrayList();
   MIValue[] values = miList.getMIValues();
   for (int i = 0; i < values.length; i++) {
     if (values[i] instanceof MITuple) {
       MIRegisterValue reg = getMIRegisterValue((MITuple) values[i]);
       if (reg != null) {
         aList.add(reg);
       }
     }
   }
   return ((MIRegisterValue[]) aList.toArray(new MIRegisterValue[aList.size()]));
 }
  private void parseGroups(MIList list) {
    MIValue[] values = list.getMIValues();
    fGroupList = new IThreadGroupInfo[values.length];
    for (int i = 0; i < values.length; i++) {
      MIResult[] results = ((MITuple) values[i]).getMIResults();
      String id, desc, type, pid, exec, user;
      id = desc = type = pid = exec = user = ""; // $NON-NLS-1$
      MIThread[] threads = null;

      String[] cores = null;

      for (MIResult result : results) {
        String var = result.getVariable();
        if (var.equals("id")) { // $NON-NLS-1$
          MIValue value = result.getMIValue();
          if (value instanceof MIConst) {
            String str = ((MIConst) value).getCString();
            id = str.trim();
          }
        } else if (var.equals("description")) { // $NON-NLS-1$
          MIValue value = result.getMIValue();
          if (value instanceof MIConst) {
            String str = ((MIConst) value).getCString();
            desc = str.trim();
          }
        } else if (var.equals("type")) { // $NON-NLS-1$
          MIValue value = result.getMIValue();
          if (value instanceof MIConst) {
            String str = ((MIConst) value).getCString();
            type = str.trim();
          }
        } else if (var.equals("pid")) { // $NON-NLS-1$
          MIValue value = result.getMIValue();
          if (value instanceof MIConst) {
            String str = ((MIConst) value).getCString();
            pid = str.trim();
          }
        } else if (var.equals("user")) { // $NON-NLS-1$
          MIValue value = result.getMIValue();
          if (value instanceof MIConst) {
            String str = ((MIConst) value).getCString();
            user = str.trim();
          }
        } else if (var.equals("cores")) { // $NON-NLS-1$
          // Staring with GDB 7.1
          MIValue value = result.getMIValue();
          if (value instanceof MIList) {
            cores = parseCores((MIList) value);
          }
        } else if (var.equals("executable")) { // $NON-NLS-1$
          // Staring with GDB 7.2
          MIValue value = result.getMIValue();
          if (value instanceof MIConst) {
            String str = ((MIConst) value).getCString();
            exec = str.trim();
          }
        } else if (var.equals("threads")) { // $NON-NLS-1$
          // Staring with GDB 7.1
          // Re-use the MIThreadInfoInfo parsing
          MIValue value = result.getMIValue();
          if (value instanceof MIList) {
            threads = MIThreadInfoInfo.parseThreads(((MIList) value));
          }
        }
      }
      // In the case of -list-thread-groups --available, the pid field is not present, but the
      // pid is used as the main id.  To know we are in this case, we check that we have
      // a description, that only happens for -list-thread-groups --available
      // We must check this because with GDB 7.2, there will be no pid field as a result
      // of -list-thread-groups, if no process is actually running yet.
      if (pid.equals("") && !desc.equals("")) { // $NON-NLS-1$ //$NON-NLS-2$
        pid = id;
      }
      fGroupList[i] = new ThreadGroupInfo(id, desc, type, pid, user, cores, exec, threads);
    }
  }