Example #1
0
  /** @see pong.ApplicationState#stop() */
  @Override
  public void stop() {
    Debugger.debugWriteln("Stopping main menu.", this.getClass());

    mainFrame.dispose();
    mainFrame = null;
  }
 void destroy(VirtualMachine vm) throws Exception {
   EventRequestManager requestManager = vm.eventRequestManager();
   for (EventRequest request : handlers.keySet()) {
     requestManager.deleteEventRequest(request);
   }
   debugger.destroyHandler();
 }
Example #3
0
 @Override
 public void compile() {
   Debugger debugContext = DinaCompiler.getDebugger();
   int variablesWithValue = 0;
   int variablesAmount = getVariablesAmount();
   for (int variableIndex = 0; variableIndex < variablesAmount; variableIndex++) {
     Variable variable = getVariable(variableIndex);
     if (variable.getValue() != null) {
       if (constructor == null) {
         constructor = new Function(ParserConstants.CONSTRUCTOR);
         constructor.setStatement(new Block());
         constructor.getStatement().setFunction(constructor);
       }
       Assignment assignment = new Assignment(variable, variable.getValue());
       constructor.getStatement().insertNode(assignment, variablesWithValue);
       variablesWithValue++;
     }
   }
   if (constructor != null) {
     Output.writeSystemInformation(Constants.BEGIN_FUNCTION);
     constructor.compile();
     if (Debugger.DEVELOPMENT_MODE) {
       debugContext.putFunction("<constructor>", constructor.getAddress());
     }
     Output.writeSystemInformation(Constants.END_FUNCTION);
   }
   int functionsAmount = functions.size();
   for (int functionIndex = 0; functionIndex < functionsAmount; functionIndex++) {
     Function function = functions.getValue(functionIndex);
     Output.writeSystemInformation(Constants.BEGIN_FUNCTION);
     function.compile();
     if (Debugger.DEVELOPMENT_MODE) {
       debugContext.putFunction(
           function.getSignatureLabel() + function.getNodeType().getSignature(),
           function.getAddress());
     }
     Output.writeSystemInformation(Constants.END_FUNCTION);
   }
   if (destructor != null) {
     Output.writeSystemInformation(Constants.BEGIN_FUNCTION);
     destructor.compile();
     if (Debugger.DEVELOPMENT_MODE) {
       debugContext.putFunction("<destructor>", destructor.getAddress());
     }
     Output.writeSystemInformation(Constants.END_FUNCTION);
   }
 }
Example #4
0
  private void toggleBreakpoint() {
    try {
      int lineno = sourceTextarea.getLineOfOffset(sourceTextarea.getCaretPosition()) + 1;
      Character asmaddr = asmMap.src2bin(lineno);
      if (srcBreakpoints.contains(lineno)) {
        srcBreakpoints.remove(lineno);
        if (asmaddr != null) debugger.setBreakpoint(asmaddr, false);
      } else {
        srcBreakpoints.add(lineno);
        if (asmaddr != null) debugger.setBreakpoint(asmaddr, true);
      }

      sourceRowHeader.breakpointChanged(lineno);
    } catch (BadLocationException e1) {
      e1.printStackTrace();
    }
  }
Example #5
0
  public void onEnable() {
    String[] data = loadConfig();
    if (data[3].equals("UNSET")) {
      debugger.debug(
          "!!! THE CONFIG FILE CONTAINS UNSET VALUES - YOU MUST FIX THEM BEFORE THE PLUGIN WILL WORK !!! ");
      return;
    }
    try {
      server = new ServerSocket(Integer.parseInt(data[1]), 50, InetAddress.getByName(data[0]));
      debugger.debug("Opened server on " + data[0] + ":" + data[1] + ".");
      new ClientListener(this, Integer.parseInt(data[2]), data[3]).start();
    } catch (Exception e) {
      e.printStackTrace();
    }
    loadData();
    try {
      Metrics metrics = new Metrics(this);
      Graph graph1 = metrics.createGraph("Total queries sent");
      graph1.addPlotter(
          new Metrics.Plotter() {
            public int getValue() {
              return oq.size();
            }

            public String getColumnName() {
              return "Total queries sent";
            }
          });
      Graph graph2 = metrics.createGraph("Total servers linked");
      graph2.addPlotter(
          new Metrics.Plotter() {
            public int getValue() {
              return qc.keySet().size();
            }

            public String getColumnName() {
              return "Total servers linked";
            }
          });
      metrics.start();
      getProxy().getPluginManager().registerListener(this, new EventListener(this));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 DebuggerManager(Debugger debugger, DebugHandler dh, VirtualMachine vm) {
   this.debugger = debugger;
   for (Class<?> type = debugger.getClass(); type != Debugger.class; type = type.getSuperclass()) {
     for (java.lang.reflect.Method method : type.getDeclaredMethods()) {
       Debugger.Handler annotation = method.getAnnotation(Debugger.Handler.class);
       if (annotation != null) {
         if (method.getParameterTypes().length != 0) {
           throw new IllegalArgumentException(
               "@Debugger.Handler methods must not take any arguments.");
         }
         BreakpointHandler handler =
             new BreakpointHandler(debugger, dh.request(vm, annotation.suspend()), method);
         breakpoints.put(method.getName(), handler);
         handlers.put(handler.request, handler);
       }
     }
     debugger.initHandler(this);
   }
 }
 protected String makeConstraintName(String consName) throws SchemaException {
   boolean prev_constr = constraintList.contains(consName);
   if (prev_constr) { // need to find new name --
     Debugger.trace("Changing duplicate constraint name " + consName, Debugger.SHORT);
     int i = 1;
     while (constraintList.contains(consName + i)) i++;
     consName += i;
   }
   constraintList.add(consName);
   return consName;
 }
 public static byte[] bitmap2Bytes(Bitmap bm, CompressFormat format, int quality) {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   bm.compress(CompressFormat.PNG, 100, baos);
   byte[] bytes = baos.toByteArray();
   // Release resources
   try {
     baos.close();
   } catch (IOException e) {
     Debugger.logE(new Object[] {bm, format, quality}, null, e);
   }
   return bytes;
 }
Example #9
0
  /** @see pong.ApplicationState#init() */
  @Override
  public void init() {
    JFrame.setDefaultLookAndFeelDecorated(false);

    // Set background scene.

    backgroundScene =
        new PhysicsScene(CollidableMap.getMainMenuMap(), null, null, .0f, new RandomBallStrategy());

    // Create GUI.
    mainFrame = new PongFrame("Pong Adventures -Main menu-", backgroundScene, false, null, false);
    mainFrame.addWindowListener(this);
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setResizable(false);

    // Setting frame to center of screen.
    Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
    mainFrame.setBounds(
        center.x - Global.windowSize.width / 2,
        center.y - Global.windowSize.height / 2,
        Global.windowSize.width,
        Global.windowSize.height);

    newGameButton = new JButton("New Game");
    newGameButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    newGameButton.addActionListener(this);

    settingsButton = new JButton("Settings");
    settingsButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    settingsButton.addActionListener(this);

    exitButton = new JButton("Exit");
    exitButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    exitButton.addActionListener(this);

    Container content = mainFrame.getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

    content.add(Box.createGlue());
    content.add(Box.createGlue());
    content.add(newGameButton);
    content.add(Box.createGlue());
    content.add(settingsButton);
    content.add(Box.createGlue());
    content.add(exitButton);
    content.add(Box.createGlue());
    content.add(Box.createGlue());

    mainFrame.setVisible(true);

    Debugger.debugWriteln("Initializing main menu.", this.getClass());
  }
Example #10
0
 private void loadData() {
   try {
     File file = new File(getDataFolder(), "data.txt");
     if (file.exists()) {
       BufferedReader br = new BufferedReader(new FileReader(file));
       try {
         String l = br.readLine();
         while (l != null) {
           if (l.startsWith("oq:")) {
             oq.add(new String(l.substring(3)));
           } else if (l.startsWith("pq:")) {
             String[] parts = new String(l.substring(3)).split(spacer);
             if (pq.containsKey(parts[0])) {
               List<String> commands = pq.get(parts[0]);
               commands.add(parts[1]);
               pq.put(parts[0], commands);
             } else {
               List<String> commands = new ArrayList<String>(Arrays.asList(parts[1]));
               pq.put(parts[0], commands);
             }
           } else if (l.startsWith("qc:")) {
             String[] parts = new String(l.substring(3)).split(spacer);
             qc.put(parts[0], Integer.parseInt(parts[1]));
           }
           l = br.readLine();
         }
         debugger.debug("All data loaded.");
       } finally {
         br.close();
       }
     } else {
       debugger.debug(
           "A data file was not found. If this is your first start-up with the plugin, this is normal.");
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
 protected String convertFields(String fields, JClass currentClass)
     throws SchemaException, IOException {
   Vector tokens = Tokenizer.tokenize(fields, ",", "/");
   Debugger.trace(fields + " token-size=" + tokens.size(), Debugger.VERBOSE);
   String sOut;
   if (tokens == null || tokens.size() < 1)
     throw new SchemaException(
         "Invalid constraint specification ", currentClass.getSchemaFileName());
   else sOut = jToSql((String) tokens.elementAt(0), currentClass);
   for (int j = 1; j < tokens.size(); j++) {
     sOut += "," + jToSql((String) tokens.elementAt(j), currentClass);
   }
   return sOut;
 }
Example #12
0
 private void assemble() {
   Assembler assembler = new Assembler();
   assembler.genMap = true;
   try {
     binary = new char[] {};
     binary = assembler.assemble(sourceTextarea.getText());
     cpu.upload(binary);
     memoryModel.fireUpdate(0, binary.length);
     asmMap = assembler.asmmap;
     for (Character addr : debugger.getBreakpoints()) {
       debugger.setBreakpoint(addr, false);
     }
     for (Integer breakpoint : srcBreakpoints) {
       Character addr = asmMap.src2bin(breakpoint);
       if (addr != null) { // TODO if null, mark breakpoint somehow
         debugger.setBreakpoint(addr, true);
       }
     }
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(
         frame, "Compilation error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
     ex.printStackTrace();
   }
 }
Example #13
0
 public void run(PrintStream out, Debugger dbg) {
   CDebugger cdbg = dbg.getCDebugger();
   if (cdbg != null) {
     List l = cdbg.getLoadObjectList();
     for (Iterator itr = l.iterator(); itr.hasNext(); ) {
       LoadObject lo = (LoadObject) itr.next();
       out.print(lo.getBase() + "\t");
       out.print(lo.getSize() / 1024 + "K\t");
       out.println(lo.getName());
     }
   } else {
     if (getDebugeeType() == DEBUGEE_REMOTE) {
       out.println("remote configuration is not yet implemented");
     } else {
       out.println("not yet implemented (debugger does not support CDebugger)!");
     }
   }
 }
Example #14
0
 private void saveData() {
   try {
     OutputStream os = new FileOutputStream(new File(getDataFolder(), "data.txt"));
     PrintStream ps = new PrintStream(os);
     for (String s : oq) {
       ps.println("oq:" + s);
     }
     for (Entry<String, List<String>> e : pq.entrySet()) {
       String name = e.getKey();
       for (String command : e.getValue()) {
         ps.println("pq:" + name + spacer + command);
       }
     }
     for (Entry<String, Integer> e : qc.entrySet()) {
       ps.println("qc:" + e.getKey() + spacer + String.valueOf(e.getValue()));
     }
     ps.close();
     debugger.debug("All data saved.");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Example #15
0
 private String[] loadConfig() {
   String[] defaults =
       new String[] {"ip=localhost", "port=9190", "heartbeat=1000", "pass=UNSET", "debug=false"};
   String[] data = new String[defaults.length];
   try {
     File folder = getDataFolder();
     if (!folder.exists()) {
       folder.mkdir();
     }
     File file = new File(folder, "config.txt");
     if (!file.exists()) {
       file.createNewFile();
     }
     BufferedReader br = new BufferedReader(new FileReader(file));
     for (int i = 0; i < defaults.length; i++) {
       String l = br.readLine();
       if (l == null || l.isEmpty()) {
         data[i] = defaults[i].split("=")[1];
       } else {
         data[i] = l.split("=")[1];
         defaults[i] = l;
       }
     }
     br.close();
     file.delete();
     file.createNewFile();
     PrintStream ps = new PrintStream(new FileOutputStream(file));
     for (int i = 0; i < defaults.length; i++) {
       ps.println(defaults[i]);
     }
     ps.close();
     debugger = new Debugger(this, Boolean.valueOf(data[4]));
     debugger.debug("Configuration file loaded.");
   } catch (IOException e) {
     e.printStackTrace();
   }
   return data;
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#run()
  */
 public void run() throws IOException {
   debugger.run();
 }
Example #17
0
  public IdeMain() {
    cpu = new Dcpu();
    debugger = new Debugger();
    debugger.breakpointListener =
        new PreListener<Character>() {
          public void preExecute(Character arg) {
            breakpointHit(arg);
          }
        };
    debugger.attachTo(cpu);
    asmMap = new AsmMap();

    MonitorLEM1802 monitor = new MonitorLEM1802();
    cpu.attach(monitor);
    MonitorWindow window = new MonitorWindow(cpu, monitor, false);
    window.show();

    Sped3 sped = new Sped3();
    cpu.attach(sped);
    SpedWindow spedWindow = new SpedWindow(cpu, sped, false);
    spedWindow.show();
    spedWindow.getFrame().setSize(600, 600);

    GenericClock clock = new GenericClock(MonitorLEM1802.MANUFACTURER_ID); // Nya Elektriska
    GenericKeyboard keyboard = new GenericKeyboard(MonitorLEM1802.MANUFACTURER_ID, 16);
    cpu.attach(clock);
    cpu.attach(keyboard);
    window.addKeyListener(keyboard);

    fileChooser = new JFileChooser();
    fileChooser.setCurrentDirectory(new File("."));

    registersModel = new RegistersModel(cpu, debugger);
    registersTable.setModel(registersModel);
    memoryModel = new MemoryModel(cpu, debugger);
    memoryTable.setModel(memoryModel);

    sourceRowHeader = new SourceRowHeader(sourceTextarea, srcBreakpoints);
    sourceRowHeader.setBackground(Color.LIGHT_GRAY);
    sourceScrollPane.setRowHeaderView(sourceRowHeader);

    frame = new JFrame("JA-DCPU IDE");
    frame.setContentPane(rootPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);

    openSrcButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openSrc();
          }
        });
    asmButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            assemble();
          }
        });
    saveSrcButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveSrc();
          }
        });
    hardResetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cpu.memzero();
            memoryModel.fireUpdate(0, RAM_SIZE);
            cpu.reset();
            registersModel.fireUpdate();
          }
        });
    resetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cpu.reset();
            registersModel.fireUpdate();
          }
        });
    saveBinButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveBin();
          }
        });
    openBinButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openBin();
          }
        });
    stepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            step();
          }
        });
    breakpointButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            toggleBreakpoint();
          }
        });
    runButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            debugger.breakpointsHalt = true;
            runCpu();
          }
        });
    execButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            debugger.breakpointsHalt = false;
            runCpu();
          }
        });
    pauseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cpu.halt = true;
          }
        });
  }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#stepInto()
  */
 public void stepInto(ResponseListener listener) {
   debugger.stepInto(listener);
 }
Example #19
0
 private void step() {
   debugger.breakpointsHalt = false;
   debugger.step();
   registersModel.fireUpdate();
   memoryModel.fireUpdate(0, RAM_SIZE - 1); // TODO optimize
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#isSuspended()
  */
 public boolean isSuspended() {
   return debugger.isSuspended();
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#stepOver()
  */
 public void stepOver() throws IOException {
   debugger.stepOver();
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#getStackFrames()
  */
 public List<Location> getStackFrames() throws IOException {
   return debugger.getStackFrames();
 }
 public List<Variable> getGlobalVariables() throws IOException {
   return debugger.getGlobalVariables();
 }
 @Override
 public String evaluate(String script) throws IOException {
   return debugger.evaluate(script);
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#stop()
  */
 public void stop() throws IOException {
   debugger.stop();
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#stepInto()
  */
 public void stepInto() throws IOException {
   debugger.stepInto();
 }
Example #27
0
 private void log(String msg) {
   Debugger.dbg("TupleSpace", msg);
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#isTerminated()
  */
 public boolean isTerminated() {
   return debugger.isTerminated();
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#stop()
  */
 public void stop(ResponseListener listener) {
   debugger.stop(listener);
 }
 /* (non-Javadoc)
  * @see org.exist.debugger.DebuggingSource#stepOver()
  */
 public void stepOver(ResponseListener listener) {
   debugger.stepOver(listener);
 }