diff --git a/agent/src/os/linux/ps_core.c b/agent/src/os/linux/ps_core.c index 95e145748948d3b4c6948ba59a19fd6465583daa..e2067a951ce4805ca44742a70b934d4b2067883e 100644 --- a/agent/src/os/linux/ps_core.c +++ b/agent/src/os/linux/ps_core.c @@ -884,9 +884,12 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { } // read name of the shared object - if (read_string(ph, (uintptr_t) lib_name_addr, lib_name, sizeof(lib_name)) != true) { + lib_name[0] = '\0'; + if (lib_name_addr != 0 && + read_string(ph, (uintptr_t) lib_name_addr, lib_name, sizeof(lib_name)) != true) { print_debug("can't read shared object name\n"); - return false; + // don't let failure to read the name stop opening the file. If something is really wrong + // it will fail later. } if (lib_name[0] != '\0') { diff --git a/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java b/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java index a8d802f2fec4adb783877b7175390dd5fa10f3c4..68c67aac47aa113112915c5d365782d122efacd4 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java +++ b/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -494,6 +494,68 @@ public class CommandProcessor { } } }, + new Command("revptrs", "revptrs address", false) { + public void doit(Tokens t) { + int tokens = t.countTokens(); + if (tokens != 1 && (tokens != 2 || !t.nextToken().equals("-c"))) { + usage(); + return; + } + boolean chase = tokens == 2; + ReversePtrs revptrs = VM.getVM().getRevPtrs(); + if (revptrs == null) { + out.println("Computing reverse pointers..."); + ReversePtrsAnalysis analysis = new ReversePtrsAnalysis(); + final boolean[] complete = new boolean[1]; + HeapProgressThunk thunk = new HeapProgressThunk() { + public void heapIterationFractionUpdate(double d) {} + public synchronized void heapIterationComplete() { + complete[0] = true; + notify(); + } + }; + analysis.setHeapProgressThunk(thunk); + analysis.run(); + while (!complete[0]) { + synchronized (thunk) { + try { + thunk.wait(); + } catch (Exception e) { + } + } + } + revptrs = VM.getVM().getRevPtrs(); + out.println("Done."); + } + Address a = VM.getVM().getDebugger().parseAddress(t.nextToken()); + if (VM.getVM().getUniverse().heap().isInReserved(a)) { + OopHandle handle = a.addOffsetToAsOopHandle(0); + Oop oop = VM.getVM().getObjectHeap().newOop(handle); + ArrayList ptrs = revptrs.get(oop); + if (ptrs == null) { + out.println("no live references to " + a); + } else { + if (chase) { + while (ptrs.size() == 1) { + LivenessPathElement e = (LivenessPathElement)ptrs.get(0); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + Oop.printOopValueOn(e.getObj(), new PrintStream(bos)); + out.println(bos.toString()); + ptrs = revptrs.get(e.getObj()); + } + } else { + for (int i = 0; i < ptrs.size(); i++) { + LivenessPathElement e = (LivenessPathElement)ptrs.get(i); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + Oop.printOopValueOn(e.getObj(), new PrintStream(bos)); + out.println(bos.toString()); + oop = e.getObj(); + } + } + } + } + } + }, new Command("inspect", "inspect expression", false) { public void doit(Tokens t) { if (t.countTokens() != 1) { @@ -816,8 +878,24 @@ public class CommandProcessor { dumpType(type); } else { Iterator i = agent.getTypeDataBase().getTypes(); + // Make sure the types are emitted in an order than can be read back in + HashSet emitted = new HashSet(); + Stack pending = new Stack(); while (i.hasNext()) { - dumpType((Type)i.next()); + Type n = (Type)i.next(); + if (emitted.contains(n.getName())) { + continue; + } + + while (n != null && !emitted.contains(n.getName())) { + pending.push(n); + n = n.getSuperclass(); + } + while (!pending.empty()) { + n = (Type)pending.pop(); + dumpType(n); + emitted.add(n.getName()); + } } } } @@ -846,83 +924,105 @@ public class CommandProcessor { } }, - new Command("search", "search [ heap | codecache | threads ] value", false) { + new Command("search", "search [ heap | perm | rawheap | codecache | threads ] value", false) { public void doit(Tokens t) { if (t.countTokens() != 2) { usage(); - } else { - String type = t.nextToken(); - final Address value = VM.getVM().getDebugger().parseAddress(t.nextToken()); - final long stride = VM.getVM().getAddressSize(); - if (type.equals("threads")) { - Threads threads = VM.getVM().getThreads(); - for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) { - Address base = thread.getBaseOfStackPointer(); - Address end = thread.getLastJavaSP(); - if (end == null) continue; - if (end.lessThan(base)) { - Address tmp = base; - base = end; - end = tmp; + return; + } + String type = t.nextToken(); + final Address value = VM.getVM().getDebugger().parseAddress(t.nextToken()); + final long stride = VM.getVM().getAddressSize(); + if (type.equals("threads")) { + Threads threads = VM.getVM().getThreads(); + for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) { + Address base = thread.getBaseOfStackPointer(); + Address end = thread.getLastJavaSP(); + if (end == null) continue; + if (end.lessThan(base)) { + Address tmp = base; + base = end; + end = tmp; + } + out.println("Searching " + base + " " + end); + while (base != null && base.lessThan(end)) { + Address val = base.getAddressAt(0); + if (AddressOps.equal(val, value)) { + out.println(base); + } + base = base.addOffsetTo(stride); + } + } + } else if (type.equals("rawheap")) { + RawHeapVisitor iterator = new RawHeapVisitor() { + public void prologue(long used) { } - out.println("Searching " + base + " " + end); - while (base != null && base.lessThan(end)) { - Address val = base.getAddressAt(0); + + public void visitAddress(Address addr) { + Address val = addr.getAddressAt(0); if (AddressOps.equal(val, value)) { - out.println(base); + out.println("found at " + addr); } - base = base.addOffsetTo(stride); } - } - } else if (type.equals("heap")) { - RawHeapVisitor iterator = new RawHeapVisitor() { - public void prologue(long used) { + public void visitCompOopAddress(Address addr) { + Address val = addr.getCompOopAddressAt(0); + if (AddressOps.equal(val, value)) { + out.println("found at " + addr); } - - public void visitAddress(Address addr) { - Address val = addr.getAddressAt(0); + } + public void epilogue() { + } + }; + VM.getVM().getObjectHeap().iterateRaw(iterator); + } else if (type.equals("heap") || type.equals("perm")) { + HeapVisitor iterator = new DefaultHeapVisitor() { + public boolean doObj(Oop obj) { + int index = 0; + Address start = obj.getHandle(); + long end = obj.getObjectSize(); + while (index < end) { + Address val = start.getAddressAt(index); if (AddressOps.equal(val, value)) { - out.println("found at " + addr); + out.println("found in " + obj.getHandle()); + break; } + index += 4; } - public void visitCompOopAddress(Address addr) { - Address val = addr.getCompOopAddressAt(0); + return false; + } + }; + if (type.equals("heap")) { + VM.getVM().getObjectHeap().iterate(iterator); + } else { + VM.getVM().getObjectHeap().iteratePerm(iterator); + } + } else if (type.equals("codecache")) { + CodeCacheVisitor v = new CodeCacheVisitor() { + public void prologue(Address start, Address end) { + } + public void visit(CodeBlob blob) { + boolean printed = false; + Address base = blob.getAddress(); + Address end = base.addOffsetTo(blob.getSize()); + while (base != null && base.lessThan(end)) { + Address val = base.getAddressAt(0); if (AddressOps.equal(val, value)) { - out.println("found at " + addr); - } - } - public void epilogue() { - } - }; - VM.getVM().getObjectHeap().iterateRaw(iterator); - } else if (type.equals("codecache")) { - CodeCacheVisitor v = new CodeCacheVisitor() { - public void prologue(Address start, Address end) { - } - public void visit(CodeBlob blob) { - boolean printed = false; - Address base = blob.getAddress(); - Address end = base.addOffsetTo(blob.getSize()); - while (base != null && base.lessThan(end)) { - Address val = base.getAddressAt(0); - if (AddressOps.equal(val, value)) { - if (!printed) { - printed = true; - blob.printOn(out); - } - out.println("found at " + base + "\n"); + if (!printed) { + printed = true; + blob.printOn(out); } - base = base.addOffsetTo(stride); + out.println("found at " + base + "\n"); } + base = base.addOffsetTo(stride); } - public void epilogue() { - } + } + public void epilogue() { + } - }; - VM.getVM().getCodeCache().iterate(v); + }; + VM.getVM().getCodeCache().iterate(v); - } } } }, @@ -957,12 +1057,19 @@ public class CommandProcessor { Threads threads = VM.getVM().getThreads(); boolean all = name.equals("-a"); for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) { - StringWriter sw = new StringWriter(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); thread.printThreadIDOn(new PrintStream(bos)); if (all || bos.toString().equals(name)) { + out.println(bos.toString() + " = " + thread.getAddress()); HTMLGenerator gen = new HTMLGenerator(false); - out.println(gen.genHTMLForJavaStackTrace(thread)); + try { + out.println(gen.genHTMLForJavaStackTrace(thread)); + } catch (Exception e) { + err.println("Error: " + e); + if (verboseExceptions) { + e.printStackTrace(err); + } + } if (!all) return; } } @@ -970,6 +1077,26 @@ public class CommandProcessor { } } }, + new Command("thread", "thread { -a | id }", false) { + public void doit(Tokens t) { + if (t.countTokens() != 1) { + usage(); + } else { + String name = t.nextToken(); + Threads threads = VM.getVM().getThreads(); + boolean all = name.equals("-a"); + for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + thread.printThreadIDOn(new PrintStream(bos)); + if (all || bos.toString().equals(name)) { + out.println(bos.toString() + " = " + thread.getAddress()); + if (!all) return; + } + } + out.println("Couldn't find thread " + name); + } + } + }, new Command("threads", false) { public void doit(Tokens t) { @@ -1161,7 +1288,7 @@ public class CommandProcessor { } } - static Pattern historyPattern = Pattern.compile("((!\\*)|(!\\$)|(!!-?)|(!-?[0-9][0-9]*))"); + static Pattern historyPattern = Pattern.compile("((!\\*)|(!\\$)|(!!-?)|(!-?[0-9][0-9]*)|(![a-zA-Z][^ ]*))"); public void executeCommand(String ln) { if (ln.indexOf('!') != -1) { @@ -1195,14 +1322,37 @@ public class CommandProcessor { result.append(item.at(item.countTokens() - 1)); } else { String tail = cmd.substring(1); - int index = Integer.parseInt(tail); - if (index < 0) { - index = history.size() + index; + switch (tail.charAt(0)) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': { + int index = Integer.parseInt(tail); + if (index < 0) { + index = history.size() + index; + } + if (index > size) { + err.println("No such history item"); + } else { + result.append((String)history.get(index)); + } + break; + } + default: { + for (int i = history.size() - 1; i >= 0; i--) { + String s = (String)history.get(i); + if (s.startsWith(tail)) { + result.append(s); + } + } } - if (index > size) { - err.println("No such history item"); - } else { - result.append((String)history.get(index)); } } } diff --git a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java index 8a2ef3c84c2ec7d99dc4c642c976b99de0279aaa..df22e2604ea0b2e3be03e01b3f5030cad8eb94b3 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java +++ b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -985,6 +985,12 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener { annoPanel.addAnnotation(new Annotation(curFrame.addressOfInterpreterFrameExpressionStack(), curFrame.addressOfInterpreterFrameTOS(), "Interpreter expression stack")); + Address monBegin = curFrame.interpreterFrameMonitorBegin().address(); + Address monEnd = curFrame.interpreterFrameMonitorEnd().address(); + if (!monBegin.equals(monEnd)) { + annoPanel.addAnnotation(new Annotation(monBegin, monEnd, + "BasicObjectLocks")); + } if (interpreterFrameMethod != null) { // The offset is just to get the right stack slots highlighted in the output int offset = 1; diff --git a/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java b/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java index 66bb719e5cead3f77f109d7fdbddeb4c9c8bdec1..4902d6f0d86bf83aa95346d146c7ed5801fae18b 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java +++ b/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java @@ -1,5 +1,5 @@ /* - * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2001-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -294,7 +294,7 @@ public class BugSpot extends JPanel { attachDialog.setSize(400, 300); GraphicsUtilities.centerInContainer(attachDialog.getComponent(), getParentDimension(attachDialog.getComponent())); - attachDialog.show(); + attachDialog.setVisible(true); } public void showThreadsDialog() { @@ -321,7 +321,7 @@ public class BugSpot extends JPanel { getParentDimension(threadsDialog.getComponent())); GraphicsUtilities.centerInContainer(threadsDialog.getComponent(), getParentDimension(threadsDialog.getComponent())); - threadsDialog.show(); + threadsDialog.setVisible(true); } public void showMemoryDialog() { @@ -341,7 +341,7 @@ public class BugSpot extends JPanel { getParentDimension(memoryDialog.getComponent())); GraphicsUtilities.centerInContainer(memoryDialog.getComponent(), getParentDimension(memoryDialog.getComponent())); - memoryDialog.show(); + memoryDialog.setVisible(true); } /** Changes the editor factory this debugger uses to display source @@ -530,7 +530,7 @@ public class BugSpot extends JPanel { addFrame(stackFrame); stackFrame.setSize(400, 200); GraphicsUtilities.moveToInContainer(stackFrame.getComponent(), 0.0f, 1.0f, 0, 20); - stackFrame.show(); + stackFrame.setVisible(true); // Create register panel registerPanel = new RegisterPanel(); @@ -544,7 +544,7 @@ public class BugSpot extends JPanel { registerFrame.setSize(225, 200); GraphicsUtilities.moveToInContainer(registerFrame.getComponent(), 1.0f, 0.0f, 0, 0); - registerFrame.show(); + registerFrame.setVisible(true); resetCurrentThread(); } catch (DebuggerException e) { @@ -979,7 +979,7 @@ public class BugSpot extends JPanel { 1.0f, 0.85f, getParentDimension(editorFrame.getComponent())); - editorFrame.show(); + editorFrame.setVisible(true); shown = true; } code.showLineNumber(lineNo); diff --git a/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java b/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java index 7ba662b126267032fe5d8d56e8ca86747beeea0d..09e466d99bba0eeeea157dd30c9b0b94c04beede 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java +++ b/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,10 +96,6 @@ public class BytecodeDisassembler { addBytecodeClass(Bytecodes._dstore, BytecodeStore.class); addBytecodeClass(Bytecodes._astore, BytecodeStore.class); addBytecodeClass(Bytecodes._tableswitch, BytecodeTableswitch.class); - - // only special fast_xxx cases. others are handled differently. - addBytecodeClass(Bytecodes._fast_iaccess_0, BytecodeFastAAccess0.class); - addBytecodeClass(Bytecodes._fast_aaccess_0, BytecodeFastIAccess0.class); } public BytecodeDisassembler(Method method) { diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java b/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java index 236ab20822e265617f56c38ddcbd635ff40aecf3..730643c45bc7d90cb00bf107eb895fba57bf6484 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -263,11 +263,12 @@ public class ConstantPool extends Oop implements ClassConstants { case JVM_CONSTANT_NameAndType: return "JVM_CONSTANT_NameAndType"; case JVM_CONSTANT_Invalid: return "JVM_CONSTANT_Invalid"; case JVM_CONSTANT_UnresolvedClass: return "JVM_CONSTANT_UnresolvedClass"; + case JVM_CONSTANT_UnresolvedClassInError: return "JVM_CONSTANT_UnresolvedClassInError"; case JVM_CONSTANT_ClassIndex: return "JVM_CONSTANT_ClassIndex"; case JVM_CONSTANT_UnresolvedString: return "JVM_CONSTANT_UnresolvedString"; case JVM_CONSTANT_StringIndex: return "JVM_CONSTANT_StringIndex"; } - throw new InternalError("unknown tag"); + throw new InternalError("Unknown tag: " + tag); } public void iterateFields(OopVisitor visitor, boolean doVMFields) { @@ -304,6 +305,7 @@ public class ConstantPool extends Oop implements ClassConstants { index++; break; + case JVM_CONSTANT_UnresolvedClassInError: case JVM_CONSTANT_UnresolvedClass: case JVM_CONSTANT_Class: case JVM_CONSTANT_UnresolvedString: @@ -409,6 +411,7 @@ public class ConstantPool extends Oop implements ClassConstants { } // case JVM_CONSTANT_ClassIndex: + case JVM_CONSTANT_UnresolvedClassInError: case JVM_CONSTANT_UnresolvedClass: { dos.writeByte(JVM_CONSTANT_Class); String klassName = getSymbolAt(ci).asString(); @@ -464,6 +467,8 @@ public class ConstantPool extends Oop implements ClassConstants { + ", type = " + signatureIndex); break; } + default: + throw new InternalError("unknown tag: " + cpConstType); } // switch } dos.flush(); diff --git a/agent/src/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java b/agent/src/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java index 431a18261a9f07c68bd4a958003b73f6c3a1b1b6..6e34ef5d102cb927a4de185a3c4cf51014e6220c 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,9 @@ public interface ClassConstants // Temporary tag while constructing constant pool public static final int JVM_CONSTANT_StringIndex = 103; + // Temporary tag while constructing constant pool + public static final int JVM_CONSTANT_UnresolvedClassInError = 104; + // 1.5 major/minor version numbers from JVM spec. 3rd edition public static final short MAJOR_VERSION = 49; public static final short MINOR_VERSION = 0; diff --git a/agent/src/share/classes/sun/jvm/hotspot/runtime/SignatureIterator.java b/agent/src/share/classes/sun/jvm/hotspot/runtime/SignatureIterator.java index 4707452e334340c53350a73f94d7e4b2f2458d7f..faf5aaf34b7f5ad512c7dc10f3d9b83801816dd4 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/SignatureIterator.java +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/SignatureIterator.java @@ -1,5 +1,5 @@ /* - * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2001-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,7 +108,7 @@ public abstract class SignatureIterator { return BasicTypeSize.getTArraySize(); } } - throw new RuntimeException("Should not reach here"); + throw new RuntimeException("Should not reach here: char " + (char)_signature.getByteAt(_index) + " @ " + _index + " in " + _signature.asString()); } protected void checkSignatureEnd() { if (_index < _signature.getLength()) { diff --git a/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java b/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java index 077ce1241e1e86028179f13521c129d4e32540be..cc247d0d5bebb46843425591da6fe244ae984139 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -238,6 +238,7 @@ public class ClassWriter implements /* imports */ ClassConstants } // case JVM_CONSTANT_ClassIndex: + case JVM_CONSTANT_UnresolvedClassInError: case JVM_CONSTANT_UnresolvedClass: { dos.writeByte(JVM_CONSTANT_Class); String klassName = cpool.getSymbolAt(ci).asString(); @@ -296,6 +297,8 @@ public class ClassWriter implements /* imports */ ClassConstants + ", type = " + signatureIndex); break; } + default: + throw new InternalError("Unknown tag: " + cpConstType); } // switch } } diff --git a/agent/src/share/classes/sun/jvm/hotspot/ui/FrameWrapper.java b/agent/src/share/classes/sun/jvm/hotspot/ui/FrameWrapper.java index 4fb9fecd75064d891ecad2aed343fa98d9c52878..d85b31da34246475435b3f9a14fb123440ba86ca 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/ui/FrameWrapper.java +++ b/agent/src/share/classes/sun/jvm/hotspot/ui/FrameWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2001-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ public interface FrameWrapper { public void setVisible(boolean visible); public void setSize(int x, int y); public void pack(); - public void show(); public void dispose(); public void setBackground(Color color); public void setResizable(boolean resizable); diff --git a/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java b/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java index c7d29d7d2e50118bda2302c2f1a143335abae779..475b6663fa883f756a6f928f0721222b389283fb 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java +++ b/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,8 +95,10 @@ public class HTMLGenerator implements /* imports */ ClassConstants { // list tags void beginList() { beginTag("ul"); nl(); } - void li(String s) { wrap("li", s); nl(); } void endList() { endTag("ul"); nl(); } + void beginListItem() { beginTag("li"); } + void endListItem() { endTag("li"); nl(); } + void li(String s) { wrap("li", s); nl(); } // table tags void beginTable(int border) { @@ -505,6 +507,11 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.cell(cpool.getSymbolAt(index).asString()); break; + case JVM_CONSTANT_UnresolvedClassInError: + buf.cell("JVM_CONSTANT_UnresolvedClassInError"); + buf.cell(cpool.getSymbolAt(index).asString()); + break; + case JVM_CONSTANT_Class: buf.cell("JVM_CONSTANT_Class"); Klass klass = (Klass) cpool.getObjAt(index); @@ -564,6 +571,9 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.cell("JVM_CONSTANT_StringIndex"); buf.cell(Integer.toString(cpool.getIntAt(index))); break; + + default: + throw new InternalError("unknown tag: " + ctag); } buf.endTag("tr"); @@ -671,7 +681,16 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.cell(Integer.toString(curBci) + spaces); buf.beginTag("td"); - String instrStr = escapeHTMLSpecialChars(instr.toString()); + String instrStr = null; + try { + instrStr = escapeHTMLSpecialChars(instr.toString()); + } catch (RuntimeException re) { + buf.append("exception during bytecode processing"); + buf.endTag("td"); + buf.endTag("tr"); + re.printStackTrace(); + return; + } if (instr instanceof BytecodeNew) { BytecodeNew newBytecode = (BytecodeNew) instr; @@ -1396,9 +1415,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { final SymbolFinder symFinder = createSymbolFinder(); final Disassembler disasm = createDisassembler(startPc, code); class NMethodVisitor implements InstructionVisitor { - boolean prevWasCall; public void prologue() { - prevWasCall = false; } public void visit(long currentPc, Instruction instr) { @@ -1418,8 +1435,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { PCDesc pcDesc = (PCDesc) safepoints.get(longToAddress(currentPc)); - boolean isSafepoint = (pcDesc != null); - if (isSafepoint && prevWasCall) { + if (pcDesc != null) { buf.append(genSafepointInfo(nmethod, pcDesc)); } @@ -1435,11 +1451,6 @@ public class HTMLGenerator implements /* imports */ ClassConstants { } buf.br(); - if (isSafepoint && !prevWasCall) { - buf.append(genSafepointInfo(nmethod, pcDesc)); - } - - prevWasCall = instr.isCall(); } public void epilogue() { @@ -1783,22 +1794,20 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.h3("Fields"); buf.beginList(); for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) { - int nameIndex = fields.getShortAt(f + InstanceKlass.NAME_INDEX_OFFSET); - int sigIndex = fields.getShortAt(f + InstanceKlass.SIGNATURE_INDEX_OFFSET); - int genSigIndex = fields.getShortAt(f + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET); - Symbol f_name = cp.getSymbolAt(nameIndex); - Symbol f_sig = cp.getSymbolAt(sigIndex); - Symbol f_genSig = (genSigIndex != 0)? cp.getSymbolAt(genSigIndex) : null; - AccessFlags acc = new AccessFlags(fields.getShortAt(f + InstanceKlass.ACCESS_FLAGS_OFFSET)); - - buf.beginTag("li"); + sun.jvm.hotspot.oops.Field field = klass.getFieldByIndex(f); + String f_name = ((NamedFieldIdentifier)field.getID()).getName(); + Symbol f_sig = field.getSignature(); + Symbol f_genSig = field.getGenericSignature(); + AccessFlags acc = field.getAccessFlagsObj(); + + buf.beginListItem(); buf.append(genFieldModifierString(acc)); buf.append(' '); Formatter sigBuf = new Formatter(genHTML); new SignatureConverter(f_sig, sigBuf.getBuffer()).dispatchField(); buf.append(sigBuf.toString().replace('/', '.')); buf.append(' '); - buf.append(f_name.asString()); + buf.append(f_name); buf.append(';'); // is it generic? if (f_genSig != null) { @@ -1806,7 +1815,8 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.append(escapeHTMLSpecialChars(f_genSig.asString())); buf.append("] "); } - buf.endTag("li"); + buf.append(" (offset = " + field.getOffset() + ")"); + buf.endListItem(); } buf.endList(); } diff --git a/agent/src/share/classes/sun/jvm/hotspot/utilities/Assert.java b/agent/src/share/classes/sun/jvm/hotspot/utilities/Assert.java index 62ae9b3e7aafd7532ca23d6c3cc5b346fa617eea..a675f54adc12c8629164a1eda148f9ca9073b7aa 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/Assert.java +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/Assert.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ public class Assert { public static boolean ASSERTS_ENABLED = true; public static void that(boolean test, String message) { - if (!test) { + if (ASSERTS_ENABLED && !test) { throw new AssertionFailure(message); } }