private void doEdit() { MemState s = factory.getState(instance, circState); if (s == null) return; HexFrame frame = factory.getHexFrame(proj, instance, circState); frame.setVisible(true); frame.toFront(); }
public static void getServerMemoryInfo(Sigar sigar, ServerStatus status) { try { Mem mem = sigar.getMem(); status.setTotalMem(mem.getTotal() / (1024 * 1024)); status.setUsedMem(mem.getUsed() / (1024 * 1024)); status.setFreeMem(mem.getFree() / (1024 * 1024)); // 交换区 Swap swap = sigar.getSwap(); status.setTotalSwap(swap.getTotal() / (1024 * 1024)); status.setUsedSwap(swap.getUsed() / (1024 * 1024)); status.setFreeSwap(swap.getFree() / (1024 * 1024)); } catch (Exception e) { } }
@Override public void readFrom(StreamInput in) throws IOException { pid = in.readLong(); version = in.readString(); vmName = in.readString(); vmVersion = in.readString(); vmVendor = in.readString(); startTime = in.readLong(); inputArguments = new String[in.readInt()]; for (int i = 0; i < inputArguments.length; i++) { inputArguments[i] = in.readString(); } bootClassPath = in.readString(); classPath = in.readString(); systemProperties = new HashMap<>(); int size = in.readInt(); for (int i = 0; i < size; i++) { systemProperties.put(in.readString(), in.readString()); } mem = new Mem(); mem.readFrom(in); gcCollectors = in.readStringArray(); memoryPools = in.readStringArray(); useCompressedOops = in.readString(); }
private void doLoad() { JFileChooser chooser = proj.createChooser(); File oldSelected = factory.getCurrentImage(instance); if (oldSelected != null) chooser.setSelectedFile(oldSelected); chooser.setDialogTitle(_("ramLoadDialogTitle")); int choice = chooser.showOpenDialog(frame); if (choice == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); try { factory.loadImage(circState.getInstanceState(instance), f); } catch (IOException e) { JOptionPane.showMessageDialog(frame, e.getMessage(), _("ramLoadErrorTitle"), JOptionPane.ERROR_MESSAGE); } } }
/** * Assembly a reply from a decomp rule and the input. If the reassembly rule is goto, return null * and give the gotoKey to use. Otherwise return the response. */ String assemble(Decomp d, String reply[], Key gotoKey) { String lines[] = new String[3]; d.stepRule(); String rule = d.nextRule(); if (EString.match(rule, "goto *", lines)) { // goto rule -- set gotoKey and return false. gotoKey.copy(keys.getKey(lines[0])); if (gotoKey.key() != null) return null; System.out.println("Goto rule did not match key: " + lines[0]); return null; } String work = ""; while (EString.match(rule, "* (#)*", lines)) { // reassembly rule with number substitution rule = lines[2]; // there might be more int n = 0; try { n = Integer.parseInt(lines[1]) - 1; } catch (NumberFormatException e) { System.out.println("Number is wrong in reassembly rule " + lines[1]); } if (n < 0 || n >= reply.length) { System.out.println("Substitution number is bad " + lines[1]); return null; } reply[n] = post.translate(reply[n]); work += lines[0] + " " + reply[n]; } work += rule; if (d.mem()) { mem.save(work); return null; } return work; }
/** Process a line of input. */ public String processInput(String s) { String reply; // Do some input transformations first. s = EString.translate(s, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"); s = EString.translate(s, "@#$%^&*()_-+=~`{[}]|:;<>\\\"", " "); s = EString.translate(s, ",?!", "..."); // Compress out multiple speace. s = EString.compress(s); String lines[] = new String[2]; // Break apart sentences, and do each separately. while (EString.match(s, "*.*", lines)) { reply = sentence(lines[0]); if (reply != null) return reply; s = EString.trim(lines[1]); } if (s.length() != 0) { reply = sentence(s); if (reply != null) return reply; } // Nothing matched, so try memory. String m = mem.get(); if (m != null) return m; // No memory, reply with xnone. Key key = keys.getKey("xnone"); if (key != null) { Key dummy = null; reply = decompose(key, s, dummy); if (reply != null) return reply; } // No xnone, just say anything. return "I am at a loss for words."; }
@Override protected void configureNewInstance(Instance instance) { super.configureNewInstance(instance); MemContents contents = getMemContents(instance); MemListener listener = new MemListener(instance); memListeners.put(instance, listener); contents.addHexModelListener(listener); }
private void doSave() { MemState s = factory.getState(instance, circState); JFileChooser chooser = proj.createChooser(); File oldSelected = factory.getCurrentImage(instance); if (oldSelected != null) chooser.setSelectedFile(oldSelected); chooser.setDialogTitle(_("ramSaveDialogTitle")); int choice = chooser.showSaveDialog(frame); if (choice == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); try { HexFile.save(f, s.getContents()); factory.setCurrentImage(instance, f); } catch (IOException e) { JOptionPane.showMessageDialog(frame, e.getMessage(), _("ramSaveErrorTitle"), JOptionPane.ERROR_MESSAGE); } } }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeVLong(timestamp); cpu.writeTo(out); mem.writeTo(out); swap.writeTo(out); if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) { out.writeOptionalWriteable(cgroup); } }
private void doClear() { MemState s = factory.getState(instance, circState); boolean isAllZero = s.getContents().isClear(); if (isAllZero) return; int choice = JOptionPane.showConfirmDialog(frame, _("ramConfirmClearMsg"), _("ramConfirmClearTitle"), JOptionPane.YES_NO_OPTION); if (choice == JOptionPane.YES_OPTION) { s.getContents().clear(); } }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.OS); builder.field(Fields.TIMESTAMP, getTimestamp()); cpu.toXContent(builder, params); mem.toXContent(builder, params); swap.toXContent(builder, params); if (cgroup != null) { cgroup.toXContent(builder, params); } builder.endObject(); return builder; }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeLong(pid); out.writeString(version); out.writeString(vmName); out.writeString(vmVersion); out.writeString(vmVendor); out.writeLong(startTime); out.writeInt(inputArguments.length); for (String inputArgument : inputArguments) { out.writeString(inputArgument); } out.writeString(bootClassPath); out.writeString(classPath); out.writeInt(systemProperties.size()); for (Map.Entry<String, String> entry : systemProperties.entrySet()) { out.writeString(entry.getKey()); out.writeString(entry.getValue()); } mem.writeTo(out); out.writeStringArray(gcCollectors); out.writeStringArray(memoryPools); out.writeString(useCompressedOops); }