📄 debuggerlistener.java
字号:
break; } break; case REFERENCE_TYPE_CMDSET: switch(p.cmd) { case SIGNATURE_CMD: cid = in.readInt(); Log.LOGN(3, "Signature cmd: class id = " + Integer.toHexString(cid)); try { if ((cf = (ClassFile)ClassManager.classMap.get(new Integer(cid))) == null) { throw new Exception("Couldn't get ClassFile object for signature cmd"); } ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); if (cid == ONLY_THREADGROUP_ID) { ps.writeString("Lvm_threadgroup;"); } else { ps.writeString(cf.getClassSignature()); } ps.send(); handled = true; break; } catch (Exception e) { System.out.println("Signature cmd: exception " + e); ps = new PacketStream(this, in.id, Packet.Reply, INVALID_OBJECT); ps.send(); handled = true; } break; case CLASSLOADER_CMD: in.readInt(); // ignore the reference ID ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeInt(0); // the null classloader object ps.send(); handled = true; break; case MODIFIERS_CMD: cid = in.readInt(); try { if ((cf = (ClassFile)ClassManager.classMap.get(new Integer(cid))) == null) { throw new Exception("Couldn't get ClassFile object for Modifiers cmd"); } ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeInt(cf.getRawAccessFlags()); ps.send(); handled = true; break; } catch (Exception e) { System.out.println("Modifiers cmd: exception " + e); ps = new PacketStream(this, in.id, Packet.Reply, INVALID_OBJECT); ps.send(); handled = true; } break; case FIELDS_CMD: cid = in.readInt(); Log.LOGN(3, "field command: cid = " + Integer.toHexString(cid)); if ((cf = (ClassFile)ClassManager.classMap. get(new Integer(cid))) == null) { Log.LOGN(3, "field_cmd: cf == null"); ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeInt(0); ps.send(); handled = true; break; } ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); if (processFields(cf, ps, in.id)) { ps.send(); } handled = true; break; case METHODS_CMD: cid = in.readInt(); Log.LOGN(3, "methods command: cid = " + Integer.toHexString(cid)); if ((cf = (ClassFile)ClassManager.classMap. get(new Integer(cid))) == null || cf.getJDWPTypeTag() == TYPE_TAG_ARRAY) { Log.LOGN(3, "methods_cmd: cf == null or cf == arrayclass"); ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeInt(0); ps.send(); handled = true; break; } Log.LOGN(3, "methods for " + cf.getClassFileName()); try { MethodInfo mi; int index = method_index_base; List miList = cf.getAllMethodInfo(); Iterator iter = miList.iterator(); ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); Log.LOGN(5, "Methods: " + miList.size() + " methods"); ps.writeInt(miList.size()); while (iter.hasNext()) { mi = (MethodInfo)iter.next(); if (mi == null) { throw new Exception("methodinfo null"); } Log.LOGN(5, "Method: id = " + Integer.toHexString(index)); ps.writeInt(index++); Log.LOGN(5, "Method: name = " + mi.getName()); ps.writeString(mi.getName()); Log.LOGN(5, "Method: sig = " + mi.getSignatureRaw()); ps.writeString(mi.getSignatureRaw()); Log.LOGN(5, "Method: flags = " + mi.getAccessFlags()); ps.writeInt(mi.getAccessFlags()); } ps.send(); handled = true; break; } catch (Exception e) { System.out.println("Methods cmd: exception " + e); ps = new PacketStream(this, in.id, Packet.Reply, NOTFOUND_ERROR); ps.send(); handled = true; } break; case SOURCEFILE_CMD: SourceFileAttribute sfAttr; int slash_index; Log.LOGN(3, "Source file cmd"); cid = in.readInt(); try { if ((cf = (ClassFile)ClassManager.classMap.get(new Integer(cid))) == null) { throw new Exception("Couldn't get ClassFile object for Modifiers cmd"); } ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); if ((sfAttr = cf.getSourceAttribute()) != null) { String s = sfAttr.getSourceFileName(); if ((slash_index = s.lastIndexOf('/')) != -1 || (slash_index = s.lastIndexOf('\\')) != -1) { s = s.substring(slash_index + 1); } Log.LOGN(3, "Returning from attribute: " + s); ps.writeString(s); } else { Log.LOGN(3, "Creating source name: " + cf.getBaseName() + ".java"); ps.writeString(cf.getBaseName() + ".java"); } ps.send(); handled = true; break; } catch (Exception e) { System.out.println("Sourcefile cmd: exception " + e); ps = new PacketStream(this, in.id, Packet.Reply, INVALID_OBJECT); ps.send(); handled = true; } break; case INTERFACES_CMD: cid = in.readInt(); try { if ((cf = (ClassFile)ClassManager.classMap.get(new Integer(cid))) == null) { throw new Exception("Couldn't get ClassFile object for Interfaces cmd"); } List iList = cf.getAllInterfaces(); Iterator iIter = iList.iterator(); ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); Log.LOGN(3, "Interfaces: class " + cf.getClassName() + " " + iList.size() + " interfaces"); ps.writeInt(iList.size()); while (iIter.hasNext()) { String className = (String)iIter.next(); Log.LOGN(3, "interfaces: classname: " + className); if (className == null) { throw new Exception("interface name null"); } if ((cf = manager.findClass((byte)'L', className)) == null) { ps.writeInt(0); } else { ps.writeInt(cf.getClassID()); } } ps.send(); handled = true; break; } catch (Exception e) { System.out.println("Interfaces cmd: exception " + e); ps = new PacketStream(this, in.id, Packet.Reply, INVALID_OBJECT); ps.send(); handled = true; } break; } break; case METHOD_CMDSET: /* Method */ switch(p.cmd) { case METHOD_LINETABLE_CMD: // LineTable handleLineTable(in); handled = true; break; case METHOD_VARIABLETABLE_CMD: // VariableTable handleVariableTable(in); handled = true; break; case METHOD_BYTECODES_CMD: // Bytecodes handleByteCode(in); handled = true; break; } break; case THREADREFERENCE_CMDSET: switch(p.cmd) { case THREADGROUP_CMD: Log.LOGN(3, "Threadreference: threadgroup"); ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeInt(ONLY_THREADGROUP_ID); ps.send(); handled = true; break; } break; case THREADGROUPREFERENCE_CMDSET: switch(p.cmd) { case THREADGROUP_NAME_CMD: in.readInt(); // threadgroup ID Log.LOGN(3, "ThreadGroup: name"); ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeString(VM_THREADGROUP_NAME); ps.send(); handled = true; break; case THREADGROUP_PARENT_CMD: int tgID = in.readInt(); // threadgroup ID Log.LOGN(3, "ThreadGroup: parent"); ps = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeInt(0); // we're the top level ps.send(); handled = true; break; case THREADGROUP_CHILDREN_CMD: tgID = in.readInt(); Log.LOGN(3, "ThreadGroup: children"); PacketStream ps2 = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); if (tgID == ONLY_THREADGROUP_ID) { ps = new PacketStream(KVMListener, VIRTUALMACHINE_CMDSET, ALL_THREADS_CMD); ps.send(); try { ps.waitForReply(); } catch (Exception e) { ps2.writeInt(0); ps2.writeInt(0); ps2.send(); handled = true; break; } int numThreads = ps.readInt(); Log.LOGN(3, "threadgroup: " + numThreads + " children"); ps2.writeInt(numThreads); while (numThreads-- > 0) { ps2.writeInt(ps.readInt()); } } else { ps2.writeInt(0); // number of child threads; } ps2.writeInt(0); // number of child threadgroups ps2.send(); handled = true; break; } break; case STACKFRAME_CMDSET: switch(p.cmd) { case STACKFRAME_THISOBJECT_CMD: Log.LOGN(3, "Stackframe: thisobject"); int tID = in.readInt(); // get thread id; int fID = in.readInt(); // get frame id; ps = new PacketStream(KVMListener, STACKFRAME_CMDSET, STACKFRAME_GETVALUES_CMD); PacketStream ps2 = new PacketStream(this, in.id, Packet.Reply, Packet.ReplyNoError); ps.writeInt(tID); ps.writeInt(fID); ps.writeInt(1); // just want the 'this' object ps.writeInt(0); // it's at slot 0 ps.writeByte((byte)'L'); // it's an object type ps.send(); try { ps.waitForReply(); } catch (Exception e) { ps2.writeByte((byte)'L'); ps2.writeInt(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -