org.eclipse.cdt.debug.mi.core_7.1.1.201202111925

16:41:43.066 INFO  jd.cli.Main - Decompiling org.eclipse.cdt.debug.mi.core_7.1.1.201202111925.jar
package org.eclipse.cdt.debug.mi.core.cdi;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.cdi.model.Register;
import org.eclipse.cdt.debug.mi.core.cdi.model.RegisterDescriptor;
import org.eclipse.cdt.debug.mi.core.cdi.model.RegisterGroup;
import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
import org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIDataListChangedRegisters;
import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterNames;
import org.eclipse.cdt.debug.mi.core.command.MIVarCreate;
import org.eclipse.cdt.debug.mi.core.command.MIVarDelete;
import org.eclipse.cdt.debug.mi.core.command.MIVarUpdate;
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MIRegisterChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
import org.eclipse.cdt.debug.mi.core.output.MIDataListChangedRegistersInfo;
import org.eclipse.cdt.debug.mi.core.output.MIDataListRegisterNamesInfo;
import org.eclipse.cdt.debug.mi.core.output.MIVar;
import org.eclipse.cdt.debug.mi.core.output.MIVarChange;
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;

public class RegisterManager
  extends Manager
{
  final int MAX_ENTRIES = 150;
  Map regsMap;
  Map varsMap;
  
  class LRUMap
    extends LinkedHashMap
  {
    private static final long serialVersionUID = 1L;
    
    LRUMap()
    {
      super(0.75F, true);
    }
    
    protected boolean removeEldestEntry(Map.Entry eldest)
    {
      boolean toRemove = size() > 150;
      if (toRemove)
      {
        RegisterManager.ShadowRegister v = (RegisterManager.ShadowRegister)eldest.getValue();
        try
        {
          Target target = (Target)v.getTarget();
          removeMIVar(target.getMISession(), v.getMIVar());
        }
        catch (Exception localException) {}
        v.setMIVar(null);
      }
      return toRemove;
    }
  }
  
  class ShadowRegister
    extends Register
  {
    public ShadowRegister(Register reg, StackFrame frame, String n, MIVar v)
    {
      super((Thread)frame.getThread(), frame, n, null, 0, 0, v);
      try
      {
        fTypename = reg.getTypeName();
      }
      catch (CDIException localCDIException1) {}
      try
      {
        fType = reg.getType();
      }
      catch (CDIException localCDIException2) {}
    }
    
    public MIVar getMIVar()
      throws CDIException
    {
      if (fMIVar == null) {
        fMIVar = createMiVar((StackFrame)getStackFrame(), getName());
      }
      return fMIVar;
    }
    
    public void setMIVar(MIVar newMIVar)
    {
      fMIVar = newMIVar;
    }
  }
  
  MIVarChange[] noChanges = new MIVarChange[0];
  HashMap fTypeCache;
  
  public RegisterManager(Session session)
  {
    super(session, true);
    regsMap = new Hashtable();
    varsMap = new Hashtable();
    
    setAutoUpdate(true);
    fTypeCache = new HashMap();
  }
  
  public ICDIType getFromTypeCache(String typeName)
  {
    return (ICDIType)fTypeCache.get(typeName);
  }
  
  public void addToTypeCache(String typeName, ICDIType type)
  {
    fTypeCache.put(typeName, type);
  }
  
  synchronized List getRegistersList(Target target)
  {
    List regsList = (List)regsMap.get(target);
    if (regsList == null)
    {
      regsList = Collections.synchronizedList(new ArrayList());
      regsMap.put(target, regsList);
    }
    return regsList;
  }
  
  synchronized Map getVariableMap(Target target)
  {
    Map varMap = (Map)varsMap.get(target);
    if (varMap == null)
    {
      varMap = Collections.synchronizedMap(new LRUMap());
      varsMap.put(target, varMap);
    }
    return varMap;
  }
  
  public ICDIRegisterGroup[] getRegisterGroups(Target target)
    throws CDIException
  {
    RegisterGroup group = new RegisterGroup(target, "Main");
    return new ICDIRegisterGroup[] { group };
  }
  
  public ICDIRegisterDescriptor[] getRegisterDescriptors(RegisterGroup group)
    throws CDIException
  {
    Target target = (Target)group.getTarget();
    return getRegisterDescriptors(target);
  }
  
  public ICDIRegisterDescriptor[] getRegisterDescriptors(Target target)
    throws CDIException
  {
    MISession mi = target.getMISession();
    CommandFactory factory = mi.getCommandFactory();
    MIDataListRegisterNames registers = factory.createMIDataListRegisterNames();
    try
    {
      mi.postCommand(registers);
      MIDataListRegisterNamesInfo info = 
        registers.getMIDataListRegisterNamesInfo();
      if (info == null) {
        throw new CDIException(CdiResources.getString("cdi.Common.No_answer"));
      }
      String[] names = info.getRegisterNames();
      List regsList = new ArrayList(names.length);
      for (int i = 0; i < names.length; i++) {
        if (names[i].length() > 0) {
          regsList.add(new RegisterDescriptor(target, null, null, names[i], null, i, 0));
        }
      }
      return (ICDIRegisterDescriptor[])regsList.toArray(new ICDIRegisterDescriptor[0]);
    }
    catch (MIException e)
    {
      throw new MI2CDIException(e);
    }
  }
  
  public Register createRegister(RegisterDescriptor regDesc)
    throws CDIException
  {
    Register reg = findRegister(regDesc);
    if (reg == null) {
      try
      {
        String name = regDesc.getQualifiedName();
        Target target = (Target)regDesc.getTarget();
        MISession mi = target.getMISession();
        CommandFactory factory = mi.getCommandFactory();
        MIVarCreate var = factory.createMIVarCreate(name);
        mi.postCommand(var, -1L);
        
        reg = new Register(regDesc, var);
        List regList = getRegistersList(target);
        regList.add(reg);
      }
      catch (MIException e)
      {
        throw new MI2CDIException(e);
      }
    }
    return reg;
  }
  
  public void destroyRegister(Register reg)
  {
    Target target = (Target)reg.getTarget();
    List regList = (List)regsMap.get(target);
    if ((regList != null) && 
      (regList.remove(reg)))
    {
      MISession miSession = target.getMISession();
      try
      {
        removeMIVar(miSession, reg.getMIVar());
      }
      catch (CDIException localCDIException) {}
    }
  }
  
  void removeMIVar(MISession miSession, MIVar miVar)
    throws CDIException
  {
    CommandFactory factory = miSession.getCommandFactory();
    MIVarDelete var = factory.createMIVarDelete(miVar.getVarName());
    try
    {
      miSession.postCommand(var);
      var.getMIInfo();
    }
    catch (MIException e)
    {
      throw new MI2CDIException(e);
    }
  }
  
  public MIVar createMiVar(StackFrame frame, String regName)
    throws CDIException
  {
    Target target = (Target)frame.getTarget();
    Thread currentThread = (Thread)target.getCurrentThread();
    StackFrame currentFrame = currentThread.getCurrentStackFrame();
    synchronized (target.getLock())
    {
      try
      {
        target.setCurrentThread(frame.getThread(), false);
        ((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
        MISession mi = target.getMISession();
        CommandFactory factory = mi.getCommandFactory();
        MIVarCreate var = factory.createMIVarCreate(regName);
        mi.postCommand(var);
        MIVarCreateInfo info = var.getMIVarCreateInfo();
        if (info == null) {
          throw new CDIException(CdiResources.getString("cdi.Common.No_answer"));
        }
        MIVar localMIVar = info.getMIVar();
        
        target.setCurrentThread(currentThread, false);
        currentThread.setCurrentStackFrame(currentFrame, false);return localMIVar;
      }
      catch (MIException e)
      {
        throw new MI2CDIException(e);
      }
      finally
      {
        target.setCurrentThread(currentThread, false);
        currentThread.setCurrentStackFrame(currentFrame, false);
      }
    }
  }
  
  public MIVarChange[] updateMiVar(StackFrame frame, String varName)
    throws CDIException
  {
    Target target = (Target)frame.getTarget();
    Thread currentThread = (Thread)target.getCurrentThread();
    StackFrame currentFrame = currentThread.getCurrentStackFrame();
    synchronized (target.getLock())
    {
      try
      {
        target.setCurrentThread(frame.getThread(), false);
        ((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
        
        MISession mi = target.getMISession();
        CommandFactory factory = mi.getCommandFactory();
        MIVarUpdate var = factory.createMIVarUpdate(varName);
        mi.postCommand(var);
        MIVarUpdateInfo info = var.getMIVarUpdateInfo();
        if (info == null) {
          throw new CDIException(CdiResources.getString("cdi.Common.No_answer"));
        }
        MIVarChange[] arrayOfMIVarChange = info.getMIVarChanges();
        
        target.setCurrentThread(currentThread, false);
        currentThread.setCurrentStackFrame(currentFrame, false);return arrayOfMIVarChange;
      }
      catch (MIException e)
      {
        throw new MI2CDIException(e);
      }
      finally
      {
        target.setCurrentThread(currentThread, false);
        currentThread.setCurrentStackFrame(currentFrame, false);
      }
    }
  }
  
  public Variable createShadowRegister(Register register, StackFrame frame, String regName)
    throws CDIException
  {
    Target target = (Target)frame.getTarget();
    Map varMap = getVariableMap(target);
    ShadowRegister variable = null;
    if (varMap.containsKey(regName))
    {
      variable = (ShadowRegister)varMap.get(regName);
      updateMiVar(frame, variable.getMIVar().getVarName());
    }
    else
    {
      MIVar miVar = createMiVar(frame, regName);
      variable = new ShadowRegister(register, frame, regName, miVar);
      
      varMap.put(regName, variable);
    }
    return variable;
  }
  
  public Register getRegister(MISession miSession, String varName)
  {
    Target target = ((Session)getSession()).getTarget(miSession);
    Register[] regs = getRegisters(target);
    for (int i = 0; i < regs.length;) {
      try
      {
        if (regs[i].getMIVar().getVarName().equals(varName)) {
          return regs[i];
        }
        try
        {
          Register r = (Register)regs[i].getChild(varName);
          if (r != null) {
            return r;
          }
        }
        catch (ClassCastException localClassCastException) {}
        i++;
      }
      catch (CDIException localCDIException) {}
    }
    return null;
  }
  
  public Register getRegister(MISession miSession, int regno)
  {
    Target target = ((Session)getSession()).getTarget(miSession);
    return getRegister(target, regno);
  }
  
  public Register getRegister(Target target, int regno)
  {
    Register[] regs = getRegisters(target);
    for (int i = 0; i < regs.length; i++) {
      if (regs[i].getPosition() == regno) {
        return regs[i];
      }
    }
    return null;
  }
  
  public void update(Target target)
    throws CDIException
  {
    MISession mi = target.getMISession();
    CommandFactory factory = mi.getCommandFactory();
    MIDataListChangedRegisters changed = factory.createMIDataListChangedRegisters();
    try
    {
      mi.postCommand(changed);
      MIDataListChangedRegistersInfo info = 
        changed.getMIDataListChangedRegistersInfo();
      if (info == null) {
        throw new CDIException(CdiResources.getString("cdi.Common.No_answer"));
      }
      int[] regnos = info.getRegisterNumbers();
      List eventList = new ArrayList(regnos.length);
      for (int i = 0; i < regnos.length; i++)
      {
        Register reg = getRegister(target, regnos[i]);
        if (reg != null)
        {
          String varName = reg.getMIVar().getVarName();
          MIVarChange[] changes = noChanges;
          MIVarUpdate update = factory.createMIVarUpdate(varName);
          try
          {
            mi.postCommand(update);
            MIVarUpdateInfo updateInfo = update.getMIVarUpdateInfo();
            if (updateInfo == null) {
              throw new CDIException(CdiResources.getString("cdi.Common.No_answer"));
            }
            changes = updateInfo.getMIVarChanges();
          }
          catch (MIException localMIException1) {}
          if (changes.length != 0) {
            for (int j = 0; j < changes.length; j++)
            {
              String n = changes[j].getVarName();
              if (changes[j].isInScope()) {
                eventList.add(new MIVarChangedEvent(mi, n));
              }
            }
          } else {
            eventList.add(new MIRegisterChangedEvent(mi, update.getToken(), reg.getName(), regnos[i]));
          }
        }
      }
      MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
      mi.fireEvents(events);
    }
    catch (MIException e)
    {
      if (!target.isTerminated()) {
        throw new MI2CDIException(e);
      }
    }
  }
  
  private Register[] getRegisters(Target target)
  {
    List regsList = (List)regsMap.get(target);
    if (regsList != null) {
      return (Register[])regsList.toArray(new Register[regsList.size()]);
    }
    return new Register[0];
  }
  
  private Register findRegister(RegisterDescriptor rd)
    throws CDIException
  {
    Target target = (Target)rd.getTarget();
    String name = rd.getName();
    String fullName = rd.getFullName();
    int position = rd.getPosition();
    Register[] regs = getRegisters(target);
    for (int i = 0; i < regs.length; i++) {
      if ((regs[i].getName().equals(name)) && 
        (regs[i].getFullName().equals(fullName)) && 
        (regs[i].getCastingArrayStart() == rd.getCastingArrayStart()) && 
        (regs[i].getCastingArrayEnd() == rd.getCastingArrayEnd()) && 
        (VariableDescriptor.equalsCasting(regs[i], rd))) {
        if (regs[i].getPosition() == position) {
          return regs[i];
        }
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.debug.mi.core.cdi.RegisterManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.debug.mi.core.cdi;

import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.mi.core.MIException;

public class MI2CDIException
  extends CDIException
{
  private static final long serialVersionUID = 1L;
  
  public MI2CDIException(MIException e)
  {
    super(e.getMessage(), e.getLogMessage());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.debug.mi.core.cdi;

import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;

public class SessionObject
  implements ICDISessionObject
{
  private Session fSession;
  
  public SessionObject(Session session)
  {
    fSession = session;
  }
  
  public ICDISession getSession()
  {
    return fSession;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.debug.mi.core.cdi.SessionObject
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.debug.mi.core.cdi;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.cdi.model.Expression;
import org.eclipse.cdt.debug.mi.core.cdi.model.LocalVariable;
import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIVarCreate;
import org.eclipse.cdt.debug.mi.core.command.MIVarDelete;
import org.eclipse.cdt.debug.mi.core.command.MIVarUpdate;
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIVarDeletedEvent;
import org.eclipse.cdt.debug.mi.core.output.MIVar;
import org.eclipse.cdt.debug.mi.core.output.MIVarChange;
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;

public class ExpressionManager
  extends Manager
{
  static final ICDIExpression[] EMPTY_EXPRESSIONS = new ICDIExpression[0];
  Map expMap;
  Map varMap;
  MIVarChange[] noChanges = new MIVarChange[0];
  
  public ExpressionManager(Session session)
  {
    super(session, true);
    expMap = new Hashtable();
    varMap = new Hashtable();
  }
  
  synchronized List getExpressionList(Target target)
  {
    List expList = (List)expMap.get(target);
    if (expList == null)
    {
      expList = Collections.synchronizedList(new ArrayList());
      expMap.put(target, expList);
    }
    return expList;
  }
  
  synchronized List getVariableList(Target target)
  {
    List varList = (List)varMap.get(target);
    if (varList == null)
    {
      varList = Collections.synchronizedList(new ArrayList());
      varMap.put(target, varList);
    }
    return varList;
  }
  
  public ICDIExpression createExpression(Target target, String name)
    throws CDIException
  {
    Expression expression = new Expression(target, name);
    List exprList = getExpressionList(target);
    exprList.add(expression);
    return expression;
  }
  
  public ICDIExpression[] getExpressions(Target target)
    throws CDIException
  {
    List expList = (List)expMap.get(target);
    if (expList != null) {
      return (ICDIExpression[])expList.toArray(EMPTY_EXPRESSIONS);
    }
    return EMPTY_EXPRESSIONS;
  }
  
  public void destroyExpressions(Target target, ICDIExpression[] expressions)
    throws CDIException
  {
    List expList = getExpressionList(target);
    for (int i = 0; i < expressions.length; i++) {
      expList.remove(expressions[i]);
    }
  }
  
  public void destroyAllExpressions(Target target)
    throws CDIException
  {
    ICDIExpression[] expressions = getExpressions(target);
    destroyExpressions(target, expressions);
  }
  
  public void update(Target target)
    throws CDIException
  {
    List eventList = new ArrayList();
    MISession mi = target.getMISession();
    CommandFactory factory = mi.getCommandFactory();
    List varList = getVariableList(target);
    Variable[] variables = (Variable[])varList.toArray(new Variable[varList.size()]);
    for (int i = 0; i < variables.length; i++)
    {
      Variable variable = variables[i];
      String varName = variable.getMIVar().getVarName();
      MIVarChange[] changes = noChanges;
      MIVarUpdate update = factory.createMIVarUpdate(varName);
      MIVarUpdateInfo info = null;
      try
      {
        mi.postCommand(update);
      }
      catch (MIException e)
      {
        throw new MI2CDIException(e);
      }
      boolean timedout = false;
      try
      {
        info = update.getMIVarUpdateInfo();
        if (info == null)
        {
          timedout = true;
          throw new CDIException(CdiResources.getString("cdi.Common.No_answer"));
        }
        changes = info.getMIVarChanges();
      }
      catch (MIException e)
      {
        if (timedout) {
          throw new MI2CDIException(e);
        }
        eventList.add(new MIVarDeletedEvent(mi, varName));
      }
      for (int j = 0; j < changes.length; j++)
      {
        String n = changes[j].getVarName();
        if (changes[j].isInScope())
        {
          eventList.add(new MIVarChangedEvent(mi, n));
        }
        else
        {
          deleteVariable(variable);
          eventList.add(new MIVarDeletedEvent(mi, n));
        }
      }
    }
    MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
    mi.fireEvents(events);
  }
  
  public Variable getVariable(MISession miSession, String varName)
  {
    Session session = (Session)getSession();
    Target target = session.getTarget(miSession);
    List varList = getVariableList(target);
    Variable[] vars = (Variable[])varList.toArray(new Variable[0]);
    for (int i = 0; i < vars.length; i++) {
      try
      {
        if (vars[i].getMIVar().getVarName().equals(varName)) {
          return vars[i];
        }
        Variable v = vars[i].getChild(varName);
        if (v != null) {
          return v;
        }
      }
      catch (CDIException localCDIException) {}
    }
    return null;
  }
  
  public Variable createVariable(StackFrame frame, String code)
    throws CDIException
  {
    Target target = (Target)frame.getTarget();
    Thread currentThread = (Thread)target.getCurrentThread();
    StackFrame currentFrame = currentThread.getCurrentStackFrame();
    synchronized (target.getLock())
    {
      try
      {
        target.setCurrentThread(frame.getThread(), false);
        ((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
        MISession mi = target.getMISession();
        CommandFactory factory = mi.getCommandFactory();
        MIVarCreate var = factory.createMIVarCreate(code);
        mi.postCommand(var);
        MIVarCreateInfo info = var.getMIVarCreateInfo();
        if (info == null) {
          throw new CDIException(CdiResources.getString("cdi.Common.No_answer"));
        }
        Variable variable = new LocalVariable(target, null, frame, code, null, 0, 0, info.getMIVar());
        List varList = getVariableList(target);
        varList.add(variable);
        Variable localVariable1 = variable;
        
        target.setCurrentThread(currentThread, false);
        currentThread.setCurrentStackFrame(currentFrame, false);return localVariable1;
      }
      catch (MIException e)
      {
        throw new MI2CDIException(e);
      }
      finally
      {
        target.setCurrentThread(currentThread, false);
        currentThread.setCurrentStackFrame(currentFrame, false);
      }
    }
  }
  
  public Variable removeVariableFromList(MISession miSession, String varName)
  {
    Variable var = getVariable(miSession, varName);
    if (var != null)
    {
      Target target = ((Session)getSession()).getTarget(miSession);
      List varList = getVariableList(target);
      varList.remove(var);
      return var;
    }
    return null;
  }
  
  public void deleteAllVariables(Target target)
    throws CDIException
  {
    List varList = getVariableList(target);
    Variable[] variables = (Variable[])varList.toArray(new Variable[varList.size()]);
    for (int i = 0; i < variables.length; i++) {
      deleteVariable(variables[i]);
    }
  }
  
  public void deleteVariable(Variable variable)
    throws CDIException
  {
    Target target = (Target)variable.getTarget();
    MISession miSession = target.getMISession();
    MIVar miVar = variable.getMIVar();
    
    CommandFactory factory = miSession.getCommandFactory();
    MIVarDelete var = factory.createMIVarDelete(miVar.getVarName());
    try
    {
      miSession.postCommand(var);
      var.getMIInfo();
    }
    catch (MIException localMIException) {}
    List varList = getVariableList(target);
    varList.remove(variable);
    
    ICDIVariable[] children = children;
    if (children != null) {
      for (int i = 0; i < children.length; i++) {
        if ((children[0] instanceof Variable))
        {
          Variable child = (Variable)children[i];
          MIVarDeletedEvent event = new MIVarDeletedEvent(miSession, child.getMIVar().getVarName());
          miSession.fireEvent(event);
        }
      }
    }
    miSession.fireEvent(new MIVarDeletedEvent(miSession, variable.getMIVar().getVarName()));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.debug.mi.core.cdi.ExpressionManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.debug.mi.core.cdi;

import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.cdi.model.ICDITargetConfiguration;
import org.eclipse.cdt.debug.mi.core.IMIConstants;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.MIPlugin;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.model.EventBreakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.model.LocationBreakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.model.SharedLibrary;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.cdi.model.Watchpoint;
import org.eclipse.cdt.debug.mi.core.command.CLISharedLibrary;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetAutoSolib;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetStopOnSolibEvents;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShow;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MISharedLibChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MISharedLibCreatedEvent;
import org.eclipse.cdt.debug.mi.core.event.MISharedLibUnloadedEvent;
import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowInfo;
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowSolibSearchPathInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIShared;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;

public class SharedLibraryManager
  extends Manager
{
  ICDISharedLibrary[] EMPTY_SHAREDLIB = new ICDISharedLibrary[0];
  Map sharedMap;
  Set autoLoadSet;
  boolean isDeferred = true;
  
  public SharedLibraryManager(Session session)
  {
    super(session, true);
    sharedMap = new Hashtable();
    autoLoadSet = new HashSet();
    setAutoUpdate(MIPlugin.getDefault().getPluginPreferences().getBoolean(IMIConstants.PREF_SHARED_LIBRARIES_AUTO_REFRESH));
  }
  
  synchronized List getSharedList(Target target)
  {
    List sharedList = (List)sharedMap.get(target);
    if (sharedList == null)
    {
      sharedList = Collections.synchronizedList(new ArrayList());
      sharedMap.put(target, sharedList);
    }
    return sharedList;
  }
  
  /* Error */
  MIShared[] getMIShareds(MISession miSession)
    throws CDIException
  {
    // Byte code:
    //   0: iconst_0
    //   1: anewarray 273	org/eclipse/cdt/debug/mi/core/output/MIShared
    //   4: astore_2
    //   5: aload_1
    //   6: invokevirtual 496	org/eclipse/cdt/debug/mi/core/MISession:getCommandFactory	()Lorg/eclipse/cdt/debug/mi/core/command/CommandFactory;
    //   9: astore_3
    //   10: aload_3
    //   11: invokevirtual 541	org/eclipse/cdt/debug/mi/core/command/CommandFactory:createMIInfoSharedLibrary	()Lorg/eclipse/cdt/debug/mi/core/command/MIInfoSharedLibrary;
    //   14: astore 4
    //   16: aload 4
    //   18: ifnull +67 -> 85
    //   21: aload_1
    //   22: invokevirtual 494	org/eclipse/cdt/debug/mi/core/MISession:getRxThread	()Lorg/eclipse/cdt/debug/mi/core/RxThread;
    //   25: astore 5
    //   27: aload 5
    //   29: iconst_0
    //   30: invokevirtual 498	org/eclipse/cdt/debug/mi/core/RxThread:setEnableConsole	(Z)V
    //   33: aload_1
    //   34: aload 4
    //   36: invokevirtual 495	org/eclipse/cdt/debug/mi/core/MISession:postCommand	(Lorg/eclipse/cdt/debug/mi/core/command/Command;)V
    //   39: aload 4
    //   41: invokevirtual 550	org/eclipse/cdt/debug/mi/core/command/MIInfoSharedLibrary:getMIInfoSharedLibraryInfo	()Lorg/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo;
    //   44: astore 6
    //   46: aload 6
    //   48: ifnonnull +16 -> 64
    //   51: new 232	org/eclipse/cdt/debug/core/cdi/CDIException
    //   54: dup
    //   55: ldc 1
    //   57: invokestatic 506	org/eclipse/cdt/debug/mi/core/cdi/CdiResources:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   60: invokespecial 490	org/eclipse/cdt/debug/core/cdi/CDIException:<init>	(Ljava/lang/String;)V
    //   63: athrow
    //   64: aload 6
    //   66: invokevirtual 559	org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo:getMIShared	()[Lorg/eclipse/cdt/debug/mi/core/output/MIShared;
    //   69: astore_2
    //   70: goto +114 -> 184
    //   73: astore 5
    //   75: new 244	org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException
    //   78: dup
    //   79: aload 5
    //   81: invokespecial 507	org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException:<init>	(Lorg/eclipse/cdt/debug/mi/core/MIException;)V
    //   84: athrow
    //   85: aload_3
    //   86: invokevirtual 536	org/eclipse/cdt/debug/mi/core/command/CommandFactory:createCLIInfoSharedLibrary	()Lorg/eclipse/cdt/debug/mi/core/command/CLIInfoSharedLibrary;
    //   89: astore 5
    //   91: aload_1
    //   92: invokevirtual 494	org/eclipse/cdt/debug/mi/core/MISession:getRxThread	()Lorg/eclipse/cdt/debug/mi/core/RxThread;
    //   95: astore 6
    //   97: aload 6
    //   99: iconst_0
    //   100: invokevirtual 498	org/eclipse/cdt/debug/mi/core/RxThread:setEnableConsole	(Z)V
    //   103: aload_1
    //   104: aload 5
    //   106: invokevirtual 495	org/eclipse/cdt/debug/mi/core/MISession:postCommand	(Lorg/eclipse/cdt/debug/mi/core/command/Command;)V
    //   109: aload 5
    //   111: invokevirtual 534	org/eclipse/cdt/debug/mi/core/command/CLIInfoSharedLibrary:getMIInfoSharedLibraryInfo	()Lorg/eclipse/cdt/debug/mi/core/output/CLIInfoSharedLibraryInfo;
    //   114: astore 7
    //   116: aload 7
    //   118: ifnonnull +16 -> 134
    //   121: new 232	org/eclipse/cdt/debug/core/cdi/CDIException
    //   124: dup
    //   125: ldc 1
    //   127: invokestatic 506	org/eclipse/cdt/debug/mi/core/cdi/CdiResources:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   130: invokespecial 490	org/eclipse/cdt/debug/core/cdi/CDIException:<init>	(Ljava/lang/String;)V
    //   133: athrow
    //   134: aload 7
    //   136: invokevirtual 555	org/eclipse/cdt/debug/mi/core/output/CLIInfoSharedLibraryInfo:getMIShared	()[Lorg/eclipse/cdt/debug/mi/core/output/MIShared;
    //   139: astore_2
    //   140: goto +32 -> 172
    //   143: astore 6
    //   145: new 244	org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException
    //   148: dup
    //   149: aload 6
    //   151: invokespecial 507	org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException:<init>	(Lorg/eclipse/cdt/debug/mi/core/MIException;)V
    //   154: athrow
    //   155: astore 8
    //   157: aload_1
    //   158: invokevirtual 494	org/eclipse/cdt/debug/mi/core/MISession:getRxThread	()Lorg/eclipse/cdt/debug/mi/core/RxThread;
    //   161: astore 9
    //   163: aload 9
    //   165: iconst_1
    //   166: invokevirtual 498	org/eclipse/cdt/debug/mi/core/RxThread:setEnableConsole	(Z)V
    //   169: aload 8
    //   171: athrow
    //   172: aload_1
    //   173: invokevirtual 494	org/eclipse/cdt/debug/mi/core/MISession:getRxThread	()Lorg/eclipse/cdt/debug/mi/core/RxThread;
    //   176: astore 9
    //   178: aload 9
    //   180: iconst_1
    //   181: invokevirtual 498	org/eclipse/cdt/debug/mi/core/RxThread:setEnableConsole	(Z)V
    //   184: aload_2
    //   185: areturn
    // Line number table:
    //   Java source line #90	-> byte code offset #0
    //   Java source line #91	-> byte code offset #5
    //   Java source line #92	-> byte code offset #10
    //   Java source line #94	-> byte code offset #16
    //   Java source line #97	-> byte code offset #21
    //   Java source line #98	-> byte code offset #27
    //   Java source line #99	-> byte code offset #33
    //   Java source line #100	-> byte code offset #39
    //   Java source line #101	-> byte code offset #46
    //   Java source line #102	-> byte code offset #51
    //   Java source line #104	-> byte code offset #64
    //   Java source line #105	-> byte code offset #73
    //   Java source line #106	-> byte code offset #75
    //   Java source line #112	-> byte code offset #85
    //   Java source line #114	-> byte code offset #91
    //   Java source line #115	-> byte code offset #97
    //   Java source line #116	-> byte code offset #103
    //   Java source line #117	-> byte code offset #109
    //   Java source line #118	-> byte code offset #116
    //   Java source line #119	-> byte code offset #121
    //   Java source line #121	-> byte code offset #134
    //   Java source line #122	-> byte code offset #143
    //   Java source line #123	-> byte code offset #145
    //   Java source line #124	-> byte code offset #155
    //   Java source line #125	-> byte code offset #157
    //   Java source line #126	-> byte code offset #163
    //   Java source line #127	-> byte code offset #169
    //   Java source line #125	-> byte code offset #172
    //   Java source line #126	-> byte code offset #178
    //   Java source line #130	-> byte code offset #184
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	186	0	this	SharedLibraryManager
    //   0	186	1	miSession	MISession
    //   4	181	2	miLibs	MIShared[]
    //   9	77	3	factory	CommandFactory
    //   14	26	4	infoSharedMI	org.eclipse.cdt.debug.mi.core.command.MIInfoSharedLibrary
    //   25	3	5	rxThread	org.eclipse.cdt.debug.mi.core.RxThread
    //   73	7	5	e	MIException
    //   89	21	5	infoShared	org.eclipse.cdt.debug.mi.core.command.CLIInfoSharedLibrary
    //   44	21	6	info	org.eclipse.cdt.debug.mi.core.output.MIInfoSharedLibraryInfo
    //   95	3	6	rxThread	org.eclipse.cdt.debug.mi.core.RxThread
    //   143	7	6	e	MIException
    //   114	21	7	info	org.eclipse.cdt.debug.mi.core.output.CLIInfoSharedLibraryInfo
    //   155	15	8	localObject	Object
    //   161	3	9	rxThread	org.eclipse.cdt.debug.mi.core.RxThread
    //   176	3	9	rxThread	org.eclipse.cdt.debug.mi.core.RxThread
    // Exception table:
    //   from	to	target	type
    //   21	70	73	org/eclipse/cdt/debug/mi/core/MIException
    //   91	140	143	org/eclipse/cdt/debug/mi/core/MIException
    //   91	155	155	finally
  }
  
  public void update(Target target)
    throws CDIException
  {
    MISession miSession = target.getMISession();
    Session session = (Session)target.getSession();
    List eventList = updateState(target);
    if (eventList.size() > 0)
    {
      BreakpointManager bpMgr = session.getBreakpointManager();
      ICDIBreakpoint[] bpoints = (ICDIBreakpoint[])null;
      try
      {
        bpoints = bpMgr.getDeferredBreakpoints(target);
      }
      catch (CDIException localCDIException1)
      {
        bpoints = new ICDIBreakpoint[0];
      }
      for (int i = 0; i < bpoints.length; i++) {
        if ((bpoints[i] instanceof Breakpoint))
        {
          Breakpoint bkpt = (Breakpoint)bpoints[i];
          try
          {
            boolean enable = bkpt.isEnabled();
            if ((bkpt instanceof LocationBreakpoint)) {
              bpMgr.setLocationBreakpoint((LocationBreakpoint)bkpt);
            } else if ((bkpt instanceof Watchpoint)) {
              bpMgr.setWatchpoint((Watchpoint)bkpt);
            } else if ((bkpt instanceof EventBreakpoint)) {
              bpMgr.setEventBreakpoint((EventBreakpoint)bkpt);
            } else {
              throw new CDIException();
            }
            bpMgr.deleteFromDeferredList(bkpt);
            bpMgr.addToBreakpointList(bkpt);
            if (!enable) {
              bpMgr.disableBreakpoint(bkpt);
            }
            MIBreakpoint[] miBreakpoints = bkpt.getMIBreakpoints();
            if ((miBreakpoints != null) && (miBreakpoints.length > 0)) {
              eventList.add(new MIBreakpointCreatedEvent(miSession, miBreakpoints[0].getNumber()));
            }
          }
          catch (CDIException localCDIException2) {}
        }
      }
    }
    MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
    miSession.fireEvents(events);
  }
  
  private List updateState(Target target)
    throws CDIException
  {
    MISession miSession = target.getMISession();
    ICDITargetConfiguration conf = target.getConfiguration();
    if (!conf.supportsSharedLibrary()) {
      return Collections.EMPTY_LIST;
    }
    MIShared[] miLibs = getMIShareds(miSession);
    ArrayList newLibList = new ArrayList();
    ArrayList eventList = new ArrayList(miLibs.length);
    for (int i = 0; i < miLibs.length; i++)
    {
      SharedLibrary sharedlib = getSharedLibrary(target, miLibs[i].getName());
      if (sharedlib != null)
      {
        if (hasSharedLibChanged(sharedlib, miLibs[i]))
        {
          sharedlib.setMIShared(miLibs[i]);
          eventList.add(new MISharedLibChangedEvent(miSession, miLibs[i].getName()));
        }
      }
      else
      {
        List sharedList = getSharedList(target);
        SharedLibrary lib = new SharedLibrary(target, miLibs[i]);
        sharedList.add(lib);
        newLibList.add(lib);
        eventList.add(new MISharedLibCreatedEvent(miSession, miLibs[i].getName()));
      }
    }
    List sharedList = (List)sharedMap.get(target);
    if (sharedList != null)
    {
      SharedLibrary[] oldlibs = (SharedLibrary[])sharedList.toArray(new SharedLibrary[sharedList.size()]);
      for (int i = 0; i < oldlibs.length; i++)
      {
        boolean found = false;
        for (int j = 0; j < miLibs.length; j++) {
          if (miLibs[j].getName().equals(oldlibs[i].getFileName()))
          {
            found = true;
            break;
          }
        }
        if (!found) {
          eventList.add(new MISharedLibUnloadedEvent(miSession, oldlibs[i].getFileName()));
        }
      }
    }
    eventList.addAll(autoLoadSymbols(target, (SharedLibrary[])newLibList.toArray(new SharedLibrary[newLibList.size()])));
    return eventList;
  }
  
  public boolean hasSharedLibChanged(SharedLibrary lib, MIShared miLib)
  {
    return (!miLib.getName().equals(lib.getFileName())) || (!MIFormat.getBigInteger(miLib.getFrom()).equals(lib.getStartAddress())) || (!MIFormat.getBigInteger(miLib.getTo()).equals(lib.getEndAddress())) || (miLib.isRead() != lib.areSymbolsLoaded());
  }
  
  public void deleteSharedLibrary(MISession miSession, SharedLibrary lib)
  {
    Target target = ((Session)getSession()).getTarget(miSession);
    List sharedList = (List)sharedMap.get(target);
    if (sharedList != null) {
      sharedList.remove(lib);
    }
  }
  
  public SharedLibrary getSharedLibrary(MISession miSession, String name)
  {
    Ta
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd