7165259: Remove BugSpot

Fri, 22 Feb 2013 10:03:02 +0100

author
sla
date
Fri, 22 Feb 2013 10:03:02 +0100
changeset 4642
5ed317b25e23
parent 4641
fc64254f5579
child 4643
f16e75e0cf11

7165259: Remove BugSpot
Reviewed-by: coleenp, mgronlun

agent/make/Makefile file | annotate | diff | comparison | revisions
agent/make/bugspot.bat file | annotate | diff | comparison | revisions
agent/make/marks_notes.html file | annotate | diff | comparison | revisions
agent/src/os/win32/windbg/sawindbg.cpp file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/asm/amd64/AMD64FloatRegister.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/JavaLineNumberInfo.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/Main.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/PCFinder.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/PackageScanner.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/RegisterPanel.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/StackTraceEntry.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/StackTracePanel.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/ThreadListPanel.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/VariablePanel.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/AddressTreeNodeAdapter.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/DoubleTreeNodeAdapter.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/EnumTreeNodeAdapter.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/FieldTreeNodeAdapter.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/FloatTreeNodeAdapter.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/LongTreeNodeAdapter.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/ObjectTreeNodeAdapter.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/livejvm/BreakpointEvent.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/livejvm/CIntegerAccessor.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/livejvm/CStringAccessor.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/livejvm/Event.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/livejvm/ExceptionEvent.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/livejvm/JNIHandleAccessor.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/livejvm/ServiceabilityAgentJVMDIModule.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js file | annotate | diff | comparison | revisions
agent/src/share/native/jvmdi/sa.cpp file | annotate | diff | comparison | revisions
agent/src/share/native/jvmdi/sa.dsp file | annotate | diff | comparison | revisions
agent/src/share/native/jvmdi/sa.dsw file | annotate | diff | comparison | revisions
agent/src/share/native/jvmdi/sa.hpp file | annotate | diff | comparison | revisions
make/sa.files file | annotate | diff | comparison | revisions
     1.1 --- a/agent/make/Makefile	Thu Feb 21 07:50:48 2013 -0500
     1.2 +++ b/agent/make/Makefile	Fri Feb 22 10:03:02 2013 +0100
     1.3 @@ -19,7 +19,7 @@
     1.4  # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     1.5  # or visit www.oracle.com if you need additional information or have any
     1.6  # questions.
     1.7 -#  
     1.8 +#
     1.9  #
    1.10  
    1.11  # This guards against adding broken .java files to the directory
    1.12 @@ -42,8 +42,6 @@
    1.13  sun.jvm.hotspot \
    1.14  sun.jvm.hotspot.asm \
    1.15  sun.jvm.hotspot.asm.sparc \
    1.16 -sun.jvm.hotspot.bugspot \
    1.17 -sun.jvm.hotspot.bugspot.tree \
    1.18  sun.jvm.hotspot.c1 \
    1.19  sun.jvm.hotspot.ci \
    1.20  sun.jvm.hotspot.code \
    1.21 @@ -84,7 +82,6 @@
    1.22  sun.jvm.hotspot.gc_interface \
    1.23  sun.jvm.hotspot.interpreter \
    1.24  sun.jvm.hotspot.jdi \
    1.25 -sun.jvm.hotspot.livejvm \
    1.26  sun.jvm.hotspot.memory \
    1.27  sun.jvm.hotspot.opto \
    1.28  sun.jvm.hotspot.oops \
    1.29 @@ -130,8 +127,6 @@
    1.30  sun/jvm/hotspot/*.java \
    1.31  sun/jvm/hotspot/asm/*.java \
    1.32  sun/jvm/hotspot/asm/sparc/*.java \
    1.33 -sun/jvm/hotspot/bugspot/*.java \
    1.34 -sun/jvm/hotspot/bugspot/tree/*.java \
    1.35  sun/jvm/hotspot/c1/*.java \
    1.36  sun/jvm/hotspot/ci/*.java \
    1.37  sun/jvm/hotspot/code/*.java \
    1.38 @@ -168,7 +163,6 @@
    1.39  sun/jvm/hotspot/gc_implementation/shared/*.java \
    1.40  sun/jvm/hotspot/interpreter/*.java \
    1.41  sun/jvm/hotspot/jdi/*.java \
    1.42 -sun/jvm/hotspot/livejvm/*.java \
    1.43  sun/jvm/hotspot/memory/*.java \
    1.44  sun/jvm/hotspot/oops/*.java \
    1.45  sun/jvm/hotspot/opto/*.java \
    1.46 @@ -205,7 +199,7 @@
    1.47  sun/jvm/hotspot/utilities/memo/*.java \
    1.48  sun/jvm/hotspot/utilities/soql/*.java \
    1.49  com/sun/java/swing/action/*.java \
    1.50 -com/sun/java/swing/ui/*.java 
    1.51 +com/sun/java/swing/ui/*.java
    1.52  #END FILELIST
    1.53  
    1.54  ifneq "x$(ALT_BOOTDIR)" "x"
    1.55 @@ -231,7 +225,7 @@
    1.56  OUTPUT_DIR = $(BUILD_DIR)/classes
    1.57  DOC_DIR    = $(BUILD_DIR)/doc
    1.58  
    1.59 -# gnumake 3.78.1 does not accept the *s, 
    1.60 +# gnumake 3.78.1 does not accept the *s,
    1.61  # so use the shell to expand them
    1.62  ALLFILES := $(patsubst %,$(SRC_DIR)/%,$(FILELIST))
    1.63  ALLFILES := $(shell /bin/ls $(ALLFILES))
    1.64 @@ -303,7 +297,7 @@
    1.65  cscope: $(ALLFILES)
    1.66  	rm -f java.files
    1.67  	echo $(ALLFILES) > java.files
    1.68 -	cscope -b -i java.files -f java.out 
    1.69 +	cscope -b -i java.files -f java.out
    1.70  	rm -f java.files
    1.71  
    1.72  .PHONY: sa.jar
     2.1 --- a/agent/make/bugspot.bat	Thu Feb 21 07:50:48 2013 -0500
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,25 +0,0 @@
     2.4 -REM
     2.5 -REM Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
     2.6 -REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 -REM
     2.8 -REM This code is free software; you can redistribute it and/or modify it
     2.9 -REM under the terms of the GNU General Public License version 2 only, as
    2.10 -REM published by the Free Software Foundation.
    2.11 -REM
    2.12 -REM This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 -REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 -REM FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 -REM version 2 for more details (a copy is included in the LICENSE file that
    2.16 -REM accompanied this code).
    2.17 -REM
    2.18 -REM You should have received a copy of the GNU General Public License version
    2.19 -REM 2 along with this work; if not, write to the Free Software Foundation,
    2.20 -REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 -REM
    2.22 -REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 -REM or visit www.oracle.com if you need additional information or have any
    2.24 -REM questions.
    2.25 -REM  
    2.26 -REM
    2.27 -
    2.28 -java -showversion -cp ..\build\classes;..\src\share\lib\js.jar;.\sa.jar;lib\js.jar sun.jvm.hotspot.bugspot.Main
     3.1 --- a/agent/make/marks_notes.html	Thu Feb 21 07:50:48 2013 -0500
     3.2 +++ b/agent/make/marks_notes.html	Fri Feb 22 10:03:02 2013 +0100
     3.3 @@ -26,14 +26,12 @@
     3.4  
     3.5      <ul>
     3.6        <li><code>java -cp classes sun.jvm.hotspot.HSDB</code>
     3.7 -      <li><code>java -cp classes sun.jvm.hotspot.bugspot.Main</code>
     3.8      </ul>
     3.9  
    3.10      <h2>Feedback</h2>
    3.11      <p>
    3.12        Refactoring of package hierarchy. All user interface components should be in
    3.13 -      the ui package. Perhaps: sun.jvm.hotspot.ui.hsdb.Main for the HSDB and
    3.14 -      sun.jvm.hotspot.ui.bugspot.Main for BugSpot.
    3.15 +      the ui package. Perhaps: sun.jvm.hotspot.ui.hsdb.Main for the HSDB.
    3.16      <p>
    3.17        The src\share\vm\agent area seems like a workspace so it should be organized like
    3.18        one. In particular, I'd like to suggest the following directory layout:<br>
    3.19 @@ -47,7 +45,7 @@
    3.20      </ul>
    3.21  
    3.22      <p>
    3.23 -      Seems like there is a lot of redundant functionality. Between the HSDB and BugSpot. Perhaps
    3.24 +      Seems like there is a lot of redundant functionality. Perhaps
    3.25        this can be consolidated with a <code>javax.swing.Actions</code> architecture.
    3.26  
    3.27      <h2>Tasklist</h2>
    3.28 @@ -55,11 +53,7 @@
    3.29      <p>
    3.30        <b>Stack memory pane</b>: 
    3.31        It's one of the more useful JVM debugging tools in the SA. However, it
    3.32 -      doesn't support any interaction with the text; the Memory Panel in BugSpot
    3.33 -      was written afterward (with help from Shannon) and implements proper
    3.34 -      selection, scrolling, and drag-and-drop, but no annotations. I'm not sure how
    3.35 -      to integrate the annotations with the JTable that's being used for the memory
    3.36 -      view; if you have suggestions here please let me know.
    3.37 +      doesn't support any interaction with the text.
    3.38      <p>
    3.39        <b>Integrations with the NetBeans architecture (plug in).</b> See the
    3.40        <a href="http://openide.netbeans.org">Netbeans Open APIs homepage</a>
     4.1 --- a/agent/src/os/win32/windbg/sawindbg.cpp	Thu Feb 21 07:50:48 2013 -0500
     4.2 +++ b/agent/src/os/win32/windbg/sawindbg.cpp	Fri Feb 22 10:03:02 2013 +0100
     4.3 @@ -372,8 +372,7 @@
     4.4  
     4.5       We are attaching to a process in 'read-only' mode. i.e., we do not want to
     4.6       put breakpoints, suspend/resume threads etc. For read-only JDI and HSDB kind of
     4.7 -     usage this should suffice. We are not intending to use this for full-fledged
     4.8 -     ProcessControl implementation to be used with BugSpotAgent.
     4.9 +     usage this should suffice.
    4.10  
    4.11       Please refer to DEBUG_ATTACH_NONINVASIVE mode source comments from dbgeng.h.
    4.12       In this mode, debug engine does not call DebugActiveProrcess. i.e., we are not
     5.1 --- a/agent/src/share/classes/sun/jvm/hotspot/asm/amd64/AMD64FloatRegister.java	Thu Feb 21 07:50:48 2013 -0500
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,64 +0,0 @@
     5.4 -/*
     5.5 - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
     5.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 - *
     5.8 - * This code is free software; you can redistribute it and/or modify it
     5.9 - * under the terms of the GNU General Public License version 2 only, as
    5.10 - * published by the Free Software Foundation.
    5.11 - *
    5.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 - * version 2 for more details (a copy is included in the LICENSE file that
    5.16 - * accompanied this code).
    5.17 - *
    5.18 - * You should have received a copy of the GNU General Public License version
    5.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 - *
    5.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 - * or visit www.oracle.com if you need additional information or have any
    5.24 - * questions.
    5.25 - *
    5.26 - */
    5.27 -
    5.28 -package sun.jvm.hotspot.asm.amd64;
    5.29 -
    5.30 -import sun.jvm.hotspot.asm.Register;
    5.31 -import sun.jvm.hotspot.utilities.Assert;
    5.32 -
    5.33 -public class AMD64FloatRegister extends Register {
    5.34 -
    5.35 -   public AMD64FloatRegister(int number) {
    5.36 -      super(number);
    5.37 -   }
    5.38 -
    5.39 -   public int getNumber() {
    5.40 -      return number;
    5.41 -   }
    5.42 -
    5.43 -   public int getNumberOfRegisters() {
    5.44 -      return AMD64FloatRegisters.getNumRegisters();
    5.45 -   }
    5.46 -
    5.47 -   public boolean isFloat() {
    5.48 -      return true;
    5.49 -   }
    5.50 -
    5.51 -   public boolean isFramePointer() {
    5.52 -      return false;
    5.53 -   }
    5.54 -
    5.55 -   public boolean isStackPointer() {
    5.56 -      return false;
    5.57 -   }
    5.58 -
    5.59 -   public boolean isValid() {
    5.60 -      return number >= 0 && number < AMD64FloatRegisters.getNumRegisters();
    5.61 -   }
    5.62 -
    5.63 -   public String toString() {
    5.64 -      return AMD64FloatRegisters.getRegisterName(number);
    5.65 -   }
    5.66 -
    5.67 -}
     6.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java	Thu Feb 21 07:50:48 2013 -0500
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,1536 +0,0 @@
     6.4 -/*
     6.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     6.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 - *
     6.8 - * This code is free software; you can redistribute it and/or modify it
     6.9 - * under the terms of the GNU General Public License version 2 only, as
    6.10 - * published by the Free Software Foundation.
    6.11 - *
    6.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 - * version 2 for more details (a copy is included in the LICENSE file that
    6.16 - * accompanied this code).
    6.17 - *
    6.18 - * You should have received a copy of the GNU General Public License version
    6.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 - *
    6.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 - * or visit www.oracle.com if you need additional information or have any
    6.24 - * questions.
    6.25 - *
    6.26 - */
    6.27 -
    6.28 -package sun.jvm.hotspot.bugspot;
    6.29 -
    6.30 -import java.awt.*;
    6.31 -import java.awt.event.*;
    6.32 -import java.io.*;
    6.33 -import java.net.*;
    6.34 -import java.util.*;
    6.35 -import javax.swing.*;
    6.36 -import javax.swing.filechooser.*;
    6.37 -import sun.jvm.hotspot.debugger.*;
    6.38 -import sun.jvm.hotspot.debugger.cdbg.*;
    6.39 -import sun.jvm.hotspot.debugger.posix.*;
    6.40 -import sun.jvm.hotspot.debugger.windbg.*;
    6.41 -import sun.jvm.hotspot.livejvm.*;
    6.42 -import sun.jvm.hotspot.memory.*;
    6.43 -import sun.jvm.hotspot.oops.*;
    6.44 -import sun.jvm.hotspot.runtime.*;
    6.45 -import sun.jvm.hotspot.ui.*;
    6.46 -import sun.jvm.hotspot.utilities.*;
    6.47 -
    6.48 -/** The BugSpot component. This is embeddable in an application by
    6.49 -    virtue of its being a JComponent. It (currently) requires the use
    6.50 -    of a menu bar which can be fetched via getMenuBar(). This is
    6.51 -    intended ultimately to replace HSDB. */
    6.52 -
    6.53 -public class BugSpot extends JPanel {
    6.54 -  public BugSpot() {
    6.55 -    super();
    6.56 -    Runtime.getRuntime().addShutdownHook(new java.lang.Thread() {
    6.57 -        public void run() {
    6.58 -          detachDebugger();
    6.59 -        }
    6.60 -      });
    6.61 -  }
    6.62 -
    6.63 -  /** Turn on or off MDI (Multiple Document Interface) mode. When MDI
    6.64 -      is enabled, the BugSpot component contains a JDesktopPane and all
    6.65 -      windows are JInternalFrames. When disabled, only the menu bar is
    6.66 -      relevant. */
    6.67 -  public void setMDIMode(boolean onOrOff) {
    6.68 -    mdiMode = onOrOff;
    6.69 -  }
    6.70 -
    6.71 -  /** Indicates whether MDI mode is enabled. */
    6.72 -  public boolean getMDIMode() {
    6.73 -    return mdiMode;
    6.74 -  }
    6.75 -
    6.76 -  /** Build user interface widgets. This must be called before adding
    6.77 -      the BugSpot component to its parent. */
    6.78 -  public void build() {
    6.79 -    setLayout(new BorderLayout());
    6.80 -
    6.81 -    menuBar = new JMenuBar();
    6.82 -
    6.83 -    attachMenuItems = new java.util.ArrayList();
    6.84 -    detachMenuItems = new java.util.ArrayList();
    6.85 -    debugMenuItems  = new java.util.ArrayList();
    6.86 -    suspendDebugMenuItems = new java.util.ArrayList();
    6.87 -    resumeDebugMenuItems = new java.util.ArrayList();
    6.88 -
    6.89 -    //
    6.90 -    // File menu
    6.91 -    //
    6.92 -
    6.93 -    JMenu menu = createMenu("File", 'F', 0);
    6.94 -    JMenuItem item;
    6.95 -    item = createMenuItem("Open source file...",
    6.96 -                          new ActionListener() {
    6.97 -                              public void actionPerformed(ActionEvent e) {
    6.98 -                                openSourceFile();
    6.99 -                              }
   6.100 -                            },
   6.101 -                          KeyEvent.VK_O, InputEvent.CTRL_MASK,
   6.102 -                          'O', 0);
   6.103 -    menu.add(item);
   6.104 -    detachMenuItems.add(item);
   6.105 -
   6.106 -    menu.addSeparator();
   6.107 -
   6.108 -    item = createMenuItem("Attach to process...",
   6.109 -                          new ActionListener() {
   6.110 -                              public void actionPerformed(ActionEvent e) {
   6.111 -                                showAttachDialog();
   6.112 -                              }
   6.113 -                            },
   6.114 -                          'A', 0);
   6.115 -    menu.add(item);
   6.116 -    attachMenuItems.add(item);
   6.117 -
   6.118 -    item = createMenuItem("Detach",
   6.119 -                          new ActionListener() {
   6.120 -                              public void actionPerformed(ActionEvent e) {
   6.121 -                                detach();
   6.122 -                              }
   6.123 -                            },
   6.124 -                          'D', 0);
   6.125 -    menu.add(item);
   6.126 -    detachMenuItems.add(item);
   6.127 -
   6.128 -    // Disable detach menu items at first
   6.129 -    setMenuItemsEnabled(detachMenuItems, false);
   6.130 -
   6.131 -    menu.addSeparator();
   6.132 -
   6.133 -    menu.add(createMenuItem("Exit",
   6.134 -                            new ActionListener() {
   6.135 -                                public void actionPerformed(ActionEvent e) {
   6.136 -                                  detach();
   6.137 -                                  System.exit(0);
   6.138 -                                }
   6.139 -                              },
   6.140 -                            'x', 1));
   6.141 -
   6.142 -    menuBar.add(menu);
   6.143 -
   6.144 -    //
   6.145 -    // Debug menu
   6.146 -    //
   6.147 -
   6.148 -    debugMenu = createMenu("Debug", 'D', 0);
   6.149 -    item = createMenuItem("Go",
   6.150 -                          new ActionListener() {
   6.151 -                              public void actionPerformed(ActionEvent e) {
   6.152 -                                if (!attached) return;
   6.153 -                                if (!isSuspended()) return;
   6.154 -                                resume();
   6.155 -                              }
   6.156 -                            },
   6.157 -                          KeyEvent.VK_F5, 0,
   6.158 -                          'G', 0);
   6.159 -    debugMenu.add(item);
   6.160 -    resumeDebugMenuItems.add(item);
   6.161 -
   6.162 -    item = createMenuItem("Break",
   6.163 -                          new ActionListener() {
   6.164 -                              public void actionPerformed(ActionEvent e) {
   6.165 -                                if (!attached) {
   6.166 -                                  System.err.println("Not attached");
   6.167 -                                  return;
   6.168 -                                }
   6.169 -                                if (isSuspended()) {
   6.170 -                                  System.err.println("Already suspended");
   6.171 -                                  return;
   6.172 -                                }
   6.173 -                                suspend();
   6.174 -                              }
   6.175 -                            },
   6.176 -                          'B', 0);
   6.177 -    debugMenu.add(item);
   6.178 -    suspendDebugMenuItems.add(item);
   6.179 -
   6.180 -    debugMenu.addSeparator();
   6.181 -
   6.182 -    item = createMenuItem("Threads...",
   6.183 -                          new ActionListener() {
   6.184 -                              public void actionPerformed(ActionEvent e) {
   6.185 -                                showThreadsDialog();
   6.186 -                              }
   6.187 -                            },
   6.188 -                          'T', 0);
   6.189 -    debugMenu.add(item);
   6.190 -    debugMenuItems.add(item);
   6.191 -    // FIXME: belongs under "View -> Debug Windows"
   6.192 -    item = createMenuItem("Memory",
   6.193 -                          new ActionListener() {
   6.194 -                              public void actionPerformed(ActionEvent e) {
   6.195 -                                showMemoryDialog();
   6.196 -                              }
   6.197 -                            },
   6.198 -                          'M', 0);
   6.199 -    debugMenu.add(item);
   6.200 -    debugMenuItems.add(item);
   6.201 -
   6.202 -    debugMenu.setEnabled(false);
   6.203 -    menuBar.add(debugMenu);
   6.204 -
   6.205 -    if (mdiMode) {
   6.206 -      desktop = new JDesktopPane();
   6.207 -      add(desktop, BorderLayout.CENTER);
   6.208 -    }
   6.209 -
   6.210 -    fixedWidthFont = GraphicsUtilities.lookupFont("Courier");
   6.211 -
   6.212 -    debugEventTimer = new javax.swing.Timer(100, new ActionListener() {
   6.213 -        public void actionPerformed(ActionEvent e) {
   6.214 -          pollForDebugEvent();
   6.215 -        }
   6.216 -      });
   6.217 -  }
   6.218 -
   6.219 -  public JMenuBar getMenuBar() {
   6.220 -    return menuBar;
   6.221 -  }
   6.222 -
   6.223 -  public void showAttachDialog() {
   6.224 -    setMenuItemsEnabled(attachMenuItems, false);
   6.225 -    final FrameWrapper attachDialog = newFrame("Attach to process");
   6.226 -    attachDialog.getContentPane().setLayout(new BorderLayout());
   6.227 -    attachDialog.setClosable(true);
   6.228 -    attachDialog.setResizable(true);
   6.229 -
   6.230 -    JPanel panel = new JPanel();
   6.231 -    panel.setLayout(new BorderLayout());
   6.232 -    panel.setBorder(GraphicsUtilities.newBorder(5));
   6.233 -    attachDialog.setBackground(panel.getBackground());
   6.234 -
   6.235 -    JPanel listPanel = new JPanel();
   6.236 -    listPanel.setLayout(new BorderLayout());
   6.237 -    final ProcessListPanel plist = new ProcessListPanel(getLocalDebugger());
   6.238 -    panel.add(plist, BorderLayout.CENTER);
   6.239 -    JCheckBox check = new JCheckBox("Update list continuously");
   6.240 -    check.addItemListener(new ItemListener() {
   6.241 -        public void itemStateChanged(ItemEvent e) {
   6.242 -          if (e.getStateChange() == ItemEvent.SELECTED) {
   6.243 -            plist.start();
   6.244 -          } else {
   6.245 -            plist.stop();
   6.246 -          }
   6.247 -        }
   6.248 -      });
   6.249 -    listPanel.add(plist, BorderLayout.CENTER);
   6.250 -    listPanel.add(check, BorderLayout.SOUTH);
   6.251 -    panel.add(listPanel, BorderLayout.CENTER);
   6.252 -    attachDialog.getContentPane().add(panel, BorderLayout.CENTER);
   6.253 -    attachDialog.setClosingActionListener(new ActionListener() {
   6.254 -        public void actionPerformed(ActionEvent e) {
   6.255 -          plist.stop();
   6.256 -          setMenuItemsEnabled(attachMenuItems, true);
   6.257 -        }
   6.258 -      });
   6.259 -
   6.260 -    ActionListener attacher = new ActionListener() {
   6.261 -        public void actionPerformed(ActionEvent e) {
   6.262 -          plist.stop();
   6.263 -          attachDialog.setVisible(false);
   6.264 -          removeFrame(attachDialog);
   6.265 -          ProcessInfo info = plist.getSelectedProcess();
   6.266 -          if (info != null) {
   6.267 -            attach(info.getPid());
   6.268 -          }
   6.269 -        }
   6.270 -      };
   6.271 -
   6.272 -    Box hbox = Box.createHorizontalBox();
   6.273 -    hbox.add(Box.createGlue());
   6.274 -    JButton button = new JButton("OK");
   6.275 -    button.addActionListener(attacher);
   6.276 -    hbox.add(button);
   6.277 -    hbox.add(Box.createHorizontalStrut(20));
   6.278 -    button = new JButton("Cancel");
   6.279 -    button.addActionListener(new ActionListener() {
   6.280 -        public void actionPerformed(ActionEvent e) {
   6.281 -          plist.stop();
   6.282 -          attachDialog.setVisible(false);
   6.283 -          removeFrame(attachDialog);
   6.284 -          setMenuItemsEnabled(attachMenuItems, true);
   6.285 -        }
   6.286 -      });
   6.287 -    hbox.add(button);
   6.288 -    hbox.add(Box.createGlue());
   6.289 -    panel = new JPanel();
   6.290 -    panel.setBorder(GraphicsUtilities.newBorder(5));
   6.291 -    panel.add(hbox);
   6.292 -
   6.293 -    attachDialog.getContentPane().add(panel, BorderLayout.SOUTH);
   6.294 -
   6.295 -    addFrame(attachDialog);
   6.296 -    attachDialog.pack();
   6.297 -    attachDialog.setSize(400, 300);
   6.298 -    GraphicsUtilities.centerInContainer(attachDialog.getComponent(),
   6.299 -                                        getParentDimension(attachDialog.getComponent()));
   6.300 -    attachDialog.setVisible(true);
   6.301 -  }
   6.302 -
   6.303 -  public void showThreadsDialog() {
   6.304 -    final FrameWrapper threadsDialog = newFrame("Threads");
   6.305 -    threadsDialog.getContentPane().setLayout(new BorderLayout());
   6.306 -    threadsDialog.setClosable(true);
   6.307 -    threadsDialog.setResizable(true);
   6.308 -
   6.309 -    ThreadListPanel threads = new ThreadListPanel(getCDebugger(), getAgent().isJavaMode());
   6.310 -    threads.addListener(new ThreadListPanel.Listener() {
   6.311 -        public void setFocus(ThreadProxy thread, JavaThread jthread) {
   6.312 -          setCurrentThread(thread);
   6.313 -          // FIXME: print this to GUI, bring some windows to foreground
   6.314 -          System.err.println("Focus changed to thread " + thread);
   6.315 -        }
   6.316 -      });
   6.317 -    threads.setBorder(GraphicsUtilities.newBorder(5));
   6.318 -    threadsDialog.getContentPane().add(threads);
   6.319 -    addFrame(threadsDialog);
   6.320 -    threadsDialog.pack();
   6.321 -    GraphicsUtilities.reshapeToAspectRatio(threadsDialog.getComponent(),
   6.322 -                                           3.0f,
   6.323 -                                           0.9f,
   6.324 -                                           getParentDimension(threadsDialog.getComponent()));
   6.325 -    GraphicsUtilities.centerInContainer(threadsDialog.getComponent(),
   6.326 -                                        getParentDimension(threadsDialog.getComponent()));
   6.327 -    threadsDialog.setVisible(true);
   6.328 -  }
   6.329 -
   6.330 -  public void showMemoryDialog() {
   6.331 -    final FrameWrapper memoryDialog = newFrame("Memory");
   6.332 -    memoryDialog.getContentPane().setLayout(new BorderLayout());
   6.333 -    memoryDialog.setClosable(true);
   6.334 -    memoryDialog.setResizable(true);
   6.335 -
   6.336 -    memoryDialog.getContentPane().add(new MemoryViewer(getDebugger(),
   6.337 -                                                       (getDebugger().getMachineDescription().getAddressSize() == 8)),
   6.338 -                                      BorderLayout.CENTER);
   6.339 -    addFrame(memoryDialog);
   6.340 -    memoryDialog.pack();
   6.341 -    GraphicsUtilities.reshapeToAspectRatio(memoryDialog.getComponent(),
   6.342 -                                           1.0f,
   6.343 -                                           0.7f,
   6.344 -                                           getParentDimension(memoryDialog.getComponent()));
   6.345 -    GraphicsUtilities.centerInContainer(memoryDialog.getComponent(),
   6.346 -                                        getParentDimension(memoryDialog.getComponent()));
   6.347 -    memoryDialog.setVisible(true);
   6.348 -  }
   6.349 -
   6.350 -  /** Changes the editor factory this debugger uses to display source
   6.351 -      code. Specified factory may be null, in which case the default
   6.352 -      factory is used. */
   6.353 -  public void setEditorFactory(EditorFactory fact) {
   6.354 -    if (fact != null) {
   6.355 -      editorFact = fact;
   6.356 -    } else {
   6.357 -      editorFact = new DefaultEditorFactory();
   6.358 -    }
   6.359 -  }
   6.360 -
   6.361 -  //----------------------------------------------------------------------
   6.362 -  // Internals only below this point
   6.363 -  //
   6.364 -
   6.365 -  private WorkerThread    workerThread;
   6.366 -  private boolean         mdiMode;
   6.367 -  private JVMDebugger     localDebugger;
   6.368 -  private BugSpotAgent    agent = new BugSpotAgent();
   6.369 -  private JMenuBar        menuBar;
   6.370 -  /** List <JMenuItem> */
   6.371 -  private java.util.List  attachMenuItems;
   6.372 -  private java.util.List  detachMenuItems;
   6.373 -  private java.util.List  debugMenuItems;
   6.374 -  private java.util.List  suspendDebugMenuItems;
   6.375 -  private java.util.List  resumeDebugMenuItems;
   6.376 -  private FrameWrapper    stackFrame;
   6.377 -  private VariablePanel   localsPanel;
   6.378 -  private StackTracePanel stackTracePanel;
   6.379 -  private FrameWrapper    registerFrame;
   6.380 -  private RegisterPanel   registerPanel;
   6.381 -  // Used for mixed-language stack traces
   6.382 -  private Map             threadToJavaThreadMap;
   6.383 -
   6.384 -  private JMenu debugMenu;
   6.385 -
   6.386 -  // MDI mode only: desktop pane
   6.387 -  private JDesktopPane desktop;
   6.388 -
   6.389 -  // Attach/detach state
   6.390 -  private boolean attached;
   6.391 -
   6.392 -  // Suspension (combined Java/C++) state
   6.393 -  private boolean suspended;
   6.394 -
   6.395 -  // Fixed-width font
   6.396 -  private Font fixedWidthFont;
   6.397 -
   6.398 -  // Breakpoint setting
   6.399 -  // Maps Strings to List/*<LineNumberInfo>*/
   6.400 -  private Map sourceFileToLineNumberInfoMap;
   6.401 -  // Maps Strings (file names) to Sets of Integers (line numbers)
   6.402 -  private Map fileToBreakpointMap;
   6.403 -
   6.404 -  // Debug events
   6.405 -  private javax.swing.Timer debugEventTimer;
   6.406 -
   6.407 -  // Java debug events
   6.408 -  private boolean javaEventPending;
   6.409 -
   6.410 -  static class BreakpointResult {
   6.411 -    private boolean success;
   6.412 -    private boolean set;
   6.413 -    private int lineNo;
   6.414 -    private String why;
   6.415 -
   6.416 -    /** For positive results */
   6.417 -    BreakpointResult(boolean success, boolean set, int lineNo) {
   6.418 -      this(success, set, lineNo, null);
   6.419 -    }
   6.420 -
   6.421 -    /** For negative results */
   6.422 -    BreakpointResult(boolean success, boolean set, int lineNo, String why) {
   6.423 -      this.success = success;
   6.424 -      this.set = set;
   6.425 -      this.lineNo = lineNo;
   6.426 -      this.why = why;
   6.427 -    }
   6.428 -
   6.429 -    public boolean succeeded() {
   6.430 -      return success;
   6.431 -    }
   6.432 -
   6.433 -    public boolean set() {
   6.434 -      return set;
   6.435 -    }
   6.436 -
   6.437 -    /** Line at which the breakpoint was actually set; only valid if
   6.438 -        succeeded() returns true */
   6.439 -    public int getLine() {
   6.440 -      return lineNo;
   6.441 -    }
   6.442 -
   6.443 -    public String getWhy() {
   6.444 -      return why;
   6.445 -    }
   6.446 -  }
   6.447 -
   6.448 -
   6.449 -  // Editors for source code. File name-to-Editor mapping.
   6.450 -  private Map editors;
   6.451 -  private EditorFactory editorFact = new DefaultEditorFactory();
   6.452 -  private EditorCommands editorComm = new EditorCommands() {
   6.453 -      public void windowClosed(Editor editor) {
   6.454 -        editors.remove(editor.getSourceFileName());
   6.455 -      }
   6.456 -
   6.457 -      public void toggleBreakpointAtLine(Editor editor, int lineNumber) {
   6.458 -        // FIXME: handle "lazy" breakpoints where the source file has
   6.459 -        // been opened with some other mechanism (File -> Open) and we
   6.460 -        // don't have debug information pointing to that file yet
   6.461 -        // FIXME: NOT FINISHED
   6.462 -
   6.463 -        BreakpointResult res =
   6.464 -          handleBreakpointToggle(editor, lineNumber);
   6.465 -        if (res.succeeded()) {
   6.466 -          if (res.set()) {
   6.467 -            editor.showBreakpointAtLine(res.getLine());
   6.468 -          } else {
   6.469 -            editor.clearBreakpointAtLine(res.getLine());
   6.470 -          }
   6.471 -        } else {
   6.472 -          String why = res.getWhy();
   6.473 -          if (why == null) {
   6.474 -            why = "";
   6.475 -          } else {
   6.476 -            why = ": " + why;
   6.477 -          }
   6.478 -          showMessageDialog("Unable to toggle breakpoint" + why,
   6.479 -                            "Unable to toggle breakpoint",
   6.480 -                            JOptionPane.WARNING_MESSAGE);
   6.481 -        }
   6.482 -      }
   6.483 -    };
   6.484 -
   6.485 -  private void attach(final int pid) {
   6.486 -    try {
   6.487 -      getAgent().attach(pid);
   6.488 -      setMenuItemsEnabled(detachMenuItems, true);
   6.489 -      setMenuItemsEnabled(suspendDebugMenuItems, false);
   6.490 -      setMenuItemsEnabled(resumeDebugMenuItems, true);
   6.491 -      debugMenu.setEnabled(true);
   6.492 -      attached = true;
   6.493 -      suspended = true;
   6.494 -
   6.495 -      if (getAgent().isJavaMode()) {
   6.496 -        System.err.println("Java HotSpot(TM) virtual machine detected.");
   6.497 -      } else {
   6.498 -        System.err.println("(No Java(TM) virtual machine detected)");
   6.499 -      }
   6.500 -
   6.501 -      // Set up editor map
   6.502 -      editors = new HashMap();
   6.503 -
   6.504 -      // Initialize breakpoints
   6.505 -      fileToBreakpointMap = new HashMap();
   6.506 -
   6.507 -      // Create combined stack trace and local variable panel
   6.508 -      JPanel framePanel = new JPanel();
   6.509 -      framePanel.setLayout(new BorderLayout());
   6.510 -      framePanel.setBorder(GraphicsUtilities.newBorder(5));
   6.511 -      localsPanel = new VariablePanel();
   6.512 -      JTabbedPane tab = new JTabbedPane();
   6.513 -      tab.addTab("Locals", localsPanel);
   6.514 -      tab.setTabPlacement(JTabbedPane.BOTTOM);
   6.515 -      framePanel.add(tab, BorderLayout.CENTER);
   6.516 -      JPanel stackPanel = new JPanel();
   6.517 -      stackPanel.setLayout(new BoxLayout(stackPanel, BoxLayout.X_AXIS));
   6.518 -      stackPanel.add(new JLabel("Context:"));
   6.519 -      stackPanel.add(Box.createHorizontalStrut(5));
   6.520 -      stackTracePanel = new StackTracePanel();
   6.521 -      stackTracePanel.addListener(new StackTracePanel.Listener() {
   6.522 -          public void frameChanged(CFrame fr, JavaVFrame jfr) {
   6.523 -            setCurrentFrame(fr, jfr);
   6.524 -          }
   6.525 -        });
   6.526 -      stackPanel.add(stackTracePanel);
   6.527 -      framePanel.add(stackPanel, BorderLayout.NORTH);
   6.528 -      stackFrame = newFrame("Stack");
   6.529 -      stackFrame.getContentPane().setLayout(new BorderLayout());
   6.530 -      stackFrame.getContentPane().add(framePanel, BorderLayout.CENTER);
   6.531 -      stackFrame.setResizable(true);
   6.532 -      stackFrame.setClosable(false);
   6.533 -      addFrame(stackFrame);
   6.534 -      stackFrame.setSize(400, 200);
   6.535 -      GraphicsUtilities.moveToInContainer(stackFrame.getComponent(), 0.0f, 1.0f, 0, 20);
   6.536 -      stackFrame.setVisible(true);
   6.537 -
   6.538 -      // Create register panel
   6.539 -      registerPanel = new RegisterPanel();
   6.540 -      registerPanel.setFont(fixedWidthFont);
   6.541 -      registerFrame = newFrame("Registers");
   6.542 -      registerFrame.getContentPane().setLayout(new BorderLayout());
   6.543 -      registerFrame.getContentPane().add(registerPanel, BorderLayout.CENTER);
   6.544 -      addFrame(registerFrame);
   6.545 -      registerFrame.setResizable(true);
   6.546 -      registerFrame.setClosable(false);
   6.547 -      registerFrame.setSize(225, 200);
   6.548 -      GraphicsUtilities.moveToInContainer(registerFrame.getComponent(),
   6.549 -                                          1.0f, 0.0f, 0, 0);
   6.550 -      registerFrame.setVisible(true);
   6.551 -
   6.552 -      resetCurrentThread();
   6.553 -    } catch (DebuggerException e) {
   6.554 -      final String errMsg = formatMessage(e.getMessage(), 80);
   6.555 -      setMenuItemsEnabled(attachMenuItems, true);
   6.556 -      showMessageDialog("Unable to connect to process ID " + pid + ":\n\n" + errMsg,
   6.557 -                        "Unable to Connect",
   6.558 -                        JOptionPane.WARNING_MESSAGE);
   6.559 -      getAgent().detach();
   6.560 -    }
   6.561 -  }
   6.562 -
   6.563 -  private synchronized void detachDebugger() {
   6.564 -    if (!attached) {
   6.565 -      return;
   6.566 -    }
   6.567 -    if (isSuspended()) {
   6.568 -      resume(); // Necessary for JVMDI resumption
   6.569 -    }
   6.570 -    getAgent().detach();
   6.571 -    // FIXME: clear out breakpoints (both Java and C/C++) from target
   6.572 -    // process
   6.573 -    sourceFileToLineNumberInfoMap = null;
   6.574 -    fileToBreakpointMap = null;
   6.575 -    threadToJavaThreadMap = null;
   6.576 -    editors = null;
   6.577 -    attached = false;
   6.578 -  }
   6.579 -
   6.580 -  private synchronized void detach() {
   6.581 -    detachDebugger();
   6.582 -    setMenuItemsEnabled(attachMenuItems, true);
   6.583 -    setMenuItemsEnabled(detachMenuItems, false);
   6.584 -    debugMenu.setEnabled(false);
   6.585 -    if (mdiMode) {
   6.586 -      // FIXME: is this sufficient, or will I have to do anything else
   6.587 -      // to the components to kill them off? What about WorkerThreads?
   6.588 -      desktop.removeAll();
   6.589 -      desktop.invalidate();
   6.590 -      desktop.validate();
   6.591 -      desktop.repaint();
   6.592 -    }
   6.593 -    // FIXME: keep track of all windows and close them even in non-MDI
   6.594 -    // mode
   6.595 -    debugEventTimer.stop();
   6.596 -  }
   6.597 -
   6.598 -  // Returns a Debugger for processes on the local machine. This is
   6.599 -  // only used to fetch the process list.
   6.600 -  private Debugger getLocalDebugger() {
   6.601 -    if (localDebugger == null) {
   6.602 -      String os  = PlatformInfo.getOS();
   6.603 -      String cpu = PlatformInfo.getCPU();
   6.604 -
   6.605 -      if (os.equals("win32")) {
   6.606 -        if (!cpu.equals("x86")) {
   6.607 -          throw new DebuggerException("Unsupported CPU \"" + cpu + "\" for Windows");
   6.608 -        }
   6.609 -
   6.610 -        localDebugger = new WindbgDebuggerLocal(new MachineDescriptionIntelX86(), true);
   6.611 -      } else if (os.equals("linux")) {
   6.612 -        if (!cpu.equals("x86")) {
   6.613 -          throw new DebuggerException("Unsupported CPU \"" + cpu + "\" for Linux");
   6.614 -        }
   6.615 -
   6.616 -        // FIXME: figure out how to specify path to debugger module
   6.617 -        throw new RuntimeException("FIXME: figure out how to specify path to debugger module");
   6.618 -        //        localDebugger = new PosixDebuggerLocal(new MachineDescriptionIntelX86(), true);
   6.619 -      } else {
   6.620 -        // FIXME: port to Solaris
   6.621 -        throw new DebuggerException("Unsupported OS \"" + os + "\"");
   6.622 -      }
   6.623 -
   6.624 -      // FIXME: we require that the primitive type sizes be configured
   6.625 -      // in order to use basic functionality in class Address such as
   6.626 -      // the fetching of floating-point values. There are a lot of
   6.627 -      // assumptions in the current code that Java floats and doubles
   6.628 -      // are of equivalent size to C values. The configurability of the
   6.629 -      // primitive type sizes hasn't seemed necessary and in this kind
   6.630 -      // of debugging scenario (namely, debugging arbitrary C++
   6.631 -      // processes) it appears difficult to support that kind of
   6.632 -      // flexibility.
   6.633 -      localDebugger.configureJavaPrimitiveTypeSizes(1, 1, 2, 8, 4, 4, 8, 2);
   6.634 -    }
   6.635 -
   6.636 -    return localDebugger;
   6.637 -  }
   6.638 -
   6.639 -  private BugSpotAgent getAgent() {
   6.640 -    return agent;
   6.641 -  }
   6.642 -
   6.643 -  private Debugger getDebugger() {
   6.644 -    return getAgent().getDebugger();
   6.645 -  }
   6.646 -
   6.647 -  private CDebugger getCDebugger() {
   6.648 -    return getAgent().getCDebugger();
   6.649 -  }
   6.650 -
   6.651 -  private void resetCurrentThread() {
   6.652 -    setCurrentThread((ThreadProxy) getCDebugger().getThreadList().get(0));
   6.653 -  }
   6.654 -
   6.655 -  private void setCurrentThread(ThreadProxy t) {
   6.656 -    // Create stack trace
   6.657 -    // FIXME: add ability to intermix C/Java frames
   6.658 -    java.util.List trace = new ArrayList();
   6.659 -    CFrame fr = getCDebugger().topFrameForThread(t);
   6.660 -    while (fr != null) {
   6.661 -      trace.add(new StackTraceEntry(fr, getCDebugger()));
   6.662 -      try {
   6.663 -        fr = fr.sender(t);
   6.664 -      } catch (AddressException e) {
   6.665 -        e.printStackTrace();
   6.666 -        showMessageDialog("Error while walking stack; stack trace will be truncated\n(see console for details)",
   6.667 -                          "Error walking stack",
   6.668 -                          JOptionPane.WARNING_MESSAGE);
   6.669 -        fr = null;
   6.670 -      }
   6.671 -    }
   6.672 -    JavaThread jthread = javaThreadForProxy(t);
   6.673 -    if (jthread != null) {
   6.674 -      // Java mode, and we have a Java thread.
   6.675 -      // Find all Java frames on the stack. We currently do this in a
   6.676 -      // manner which involves minimal interaction between the Java
   6.677 -      // and C/C++ debugging systems: any C frame which has a PC in an
   6.678 -      // unknown location (i.e., not in any DSO) is assumed to be a
   6.679 -      // Java frame. We merge stack segments of unknown frames with
   6.680 -      // segments of Java frames beginning with native methods.
   6.681 -      java.util.List javaTrace = new ArrayList();
   6.682 -      VFrame vf = jthread.getLastJavaVFrameDbg();
   6.683 -      while (vf != null) {
   6.684 -        if (vf.isJavaFrame()) {
   6.685 -          javaTrace.add(new StackTraceEntry((JavaVFrame) vf));
   6.686 -          vf = vf.sender();
   6.687 -        }
   6.688 -      }
   6.689 -      // Merge stack traces
   6.690 -      java.util.List mergedTrace = new ArrayList();
   6.691 -      int c = 0;
   6.692 -      int j = 0;
   6.693 -      while (c < trace.size()) {
   6.694 -        StackTraceEntry entry = (StackTraceEntry) trace.get(c);
   6.695 -        if (entry.isUnknownCFrame()) {
   6.696 -          boolean gotJavaFrame = false;
   6.697 -          while (j < javaTrace.size()) {
   6.698 -            StackTraceEntry javaEntry = (StackTraceEntry) javaTrace.get(j);
   6.699 -            JavaVFrame jvf = javaEntry.getJavaFrame();
   6.700 -            Method m = jvf.getMethod();
   6.701 -            if (!m.isNative() || !gotJavaFrame) {
   6.702 -              gotJavaFrame = true;
   6.703 -              mergedTrace.add(javaEntry);
   6.704 -              ++j;
   6.705 -            } else {
   6.706 -              break; // Reached native method; have intervening C frames
   6.707 -            }
   6.708 -          }
   6.709 -          if (gotJavaFrame) {
   6.710 -            // Skip this sequence of unknown frames, as we've
   6.711 -            // successfully identified it as Java frames
   6.712 -            while (c < trace.size() && entry.isUnknownCFrame()) {
   6.713 -              ++c;
   6.714 -              if (c < trace.size()) {
   6.715 -                entry = (StackTraceEntry) trace.get(c);
   6.716 -              }
   6.717 -            }
   6.718 -            continue;
   6.719 -          }
   6.720 -        }
   6.721 -        // If we get here, we either have an unknown frame we didn't
   6.722 -        // know how to categorize or we have a known C frame. Add it
   6.723 -        // to the trace.
   6.724 -        mergedTrace.add(entry);
   6.725 -        ++c;
   6.726 -      }
   6.727 -      trace = mergedTrace;
   6.728 -    }
   6.729 -    stackTracePanel.setTrace(trace);
   6.730 -
   6.731 -    registerPanel.update(t);
   6.732 -  }
   6.733 -
   6.734 -  private void setCurrentFrame(CFrame fr, JavaVFrame jfr) {
   6.735 -    localsPanel.clear();
   6.736 -
   6.737 -    if (fr != null) {
   6.738 -      localsPanel.update(fr);
   6.739 -
   6.740 -      // FIXME: load source file if we can find it, otherwise display disassembly
   6.741 -      LoadObject lo = getCDebugger().loadObjectContainingPC(fr.pc());
   6.742 -      if (lo != null) {
   6.743 -        CDebugInfoDataBase db = lo.getDebugInfoDataBase();
   6.744 -        if (db != null) {
   6.745 -          LineNumberInfo info = db.lineNumberForPC(fr.pc());
   6.746 -          if (info != null) {
   6.747 -            System.err.println("PC " + fr.pc() + ": Source file \"" +
   6.748 -                               info.getSourceFileName() +
   6.749 -                               "\", line number " +
   6.750 -                               info.getLineNumber() +
   6.751 -                               ", PC range [" +
   6.752 -                               info.getStartPC() +
   6.753 -                               ", " +
   6.754 -                               info.getEndPC() +
   6.755 -                               ")");
   6.756 -            // OK, here we go...
   6.757 -            showLineNumber(null, info.getSourceFileName(), info.getLineNumber());
   6.758 -          } else {
   6.759 -            System.err.println("(No line number information for PC " + fr.pc() + ")");
   6.760 -            // Dump line number information for database
   6.761 -            db.iterate(new LineNumberVisitor() {
   6.762 -                public void doLineNumber(LineNumberInfo info) {
   6.763 -                  System.err.println("  Source file \"" +
   6.764 -                                     info.getSourceFileName() +
   6.765 -                                     "\", line number " +
   6.766 -                                     info.getLineNumber() +
   6.767 -                                     ", PC range [" +
   6.768 -                                     info.getStartPC() +
   6.769 -                                     ", " +
   6.770 -                                     info.getEndPC() +
   6.771 -                                     ")");
   6.772 -                }
   6.773 -              });
   6.774 -          }
   6.775 -        }
   6.776 -      }
   6.777 -    } else {
   6.778 -      if (Assert.ASSERTS_ENABLED) {
   6.779 -        Assert.that(jfr != null, "Must have either C or Java frame");
   6.780 -      }
   6.781 -      localsPanel.update(jfr);
   6.782 -      // See whether we can locate source file and line number
   6.783 -      // FIXME: infer pathmap entries from user's locating of this
   6.784 -      // source file
   6.785 -      // FIXME: figure out what to do for native methods. Possible to
   6.786 -      // go to line number for the native method declaration?
   6.787 -      Method m = jfr.getMethod();
   6.788 -      Symbol sfn = ((InstanceKlass) m.getMethodHolder()).getSourceFileName();
   6.789 -      if (sfn != null) {
   6.790 -        int bci = jfr.getBCI();
   6.791 -        int lineNo = m.getLineNumberFromBCI(bci);
   6.792 -        if (lineNo >= 0) {
   6.793 -          // FIXME: show disassembly otherwise
   6.794 -          showLineNumber(packageName(m.getMethodHolder().getName().asString()),
   6.795 -                         sfn.asString(), lineNo);
   6.796 -        }
   6.797 -      }
   6.798 -    }
   6.799 -  }
   6.800 -
   6.801 -  private String packageName(String str) {
   6.802 -    int idx = str.lastIndexOf('/');
   6.803 -    if (idx < 0) {
   6.804 -      return "";
   6.805 -    }
   6.806 -    return str.substring(0, idx).replace('/', '.');
   6.807 -  }
   6.808 -
   6.809 -  private JavaThread javaThreadForProxy(ThreadProxy t) {
   6.810 -    if (!getAgent().isJavaMode()) {
   6.811 -      return null;
   6.812 -    }
   6.813 -    if (threadToJavaThreadMap == null) {
   6.814 -      threadToJavaThreadMap = new HashMap();
   6.815 -      Threads threads = VM.getVM().getThreads();
   6.816 -      for (JavaThread thr = threads.first(); thr != null; thr = thr.next()) {
   6.817 -        threadToJavaThreadMap.put(thr.getThreadProxy(), thr);
   6.818 -      }
   6.819 -    }
   6.820 -    return (JavaThread) threadToJavaThreadMap.get(t);
   6.821 -  }
   6.822 -
   6.823 -  private static JMenu createMenu(String name, char mnemonic, int mnemonicPos) {
   6.824 -    JMenu menu = new JMenu(name);
   6.825 -    menu.setMnemonic(mnemonic);
   6.826 -    menu.setDisplayedMnemonicIndex(mnemonicPos);
   6.827 -    return menu;
   6.828 -  }
   6.829 -
   6.830 -  private static JMenuItem createMenuItem(String name, ActionListener l) {
   6.831 -    JMenuItem item = new JMenuItem(name);
   6.832 -    item.addActionListener(l);
   6.833 -    return item;
   6.834 -  }
   6.835 -
   6.836 -  private static JMenuItem createMenuItemInternal(String name, ActionListener l, int accelerator, int modifiers) {
   6.837 -    JMenuItem item = createMenuItem(name, l);
   6.838 -    item.setAccelerator(KeyStroke.getKeyStroke(accelerator, modifiers));
   6.839 -    return item;
   6.840 -  }
   6.841 -
   6.842 -  private static JMenuItem createMenuItem(String name, ActionListener l, int accelerator) {
   6.843 -    return createMenuItemInternal(name, l, accelerator, 0);
   6.844 -  }
   6.845 -
   6.846 -  private static JMenuItem createMenuItem(String name, ActionListener l, char mnemonic, int mnemonicPos) {
   6.847 -    JMenuItem item = createMenuItem(name, l);
   6.848 -    item.setMnemonic(mnemonic);
   6.849 -    item.setDisplayedMnemonicIndex(mnemonicPos);
   6.850 -    return item;
   6.851 -  }
   6.852 -
   6.853 -  private static JMenuItem createMenuItem(String name,
   6.854 -                                          ActionListener l,
   6.855 -                                          int accelerator,
   6.856 -                                          int acceleratorMods,
   6.857 -                                          char mnemonic,
   6.858 -                                          int mnemonicPos) {
   6.859 -    JMenuItem item = createMenuItemInternal(name, l, accelerator, acceleratorMods);
   6.860 -    item.setMnemonic(mnemonic);
   6.861 -    item.setDisplayedMnemonicIndex(mnemonicPos);
   6.862 -    return item;
   6.863 -  }
   6.864 -
   6.865 -  /** Punctuates the given string with \n's where necessary to not
   6.866 -      exceed the given number of characters per line. Strips
   6.867 -      extraneous whitespace. */
   6.868 -  private static String formatMessage(String message, int charsPerLine) {
   6.869 -    StringBuffer buf = new StringBuffer(message.length());
   6.870 -    StringTokenizer tokenizer = new StringTokenizer(message);
   6.871 -    int curLineLength = 0;
   6.872 -    while (tokenizer.hasMoreTokens()) {
   6.873 -      String tok = tokenizer.nextToken();
   6.874 -      if (curLineLength + tok.length() > charsPerLine) {
   6.875 -        buf.append('\n');
   6.876 -        curLineLength = 0;
   6.877 -      } else {
   6.878 -        if (curLineLength != 0) {
   6.879 -          buf.append(' ');
   6.880 -          ++curLineLength;
   6.881 -        }
   6.882 -      }
   6.883 -      buf.append(tok);
   6.884 -      curLineLength += tok.length();
   6.885 -    }
   6.886 -    return buf.toString();
   6.887 -  }
   6.888 -
   6.889 -  private void setMenuItemsEnabled(java.util.List items, boolean enabled) {
   6.890 -    for (Iterator iter = items.iterator(); iter.hasNext(); ) {
   6.891 -      ((JMenuItem) iter.next()).setEnabled(enabled);
   6.892 -    }
   6.893 -  }
   6.894 -
   6.895 -  private void showMessageDialog(final String message, final String title, final int jOptionPaneKind) {
   6.896 -    SwingUtilities.invokeLater(new Runnable() {
   6.897 -        public void run() {
   6.898 -          if (mdiMode) {
   6.899 -            JOptionPane.showInternalMessageDialog(desktop, message, title, jOptionPaneKind);
   6.900 -          } else {
   6.901 -            JOptionPane.showMessageDialog(null, message, title, jOptionPaneKind);
   6.902 -          }
   6.903 -        }
   6.904 -      });
   6.905 -  }
   6.906 -
   6.907 -  private FrameWrapper newFrame(String title) {
   6.908 -    if (mdiMode) {
   6.909 -      return new JInternalFrameWrapper(new JInternalFrame(title));
   6.910 -    } else {
   6.911 -      return new JFrameWrapper(new JFrame(title));
   6.912 -    }
   6.913 -  }
   6.914 -
   6.915 -  private void addFrame(FrameWrapper frame) {
   6.916 -    if (mdiMode) {
   6.917 -      desktop.add(frame.getComponent());
   6.918 -    }
   6.919 -  }
   6.920 -
   6.921 -  private void removeFrame(FrameWrapper frame) {
   6.922 -    if (mdiMode) {
   6.923 -      desktop.remove(frame.getComponent());
   6.924 -      desktop.invalidate();
   6.925 -      desktop.validate();
   6.926 -      desktop.repaint();
   6.927 -    }
   6.928 -    // FIXME: do something when not in MDI mode
   6.929 -  }
   6.930 -
   6.931 -  private Dimension getParentDimension(Component c) {
   6.932 -    if (mdiMode) {
   6.933 -      return desktop.getSize();
   6.934 -    } else {
   6.935 -      return Toolkit.getDefaultToolkit().getScreenSize();
   6.936 -    }
   6.937 -  }
   6.938 -
   6.939 -  // Default editor implementation
   6.940 -  class DefaultEditor implements Editor {
   6.941 -    private DefaultEditorFactory factory;
   6.942 -    private FrameWrapper    editorFrame;
   6.943 -    private String          filename;
   6.944 -    private SourceCodePanel code;
   6.945 -    private boolean         shown;
   6.946 -    private Object          userData;
   6.947 -
   6.948 -    public DefaultEditor(DefaultEditorFactory fact, String filename, final EditorCommands comm) {
   6.949 -      this.filename = filename;
   6.950 -      this.factory = fact;
   6.951 -      editorFrame = newFrame(filename);
   6.952 -      code = new SourceCodePanel();
   6.953 -      // FIXME: when font changes, change font in editors as well
   6.954 -      code.setFont(fixedWidthFont);
   6.955 -      editorFrame.getContentPane().add(code);
   6.956 -      editorFrame.setClosable(true);
   6.957 -      editorFrame.setResizable(true);
   6.958 -      editorFrame.setClosingActionListener(new ActionListener() {
   6.959 -          public void actionPerformed(ActionEvent e) {
   6.960 -            comm.windowClosed(DefaultEditor.this);
   6.961 -            removeFrame(editorFrame);
   6.962 -            editorFrame.dispose();
   6.963 -            factory.editorClosed(DefaultEditor.this);
   6.964 -          }
   6.965 -        });
   6.966 -      editorFrame.setActivatedActionListener(new ActionListener() {
   6.967 -          public void actionPerformed(ActionEvent e) {
   6.968 -            factory.makeEditorCurrent(DefaultEditor.this);
   6.969 -            code.requestFocus();
   6.970 -          }
   6.971 -        });
   6.972 -      code.setEditorCommands(comm, this);
   6.973 -    }
   6.974 -
   6.975 -    public boolean openFile()                        { return code.openFile(filename);     }
   6.976 -    public String  getSourceFileName()               { return filename;                    }
   6.977 -    public int     getCurrentLineNumber()            { return code.getCurrentLineNumber(); }
   6.978 -    public void showLineNumber(int lineNo) {
   6.979 -      if (!shown) {
   6.980 -        addFrame(editorFrame);
   6.981 -        GraphicsUtilities.reshapeToAspectRatio(editorFrame.getComponent(),
   6.982 -                                               1.0f,
   6.983 -                                               0.85f,
   6.984 -                                               getParentDimension(editorFrame.getComponent()));
   6.985 -        editorFrame.setVisible(true);
   6.986 -        shown = true;
   6.987 -      }
   6.988 -      code.showLineNumber(lineNo);
   6.989 -      editorFrame.toFront();
   6.990 -    }
   6.991 -    public void    highlightLineNumber(int lineNo)   { code.highlightLineNumber(lineNo);        }
   6.992 -    public void    showBreakpointAtLine(int lineNo)  { code.showBreakpointAtLine(lineNo);       }
   6.993 -    public boolean hasBreakpointAtLine(int lineNo)   { return code.hasBreakpointAtLine(lineNo); }
   6.994 -    public void    clearBreakpointAtLine(int lineNo) { code.clearBreakpointAtLine(lineNo);      }
   6.995 -    public void    clearBreakpoints()                { code.clearBreakpoints();                 }
   6.996 -    public void    setUserData(Object o)             { userData = o;                            }
   6.997 -    public Object  getUserData()                     { return userData;                         }
   6.998 -    public void    toFront()                         { editorFrame.toFront();
   6.999 -                                                       factory.makeEditorCurrent(this);         }
  6.1000 -  }
  6.1001 -
  6.1002 -  class DefaultEditorFactory implements EditorFactory {
  6.1003 -    private LinkedList/*<Editor>*/ editors = new LinkedList();
  6.1004 -
  6.1005 -    public Editor openFile(String filename, EditorCommands commands) {
  6.1006 -      DefaultEditor editor = new DefaultEditor(this, filename, editorComm);
  6.1007 -      if (!editor.openFile()) {
  6.1008 -        return null;
  6.1009 -      }
  6.1010 -      return editor;
  6.1011 -    }
  6.1012 -
  6.1013 -    public Editor getCurrentEditor() {
  6.1014 -      if (editors.isEmpty()) {
  6.1015 -        return null;
  6.1016 -      }
  6.1017 -      return (Editor) editors.getFirst();
  6.1018 -    }
  6.1019 -
  6.1020 -    void editorClosed(Editor editor) {
  6.1021 -      editors.remove(editor);
  6.1022 -    }
  6.1023 -
  6.1024 -    void makeEditorCurrent(Editor editor) {
  6.1025 -      editors.remove(editor);
  6.1026 -      editors.addFirst(editor);
  6.1027 -    }
  6.1028 -  }
  6.1029 -
  6.1030 -  // Helper class for loading .java files; show only those with
  6.1031 -  // correct file name which are also in the correct package
  6.1032 -  static class JavaFileFilter extends javax.swing.filechooser.FileFilter {
  6.1033 -    private String packageName;
  6.1034 -    private String fileName;
  6.1035 -
  6.1036 -    JavaFileFilter(String packageName, String fileName) {
  6.1037 -      this.packageName = packageName;
  6.1038 -      this.fileName = fileName;
  6.1039 -    }
  6.1040 -
  6.1041 -    public boolean accept(File f) {
  6.1042 -      if (f.isDirectory()) {
  6.1043 -        return true;
  6.1044 -      }
  6.1045 -      // This rejects most files
  6.1046 -      if (!f.getName().equals(fileName)) {
  6.1047 -        return false;
  6.1048 -      }
  6.1049 -      // Ensure selected file is in the correct package
  6.1050 -      PackageScanner scanner = new PackageScanner();
  6.1051 -      String pkg = scanner.scan(f);
  6.1052 -      if (!pkg.equals(packageName)) {
  6.1053 -        return false;
  6.1054 -      }
  6.1055 -      return true;
  6.1056 -    }
  6.1057 -
  6.1058 -    public String getDescription() { return "Java source files"; }
  6.1059 -  }
  6.1060 -
  6.1061 -  // Auxiliary information used only for Java source files
  6.1062 -  static class JavaUserData {
  6.1063 -    private String packageName; // External format
  6.1064 -    private String sourceFileName;
  6.1065 -
  6.1066 -    /** Source file name is equivalent to that found in the .java
  6.1067 -        file; i.e., not a full path */
  6.1068 -    JavaUserData(String packageName, String sourceFileName) {
  6.1069 -      this.packageName = packageName;
  6.1070 -      this.sourceFileName = sourceFileName;
  6.1071 -    }
  6.1072 -
  6.1073 -    String packageName()    { return packageName; }
  6.1074 -    String sourceFileName() { return sourceFileName; }
  6.1075 -  }
  6.1076 -
  6.1077 -  // Opens a source file. This makes it available for the setting of
  6.1078 -  // lazy breakpoints.
  6.1079 -  private void openSourceFile() {
  6.1080 -    JFileChooser chooser = new JFileChooser();
  6.1081 -    chooser.setDialogTitle("Open source code file");
  6.1082 -    chooser.setMultiSelectionEnabled(false);
  6.1083 -    if (chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
  6.1084 -      return;
  6.1085 -    }
  6.1086 -    File chosen = chooser.getSelectedFile();
  6.1087 -    if (chosen == null) {
  6.1088 -      return;
  6.1089 -    }
  6.1090 -
  6.1091 -    // See whether we have a Java source file. If so, derive a package
  6.1092 -    // name for it.
  6.1093 -    String path = chosen.getPath();
  6.1094 -    String name = null;
  6.1095 -    JavaUserData data = null;
  6.1096 -    if (path.endsWith(".java")) {
  6.1097 -      PackageScanner scanner = new PackageScanner();
  6.1098 -      String pkg = scanner.scan(chosen);
  6.1099 -      // Now knowing both the package name and file name, we can put
  6.1100 -      // this in the editor map and use it for setting breakpoints
  6.1101 -      // later
  6.1102 -      String fileName = chosen.getName();
  6.1103 -      name = pkg + "." + fileName;
  6.1104 -      data = new JavaUserData(pkg, fileName);
  6.1105 -    } else {
  6.1106 -      // FIXME: need pathmap mechanism
  6.1107 -      name = path;
  6.1108 -    }
  6.1109 -    Editor editor = (Editor) editors.get(name);
  6.1110 -    if (editor == null) {
  6.1111 -      editor = editorFact.openFile(path, editorComm);
  6.1112 -      if (editor == null) {
  6.1113 -        showMessageDialog("Unable to open file \"" + path + "\" -- unexpected error.",
  6.1114 -                          "Unable to open file",
  6.1115 -                          JOptionPane.WARNING_MESSAGE);
  6.1116 -        return;
  6.1117 -      }
  6.1118 -      editors.put(name, editor);
  6.1119 -      if (data != null) {
  6.1120 -        editor.setUserData(data);
  6.1121 -      }
  6.1122 -    } else {
  6.1123 -      editor.toFront();
  6.1124 -    }
  6.1125 -    editor.showLineNumber(1);
  6.1126 -    // Show breakpoints as well if we have any for this file
  6.1127 -    Set set = (Set) fileToBreakpointMap.get(editor.getSourceFileName());
  6.1128 -    if (set != null) {
  6.1129 -      for (Iterator iter = set.iterator(); iter.hasNext(); ) {
  6.1130 -        editor.showBreakpointAtLine(((Integer) iter.next()).intValue());
  6.1131 -      }
  6.1132 -    }
  6.1133 -  }
  6.1134 -
  6.1135 -  // Package name may be null, in which case the file is assumed to be
  6.1136 -  // a C source file. Otherwise it is assumed to be a Java source file
  6.1137 -  // and certain filtering rules will be applied.
  6.1138 -  private void showLineNumber(String packageName, String fileName, int lineNumber) {
  6.1139 -    String name;
  6.1140 -    if (packageName == null) {
  6.1141 -      name = fileName;
  6.1142 -    } else {
  6.1143 -      name = packageName + "." + fileName;
  6.1144 -    }
  6.1145 -    Editor editor = (Editor) editors.get(name);
  6.1146 -    if (editor == null) {
  6.1147 -      // See whether file exists
  6.1148 -      File file = new File(fileName);
  6.1149 -      String realFileName = fileName;
  6.1150 -      if (!file.exists()) {
  6.1151 -        // User must specify path to file
  6.1152 -        JFileChooser chooser = new JFileChooser();
  6.1153 -        chooser.setDialogTitle("Please locate " + fileName);
  6.1154 -        chooser.setMultiSelectionEnabled(false);
  6.1155 -        if (packageName != null) {
  6.1156 -          chooser.setFileFilter(new JavaFileFilter(packageName, fileName));
  6.1157 -        }
  6.1158 -        int res = chooser.showOpenDialog(null);
  6.1159 -        if (res != JFileChooser.APPROVE_OPTION) {
  6.1160 -          // FIXME: show disassembly instead
  6.1161 -          return;
  6.1162 -        }
  6.1163 -        // FIXME: would like to infer more from the selection; i.e.,
  6.1164 -        // a pathmap leading up to this file
  6.1165 -        File chosen = chooser.getSelectedFile();
  6.1166 -        if (chosen == null) {
  6.1167 -          return;
  6.1168 -        }
  6.1169 -        realFileName = chosen.getPath();
  6.1170 -      }
  6.1171 -      // Now instruct editor factory to open file
  6.1172 -      editor = editorFact.openFile(realFileName, editorComm);
  6.1173 -      if (editor == null) {
  6.1174 -        showMessageDialog("Unable to open file \"" + realFileName + "\" -- unexpected error.",
  6.1175 -                          "Unable to open file",
  6.1176 -                          JOptionPane.WARNING_MESSAGE);
  6.1177 -        return;
  6.1178 -      }
  6.1179 -      // Got an editor; put it in map
  6.1180 -      editors.put(name, editor);
  6.1181 -      // If Java source file, add additional information for later
  6.1182 -      if (packageName != null) {
  6.1183 -        editor.setUserData(new JavaUserData(packageName, fileName));
  6.1184 -      }
  6.1185 -    }
  6.1186 -    // Got editor; show line
  6.1187 -    editor.showLineNumber(lineNumber);
  6.1188 -    editor.highlightLineNumber(lineNumber);
  6.1189 -    // Show breakpoints as well if we have any for this file
  6.1190 -    Set set = (Set) fileToBreakpointMap.get(editor.getSourceFileName());
  6.1191 -    if (set != null) {
  6.1192 -      for (Iterator iter = set.iterator(); iter.hasNext(); ) {
  6.1193 -        editor.showBreakpointAtLine(((Integer) iter.next()).intValue());
  6.1194 -      }
  6.1195 -    }
  6.1196 -  }
  6.1197 -
  6.1198 -  //
  6.1199 -  // Suspend/resume
  6.1200 -  //
  6.1201 -
  6.1202 -  private boolean isSuspended() {
  6.1203 -    return suspended;
  6.1204 -  }
  6.1205 -
  6.1206 -  private synchronized void suspend() {
  6.1207 -    setMenuItemsEnabled(resumeDebugMenuItems, true);
  6.1208 -    setMenuItemsEnabled(suspendDebugMenuItems, false);
  6.1209 -    BugSpotAgent agent = getAgent();
  6.1210 -    if (agent.canInteractWithJava() && !agent.isJavaSuspended()) {
  6.1211 -      agent.suspendJava();
  6.1212 -    }
  6.1213 -    agent.suspend();
  6.1214 -    // FIXME: call VM.getVM().fireVMSuspended()
  6.1215 -    resetCurrentThread();
  6.1216 -    debugEventTimer.stop();
  6.1217 -    suspended = true;
  6.1218 -  }
  6.1219 -
  6.1220 -  private synchronized void resume() {
  6.1221 -    // Note: we don't wipe out the cached state like the
  6.1222 -    // sourceFileToLineNumberInfoMap since it is too expensive to
  6.1223 -    // recompute. Instead we recompute it if any DLLs are loaded or
  6.1224 -    // unloaded.
  6.1225 -    threadToJavaThreadMap = null;
  6.1226 -    setMenuItemsEnabled(resumeDebugMenuItems, false);
  6.1227 -    setMenuItemsEnabled(suspendDebugMenuItems, true);
  6.1228 -    registerPanel.clear();
  6.1229 -    // FIXME: call VM.getVM().fireVMResumed()
  6.1230 -    BugSpotAgent agent = getAgent();
  6.1231 -    agent.resume();
  6.1232 -    if (agent.canInteractWithJava()) {
  6.1233 -      if (agent.isJavaSuspended()) {
  6.1234 -        agent.resumeJava();
  6.1235 -      }
  6.1236 -      if (javaEventPending) {
  6.1237 -        javaEventPending = false;
  6.1238 -        // Clear it out before resuming polling for events
  6.1239 -        agent.javaEventContinue();
  6.1240 -      }
  6.1241 -    }
  6.1242 -    agent.enableJavaInteraction();
  6.1243 -    suspended = false;
  6.1244 -    debugEventTimer.start();
  6.1245 -  }
  6.1246 -
  6.1247 -  //
  6.1248 -  // Breakpoints
  6.1249 -  //
  6.1250 -
  6.1251 -  private synchronized BreakpointResult handleBreakpointToggle(Editor editor, int lineNumber) {
  6.1252 -    // Currently we only use user data in editors to indicate Java
  6.1253 -    // source files. If this changes then this code will need to
  6.1254 -    // change.
  6.1255 -    JavaUserData data = (JavaUserData) editor.getUserData();
  6.1256 -    String filename = editor.getSourceFileName();
  6.1257 -    if (data == null) {
  6.1258 -      // C/C++ code
  6.1259 -      // FIXME: as noted above in EditorCommands.toggleBreakpointAtLine,
  6.1260 -      // this needs more work to handle "lazy" breakpoints in files
  6.1261 -      // which we don't know about in the debug information yet
  6.1262 -      CDebugger dbg = getCDebugger();
  6.1263 -      ProcessControl prctl = dbg.getProcessControl();
  6.1264 -      if (prctl == null) {
  6.1265 -        return new BreakpointResult(false, false, 0, "Process control not enabled");
  6.1266 -      }
  6.1267 -      boolean mustSuspendAndResume = (!prctl.isSuspended());
  6.1268 -      try {
  6.1269 -        if (mustSuspendAndResume) {
  6.1270 -          prctl.suspend();
  6.1271 -        }
  6.1272 -        // Search debug info for all DSOs
  6.1273 -        LineNumberInfo info = getLineNumberInfo(filename, lineNumber);
  6.1274 -        if (info != null) {
  6.1275 -          Set bpset = (Set) fileToBreakpointMap.get(filename);
  6.1276 -          if (bpset == null) {
  6.1277 -            bpset = new HashSet();
  6.1278 -            fileToBreakpointMap.put(filename, bpset);
  6.1279 -          }
  6.1280 -          Integer key = new Integer(info.getLineNumber());
  6.1281 -          if (bpset.contains(key)) {
  6.1282 -            // Clear breakpoint at this line's PC
  6.1283 -            prctl.clearBreakpoint(info.getStartPC());
  6.1284 -            bpset.remove(key);
  6.1285 -            return new BreakpointResult(true, false, info.getLineNumber());
  6.1286 -          } else {
  6.1287 -            // Set breakpoint at this line's PC
  6.1288 -            System.err.println("Setting breakpoint at PC " + info.getStartPC());
  6.1289 -            prctl.setBreakpoint(info.getStartPC());
  6.1290 -            bpset.add(key);
  6.1291 -            return new BreakpointResult(true, true, info.getLineNumber());
  6.1292 -          }
  6.1293 -        } else {
  6.1294 -          return new BreakpointResult(false, false, 0, "No debug information for this source file and line");
  6.1295 -        }
  6.1296 -      } finally {
  6.1297 -        if (mustSuspendAndResume) {
  6.1298 -          prctl.resume();
  6.1299 -        }
  6.1300 -      }
  6.1301 -    } else {
  6.1302 -      BugSpotAgent agent = getAgent();
  6.1303 -      if (!agent.canInteractWithJava()) {
  6.1304 -        String why;
  6.1305 -        if (agent.isJavaInteractionDisabled()) {
  6.1306 -          why = "Can not toggle Java breakpoints while stopped because\nof C/C++ debug events (breakpoints, single-stepping)";
  6.1307 -        } else {
  6.1308 -          why = "Could not talk to SA's JVMDI module to enable Java\nprogramming language breakpoints (run with -Xdebug -Xrunsa)";
  6.1309 -        }
  6.1310 -        return new BreakpointResult(false, false, 0, why);
  6.1311 -      }
  6.1312 -      Set bpset = (Set) fileToBreakpointMap.get(filename);
  6.1313 -      if (bpset == null) {
  6.1314 -        bpset = new HashSet();
  6.1315 -        fileToBreakpointMap.put(filename, bpset);
  6.1316 -      }
  6.1317 -      boolean mustResumeAndSuspend = isSuspended();
  6.1318 -      try {
  6.1319 -        if (mustResumeAndSuspend) {
  6.1320 -          agent.resume();
  6.1321 -        }
  6.1322 -        ServiceabilityAgentJVMDIModule.BreakpointToggleResult res =
  6.1323 -          getAgent().toggleJavaBreakpoint(data.sourceFileName(),
  6.1324 -                                          data.packageName(),
  6.1325 -                                          lineNumber);
  6.1326 -        if (res.getSuccess()) {
  6.1327 -          Integer key = new Integer(res.getLineNumber());
  6.1328 -          boolean addRemRes = false;
  6.1329 -          if (res.getWasSet()) {
  6.1330 -            addRemRes = bpset.add(key);
  6.1331 -            System.err.println("Setting breakpoint at " + res.getMethodName() + res.getMethodSignature() +
  6.1332 -                               ", bci " + res.getBCI() + ", line " + res.getLineNumber());
  6.1333 -          } else {
  6.1334 -            addRemRes = bpset.remove(key);
  6.1335 -            System.err.println("Clearing breakpoint at " + res.getMethodName() + res.getMethodSignature() +
  6.1336 -                               ", bci " + res.getBCI() + ", line " + res.getLineNumber());
  6.1337 -          }
  6.1338 -          if (Assert.ASSERTS_ENABLED) {
  6.1339 -            Assert.that(addRemRes, "Inconsistent Java breakpoint state with respect to target process");
  6.1340 -          }
  6.1341 -          return new BreakpointResult(true, res.getWasSet(), res.getLineNumber());
  6.1342 -        } else {
  6.1343 -          return new BreakpointResult(false, false, 0, res.getErrMsg());
  6.1344 -        }
  6.1345 -      } finally {
  6.1346 -        if (mustResumeAndSuspend) {
  6.1347 -          agent.suspend();
  6.1348 -          resetCurrentThread();
  6.1349 -        }
  6.1350 -      }
  6.1351 -    }
  6.1352 -  }
  6.1353 -
  6.1354 -  // Must call only when suspended
  6.1355 -  private LineNumberInfo getLineNumberInfo(String filename, int lineNumber) {
  6.1356 -    Map map = getSourceFileToLineNumberInfoMap();
  6.1357 -    java.util.List infos = (java.util.List) map.get(filename);
  6.1358 -    if (infos == null) {
  6.1359 -      return null;
  6.1360 -    }
  6.1361 -    // Binary search for line number
  6.1362 -    return searchLineNumbers(infos, lineNumber, 0, infos.size());
  6.1363 -  }
  6.1364 -
  6.1365 -  // Must call only when suspended
  6.1366 -  private Map getSourceFileToLineNumberInfoMap() {
  6.1367 -    if (sourceFileToLineNumberInfoMap == null) {
  6.1368 -      // Build from debug info
  6.1369 -      java.util.List loadObjects = getCDebugger().getLoadObjectList();
  6.1370 -      final Map map = new HashMap();
  6.1371 -      for (Iterator iter = loadObjects.iterator(); iter.hasNext(); ) {
  6.1372 -        LoadObject lo = (LoadObject) iter.next();
  6.1373 -        CDebugInfoDataBase db = lo.getDebugInfoDataBase();
  6.1374 -        if (db != null) {
  6.1375 -          db.iterate(new LineNumberVisitor() {
  6.1376 -              public void doLineNumber(LineNumberInfo info) {
  6.1377 -                String name = info.getSourceFileName();
  6.1378 -                if (name != null) {
  6.1379 -                  java.util.List val = (java.util.List) map.get(name);
  6.1380 -                  if (val == null) {
  6.1381 -                    val = new ArrayList();
  6.1382 -                    map.put(name, val);
  6.1383 -                  }
  6.1384 -                  val.add(info);
  6.1385 -                }
  6.1386 -              }
  6.1387 -            });
  6.1388 -        }
  6.1389 -      }
  6.1390 -      // Sort all lists
  6.1391 -      for (Iterator iter = map.values().iterator(); iter.hasNext(); ) {
  6.1392 -        java.util.List list = (java.util.List) iter.next();
  6.1393 -        Collections.sort(list, new Comparator() {
  6.1394 -            public int compare(Object o1, Object o2) {
  6.1395 -              LineNumberInfo l1 = (LineNumberInfo) o1;
  6.1396 -              LineNumberInfo l2 = (LineNumberInfo) o2;
  6.1397 -              int n1 = l1.getLineNumber();
  6.1398 -              int n2 = l2.getLineNumber();
  6.1399 -              if (n1 < n2) return -1;
  6.1400 -              if (n1 == n2) return 0;
  6.1401 -              return 1;
  6.1402 -            }
  6.1403 -          });
  6.1404 -      }
  6.1405 -      sourceFileToLineNumberInfoMap = map;
  6.1406 -    }
  6.1407 -    return sourceFileToLineNumberInfoMap;
  6.1408 -  }
  6.1409 -
  6.1410 -  private LineNumberInfo searchLineNumbers(java.util.List infoList, int lineNo, int lowIdx, int highIdx) {
  6.1411 -    if (highIdx < lowIdx) return null;
  6.1412 -    if (lowIdx == highIdx) {
  6.1413 -      // Base case: see whether start PC is less than or equal to addr
  6.1414 -      if (checkLineNumber(infoList, lineNo, lowIdx)) {
  6.1415 -        return (LineNumberInfo) infoList.get(lowIdx);
  6.1416 -      } else {
  6.1417 -        return null;
  6.1418 -      }
  6.1419 -    } else if (lowIdx == highIdx - 1) {
  6.1420 -      if (checkLineNumber(infoList, lineNo, lowIdx)) {
  6.1421 -        return (LineNumberInfo) infoList.get(lowIdx);
  6.1422 -      } else if (checkLineNumber(infoList, lineNo, highIdx)) {
  6.1423 -        return (LineNumberInfo) infoList.get(highIdx);
  6.1424 -      } else {
  6.1425 -        return null;
  6.1426 -      }
  6.1427 -    }
  6.1428 -    int midIdx = (lowIdx + highIdx) >> 1;
  6.1429 -    LineNumberInfo info = (LineNumberInfo) infoList.get(midIdx);
  6.1430 -    if (lineNo < info.getLineNumber()) {
  6.1431 -      // Always move search down
  6.1432 -      return searchLineNumbers(infoList, lineNo, lowIdx, midIdx);
  6.1433 -    } else if (lineNo == info.getLineNumber()) {
  6.1434 -      return info;
  6.1435 -    } else {
  6.1436 -      // Move search up
  6.1437 -      return searchLineNumbers(infoList, lineNo, midIdx, highIdx);
  6.1438 -    }
  6.1439 -  }
  6.1440 -
  6.1441 -  private boolean checkLineNumber(java.util.List infoList, int lineNo, int idx) {
  6.1442 -    LineNumberInfo info = (LineNumberInfo) infoList.get(idx);
  6.1443 -    return (info.getLineNumber() >= lineNo);
  6.1444 -  }
  6.1445 -
  6.1446 -  //
  6.1447 -  // Debug events
  6.1448 -  //
  6.1449 -
  6.1450 -  private synchronized void pollForDebugEvent() {
  6.1451 -    ProcessControl prctl = getCDebugger().getProcessControl();
  6.1452 -    if (prctl == null) {
  6.1453 -      return;
  6.1454 -    }
  6.1455 -    DebugEvent ev = prctl.debugEventPoll();
  6.1456 -    if (ev != null) {
  6.1457 -      DebugEvent.Type t = ev.getType();
  6.1458 -      if (t == DebugEvent.Type.LOADOBJECT_LOAD ||
  6.1459 -          t == DebugEvent.Type.LOADOBJECT_UNLOAD) {
  6.1460 -        // Conservatively clear cached debug info state
  6.1461 -        sourceFileToLineNumberInfoMap = null;
  6.1462 -        // FIXME: would be very useful to have "stop on load/unload"
  6.1463 -        // events
  6.1464 -        // FIXME: must do work at these events to implement lazy
  6.1465 -        // breakpoints
  6.1466 -        prctl.debugEventContinue();
  6.1467 -      } else if (t == DebugEvent.Type.BREAKPOINT) {
  6.1468 -        // Note: Visual C++ only notifies on breakpoints it doesn't
  6.1469 -        // know about
  6.1470 -
  6.1471 -        // FIXME: put back test
  6.1472 -        //        if (!prctl.isBreakpointSet(ev.getPC())) {
  6.1473 -          showMessageDialog("Breakpoint reached at PC " + ev.getPC(),
  6.1474 -                            "Breakpoint reached",
  6.1475 -                            JOptionPane.INFORMATION_MESSAGE);
  6.1476 -          //        }
  6.1477 -        agent.disableJavaInteraction();
  6.1478 -        suspend();
  6.1479 -        prctl.debugEventContinue();
  6.1480 -      } else if (t == DebugEvent.Type.SINGLE_STEP) {
  6.1481 -        agent.disableJavaInteraction();
  6.1482 -        suspend();
  6.1483 -        prctl.debugEventContinue();
  6.1484 -      } else if (t == DebugEvent.Type.ACCESS_VIOLATION) {
  6.1485 -        showMessageDialog("Access violation attempting to " +
  6.1486 -                          (ev.getWasWrite() ? "write" : "read") +
  6.1487 -                          " address " + ev.getAddress() +
  6.1488 -                          " at PC " + ev.getPC(),
  6.1489 -                          "Access Violation",
  6.1490 -                          JOptionPane.WARNING_MESSAGE);
  6.1491 -        agent.disableJavaInteraction();
  6.1492 -        suspend();
  6.1493 -        prctl.debugEventContinue();
  6.1494 -      } else {
  6.1495 -        String info = "Unknown debug event encountered";
  6.1496 -        if (ev.getUnknownEventDetail() != null) {
  6.1497 -          info = info + ": " + ev.getUnknownEventDetail();
  6.1498 -        }
  6.1499 -        showMessageDialog(info, "Unknown debug event", JOptionPane.INFORMATION_MESSAGE);
  6.1500 -        suspend();
  6.1501 -        prctl.debugEventContinue();
  6.1502 -      }
  6.1503 -      return;
  6.1504 -    }
  6.1505 -
  6.1506 -    // No C++ debug event; poll for Java debug event
  6.1507 -    if (getAgent().canInteractWithJava()) {
  6.1508 -      if (!javaEventPending) {
  6.1509 -        if (getAgent().javaEventPending()) {
  6.1510 -          suspend();
  6.1511 -          // This does a lot of work and we want to have the page
  6.1512 -          // cache available to us as it runs
  6.1513 -          sun.jvm.hotspot.livejvm.Event jev = getAgent().javaEventPoll();
  6.1514 -          if (jev != null) {
  6.1515 -            javaEventPending = true;
  6.1516 -            if (jev.getType() == sun.jvm.hotspot.livejvm.Event.Type.BREAKPOINT) {
  6.1517 -              BreakpointEvent bpev = (BreakpointEvent) jev;
  6.1518 -              showMessageDialog("Breakpoint reached in method\n" +
  6.1519 -                                bpev.methodID().method().externalNameAndSignature() +
  6.1520 -                                ",\nbci " + bpev.location(),
  6.1521 -                                "Breakpoint reached",
  6.1522 -                                JOptionPane.INFORMATION_MESSAGE);
  6.1523 -            } else if (jev.getType() == sun.jvm.hotspot.livejvm.Event.Type.EXCEPTION) {
  6.1524 -              ExceptionEvent exev = (ExceptionEvent) jev;
  6.1525 -              showMessageDialog(exev.exception().getKlass().getName().asString() +
  6.1526 -                                "\nthrown in method\n" +
  6.1527 -                                exev.methodID().method().externalNameAndSignature() +
  6.1528 -                                "\nat BCI " + exev.location(),
  6.1529 -                                "Exception thrown",
  6.1530 -                                JOptionPane.INFORMATION_MESSAGE);
  6.1531 -            } else {
  6.1532 -              Assert.that(false, "Should not reach here");
  6.1533 -            }
  6.1534 -          }
  6.1535 -        }
  6.1536 -      }
  6.1537 -    }
  6.1538 -  }
  6.1539 -}
     7.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java	Thu Feb 21 07:50:48 2013 -0500
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,799 +0,0 @@
     7.4 -/*
     7.5 - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
     7.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 - *
     7.8 - * This code is free software; you can redistribute it and/or modify it
     7.9 - * under the terms of the GNU General Public License version 2 only, as
    7.10 - * published by the Free Software Foundation.
    7.11 - *
    7.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    7.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.15 - * version 2 for more details (a copy is included in the LICENSE file that
    7.16 - * accompanied this code).
    7.17 - *
    7.18 - * You should have received a copy of the GNU General Public License version
    7.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    7.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.21 - *
    7.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.23 - * or visit www.oracle.com if you need additional information or have any
    7.24 - * questions.
    7.25 - *
    7.26 - */
    7.27 -
    7.28 -package sun.jvm.hotspot.bugspot;
    7.29 -
    7.30 -import java.io.PrintStream;
    7.31 -import java.net.*;
    7.32 -import java.rmi.*;
    7.33 -import sun.jvm.hotspot.*;
    7.34 -import sun.jvm.hotspot.debugger.*;
    7.35 -import sun.jvm.hotspot.debugger.bsd.*;
    7.36 -import sun.jvm.hotspot.debugger.proc.*;
    7.37 -import sun.jvm.hotspot.debugger.cdbg.*;
    7.38 -import sun.jvm.hotspot.debugger.windbg.*;
    7.39 -import sun.jvm.hotspot.debugger.linux.*;
    7.40 -import sun.jvm.hotspot.debugger.sparc.*;
    7.41 -import sun.jvm.hotspot.debugger.remote.*;
    7.42 -import sun.jvm.hotspot.livejvm.*;
    7.43 -import sun.jvm.hotspot.memory.*;
    7.44 -import sun.jvm.hotspot.oops.*;
    7.45 -import sun.jvm.hotspot.runtime.*;
    7.46 -import sun.jvm.hotspot.types.*;
    7.47 -import sun.jvm.hotspot.utilities.*;
    7.48 -
    7.49 -/** <P> This class wraps the basic functionality for connecting to the
    7.50 - * target process or debug server. It makes it simple to start up the
    7.51 - * debugging system. </P>
    7.52 - *
    7.53 - * <P> This agent (as compared to the HotSpotAgent) can connect to
    7.54 - * and interact with arbitrary processes. If the target process
    7.55 - * happens to be a HotSpot JVM, the Java debugging features of the
    7.56 - * Serviceability Agent are enabled. Further, if the Serviceability
    7.57 - * Agent's JVMDI module is loaded into the target VM, interaction
    7.58 - * with the live Java program is possible, specifically the catching
    7.59 - * of exceptions and setting of breakpoints. </P>
    7.60 - *
    7.61 - * <P> The BugSpot debugger requires that the underlying Debugger
    7.62 - * support C/C++ debugging via the CDebugger interface. </P>
    7.63 - *
    7.64 - * <P> FIXME: especially with the addition of remote debugging, this
    7.65 - * has turned into a mess; needs rethinking. </P> */
    7.66 -
    7.67 -public class BugSpotAgent {
    7.68 -
    7.69 -    private JVMDebugger debugger;
    7.70 -    private MachineDescription machDesc;
    7.71 -    private TypeDataBase db;
    7.72 -
    7.73 -    private String os;
    7.74 -    private String cpu;
    7.75 -    private String fileSep;
    7.76 -
    7.77 -    // The system can work in several ways:
    7.78 -    //  - Attaching to local process
    7.79 -    //  - Attaching to local core file
    7.80 -    //  - Connecting to remote debug server
    7.81 -    //  - Starting debug server for process
    7.82 -    //  - Starting debug server for core file
    7.83 -
    7.84 -    // These are options for the "client" side of things
    7.85 -    private static final int PROCESS_MODE   = 0;
    7.86 -    private static final int CORE_FILE_MODE = 1;
    7.87 -    private static final int REMOTE_MODE    = 2;
    7.88 -    private int startupMode;
    7.89 -
    7.90 -    // This indicates whether we are really starting a server or not
    7.91 -    private boolean isServer;
    7.92 -
    7.93 -    // All possible required information for connecting
    7.94 -    private int pid;
    7.95 -    private String executableName;
    7.96 -    private String coreFileName;
    7.97 -    private String debugServerID;
    7.98 -
    7.99 -    // All needed information for server side
   7.100 -    private String serverID;
   7.101 -
   7.102 -    // Indicates whether we are attached to a HotSpot JVM or not
   7.103 -    private boolean javaMode;
   7.104 -
   7.105 -    // Indicates whether we have process control over a live HotSpot JVM
   7.106 -    // or not; non-null if so.
   7.107 -    private ServiceabilityAgentJVMDIModule jvmdi;
   7.108 -    // While handling C breakpoints interactivity with the Java program
   7.109 -    // is forbidden. Too many invariants are broken while the target is
   7.110 -    // stopped at a C breakpoint to risk making JVMDI calls.
   7.111 -    private boolean javaInteractionDisabled;
   7.112 -
   7.113 -    private String[] jvmLibNames;
   7.114 -    private String[] saLibNames;
   7.115 -
   7.116 -    // FIXME: make these configurable, i.e., via a dotfile; also
   7.117 -    // consider searching within the JDK from which this Java executable
   7.118 -    // comes to find them
   7.119 -    private static final String defaultDbxPathPrefix                = "/net/jano.eng/export/disk05/hotspot/sa";
   7.120 -    private static final String defaultDbxSvcAgentDSOPathPrefix     = "/net/jano.eng/export/disk05/hotspot/sa";
   7.121 -
   7.122 -    private static final boolean DEBUG;
   7.123 -    static {
   7.124 -        DEBUG = System.getProperty("sun.jvm.hotspot.bugspot.BugSpotAgent.DEBUG")
   7.125 -        != null;
   7.126 -    }
   7.127 -
   7.128 -    static void debugPrintln(String str) {
   7.129 -        if (DEBUG) {
   7.130 -            System.err.println(str);
   7.131 -        }
   7.132 -    }
   7.133 -
   7.134 -    static void showUsage() {
   7.135 -        System.out.println("    You can also pass these -D options to java to specify where to find dbx and the \n" +
   7.136 -        "    Serviceability Agent plugin for dbx:");
   7.137 -        System.out.println("       -DdbxPathName=<path-to-dbx-executable>\n" +
   7.138 -        "             Default is derived from dbxPathPrefix");
   7.139 -        System.out.println("    or");
   7.140 -        System.out.println("       -DdbxPathPrefix=<xxx>\n" +
   7.141 -        "             where xxx is the path name of a dir structure that contains:\n" +
   7.142 -        "                   <os>/<arch>/bin/dbx\n" +
   7.143 -        "             The default is " + defaultDbxPathPrefix);
   7.144 -        System.out.println("    and");
   7.145 -        System.out.println("       -DdbxSvcAgentDSOPathName=<path-to-dbx-serviceability-agent-module>\n" +
   7.146 -        "             Default is determined from dbxSvcAgentDSOPathPrefix");
   7.147 -        System.out.println("    or");
   7.148 -        System.out.println("       -DdbxSvcAgentDSOPathPrefix=<xxx>\n" +
   7.149 -        "             where xxx is the pathname of a dir structure that contains:\n" +
   7.150 -        "                   <os>/<arch>/bin/lib/libsvc_agent_dbx.so\n" +
   7.151 -        "             The default is " + defaultDbxSvcAgentDSOPathPrefix);
   7.152 -    }
   7.153 -
   7.154 -    public BugSpotAgent() {
   7.155 -        // for non-server add shutdown hook to clean-up debugger in case
   7.156 -        // of forced exit. For remote server, shutdown hook is added by
   7.157 -        // DebugServer.
   7.158 -        Runtime.getRuntime().addShutdownHook(new java.lang.Thread(
   7.159 -        new Runnable() {
   7.160 -            public void run() {
   7.161 -                synchronized (BugSpotAgent.this) {
   7.162 -                    if (!isServer) {
   7.163 -                        detach();
   7.164 -                    }
   7.165 -                }
   7.166 -            }
   7.167 -        }));
   7.168 -    }
   7.169 -
   7.170 -    //--------------------------------------------------------------------------------
   7.171 -    // Accessors (once the system is set up)
   7.172 -    //
   7.173 -
   7.174 -    public synchronized Debugger getDebugger() {
   7.175 -        return debugger;
   7.176 -    }
   7.177 -
   7.178 -    public synchronized CDebugger getCDebugger() {
   7.179 -        return getDebugger().getCDebugger();
   7.180 -    }
   7.181 -
   7.182 -    public synchronized ProcessControl getProcessControl() {
   7.183 -        return getCDebugger().getProcessControl();
   7.184 -    }
   7.185 -
   7.186 -    public synchronized TypeDataBase getTypeDataBase() {
   7.187 -        return db;
   7.188 -    }
   7.189 -
   7.190 -    /** Indicates whether the target process is suspended
   7.191 -      completely. Equivalent to getProcessControl().isSuspended(). */
   7.192 -    public synchronized boolean isSuspended() throws DebuggerException {
   7.193 -        return getProcessControl().isSuspended();
   7.194 -    }
   7.195 -
   7.196 -    /** Suspends the target process completely. Equivalent to
   7.197 -      getProcessControl().suspend(). */
   7.198 -    public synchronized void suspend() throws DebuggerException {
   7.199 -        getProcessControl().suspend();
   7.200 -    }
   7.201 -
   7.202 -    /** Resumes the target process completely. Equivalent to
   7.203 -      getProcessControl().suspend(). */
   7.204 -    public synchronized void resume() throws DebuggerException {
   7.205 -        getProcessControl().resume();
   7.206 -    }
   7.207 -
   7.208 -    /** Indicates whether we are attached to a Java HotSpot virtual
   7.209 -      machine */
   7.210 -    public synchronized boolean isJavaMode() {
   7.211 -        return javaMode;
   7.212 -    }
   7.213 -
   7.214 -    /** Temporarily disables interaction with the target process via
   7.215 -      JVMDI. This is done while the target process is stopped at a C
   7.216 -      breakpoint. Can be called even if the JVMDI agent has not been
   7.217 -      initialized. */
   7.218 -    public synchronized void disableJavaInteraction() {
   7.219 -        javaInteractionDisabled = true;
   7.220 -    }
   7.221 -
   7.222 -    /** Re-enables interaction with the target process via JVMDI. This
   7.223 -      is done while the target process is continued past a C
   7.224 -      braekpoint. Can be called even if the JVMDI agent has not been
   7.225 -      initialized. */
   7.226 -    public synchronized void enableJavaInteraction() {
   7.227 -        javaInteractionDisabled = false;
   7.228 -    }
   7.229 -
   7.230 -    /** Indicates whether Java interaction has been disabled */
   7.231 -    public synchronized boolean isJavaInteractionDisabled() {
   7.232 -        return javaInteractionDisabled;
   7.233 -    }
   7.234 -
   7.235 -    /** Indicates whether we can talk to the Serviceability Agent's
   7.236 -      JVMDI module to be able to set breakpoints */
   7.237 -    public synchronized boolean canInteractWithJava() {
   7.238 -        return (jvmdi != null) && !javaInteractionDisabled;
   7.239 -    }
   7.240 -
   7.241 -    /** Suspends all Java threads in the target process. Can only be
   7.242 -      called if we are attached to a HotSpot JVM and can connect to
   7.243 -      the SA's JVMDI module. Must not be called when the target
   7.244 -      process has been suspended with suspend(). */
   7.245 -    public synchronized void suspendJava() throws DebuggerException {
   7.246 -        if (!canInteractWithJava()) {
   7.247 -            throw new DebuggerException("Could not connect to SA's JVMDI module");
   7.248 -        }
   7.249 -        if (jvmdi.isSuspended()) {
   7.250 -            throw new DebuggerException("Target process already suspended via JVMDI");
   7.251 -        }
   7.252 -        jvmdi.suspend();
   7.253 -    }
   7.254 -
   7.255 -    /** Resumes all Java threads in the target process. Can only be
   7.256 -      called if we are attached to a HotSpot JVM and can connect to
   7.257 -      the SA's JVMDI module. Must not be called when the target
   7.258 -      process has been suspended with suspend(). */
   7.259 -    public synchronized void resumeJava() throws DebuggerException {
   7.260 -        if (!canInteractWithJava()) {
   7.261 -            throw new DebuggerException("Could not connect to SA's JVMDI module");
   7.262 -        }
   7.263 -        if (!jvmdi.isSuspended()) {
   7.264 -            throw new DebuggerException("Target process already resumed via JVMDI");
   7.265 -        }
   7.266 -        jvmdi.resume();
   7.267 -    }
   7.268 -
   7.269 -    /** Indicates whether the target process has been suspended at the
   7.270 -      Java language level via the SA's JVMDI module */
   7.271 -    public synchronized boolean isJavaSuspended() throws DebuggerException {
   7.272 -        return jvmdi.isSuspended();
   7.273 -    }
   7.274 -
   7.275 -    /** Toggle a Java breakpoint at the given location. */
   7.276 -    public synchronized ServiceabilityAgentJVMDIModule.BreakpointToggleResult
   7.277 -    toggleJavaBreakpoint(String srcFileName,
   7.278 -    String pkgName,
   7.279 -    int lineNo) {
   7.280 -        if (!canInteractWithJava()) {
   7.281 -            throw new DebuggerException("Could not connect to SA's JVMDI module; can not toggle Java breakpoints");
   7.282 -        }
   7.283 -        return jvmdi.toggleBreakpoint(srcFileName, pkgName, lineNo);
   7.284 -    }
   7.285 -
   7.286 -    /** Access to JVMDI module's eventPending */
   7.287 -    public synchronized boolean javaEventPending() throws DebuggerException {
   7.288 -        if (!canInteractWithJava()) {
   7.289 -            throw new DebuggerException("Could not connect to SA's JVMDI module; can not poll for Java debug events");
   7.290 -        }
   7.291 -        return jvmdi.eventPending();
   7.292 -    }
   7.293 -
   7.294 -    /** Access to JVMDI module's eventPoll */
   7.295 -    public synchronized Event javaEventPoll() throws DebuggerException {
   7.296 -        if (!canInteractWithJava()) {
   7.297 -            throw new DebuggerException("Could not connect to SA's JVMDI module; can not poll for Java debug events");
   7.298 -        }
   7.299 -        return jvmdi.eventPoll();
   7.300 -    }
   7.301 -
   7.302 -    /** Access to JVMDI module's eventContinue */
   7.303 -    public synchronized void javaEventContinue() throws DebuggerException {
   7.304 -        if (!canInteractWithJava()) {
   7.305 -            throw new DebuggerException("Could not connect to SA's JVMDI module; can not continue past Java debug events");
   7.306 -        }
   7.307 -        jvmdi.eventContinue();
   7.308 -    }
   7.309 -
   7.310 -
   7.311 -    // FIXME: add other accessors. For example, suspension and
   7.312 -    // resumption should be done through this interface, as well as
   7.313 -    // interaction with the live Java process such as breakpoint setting.
   7.314 -    // Probably should not expose the ServiceabilityAgentJVMDIModule
   7.315 -    // from this interface.
   7.316 -
   7.317 -    //--------------------------------------------------------------------------------
   7.318 -    // Client-side operations
   7.319 -    //
   7.320 -
   7.321 -    /** This attaches to a process running on the local machine. */
   7.322 -    public synchronized void attach(int processID)
   7.323 -    throws DebuggerException {
   7.324 -        if (debugger != null) {
   7.325 -            throw new DebuggerException("Already attached");
   7.326 -        }
   7.327 -        pid = processID;
   7.328 -        startupMode = PROCESS_MODE;
   7.329 -        isServer = false;
   7.330 -        go();
   7.331 -    }
   7.332 -
   7.333 -    /** This opens a core file on the local machine */
   7.334 -    public synchronized void attach(String executableName, String coreFileName)
   7.335 -    throws DebuggerException {
   7.336 -        if (debugger != null) {
   7.337 -            throw new DebuggerException("Already attached");
   7.338 -        }
   7.339 -        if ((executableName == null) || (coreFileName == null)) {
   7.340 -            throw new DebuggerException("Both the core file name and executable name must be specified");
   7.341 -        }
   7.342 -        this.executableName = executableName;
   7.343 -        this.coreFileName = coreFileName;
   7.344 -        startupMode = CORE_FILE_MODE;
   7.345 -        isServer = false;
   7.346 -        go();
   7.347 -    }
   7.348 -
   7.349 -    /** This attaches to a "debug server" on a remote machine; this
   7.350 -      remote server has already attached to a process or opened a
   7.351 -      core file and is waiting for RMI calls on the Debugger object to
   7.352 -      come in. */
   7.353 -    public synchronized void attach(String remoteServerID)
   7.354 -    throws DebuggerException {
   7.355 -        if (debugger != null) {
   7.356 -            throw new DebuggerException("Already attached to a process");
   7.357 -        }
   7.358 -        if (remoteServerID == null) {
   7.359 -            throw new DebuggerException("Debug server id must be specified");
   7.360 -        }
   7.361 -
   7.362 -        debugServerID = remoteServerID;
   7.363 -        startupMode = REMOTE_MODE;
   7.364 -        isServer = false;
   7.365 -        go();
   7.366 -    }
   7.367 -
   7.368 -    /** This should only be called by the user on the client machine,
   7.369 -      not the server machine */
   7.370 -    public synchronized boolean detach() throws DebuggerException {
   7.371 -        if (isServer) {
   7.372 -            throw new DebuggerException("Should not call detach() for server configuration");
   7.373 -        }
   7.374 -        return detachInternal();
   7.375 -    }
   7.376 -
   7.377 -    //--------------------------------------------------------------------------------
   7.378 -    // Server-side operations
   7.379 -    //
   7.380 -
   7.381 -    /** This attaches to a process running on the local machine and
   7.382 -      starts a debug server, allowing remote machines to connect and
   7.383 -      examine this process. uniqueID is used to uniquely identify the
   7.384 -      debuggee */
   7.385 -    public synchronized void startServer(int processID, String uniqueID)
   7.386 -    throws DebuggerException {
   7.387 -        if (debugger != null) {
   7.388 -            throw new DebuggerException("Already attached");
   7.389 -        }
   7.390 -        pid = processID;
   7.391 -        startupMode = PROCESS_MODE;
   7.392 -        isServer = true;
   7.393 -        serverID = uniqueID;
   7.394 -        go();
   7.395 -    }
   7.396 -
   7.397 -    /** This attaches to a process running on the local machine and
   7.398 -      starts a debug server, allowing remote machines to connect and
   7.399 -      examine this process. */
   7.400 -    public synchronized void startServer(int processID)
   7.401 -    throws DebuggerException {
   7.402 -        startServer(processID, null);
   7.403 -    }
   7.404 -
   7.405 -    /** This opens a core file on the local machine and starts a debug
   7.406 -      server, allowing remote machines to connect and examine this
   7.407 -      core file. uniqueID is used to uniquely identify the
   7.408 -      debuggee */
   7.409 -    public synchronized void startServer(String executableName, String coreFileName,
   7.410 -    String uniqueID)
   7.411 -    throws DebuggerException {
   7.412 -        if (debugger != null) {
   7.413 -            throw new DebuggerException("Already attached");
   7.414 -        }
   7.415 -        if ((executableName == null) || (coreFileName == null)) {
   7.416 -            throw new DebuggerException("Both the core file name and Java executable name must be specified");
   7.417 -        }
   7.418 -        this.executableName = executableName;
   7.419 -        this.coreFileName = coreFileName;
   7.420 -        startupMode = CORE_FILE_MODE;
   7.421 -        isServer = true;
   7.422 -        serverID = uniqueID;
   7.423 -        go();
   7.424 -    }
   7.425 -
   7.426 -    /** This opens a core file on the local machine and starts a debug
   7.427 -      server, allowing remote machines to connect and examine this
   7.428 -      core file.*/
   7.429 -    public synchronized void startServer(String executableName, String coreFileName)
   7.430 -    throws DebuggerException {
   7.431 -        startServer(executableName, coreFileName, null);
   7.432 -    }
   7.433 -
   7.434 -    /** This may only be called on the server side after startServer()
   7.435 -      has been called */
   7.436 -    public synchronized boolean shutdownServer() throws DebuggerException {
   7.437 -        if (!isServer) {
   7.438 -            throw new DebuggerException("Should not call shutdownServer() for client configuration");
   7.439 -        }
   7.440 -        return detachInternal();
   7.441 -    }
   7.442 -
   7.443 -
   7.444 -    //--------------------------------------------------------------------------------
   7.445 -    // Internals only below this point
   7.446 -    //
   7.447 -
   7.448 -    private boolean detachInternal() {
   7.449 -        if (debugger == null) {
   7.450 -            return false;
   7.451 -        }
   7.452 -        if (canInteractWithJava()) {
   7.453 -            jvmdi.detach();
   7.454 -            jvmdi = null;
   7.455 -        }
   7.456 -        boolean retval = true;
   7.457 -        if (!isServer) {
   7.458 -            VM.shutdown();
   7.459 -        }
   7.460 -        // We must not call detach() if we are a client and are connected
   7.461 -        // to a remote debugger
   7.462 -        Debugger dbg = null;
   7.463 -        DebuggerException ex = null;
   7.464 -        if (isServer) {
   7.465 -            try {
   7.466 -                RMIHelper.unbind(serverID);
   7.467 -            }
   7.468 -            catch (DebuggerException de) {
   7.469 -                ex = de;
   7.470 -            }
   7.471 -            dbg = debugger;
   7.472 -        } else {
   7.473 -            if (startupMode != REMOTE_MODE) {
   7.474 -                dbg = debugger;
   7.475 -            }
   7.476 -        }
   7.477 -        if (dbg != null) {
   7.478 -            retval = dbg.detach();
   7.479 -        }
   7.480 -
   7.481 -        debugger = null;
   7.482 -        machDesc = null;
   7.483 -        db = null;
   7.484 -        if (ex != null) {
   7.485 -            throw(ex);
   7.486 -        }
   7.487 -        return retval;
   7.488 -    }
   7.489 -
   7.490 -    private void go() {
   7.491 -        setupDebugger();
   7.492 -        javaMode = setupVM();
   7.493 -    }
   7.494 -
   7.495 -    private void setupDebugger() {
   7.496 -        if (startupMode != REMOTE_MODE) {
   7.497 -            //
   7.498 -            // Local mode (client attaching to local process or setting up
   7.499 -            // server, but not client attaching to server)
   7.500 -            //
   7.501 -
   7.502 -            try {
   7.503 -                os  = PlatformInfo.getOS();
   7.504 -                cpu = PlatformInfo.getCPU();
   7.505 -            }
   7.506 -            catch (UnsupportedPlatformException e) {
   7.507 -                throw new DebuggerException(e);
   7.508 -            }
   7.509 -            fileSep = System.getProperty("file.separator");
   7.510 -
   7.511 -            if (os.equals("solaris")) {
   7.512 -                setupDebuggerSolaris();
   7.513 -            } else if (os.equals("win32")) {
   7.514 -                setupDebuggerWin32();
   7.515 -            } else if (os.equals("linux")) {
   7.516 -                setupDebuggerLinux();
   7.517 -            } else if (os.equals("bsd")) {
   7.518 -                setupDebuggerBsd();
   7.519 -            } else {
   7.520 -                // Add support for more operating systems here
   7.521 -                throw new DebuggerException("Operating system " + os + " not yet supported");
   7.522 -            }
   7.523 -            if (isServer) {
   7.524 -                RemoteDebuggerServer remote = null;
   7.525 -                try {
   7.526 -                    remote = new RemoteDebuggerServer(debugger);
   7.527 -                }
   7.528 -                catch (RemoteException rem) {
   7.529 -                    throw new DebuggerException(rem);
   7.530 -                }
   7.531 -                RMIHelper.rebind(serverID, remote);
   7.532 -            }
   7.533 -        } else {
   7.534 -            //
   7.535 -            // Remote mode (client attaching to server)
   7.536 -            //
   7.537 -
   7.538 -            // Create and install a security manager
   7.539 -
   7.540 -            // FIXME: currently commented out because we were having
   7.541 -            // security problems since we're "in the sun.* hierarchy" here.
   7.542 -            // Perhaps a permissive policy file would work around this. In
   7.543 -            // the long run, will probably have to move into com.sun.*.
   7.544 -
   7.545 -            //    if (System.getSecurityManager() == null) {
   7.546 -            //      System.setSecurityManager(new RMISecurityManager());
   7.547 -            //    }
   7.548 -
   7.549 -            connectRemoteDebugger();
   7.550 -        }
   7.551 -    }
   7.552 -
   7.553 -    private boolean setupVM() {
   7.554 -        // We need to instantiate a HotSpotTypeDataBase on both the client
   7.555 -        // and server machine. On the server it is only currently used to
   7.556 -        // configure the Java primitive type sizes (which we should
   7.557 -        // consider making constant). On the client it is used to
   7.558 -        // configure the VM.
   7.559 -
   7.560 -        try {
   7.561 -            if (os.equals("solaris")) {
   7.562 -                db = new HotSpotTypeDataBase(machDesc, new HotSpotSolarisVtblAccess(debugger, jvmLibNames),
   7.563 -                debugger, jvmLibNames);
   7.564 -            } else if (os.equals("win32")) {
   7.565 -                db = new HotSpotTypeDataBase(machDesc, new Win32VtblAccess(debugger, jvmLibNames),
   7.566 -                debugger, jvmLibNames);
   7.567 -            } else if (os.equals("linux")) {
   7.568 -                db = new HotSpotTypeDataBase(machDesc, new LinuxVtblAccess(debugger, jvmLibNames),
   7.569 -                debugger, jvmLibNames);
   7.570 -            } else if (os.equals("bsd")) {
   7.571 -                db = new HotSpotTypeDataBase(machDesc, new BsdVtblAccess(debugger, jvmLibNames),
   7.572 -                debugger, jvmLibNames);
   7.573 -            } else {
   7.574 -                throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess implemented yet)");
   7.575 -            }
   7.576 -        }
   7.577 -        catch (NoSuchSymbolException e) {
   7.578 -            e.printStackTrace();
   7.579 -            return false;
   7.580 -        }
   7.581 -
   7.582 -        if (startupMode != REMOTE_MODE) {
   7.583 -            // Configure the debugger with the primitive type sizes just obtained from the VM
   7.584 -            debugger.configureJavaPrimitiveTypeSizes(db.getJBooleanType().getSize(),
   7.585 -            db.getJByteType().getSize(),
   7.586 -            db.getJCharType().getSize(),
   7.587 -            db.getJDoubleType().getSize(),
   7.588 -            db.getJFloatType().getSize(),
   7.589 -            db.getJIntType().getSize(),
   7.590 -            db.getJLongType().getSize(),
   7.591 -            db.getJShortType().getSize());
   7.592 -        }
   7.593 -
   7.594 -        if (!isServer) {
   7.595 -            // Do not initialize the VM on the server (unnecessary, since it's
   7.596 -            // instantiated on the client)
   7.597 -            VM.initialize(db, debugger);
   7.598 -        }
   7.599 -
   7.600 -        try {
   7.601 -            jvmdi = new ServiceabilityAgentJVMDIModule(debugger, saLibNames);
   7.602 -            if (jvmdi.canAttach()) {
   7.603 -                jvmdi.attach();
   7.604 -                jvmdi.setCommandTimeout(6000);
   7.605 -                debugPrintln("Attached to Serviceability Agent's JVMDI module.");
   7.606 -                // Jog VM to suspended point with JVMDI module
   7.607 -                resume();
   7.608 -                suspendJava();
   7.609 -                suspend();
   7.610 -                debugPrintln("Suspended all Java threads.");
   7.611 -            } else {
   7.612 -                debugPrintln("Could not locate SA's JVMDI module; skipping attachment");
   7.613 -                jvmdi = null;
   7.614 -            }
   7.615 -        } catch (Exception e) {
   7.616 -            e.printStackTrace();
   7.617 -            jvmdi = null;
   7.618 -        }
   7.619 -
   7.620 -        return true;
   7.621 -    }
   7.622 -
   7.623 -    //--------------------------------------------------------------------------------
   7.624 -    // OS-specific debugger setup/connect routines
   7.625 -    //
   7.626 -
   7.627 -    //
   7.628 -    // Solaris
   7.629 -    //
   7.630 -
   7.631 -    private void setupDebuggerSolaris() {
   7.632 -        setupJVMLibNamesSolaris();
   7.633 -        ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
   7.634 -        debugger = dbg;
   7.635 -        attachDebugger();
   7.636 -
   7.637 -        // Set up CPU-dependent stuff
   7.638 -        if (cpu.equals("x86")) {
   7.639 -            machDesc = new MachineDescriptionIntelX86();
   7.640 -        } else if (cpu.equals("sparc")) {
   7.641 -            int addressSize = dbg.getRemoteProcessAddressSize();
   7.642 -            if (addressSize == -1) {
   7.643 -                throw new DebuggerException("Error occurred while trying to determine the remote process's address size");
   7.644 -            }
   7.645 -
   7.646 -            if (addressSize == 32) {
   7.647 -                machDesc = new MachineDescriptionSPARC32Bit();
   7.648 -            } else if (addressSize == 64) {
   7.649 -                machDesc = new MachineDescriptionSPARC64Bit();
   7.650 -            } else {
   7.651 -                throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
   7.652 -            }
   7.653 -        } else if (cpu.equals("amd64")) {
   7.654 -            machDesc = new MachineDescriptionAMD64();
   7.655 -        } else {
   7.656 -            throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
   7.657 -        }
   7.658 -
   7.659 -        dbg.setMachineDescription(machDesc);
   7.660 -    }
   7.661 -
   7.662 -    private void connectRemoteDebugger() throws DebuggerException {
   7.663 -        RemoteDebugger remote =
   7.664 -        (RemoteDebugger) RMIHelper.lookup(debugServerID);
   7.665 -        debugger = new RemoteDebuggerClient(remote);
   7.666 -        machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
   7.667 -        os = debugger.getOS();
   7.668 -        if (os.equals("solaris")) {
   7.669 -            setupJVMLibNamesSolaris();
   7.670 -        } else if (os.equals("win32")) {
   7.671 -            setupJVMLibNamesWin32();
   7.672 -        } else if (os.equals("linux")) {
   7.673 -            setupJVMLibNamesLinux();
   7.674 -        } else if (os.equals("bsd")) {
   7.675 -            setupJVMLibNamesBsd();
   7.676 -        } else {
   7.677 -            throw new RuntimeException("Unknown OS type");
   7.678 -        }
   7.679 -
   7.680 -        cpu = debugger.getCPU();
   7.681 -    }
   7.682 -
   7.683 -    private void setupJVMLibNamesSolaris() {
   7.684 -        jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so", "gamma_g" };
   7.685 -        saLibNames = new String[] { "libsa.so", "libsa_g.so" };
   7.686 -    }
   7.687 -
   7.688 -    //
   7.689 -    // Win32
   7.690 -    //
   7.691 -
   7.692 -    private void setupDebuggerWin32() {
   7.693 -        setupJVMLibNamesWin32();
   7.694 -
   7.695 -        if (cpu.equals("x86")) {
   7.696 -            machDesc = new MachineDescriptionIntelX86();
   7.697 -        } else if (cpu.equals("amd64")) {
   7.698 -            machDesc = new MachineDescriptionAMD64();
   7.699 -        } else if (cpu.equals("ia64")) {
   7.700 -            machDesc = new MachineDescriptionIA64();
   7.701 -        } else {
   7.702 -            throw new DebuggerException("Win32 supported under x86, amd64 and ia64 only");
   7.703 -        }
   7.704 -
   7.705 -        // Note we do not use a cache for the local debugger in server
   7.706 -        // mode; it will be taken care of on the client side (once remote
   7.707 -        // debugging is implemented).
   7.708 -
   7.709 -        debugger = new WindbgDebuggerLocal(machDesc, !isServer);
   7.710 -
   7.711 -        attachDebugger();
   7.712 -    }
   7.713 -
   7.714 -    private void setupJVMLibNamesWin32() {
   7.715 -        jvmLibNames = new String[] { "jvm.dll", "jvm_g.dll" };
   7.716 -        saLibNames = new String[] { "sa.dll", "sa_g.dll" };
   7.717 -    }
   7.718 -
   7.719 -    //
   7.720 -    // Linux
   7.721 -    //
   7.722 -
   7.723 -    private void setupDebuggerLinux() {
   7.724 -        setupJVMLibNamesLinux();
   7.725 -
   7.726 -        if (cpu.equals("x86")) {
   7.727 -            machDesc = new MachineDescriptionIntelX86();
   7.728 -        } else if (cpu.equals("ia64")) {
   7.729 -            machDesc = new MachineDescriptionIA64();
   7.730 -        } else if (cpu.equals("amd64")) {
   7.731 -            machDesc = new MachineDescriptionAMD64();
   7.732 -        } else if (cpu.equals("sparc")) {
   7.733 -            if (LinuxDebuggerLocal.getAddressSize()==8) {
   7.734 -               machDesc = new MachineDescriptionSPARC64Bit();
   7.735 -            } else {
   7.736 -               machDesc = new MachineDescriptionSPARC32Bit();
   7.737 -            }
   7.738 -        } else {
   7.739 -          try {
   7.740 -            machDesc = (MachineDescription)
   7.741 -              Class.forName("sun.jvm.hotspot.debugger.MachineDescription" +
   7.742 -              cpu.toUpperCase()).newInstance();
   7.743 -          } catch (Exception e) {
   7.744 -            throw new DebuggerException("unsupported machine type");
   7.745 -          }
   7.746 -        }
   7.747 -
   7.748 -
   7.749 -        // Note we do not use a cache for the local debugger in server
   7.750 -        // mode; it will be taken care of on the client side (once remote
   7.751 -        // debugging is implemented).
   7.752 -
   7.753 -        debugger = new LinuxDebuggerLocal(machDesc, !isServer);
   7.754 -        attachDebugger();
   7.755 -    }
   7.756 -
   7.757 -    private void setupJVMLibNamesLinux() {
   7.758 -        // same as solaris
   7.759 -        setupJVMLibNamesSolaris();
   7.760 -    }
   7.761 -
   7.762 -    //
   7.763 -    // BSD
   7.764 -    //
   7.765 -
   7.766 -    private void setupDebuggerBsd() {
   7.767 -        setupJVMLibNamesBsd();
   7.768 -
   7.769 -        if (cpu.equals("x86")) {
   7.770 -            machDesc = new MachineDescriptionIntelX86();
   7.771 -        } else if (cpu.equals("amd64") || (cpu.equals("x86_64"))) {
   7.772 -            machDesc = new MachineDescriptionAMD64();
   7.773 -        } else {
   7.774 -            throw new DebuggerException("Bsd only supported on x86/x86_64. Current arch: " + cpu);
   7.775 -        }
   7.776 -
   7.777 -        // Note we do not use a cache for the local debugger in server
   7.778 -        // mode; it will be taken care of on the client side (once remote
   7.779 -        // debugging is implemented).
   7.780 -
   7.781 -        debugger = new BsdDebuggerLocal(machDesc, !isServer);
   7.782 -        attachDebugger();
   7.783 -    }
   7.784 -
   7.785 -    private void setupJVMLibNamesBsd() {
   7.786 -        // same as solaris
   7.787 -        setupJVMLibNamesSolaris();
   7.788 -    }
   7.789 -
   7.790 -    /** Convenience routine which should be called by per-platform
   7.791 -      debugger setup. Should not be called when startupMode is
   7.792 -      REMOTE_MODE. */
   7.793 -    private void attachDebugger() {
   7.794 -        if (startupMode == PROCESS_MODE) {
   7.795 -            debugger.attach(pid);
   7.796 -        } else if (startupMode == CORE_FILE_MODE) {
   7.797 -            debugger.attach(executableName, coreFileName);
   7.798 -        } else {
   7.799 -            throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
   7.800 -        }
   7.801 -    }
   7.802 -}
     8.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/JavaLineNumberInfo.java	Thu Feb 21 07:50:48 2013 -0500
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,55 +0,0 @@
     8.4 -/*
     8.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
     8.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 - *
     8.8 - * This code is free software; you can redistribute it and/or modify it
     8.9 - * under the terms of the GNU General Public License version 2 only, as
    8.10 - * published by the Free Software Foundation.
    8.11 - *
    8.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    8.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.15 - * version 2 for more details (a copy is included in the LICENSE file that
    8.16 - * accompanied this code).
    8.17 - *
    8.18 - * You should have received a copy of the GNU General Public License version
    8.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    8.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.21 - *
    8.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.23 - * or visit www.oracle.com if you need additional information or have any
    8.24 - * questions.
    8.25 - *
    8.26 - */
    8.27 -
    8.28 -package sun.jvm.hotspot.bugspot;
    8.29 -
    8.30 -import sun.jvm.hotspot.oops.*;
    8.31 -
    8.32 -/** Wrapper class which describes line number information for Java
    8.33 -    class files. The line number table is converted into this
    8.34 -    representation on demand. These objects are then sorted by line
    8.35 -    number for fast lookup when setting breakpoints in a particular
    8.36 -    source file. */
    8.37 -
    8.38 -public class JavaLineNumberInfo {
    8.39 -  private InstanceKlass klass;
    8.40 -  private Method method;
    8.41 -  private int startBCI;
    8.42 -  private int lineNumber;
    8.43 -
    8.44 -  public JavaLineNumberInfo(InstanceKlass klass,
    8.45 -                            Method method,
    8.46 -                            int startBCI,
    8.47 -                            int lineNumber) {
    8.48 -    this.klass = klass;
    8.49 -    this.method = method;
    8.50 -    this.startBCI = startBCI;
    8.51 -    this.lineNumber = lineNumber;
    8.52 -  }
    8.53 -
    8.54 -  public InstanceKlass getKlass()      { return klass; }
    8.55 -  public Method        getMethod()     { return method; }
    8.56 -  public int           getStartBCI()   { return startBCI; }
    8.57 -  public int           getLineNumber() { return lineNumber; }
    8.58 -}
     9.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/Main.java	Thu Feb 21 07:50:48 2013 -0500
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,52 +0,0 @@
     9.4 -/*
     9.5 - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
     9.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 - *
     9.8 - * This code is free software; you can redistribute it and/or modify it
     9.9 - * under the terms of the GNU General Public License version 2 only, as
    9.10 - * published by the Free Software Foundation.
    9.11 - *
    9.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    9.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.15 - * version 2 for more details (a copy is included in the LICENSE file that
    9.16 - * accompanied this code).
    9.17 - *
    9.18 - * You should have received a copy of the GNU General Public License version
    9.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    9.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.21 - *
    9.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    9.23 - * or visit www.oracle.com if you need additional information or have any
    9.24 - * questions.
    9.25 - *
    9.26 - */
    9.27 -
    9.28 -package sun.jvm.hotspot.bugspot;
    9.29 -
    9.30 -import java.awt.*;
    9.31 -import java.awt.event.*;
    9.32 -import javax.swing.*;
    9.33 -
    9.34 -import sun.jvm.hotspot.ui.*;
    9.35 -
    9.36 -/** The main class for the BugSpot debugger. */
    9.37 -
    9.38 -public class Main {
    9.39 -  public static void main(String[] args) {
    9.40 -    JFrame frame = new JFrame("BugSpot");
    9.41 -    frame.setSize(800, 600);
    9.42 -    BugSpot db = new BugSpot();
    9.43 -    db.setMDIMode(true);
    9.44 -    db.build();
    9.45 -    frame.setJMenuBar(db.getMenuBar());
    9.46 -    frame.getContentPane().add(db);
    9.47 -    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    9.48 -
    9.49 -    GraphicsUtilities.reshapeToAspectRatio(frame,
    9.50 -                                           4.0f/3.0f, 0.85f, Toolkit.getDefaultToolkit().getScreenSize());
    9.51 -    GraphicsUtilities.centerInContainer(frame,
    9.52 -                                        Toolkit.getDefaultToolkit().getScreenSize());
    9.53 -    frame.setVisible(true);
    9.54 -  }
    9.55 -}
    10.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/PCFinder.java	Thu Feb 21 07:50:48 2013 -0500
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,96 +0,0 @@
    10.4 -/*
    10.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    10.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 - *
    10.8 - * This code is free software; you can redistribute it and/or modify it
    10.9 - * under the terms of the GNU General Public License version 2 only, as
   10.10 - * published by the Free Software Foundation.
   10.11 - *
   10.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 - * version 2 for more details (a copy is included in the LICENSE file that
   10.16 - * accompanied this code).
   10.17 - *
   10.18 - * You should have received a copy of the GNU General Public License version
   10.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 - *
   10.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 - * or visit www.oracle.com if you need additional information or have any
   10.24 - * questions.
   10.25 - *
   10.26 - */
   10.27 -
   10.28 -package sun.jvm.hotspot.bugspot;
   10.29 -
   10.30 -import sun.jvm.hotspot.debugger.*;
   10.31 -import sun.jvm.hotspot.debugger.cdbg.*;
   10.32 -
   10.33 -/** Helper class for locating a program counter. Indicates the
   10.34 -    confidence of the find. */
   10.35 -
   10.36 -public class PCFinder {
   10.37 -  public static final int LOW_CONFIDENCE = 1;
   10.38 -  public static final int HIGH_CONFIDENCE = 2;
   10.39 -
   10.40 -  public static class Info {
   10.41 -    private String name;
   10.42 -    private long   offset;
   10.43 -    private int    confidence;
   10.44 -
   10.45 -    public Info(String name, long offset, int confidence) {
   10.46 -      this.name = name;
   10.47 -      this.offset = offset;
   10.48 -      this.confidence = confidence;
   10.49 -    }
   10.50 -
   10.51 -    /** May be null */
   10.52 -    public String getName()       { return name;       }
   10.53 -
   10.54 -    /** If this is -1, a symbol could not be found, and the offset
   10.55 -        should not be shown */
   10.56 -    public long   getOffset()     { return offset;     }
   10.57 -
   10.58 -    /** PCFinder.LOW_CONFIDENCE or PCFinder.HIGH_CONFIDENCE */
   10.59 -    public int    getConfidence() { return confidence; }
   10.60 -  }
   10.61 -
   10.62 -  /** Passed loadobject may be null in which case the returned Info
   10.63 -      object has low confidence */
   10.64 -  public static Info findPC(Address pc, LoadObject lo, CDebugger dbg) {
   10.65 -    if (lo == null) {
   10.66 -      return new Info(null, -1, LOW_CONFIDENCE);
   10.67 -    }
   10.68 -
   10.69 -    // First try debug info
   10.70 -    BlockSym sym = lo.debugInfoForPC(pc);
   10.71 -    while (sym != null) {
   10.72 -      if (sym.isFunction()) {
   10.73 -        // Highest confidence
   10.74 -        return new Info(sym.toString(), pc.minus(sym.getAddress()), HIGH_CONFIDENCE);
   10.75 -      }
   10.76 -    }
   10.77 -
   10.78 -    // Now try looking up symbol in loadobject
   10.79 -
   10.80 -    // FIXME: must add support for mapfiles on Win32 and try looking
   10.81 -    // up there first if possible. Should we hide that behind
   10.82 -    // LoadObject.closestSymbolToPC and have the ClosestSymbol return
   10.83 -    // confidence? I think so. On Solaris there is no notion of a
   10.84 -    // mapfile, and the confidence for closestSymbolToPC will be high
   10.85 -    // instead of low.
   10.86 -
   10.87 -    int confidence = HIGH_CONFIDENCE;
   10.88 -
   10.89 -    ClosestSymbol cs = lo.closestSymbolToPC(pc);
   10.90 -    if (cs != null) {
   10.91 -      // FIXME: currently low confidence (only on Win32)
   10.92 -      return new Info(cs.getName() + "()", cs.getOffset(), LOW_CONFIDENCE);
   10.93 -    }
   10.94 -
   10.95 -    // Unknown location
   10.96 -    return new Info(dbg.getNameOfFile(lo.getName()).toUpperCase() +
   10.97 -                    "! " + pc + "()", -1, HIGH_CONFIDENCE);
   10.98 -  }
   10.99 -}
    11.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/PackageScanner.java	Thu Feb 21 07:50:48 2013 -0500
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,89 +0,0 @@
    11.4 -/*
    11.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    11.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 - *
    11.8 - * This code is free software; you can redistribute it and/or modify it
    11.9 - * under the terms of the GNU General Public License version 2 only, as
   11.10 - * published by the Free Software Foundation.
   11.11 - *
   11.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 - * version 2 for more details (a copy is included in the LICENSE file that
   11.16 - * accompanied this code).
   11.17 - *
   11.18 - * You should have received a copy of the GNU General Public License version
   11.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 - *
   11.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 - * or visit www.oracle.com if you need additional information or have any
   11.24 - * questions.
   11.25 - *
   11.26 - */
   11.27 -
   11.28 -package sun.jvm.hotspot.bugspot;
   11.29 -
   11.30 -import java.io.*;
   11.31 -
   11.32 -/** Scans a .java file for the package that it is in. */
   11.33 -
   11.34 -public class PackageScanner {
   11.35 -
   11.36 -  public PackageScanner() {
   11.37 -  }
   11.38 -
   11.39 -  public String scan(String filename) {
   11.40 -    return scan(new File(filename));
   11.41 -  }
   11.42 -
   11.43 -  /** Returns the String comprising the package name of the classes in
   11.44 -      this .java file. Returns the (non-null) empty string if any
   11.45 -      error occurs or if the classes are in the unnamed package. */
   11.46 -  public String scan(File file) {
   11.47 -    BufferedReader buf = null;
   11.48 -    String res = "";
   11.49 -    try {
   11.50 -      buf = new BufferedReader(new FileReader(file));
   11.51 -      StreamTokenizer tok = new StreamTokenizer(buf);
   11.52 -      tok.slashStarComments(true);
   11.53 -      tok.slashSlashComments(true);
   11.54 -      if (tok.nextToken() != StreamTokenizer.TT_WORD) {
   11.55 -        return res;
   11.56 -      }
   11.57 -      if (!tok.sval.equals("package")) {
   11.58 -        return res;
   11.59 -      }
   11.60 -      if (tok.nextToken() != StreamTokenizer.TT_WORD) {
   11.61 -        return res;
   11.62 -      }
   11.63 -      res = tok.sval;
   11.64 -      return res;
   11.65 -    } catch (FileNotFoundException e) {
   11.66 -      return res;
   11.67 -    } catch (IOException e) {
   11.68 -      return res;
   11.69 -    } finally {
   11.70 -      try {
   11.71 -        if (buf != null) {
   11.72 -          buf.close();
   11.73 -        }
   11.74 -      } catch (IOException e) {
   11.75 -      }
   11.76 -    }
   11.77 -  }
   11.78 -
   11.79 -  public static void main(String[] args) {
   11.80 -    if (args.length != 1) {
   11.81 -      usage();
   11.82 -    }
   11.83 -
   11.84 -    System.out.println(new PackageScanner().scan(args[0]));
   11.85 -  }
   11.86 -
   11.87 -  private static void usage() {
   11.88 -    System.err.println("Usage: java PackageScanner <.java file name>");
   11.89 -    System.err.println("Prints package the .java file is in to stdout.");
   11.90 -    System.exit(1);
   11.91 -  }
   11.92 -}
    12.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/RegisterPanel.java	Thu Feb 21 07:50:48 2013 -0500
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,173 +0,0 @@
    12.4 -/*
    12.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    12.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 - *
    12.8 - * This code is free software; you can redistribute it and/or modify it
    12.9 - * under the terms of the GNU General Public License version 2 only, as
   12.10 - * published by the Free Software Foundation.
   12.11 - *
   12.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 - * version 2 for more details (a copy is included in the LICENSE file that
   12.16 - * accompanied this code).
   12.17 - *
   12.18 - * You should have received a copy of the GNU General Public License version
   12.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 - *
   12.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 - * or visit www.oracle.com if you need additional information or have any
   12.24 - * questions.
   12.25 - *
   12.26 - */
   12.27 -
   12.28 -package sun.jvm.hotspot.bugspot;
   12.29 -
   12.30 -import java.awt.*;
   12.31 -import java.util.*;
   12.32 -import javax.swing.*;
   12.33 -import javax.swing.table.*;
   12.34 -
   12.35 -import sun.jvm.hotspot.debugger.*;
   12.36 -
   12.37 -/** Displays registers in a window. FIXME: this will need more work to
   12.38 -    understand and handle register windows. */
   12.39 -
   12.40 -public class RegisterPanel extends JPanel {
   12.41 -  private java.util.List/*<RegisterInfo>*/ registers;
   12.42 -  private AbstractTableModel dataModel;
   12.43 -  private boolean valid;
   12.44 -  private boolean editable;
   12.45 -  private String nullAddressString;
   12.46 -  private ThreadProxy curThread;
   12.47 -  private JTable table;
   12.48 -
   12.49 -  static class RegisterInfo {
   12.50 -    private String name;
   12.51 -    private Address value;
   12.52 -
   12.53 -    RegisterInfo(String name, Address value) {
   12.54 -      this.name = name;
   12.55 -      this.value = value;
   12.56 -    }
   12.57 -
   12.58 -    String  getName()  { return name;  }
   12.59 -    Address getValue() { return value; }
   12.60 -  }
   12.61 -
   12.62 -  public RegisterPanel() {
   12.63 -    super();
   12.64 -
   12.65 -    registers = new ArrayList();
   12.66 -
   12.67 -    dataModel = new AbstractTableModel() {
   12.68 -        public int getColumnCount() { return 2; }
   12.69 -        public int getRowCount()    { return registers.size(); }
   12.70 -        public String getColumnName(int col) {
   12.71 -          switch (col) {
   12.72 -          case 0:
   12.73 -            return "Register Name";
   12.74 -          case 1:
   12.75 -            return "Register Value";
   12.76 -          default:
   12.77 -            throw new RuntimeException("Index " + col + " out of bounds");
   12.78 -          }
   12.79 -        }
   12.80 -        public Object getValueAt(int row, int col) {
   12.81 -          RegisterInfo info = (RegisterInfo) registers.get(row);
   12.82 -
   12.83 -          switch (col) {
   12.84 -          case 0:
   12.85 -            return info.getName();
   12.86 -          case 1:
   12.87 -            if (valid) {
   12.88 -              Address val = info.getValue();
   12.89 -              if (val != null) {
   12.90 -                return val;
   12.91 -              } else {
   12.92 -                return nullAddressString;
   12.93 -              }
   12.94 -            } else {
   12.95 -              return "-";
   12.96 -            }
   12.97 -          default:
   12.98 -            throw new RuntimeException("Index (" + col + ", " + row + ") out of bounds");
   12.99 -          }
  12.100 -        }
  12.101 -        public boolean isCellEditable(int row, int col) {
  12.102 -          if (col == 0) return false;
  12.103 -          if (!valid) return false;
  12.104 -          if (curThread == null) return false;
  12.105 -          if (!curThread.canSetContext()) return false;
  12.106 -
  12.107 -          // FIXME: add listener to watch for register changes
  12.108 -          //          return true;
  12.109 -          return false;
  12.110 -        }
  12.111 -      };
  12.112 -
  12.113 -    // Build user interface
  12.114 -    setLayout(new BorderLayout());
  12.115 -    table = new JTable(dataModel);
  12.116 -    table.setCellSelectionEnabled(true);
  12.117 -    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
  12.118 -    table.setDragEnabled(true);
  12.119 -    JTableHeader header = table.getTableHeader();
  12.120 -    header.setReorderingAllowed(false);
  12.121 -    JScrollPane scrollPane = new JScrollPane(table);
  12.122 -    add(scrollPane, BorderLayout.CENTER);
  12.123 -  }
  12.124 -
  12.125 -
  12.126 -  /** Updates the register panel with the register set from the
  12.127 -      specified thread. Call this when the process has been suspended
  12.128 -      and the current thread has been set. FIXME: this interface will
  12.129 -      need to change to support register windows. */
  12.130 -  public void update(ThreadProxy curThread) {
  12.131 -    this.curThread = curThread;
  12.132 -    ThreadContext context = curThread.getContext();
  12.133 -    editable = curThread.canSetContext();
  12.134 -    registers.clear();
  12.135 -    for (int i = 0; i < context.getNumRegisters(); i++) {
  12.136 -      String name = context.getRegisterName(i);
  12.137 -      Address addr = context.getRegisterAsAddress(i);
  12.138 -      if ((nullAddressString == null) && (addr != null)) {
  12.139 -        String addrStr = addr.toString();
  12.140 -        StringBuffer buf = new StringBuffer();
  12.141 -        buf.append("0x");
  12.142 -        int len = addrStr.length() - 2;
  12.143 -        for (int j = 0; j < len; j++) {
  12.144 -          buf.append("0");
  12.145 -        }
  12.146 -        nullAddressString = buf.toString();
  12.147 -      }
  12.148 -      registers.add(new RegisterInfo(name, addr));
  12.149 -    }
  12.150 -    valid = true;
  12.151 -    SwingUtilities.invokeLater(new Runnable() {
  12.152 -        public void run() {
  12.153 -          dataModel.fireTableDataChanged();
  12.154 -        }
  12.155 -      });
  12.156 -  }
  12.157 -
  12.158 -  /** Clears the registers' values. Call this when the processs has
  12.159 -      been resumed. */
  12.160 -  public void clear() {
  12.161 -    valid = false;
  12.162 -    nullAddressString = null;
  12.163 -    SwingUtilities.invokeLater(new Runnable() {
  12.164 -        public void run() {
  12.165 -          dataModel.fireTableDataChanged();
  12.166 -        }
  12.167 -      });
  12.168 -  }
  12.169 -
  12.170 -  public void setFont(Font font) {
  12.171 -    super.setFont(font);
  12.172 -    if (table != null) {
  12.173 -      table.setFont(font);
  12.174 -    }
  12.175 -  }
  12.176 -}
    13.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/StackTraceEntry.java	Thu Feb 21 07:50:48 2013 -0500
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,87 +0,0 @@
    13.4 -/*
    13.5 - * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
    13.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 - *
    13.8 - * This code is free software; you can redistribute it and/or modify it
    13.9 - * under the terms of the GNU General Public License version 2 only, as
   13.10 - * published by the Free Software Foundation.
   13.11 - *
   13.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 - * version 2 for more details (a copy is included in the LICENSE file that
   13.16 - * accompanied this code).
   13.17 - *
   13.18 - * You should have received a copy of the GNU General Public License version
   13.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 - *
   13.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.23 - * or visit www.oracle.com if you need additional information or have any
   13.24 - * questions.
   13.25 - *
   13.26 - */
   13.27 -
   13.28 -package sun.jvm.hotspot.bugspot;
   13.29 -
   13.30 -import sun.jvm.hotspot.debugger.cdbg.*;
   13.31 -import sun.jvm.hotspot.oops.*;
   13.32 -import sun.jvm.hotspot.runtime.*;
   13.33 -
   13.34 -/** This class describes a frame in a stack trace. It abstracts over
   13.35 -    C/C++ and Java frames. */
   13.36 -
   13.37 -public class StackTraceEntry {
   13.38 -  private CFrame cFrame;
   13.39 -  private CDebugger dbg;
   13.40 -  private JavaVFrame javaFrame;
   13.41 -  private String value; // What is displayed in a stack trace
   13.42 -  // For merging C and Java stack traces.
   13.43 -  // For more precise stack traces, should probably have a way to
   13.44 -  // convert a CFrame to a sun.jvm.hotspot.runtime.Frame. For now,
   13.45 -  // doing similar algorithm to jdbx (which does not have intimate
   13.46 -  // knowledge of the VM).
   13.47 -  private boolean isUnknownCFrame;
   13.48 -
   13.49 -  public StackTraceEntry(CFrame cFrame, CDebugger dbg) {
   13.50 -    this.cFrame = cFrame;
   13.51 -    this.dbg = dbg;
   13.52 -    computeValue();
   13.53 -  }
   13.54 -
   13.55 -  public StackTraceEntry(JavaVFrame javaFrame) {
   13.56 -    this.javaFrame = javaFrame;
   13.57 -    computeValue();
   13.58 -  }
   13.59 -
   13.60 -  public boolean    isCFrame()     { return (cFrame != null);    }
   13.61 -  public boolean    isJavaFrame()  { return (javaFrame != null); }
   13.62 -  public CFrame     getCFrame()    { return cFrame;              }
   13.63 -  public JavaVFrame getJavaFrame() { return javaFrame;           }
   13.64 -  public boolean    isUnknownCFrame() { return isUnknownCFrame;  }
   13.65 -  public String toString() {
   13.66 -    return value;
   13.67 -  }
   13.68 -
   13.69 -  private void computeValue() {
   13.70 -    isUnknownCFrame = true;
   13.71 -    value = "<unknown>";
   13.72 -    if (cFrame != null) {
   13.73 -      PCFinder.Info info = PCFinder.findPC(cFrame.pc(), cFrame.loadObjectForPC(), dbg);
   13.74 -      if (info.getName() != null) {
   13.75 -        value = "(C) " + info.getName();
   13.76 -        isUnknownCFrame = false;
   13.77 -        if (info.getConfidence() == PCFinder.LOW_CONFIDENCE) {
   13.78 -          value = value + " (?)";
   13.79 -        }
   13.80 -        if (info.getOffset() >= 0) {
   13.81 -          value = value + " + 0x" + Long.toHexString(info.getOffset());
   13.82 -        }
   13.83 -      }
   13.84 -    } else if (javaFrame != null) {
   13.85 -      isUnknownCFrame = false;
   13.86 -      Method m = javaFrame.getMethod();
   13.87 -      value = "(J) " + m.externalNameAndSignature();
   13.88 -    }
   13.89 -  }
   13.90 -}
    14.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/StackTracePanel.java	Thu Feb 21 07:50:48 2013 -0500
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,115 +0,0 @@
    14.4 -/*
    14.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    14.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 - *
    14.8 - * This code is free software; you can redistribute it and/or modify it
    14.9 - * under the terms of the GNU General Public License version 2 only, as
   14.10 - * published by the Free Software Foundation.
   14.11 - *
   14.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 - * version 2 for more details (a copy is included in the LICENSE file that
   14.16 - * accompanied this code).
   14.17 - *
   14.18 - * You should have received a copy of the GNU General Public License version
   14.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 - *
   14.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 - * or visit www.oracle.com if you need additional information or have any
   14.24 - * questions.
   14.25 - *
   14.26 - */
   14.27 -
   14.28 -package sun.jvm.hotspot.bugspot;
   14.29 -
   14.30 -import java.awt.*;
   14.31 -import java.awt.event.*;
   14.32 -import java.util.*;
   14.33 -import javax.swing.*;
   14.34 -import sun.jvm.hotspot.debugger.cdbg.*;
   14.35 -import sun.jvm.hotspot.runtime.*;
   14.36 -import sun.jvm.hotspot.ui.*;
   14.37 -
   14.38 -/** This panel contains a ListBox with all of the stack frames in a
   14.39 -    given thread. When a given entry is selected, an event is
   14.40 -    fired. */
   14.41 -
   14.42 -public class StackTracePanel extends JPanel {
   14.43 -  public interface Listener {
   14.44 -    public void frameChanged(CFrame fr, JavaVFrame jfr);
   14.45 -  }
   14.46 -
   14.47 -  class Model extends AbstractListModel implements ComboBoxModel {
   14.48 -    private Object selectedItem;
   14.49 -    public Object getElementAt(int index) {
   14.50 -      if (trace == null) return null;
   14.51 -      return trace.get(index);
   14.52 -    }
   14.53 -    public int getSize() {
   14.54 -      if (trace == null) return 0;
   14.55 -      return trace.size();
   14.56 -    }
   14.57 -    public Object getSelectedItem() {
   14.58 -      return selectedItem;
   14.59 -    }
   14.60 -    public void setSelectedItem(Object item) {
   14.61 -      selectedItem = item;
   14.62 -    }
   14.63 -    public void dataChanged() {
   14.64 -      fireContentsChanged(this, 0, trace.size());
   14.65 -    }
   14.66 -  }
   14.67 -
   14.68 -  private java.util.List trace;
   14.69 -  private Model model;
   14.70 -  private JComboBox list;
   14.71 -  private java.util.List listeners;
   14.72 -
   14.73 -  public StackTracePanel() {
   14.74 -    super();
   14.75 -
   14.76 -    model = new Model();
   14.77 -
   14.78 -    // Build user interface
   14.79 -    setLayout(new BorderLayout());
   14.80 -    setBorder(GraphicsUtilities.newBorder(5));
   14.81 -    list = new JComboBox(model);
   14.82 -    list.setPrototypeDisplayValue("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ");
   14.83 -    add(list, BorderLayout.CENTER);
   14.84 -
   14.85 -    // Add selection listener
   14.86 -    list.addItemListener(new ItemListener() {
   14.87 -        public void itemStateChanged(ItemEvent e) {
   14.88 -          if (e.getStateChange() == ItemEvent.SELECTED) {
   14.89 -            fireFrameChanged();
   14.90 -          }
   14.91 -        }
   14.92 -      });
   14.93 -  }
   14.94 -
   14.95 -  /** Takes a List of StackTraceEntry objects */
   14.96 -  public void setTrace(java.util.List trace) {
   14.97 -    this.trace = trace;
   14.98 -    model.dataChanged();
   14.99 -    list.setSelectedIndex(0);
  14.100 -    fireFrameChanged();
  14.101 -  }
  14.102 -
  14.103 -  public void addListener(Listener listener) {
  14.104 -    if (listeners == null) {
  14.105 -      listeners = new ArrayList();
  14.106 -    }
  14.107 -    listeners.add(listener);
  14.108 -  }
  14.109 -
  14.110 -  protected void fireFrameChanged() {
  14.111 -    if (listeners != null) {
  14.112 -      StackTraceEntry entry = (StackTraceEntry) trace.get(list.getSelectedIndex());
  14.113 -      for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
  14.114 -        ((Listener) iter.next()).frameChanged(entry.getCFrame(), entry.getJavaFrame());
  14.115 -      }
  14.116 -    }
  14.117 -  }
  14.118 -}
    15.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/ThreadListPanel.java	Thu Feb 21 07:50:48 2013 -0500
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,237 +0,0 @@
    15.4 -/*
    15.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    15.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 - *
    15.8 - * This code is free software; you can redistribute it and/or modify it
    15.9 - * under the terms of the GNU General Public License version 2 only, as
   15.10 - * published by the Free Software Foundation.
   15.11 - *
   15.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 - * version 2 for more details (a copy is included in the LICENSE file that
   15.16 - * accompanied this code).
   15.17 - *
   15.18 - * You should have received a copy of the GNU General Public License version
   15.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 - *
   15.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 - * or visit www.oracle.com if you need additional information or have any
   15.24 - * questions.
   15.25 - *
   15.26 - */
   15.27 -
   15.28 -package sun.jvm.hotspot.bugspot;
   15.29 -
   15.30 -import java.awt.*;
   15.31 -import java.awt.event.*;
   15.32 -import java.util.*;
   15.33 -import javax.swing.*;
   15.34 -import javax.swing.table.*;
   15.35 -
   15.36 -import sun.jvm.hotspot.debugger.*;
   15.37 -import sun.jvm.hotspot.debugger.cdbg.*;
   15.38 -import sun.jvm.hotspot.runtime.*;
   15.39 -import sun.jvm.hotspot.ui.*;
   15.40 -
   15.41 -// NOTE: this class was not placed in sun.jvm.hotspot.ui to prevent
   15.42 -// mixing components designed for C and C++ debugging with the ones
   15.43 -// that work with the core serviceability agent functionality (which
   15.44 -// does not require that the CDebugger interface be implemented).
   15.45 -
   15.46 -/** The ThreadListPanel is used for C and C++ debugging and can
   15.47 -    visualize all threads in the target process. The caller passes in
   15.48 -    a CDebugger attached to the target process and can request that
   15.49 -    JavaThreads' associations with these underlying threads be
   15.50 -    displayed; this option is only valid when attached to a HotSpot
   15.51 -    JVM and when the {@link sun.jvm.hotspot.runtime.VM} has been
   15.52 -    initialized. */
   15.53 -
   15.54 -public class ThreadListPanel extends JPanel {
   15.55 -  /** Listener which can be added to receive "Set Focus" events */
   15.56 -  public static interface Listener {
   15.57 -    /** ThreadProxy will always be provided; JavaThread will only be
   15.58 -        present if displayJavaThreads was specified in the constructor
   15.59 -        for the panel and the thread was a JavaThread. */
   15.60 -    public void setFocus(ThreadProxy thread, JavaThread jthread);
   15.61 -  }
   15.62 -
   15.63 -  static class ThreadInfo {
   15.64 -    private ThreadProxy thread;
   15.65 -    // Distinguish between PC == null and no top frame
   15.66 -    private boolean     gotPC;
   15.67 -    private Address     pc;
   15.68 -    private String      location;
   15.69 -    private JavaThread  javaThread;
   15.70 -    private String      javaThreadName;
   15.71 -
   15.72 -    public ThreadInfo(ThreadProxy thread, CDebugger dbg, JavaThread jthread) {
   15.73 -      this.thread = thread;
   15.74 -      this.location = "<unknown>";
   15.75 -      CFrame fr = dbg.topFrameForThread(thread);
   15.76 -      if (fr != null) {
   15.77 -        gotPC = true;
   15.78 -        pc = fr.pc();
   15.79 -        PCFinder.Info info = PCFinder.findPC(pc, fr.loadObjectForPC(), dbg);
   15.80 -        if (info.getName() != null) {
   15.81 -          location = info.getName();
   15.82 -          if (info.getConfidence() == PCFinder.LOW_CONFIDENCE) {
   15.83 -            location = location + " (?)";
   15.84 -          }
   15.85 -          if (info.getOffset() < 0) {
   15.86 -            location = location + " + 0x" + Long.toHexString(info.getOffset());
   15.87 -          }
   15.88 -        }
   15.89 -      }
   15.90 -      if (jthread != null) {
   15.91 -        javaThread = jthread;
   15.92 -        javaThreadName = jthread.getThreadName();
   15.93 -      }
   15.94 -    }
   15.95 -
   15.96 -    public ThreadProxy getThread()    { return thread;       }
   15.97 -    public boolean     hasPC()        { return gotPC;        }
   15.98 -    public Address     getPC()        { return pc;           }
   15.99 -    public String      getLocation()  { return location;     }
  15.100 -    public boolean     isJavaThread() { return (javaThread != null); }
  15.101 -    public JavaThread  getJavaThread() { return javaThread; }
  15.102 -    public String      getJavaThreadName() { return javaThreadName; }
  15.103 -  }
  15.104 -
  15.105 -  // List<ThreadInfo>
  15.106 -  private java.util.List threadList;
  15.107 -  private JTable table;
  15.108 -  private AbstractTableModel dataModel;
  15.109 -  // List<Listener>
  15.110 -  private java.util.List listeners;
  15.111 -
  15.112 -  /** Takes a CDebugger from which the thread list is queried.
  15.113 -      displayJavaThreads must only be set to true if the debugger is
  15.114 -      attached to a HotSpot JVM and if the VM has already been
  15.115 -      initialized. */
  15.116 -  public ThreadListPanel(CDebugger dbg, final boolean displayJavaThreads) {
  15.117 -    super();
  15.118 -
  15.119 -    Map threadToJavaThreadMap = null;
  15.120 -    if (displayJavaThreads) {
  15.121 -      // Collect Java threads from virtual machine and insert them in
  15.122 -      // table for later querying
  15.123 -      threadToJavaThreadMap = new HashMap();
  15.124 -      Threads threads = VM.getVM().getThreads();
  15.125 -      for (JavaThread thr = threads.first(); thr != null; thr = thr.next()) {
  15.126 -        threadToJavaThreadMap.put(thr.getThreadProxy(), thr);
  15.127 -      }
  15.128 -    }
  15.129 -
  15.130 -    java.util.List/*<ThreadProxy>*/ threads = dbg.getThreadList();
  15.131 -    threadList = new ArrayList(threads.size());
  15.132 -    for (Iterator iter = threads.iterator(); iter.hasNext(); ) {
  15.133 -      ThreadProxy thr = (ThreadProxy) iter.next();
  15.134 -      JavaThread jthr = null;
  15.135 -      if (displayJavaThreads) {
  15.136 -        jthr = (JavaThread) threadToJavaThreadMap.get(thr);
  15.137 -      }
  15.138 -      threadList.add(new ThreadInfo(thr, dbg, jthr));
  15.139 -    }
  15.140 -
  15.141 -    // Thread ID, current PC, current symbol, Java Thread, [Java thread name]
  15.142 -    dataModel = new AbstractTableModel() {
  15.143 -        public int getColumnCount() { return (displayJavaThreads ? 5 : 3); }
  15.144 -        public int getRowCount()    { return threadList.size(); }
  15.145 -        public String getColumnName(int col) {
  15.146 -          switch (col) {
  15.147 -          case 0:
  15.148 -            return "Thread ID";
  15.149 -          case 1:
  15.150 -            return "PC";
  15.151 -          case 2:
  15.152 -            return "Location";
  15.153 -          case 3:
  15.154 -            return "Java?";
  15.155 -          case 4:
  15.156 -            return "Java Thread Name";
  15.157 -          default:
  15.158 -            throw new RuntimeException("Index " + col + " out of bounds");
  15.159 -          }
  15.160 -        }
  15.161 -        public Object getValueAt(int row, int col) {
  15.162 -          ThreadInfo info = (ThreadInfo) threadList.get(row);
  15.163 -
  15.164 -          switch (col) {
  15.165 -          case 0:
  15.166 -            return info.getThread();
  15.167 -          case 1:
  15.168 -            {
  15.169 -              if (info.hasPC()) {
  15.170 -                return info.getPC();
  15.171 -              }
  15.172 -              return "<no frames on stack>";
  15.173 -            }
  15.174 -          case 2:
  15.175 -            return info.getLocation();
  15.176 -          case 3:
  15.177 -            if (info.isJavaThread()) {
  15.178 -              return "Yes";
  15.179 -            } else {
  15.180 -              return "";
  15.181 -            }
  15.182 -          case 4:
  15.183 -            if (info.isJavaThread()) {
  15.184 -              return info.getJavaThreadName();
  15.185 -            } else {
  15.186 -              return "";
  15.187 -            }
  15.188 -          default:
  15.189 -            throw new RuntimeException("Index (" + col + ", " + row + ") out of bounds");
  15.190 -          }
  15.191 -        }
  15.192 -      };
  15.193 -
  15.194 -    // Build user interface
  15.195 -    setLayout(new BorderLayout());
  15.196 -    table = new JTable(dataModel);
  15.197 -    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  15.198 -    JTableHeader header = table.getTableHeader();
  15.199 -    header.setReorderingAllowed(false);
  15.200 -    table.setRowSelectionAllowed(true);
  15.201 -    table.setColumnSelectionAllowed(false);
  15.202 -    JScrollPane scrollPane = new JScrollPane(table);
  15.203 -    add(scrollPane, BorderLayout.CENTER);
  15.204 -    if (threadList.size() > 0) {
  15.205 -      table.setRowSelectionInterval(0, 0);
  15.206 -    }
  15.207 -
  15.208 -    JButton button = new JButton("Set Focus");
  15.209 -    button.addActionListener(new ActionListener() {
  15.210 -        public void actionPerformed(ActionEvent e) {
  15.211 -          int i = table.getSelectedRow();
  15.212 -          if (i < 0) {
  15.213 -            return;
  15.214 -          }
  15.215 -          ThreadInfo info = (ThreadInfo) threadList.get(i);
  15.216 -          for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
  15.217 -            ((Listener) iter.next()).setFocus(info.getThread(), info.getJavaThread());
  15.218 -          }
  15.219 -        }
  15.220 -      });
  15.221 -    JPanel focusPanel = new JPanel();
  15.222 -    focusPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
  15.223 -    focusPanel.setLayout(new BoxLayout(focusPanel, BoxLayout.Y_AXIS));
  15.224 -    focusPanel.add(Box.createGlue());
  15.225 -    focusPanel.add(button);
  15.226 -    focusPanel.add(Box.createGlue());
  15.227 -    add(focusPanel, BorderLayout.EAST);
  15.228 -
  15.229 -    // FIXME: make listener model for the debugger so if the user
  15.230 -    // specifies a mapfile for or path to a given DSO later we can
  15.231 -    // update our state
  15.232 -  }
  15.233 -
  15.234 -  public void addListener(Listener l) {
  15.235 -    if (listeners == null) {
  15.236 -      listeners = new ArrayList();
  15.237 -    }
  15.238 -    listeners.add(l);
  15.239 -  }
  15.240 -}
    16.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/VariablePanel.java	Thu Feb 21 07:50:48 2013 -0500
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,252 +0,0 @@
    16.4 -/*
    16.5 - * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
    16.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 - *
    16.8 - * This code is free software; you can redistribute it and/or modify it
    16.9 - * under the terms of the GNU General Public License version 2 only, as
   16.10 - * published by the Free Software Foundation.
   16.11 - *
   16.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 - * version 2 for more details (a copy is included in the LICENSE file that
   16.16 - * accompanied this code).
   16.17 - *
   16.18 - * You should have received a copy of the GNU General Public License version
   16.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 - *
   16.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.23 - * or visit www.oracle.com if you need additional information or have any
   16.24 - * questions.
   16.25 - *
   16.26 - */
   16.27 -
   16.28 -package sun.jvm.hotspot.bugspot;
   16.29 -
   16.30 -import java.awt.*;
   16.31 -import javax.swing.*;
   16.32 -import java.util.*;
   16.33 -import sun.jvm.hotspot.debugger.*;
   16.34 -import sun.jvm.hotspot.debugger.cdbg.*;
   16.35 -import sun.jvm.hotspot.bugspot.tree.*;
   16.36 -import sun.jvm.hotspot.oops.*;
   16.37 -import sun.jvm.hotspot.runtime.*;
   16.38 -import sun.jvm.hotspot.ui.tree.*;
   16.39 -import sun.jvm.hotspot.ui.treetable.*;
   16.40 -
   16.41 -/** Manages display of a set of local variables in a frame, or the
   16.42 -    contents of the "this" pointer */
   16.43 -
   16.44 -public class VariablePanel extends JPanel {
   16.45 -  private JTreeTable treeTable;
   16.46 -  private SimpleTreeTableModel model;
   16.47 -  private SimpleTreeGroupNode root;
   16.48 -
   16.49 -  public VariablePanel() {
   16.50 -    super();
   16.51 -
   16.52 -    model = new SimpleTreeTableModel();
   16.53 -    model.setValuesEditable(false);
   16.54 -    root = new SimpleTreeGroupNode();
   16.55 -    model.setRoot(root);
   16.56 -    treeTable = new JTreeTable(model);
   16.57 -    treeTable.setRootVisible(false);
   16.58 -    treeTable.setShowsRootHandles(true);
   16.59 -    treeTable.setShowsIcons(false);
   16.60 -    treeTable.setTreeEditable(false);
   16.61 -    treeTable.getTableHeader().setReorderingAllowed(false);
   16.62 -    treeTable.setCellSelectionEnabled(true);
   16.63 -    treeTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   16.64 -    treeTable.setDragEnabled(true);
   16.65 -    JScrollPane sp = new JScrollPane(treeTable);
   16.66 -    sp.getViewport().setBackground(Color.white);
   16.67 -
   16.68 -    setLayout(new BorderLayout());
   16.69 -    add(sp, BorderLayout.CENTER);
   16.70 -  }
   16.71 -
   16.72 -  /** Clear the contents of this VariablePanel */
   16.73 -  public void clear() {
   16.74 -    root.removeAllChildren();
   16.75 -    model.fireTreeStructureChanged();
   16.76 -  }
   16.77 -
   16.78 -  /** Update the contents of this VariablePanel from the given CFrame */
   16.79 -  public void update(CFrame fr) {
   16.80 -    // Collect locals
   16.81 -    CCollector coll = new CCollector();
   16.82 -    fr.iterateLocals(coll);
   16.83 -    update(coll);
   16.84 -  }
   16.85 -
   16.86 -  /** Update the contents of this VariablePanel from the given JavaVFrame */
   16.87 -  public void update(JavaVFrame jfr) {
   16.88 -    Method m = jfr.getMethod();
   16.89 -    if (!m.hasLocalVariableTable()) {
   16.90 -      return;
   16.91 -    }
   16.92 -    int bci = jfr.getBCI();
   16.93 -    // Get local variable table
   16.94 -    LocalVariableTableElement[] locals = m.getLocalVariableTable();
   16.95 -    // Get locals as StackValueCollection
   16.96 -    StackValueCollection coll = jfr.getLocals();
   16.97 -    root.removeAllChildren();
   16.98 -    // See which locals are live
   16.99 -    for (int i = 0; i < locals.length; i++) {
  16.100 -      LocalVariableTableElement local = locals[i];
  16.101 -      if (local.getStartBCI() <= bci && bci < local.getStartBCI() + local.getLength()) {
  16.102 -        // Valid; add it
  16.103 -        SimpleTreeNode node = null;
  16.104 -        Symbol name = null;
  16.105 -        try {
  16.106 -          name = m.getConstants().getSymbolAt(local.getNameCPIndex());
  16.107 -          if (name == null) {
  16.108 -            System.err.println("Null name at slot " +
  16.109 -                               local.getNameCPIndex() +
  16.110 -                               " for local variable at slot " +
  16.111 -                               local.getSlot());
  16.112 -            continue;
  16.113 -          }
  16.114 -        } catch (Exception e) {
  16.115 -          System.err.println("Unable to fetch name at slot " +
  16.116 -                             local.getNameCPIndex() +
  16.117 -                             " for local variable at slot " +
  16.118 -                             local.getSlot());
  16.119 -          e.printStackTrace();
  16.120 -          continue;
  16.121 -        }
  16.122 -        sun.jvm.hotspot.oops.NamedFieldIdentifier f =
  16.123 -          new sun.jvm.hotspot.oops.NamedFieldIdentifier(name.asString());
  16.124 -        Symbol descriptor = null;
  16.125 -        try {
  16.126 -          descriptor = m.getConstants().getSymbolAt(local.getDescriptorCPIndex());
  16.127 -        } catch (Exception e) {
  16.128 -          System.err.println("Unable to fetch descriptor at slot " +
  16.129 -                             local.getDescriptorCPIndex() +
  16.130 -                             " for local variable " + f.getName() +
  16.131 -                             " at slot " + local.getSlot());
  16.132 -          e.printStackTrace();
  16.133 -          continue;
  16.134 -        }
  16.135 -
  16.136 -        if (descriptor != null) {
  16.137 -          switch (descriptor.getByteAt(0)) {
  16.138 -          case 'F': {
  16.139 -            node = new sun.jvm.hotspot.ui.tree.FloatTreeNodeAdapter(coll.floatAt(local.getSlot()), f, true);
  16.140 -            break;
  16.141 -          }
  16.142 -          case 'D': {
  16.143 -            node = new sun.jvm.hotspot.ui.tree.DoubleTreeNodeAdapter(coll.doubleAt(local.getSlot()), f, true);
  16.144 -            break;
  16.145 -          }
  16.146 -          case 'C': {
  16.147 -            node = new sun.jvm.hotspot.ui.tree.CharTreeNodeAdapter((char) coll.intAt(local.getSlot()), f, true);
  16.148 -            break;
  16.149 -          }
  16.150 -          case 'B':
  16.151 -          case 'S':
  16.152 -          case 'I': {
  16.153 -            node = new sun.jvm.hotspot.ui.tree.LongTreeNodeAdapter(coll.intAt(local.getSlot()), f, true);
  16.154 -            break;
  16.155 -          }
  16.156 -          case 'Z': {
  16.157 -            node = new sun.jvm.hotspot.ui.tree.BooleanTreeNodeAdapter(
  16.158 -              ((coll.intAt(local.getSlot()) != 0) ? true : false), f, true
  16.159 -            );
  16.160 -            break;
  16.161 -          }
  16.162 -          case 'J': {
  16.163 -            node = new sun.jvm.hotspot.ui.tree.LongTreeNodeAdapter(coll.longAt(local.getSlot()), f, true);
  16.164 -            break;
  16.165 -          }
  16.166 -          default: {
  16.167 -            try {
  16.168 -              node = new sun.jvm.hotspot.ui.tree.OopTreeNodeAdapter(
  16.169 -                VM.getVM().getObjectHeap().newOop(coll.oopHandleAt(local.getSlot())), f, true
  16.170 -              );
  16.171 -            } catch (AddressException e) {
  16.172 -              node = new sun.jvm.hotspot.ui.tree.FieldTreeNodeAdapter(f, true) {
  16.173 -                  public int getChildCount()                       { return 0;     }
  16.174 -                  public SimpleTreeNode getChild(int i)            { return null;  }
  16.175 -                  public boolean isLeaf()                          { return false; }
  16.176 -                  public int getIndexOfChild(SimpleTreeNode child) { return 0;     }
  16.177 -                  public String getValue() {
  16.178 -                    return "<Bad oop>";
  16.179 -                  }
  16.180 -                };
  16.181 -            }
  16.182 -            break;
  16.183 -          }
  16.184 -          }
  16.185 -          if (node != null) {
  16.186 -            root.addChild(node);
  16.187 -          }
  16.188 -        }
  16.189 -      }
  16.190 -    }
  16.191 -
  16.192 -    model.fireTreeStructureChanged();
  16.193 -  }
  16.194 -
  16.195 -  /** Update the contents of this VariablePanel from the given "this"
  16.196 -      pointer of the given type */
  16.197 -  public void update(Address thisAddr, Type type) {
  16.198 -    // Collect fields
  16.199 -    CCollector coll = new CCollector();
  16.200 -    type.iterateObject(thisAddr, coll);
  16.201 -    update(coll);
  16.202 -  }
  16.203 -
  16.204 -  private void update(CCollector coll) {
  16.205 -    root.removeAllChildren();
  16.206 -    for (int i = 0; i < coll.getNumChildren(); i++) {
  16.207 -      root.addChild(coll.getChild(i));
  16.208 -    }
  16.209 -    model.fireTreeStructureChanged();
  16.210 -  }
  16.211 -
  16.212 -  static class CCollector extends DefaultObjectVisitor {
  16.213 -    private java.util.List children;
  16.214 -
  16.215 -    public CCollector() {
  16.216 -      children = new ArrayList();
  16.217 -    }
  16.218 -
  16.219 -    public int getNumChildren() {
  16.220 -      return children.size();
  16.221 -    }
  16.222 -
  16.223 -    public SimpleTreeNode getChild(int i) {
  16.224 -      return (SimpleTreeNode) children.get(i);
  16.225 -    }
  16.226 -
  16.227 -    public void doBit(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, long val) {
  16.228 -      children.add(new sun.jvm.hotspot.bugspot.tree.LongTreeNodeAdapter(val, f, true));
  16.229 -    }
  16.230 -    public void doInt(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, long val) {
  16.231 -      children.add(new sun.jvm.hotspot.bugspot.tree.LongTreeNodeAdapter(val, f, true));
  16.232 -    }
  16.233 -    public void doEnum(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, long val, String enumName) {
  16.234 -      children.add(new sun.jvm.hotspot.bugspot.tree.EnumTreeNodeAdapter(enumName, val, f, true));
  16.235 -    }
  16.236 -    public void doFloat(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, float val) {
  16.237 -      children.add(new sun.jvm.hotspot.bugspot.tree.FloatTreeNodeAdapter(val, f, true));
  16.238 -    }
  16.239 -    public void doDouble(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, double val) {
  16.240 -      children.add(new sun.jvm.hotspot.bugspot.tree.DoubleTreeNodeAdapter(val, f, true));
  16.241 -    }
  16.242 -    public void doPointer(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, Address val) {
  16.243 -      children.add(new sun.jvm.hotspot.bugspot.tree.AddressTreeNodeAdapter(val, f, true));
  16.244 -    }
  16.245 -    public void doArray(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, Address val) {
  16.246 -      children.add(new sun.jvm.hotspot.bugspot.tree.AddressTreeNodeAdapter(val, f, true));
  16.247 -    }
  16.248 -    public void doRef(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, Address val) {
  16.249 -      children.add(new sun.jvm.hotspot.bugspot.tree.AddressTreeNodeAdapter(val, f, true));
  16.250 -    }
  16.251 -    public void doCompound(sun.jvm.hotspot.debugger.cdbg.FieldIdentifier f, Address val) {
  16.252 -      children.add(new sun.jvm.hotspot.bugspot.tree.ObjectTreeNodeAdapter(val, f, true));
  16.253 -    }
  16.254 -  }
  16.255 -}
    17.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/AddressTreeNodeAdapter.java	Thu Feb 21 07:50:48 2013 -0500
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,67 +0,0 @@
    17.4 -/*
    17.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    17.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 - *
    17.8 - * This code is free software; you can redistribute it and/or modify it
    17.9 - * under the terms of the GNU General Public License version 2 only, as
   17.10 - * published by the Free Software Foundation.
   17.11 - *
   17.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 - * version 2 for more details (a copy is included in the LICENSE file that
   17.16 - * accompanied this code).
   17.17 - *
   17.18 - * You should have received a copy of the GNU General Public License version
   17.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 - *
   17.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.23 - * or visit www.oracle.com if you need additional information or have any
   17.24 - * questions.
   17.25 - *
   17.26 - */
   17.27 -
   17.28 -package sun.jvm.hotspot.bugspot.tree;
   17.29 -
   17.30 -import sun.jvm.hotspot.debugger.*;
   17.31 -import sun.jvm.hotspot.debugger.cdbg.*;
   17.32 -import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
   17.33 -
   17.34 -/** Encapsulates a float value in a tree handled by SimpleTreeModel */
   17.35 -
   17.36 -public class AddressTreeNodeAdapter extends FieldTreeNodeAdapter {
   17.37 -  private Address val;
   17.38 -
   17.39 -  public AddressTreeNodeAdapter(Address val, FieldIdentifier id) {
   17.40 -    this(val, id, false);
   17.41 -  }
   17.42 -
   17.43 -  public AddressTreeNodeAdapter(Address val, FieldIdentifier id, boolean treeTableMode) {
   17.44 -    super(id, treeTableMode);
   17.45 -    this.val = val;
   17.46 -  }
   17.47 -
   17.48 -  public int getChildCount() {
   17.49 -    return 0;
   17.50 -  }
   17.51 -
   17.52 -  public SimpleTreeNode getChild(int index) {
   17.53 -    return null;
   17.54 -  }
   17.55 -
   17.56 -  public boolean isLeaf() {
   17.57 -    return true;
   17.58 -  }
   17.59 -
   17.60 -  public int getIndexOfChild(SimpleTreeNode child) {
   17.61 -    return 0;
   17.62 -  }
   17.63 -
   17.64 -  public String getValue() {
   17.65 -    if (val != null) {
   17.66 -      return val.toString();
   17.67 -    }
   17.68 -    return "NULL";
   17.69 -  }
   17.70 -}
    18.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/DoubleTreeNodeAdapter.java	Thu Feb 21 07:50:48 2013 -0500
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,63 +0,0 @@
    18.4 -/*
    18.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    18.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 - *
    18.8 - * This code is free software; you can redistribute it and/or modify it
    18.9 - * under the terms of the GNU General Public License version 2 only, as
   18.10 - * published by the Free Software Foundation.
   18.11 - *
   18.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 - * version 2 for more details (a copy is included in the LICENSE file that
   18.16 - * accompanied this code).
   18.17 - *
   18.18 - * You should have received a copy of the GNU General Public License version
   18.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 - *
   18.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 - * or visit www.oracle.com if you need additional information or have any
   18.24 - * questions.
   18.25 - *
   18.26 - */
   18.27 -
   18.28 -package sun.jvm.hotspot.bugspot.tree;
   18.29 -
   18.30 -import sun.jvm.hotspot.debugger.cdbg.*;
   18.31 -import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
   18.32 -
   18.33 -/** Encapsulates a double value in a tree handled by SimpleTreeModel */
   18.34 -
   18.35 -public class DoubleTreeNodeAdapter extends FieldTreeNodeAdapter {
   18.36 -  private double val;
   18.37 -
   18.38 -  public DoubleTreeNodeAdapter(double val, FieldIdentifier id) {
   18.39 -    this(val, id, false);
   18.40 -  }
   18.41 -
   18.42 -  public DoubleTreeNodeAdapter(double val, FieldIdentifier id, boolean treeTableMode) {
   18.43 -    super(id, treeTableMode);
   18.44 -    this.val = val;
   18.45 -  }
   18.46 -
   18.47 -  public int getChildCount() {
   18.48 -    return 0;
   18.49 -  }
   18.50 -
   18.51 -  public SimpleTreeNode getChild(int index) {
   18.52 -    return null;
   18.53 -  }
   18.54 -
   18.55 -  public boolean isLeaf() {
   18.56 -    return true;
   18.57 -  }
   18.58 -
   18.59 -  public int getIndexOfChild(SimpleTreeNode child) {
   18.60 -    return 0;
   18.61 -  }
   18.62 -
   18.63 -  public String getValue() {
   18.64 -    return Double.toString(val);
   18.65 -  }
   18.66 -}
    19.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/EnumTreeNodeAdapter.java	Thu Feb 21 07:50:48 2013 -0500
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,69 +0,0 @@
    19.4 -/*
    19.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    19.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 - *
    19.8 - * This code is free software; you can redistribute it and/or modify it
    19.9 - * under the terms of the GNU General Public License version 2 only, as
   19.10 - * published by the Free Software Foundation.
   19.11 - *
   19.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 - * version 2 for more details (a copy is included in the LICENSE file that
   19.16 - * accompanied this code).
   19.17 - *
   19.18 - * You should have received a copy of the GNU General Public License version
   19.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 - *
   19.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 - * or visit www.oracle.com if you need additional information or have any
   19.24 - * questions.
   19.25 - *
   19.26 - */
   19.27 -
   19.28 -package sun.jvm.hotspot.bugspot.tree;
   19.29 -
   19.30 -import sun.jvm.hotspot.debugger.cdbg.*;
   19.31 -import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
   19.32 -
   19.33 -/** Encapsulates an enumerated value in a tree handled by SimpleTreeModel */
   19.34 -
   19.35 -public class EnumTreeNodeAdapter extends FieldTreeNodeAdapter {
   19.36 -  private long val;
   19.37 -  private String enumName;
   19.38 -
   19.39 -  public EnumTreeNodeAdapter(String enumName, long val, FieldIdentifier id) {
   19.40 -    this(enumName, val, id, false);
   19.41 -  }
   19.42 -
   19.43 -  public EnumTreeNodeAdapter(String enumName, long val, FieldIdentifier id, boolean treeTableMode) {
   19.44 -    super(id, treeTableMode);
   19.45 -    this.enumName = enumName;
   19.46 -    this.val = val;
   19.47 -  }
   19.48 -
   19.49 -  public int getChildCount() {
   19.50 -    return 0;
   19.51 -  }
   19.52 -
   19.53 -  public SimpleTreeNode getChild(int index) {
   19.54 -    return null;
   19.55 -  }
   19.56 -
   19.57 -  public boolean isLeaf() {
   19.58 -    return true;
   19.59 -  }
   19.60 -
   19.61 -  public int getIndexOfChild(SimpleTreeNode child) {
   19.62 -    return 0;
   19.63 -  }
   19.64 -
   19.65 -  public String getValue() {
   19.66 -    if (enumName != null) {
   19.67 -      return enumName;
   19.68 -    } else {
   19.69 -      return Long.toString(val);
   19.70 -    }
   19.71 -  }
   19.72 -}
    20.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/FieldTreeNodeAdapter.java	Thu Feb 21 07:50:48 2013 -0500
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,73 +0,0 @@
    20.4 -/*
    20.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    20.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 - *
    20.8 - * This code is free software; you can redistribute it and/or modify it
    20.9 - * under the terms of the GNU General Public License version 2 only, as
   20.10 - * published by the Free Software Foundation.
   20.11 - *
   20.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 - * version 2 for more details (a copy is included in the LICENSE file that
   20.16 - * accompanied this code).
   20.17 - *
   20.18 - * You should have received a copy of the GNU General Public License version
   20.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 - *
   20.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 - * or visit www.oracle.com if you need additional information or have any
   20.24 - * questions.
   20.25 - *
   20.26 - */
   20.27 -
   20.28 -package sun.jvm.hotspot.bugspot.tree;
   20.29 -
   20.30 -import sun.jvm.hotspot.debugger.cdbg.*;
   20.31 -import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
   20.32 -
   20.33 -/** Abstract base class for all adapters for fields of C/C++ objects */
   20.34 -
   20.35 -public abstract class FieldTreeNodeAdapter implements SimpleTreeNode {
   20.36 -  private FieldIdentifier id;
   20.37 -  private boolean         treeTableMode;
   20.38 -
   20.39 -  /** The identifier may be null, i.e., for the root of the tree */
   20.40 -  public FieldTreeNodeAdapter(FieldIdentifier id, boolean treeTableMode) {
   20.41 -    this.id = id;
   20.42 -    this.treeTableMode = treeTableMode;
   20.43 -  }
   20.44 -
   20.45 -  public FieldIdentifier getID() {
   20.46 -    return id;
   20.47 -  }
   20.48 -
   20.49 -  /** Defaults to false in subclasses */
   20.50 -  public boolean getTreeTableMode() {
   20.51 -    return treeTableMode;
   20.52 -  }
   20.53 -
   20.54 -  public Type getType() {
   20.55 -    return getID().getType();
   20.56 -  }
   20.57 -
   20.58 -  public String getName() {
   20.59 -    if (getID() != null) {
   20.60 -      return getID().toString();
   20.61 -    }
   20.62 -    return "";
   20.63 -  }
   20.64 -
   20.65 -  public String toString() {
   20.66 -    if (treeTableMode) {
   20.67 -      return getName();
   20.68 -    } else {
   20.69 -      if (getID() != null) {
   20.70 -        return getName() + ": " + getValue();
   20.71 -      } else {
   20.72 -        return getValue();
   20.73 -      }
   20.74 -    }
   20.75 -  }
   20.76 -}
    21.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/FloatTreeNodeAdapter.java	Thu Feb 21 07:50:48 2013 -0500
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,63 +0,0 @@
    21.4 -/*
    21.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    21.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 - *
    21.8 - * This code is free software; you can redistribute it and/or modify it
    21.9 - * under the terms of the GNU General Public License version 2 only, as
   21.10 - * published by the Free Software Foundation.
   21.11 - *
   21.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 - * version 2 for more details (a copy is included in the LICENSE file that
   21.16 - * accompanied this code).
   21.17 - *
   21.18 - * You should have received a copy of the GNU General Public License version
   21.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 - *
   21.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 - * or visit www.oracle.com if you need additional information or have any
   21.24 - * questions.
   21.25 - *
   21.26 - */
   21.27 -
   21.28 -package sun.jvm.hotspot.bugspot.tree;
   21.29 -
   21.30 -import sun.jvm.hotspot.debugger.cdbg.*;
   21.31 -import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
   21.32 -
   21.33 -/** Encapsulates a float value in a tree handled by SimpleTreeModel */
   21.34 -
   21.35 -public class FloatTreeNodeAdapter extends FieldTreeNodeAdapter {
   21.36 -  private float val;
   21.37 -
   21.38 -  public FloatTreeNodeAdapter(float val, FieldIdentifier id) {
   21.39 -    this(val, id, false);
   21.40 -  }
   21.41 -
   21.42 -  public FloatTreeNodeAdapter(float val, FieldIdentifier id, boolean treeTableMode) {
   21.43 -    super(id, treeTableMode);
   21.44 -    this.val = val;
   21.45 -  }
   21.46 -
   21.47 -  public int getChildCount() {
   21.48 -    return 0;
   21.49 -  }
   21.50 -
   21.51 -  public SimpleTreeNode getChild(int index) {
   21.52 -    return null;
   21.53 -  }
   21.54 -
   21.55 -  public boolean isLeaf() {
   21.56 -    return true;
   21.57 -  }
   21.58 -
   21.59 -  public int getIndexOfChild(SimpleTreeNode child) {
   21.60 -    return 0;
   21.61 -  }
   21.62 -
   21.63 -  public String getValue() {
   21.64 -    return Float.toString(val);
   21.65 -  }
   21.66 -}
    22.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/LongTreeNodeAdapter.java	Thu Feb 21 07:50:48 2013 -0500
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,63 +0,0 @@
    22.4 -/*
    22.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    22.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 - *
    22.8 - * This code is free software; you can redistribute it and/or modify it
    22.9 - * under the terms of the GNU General Public License version 2 only, as
   22.10 - * published by the Free Software Foundation.
   22.11 - *
   22.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 - * version 2 for more details (a copy is included in the LICENSE file that
   22.16 - * accompanied this code).
   22.17 - *
   22.18 - * You should have received a copy of the GNU General Public License version
   22.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 - *
   22.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 - * or visit www.oracle.com if you need additional information or have any
   22.24 - * questions.
   22.25 - *
   22.26 - */
   22.27 -
   22.28 -package sun.jvm.hotspot.bugspot.tree;
   22.29 -
   22.30 -import sun.jvm.hotspot.debugger.cdbg.*;
   22.31 -import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
   22.32 -
   22.33 -/** Encapsulates a long value in a tree handled by SimpleTreeModel */
   22.34 -
   22.35 -public class LongTreeNodeAdapter extends FieldTreeNodeAdapter {
   22.36 -  private long val;
   22.37 -
   22.38 -  public LongTreeNodeAdapter(long val, FieldIdentifier id) {
   22.39 -    this(val, id, false);
   22.40 -  }
   22.41 -
   22.42 -  public LongTreeNodeAdapter(long val, FieldIdentifier id, boolean treeTableMode) {
   22.43 -    super(id, treeTableMode);
   22.44 -    this.val = val;
   22.45 -  }
   22.46 -
   22.47 -  public int getChildCount() {
   22.48 -    return 0;
   22.49 -  }
   22.50 -
   22.51 -  public SimpleTreeNode getChild(int index) {
   22.52 -    return null;
   22.53 -  }
   22.54 -
   22.55 -  public boolean isLeaf() {
   22.56 -    return true;
   22.57 -  }
   22.58 -
   22.59 -  public int getIndexOfChild(SimpleTreeNode child) {
   22.60 -    return 0;
   22.61 -  }
   22.62 -
   22.63 -  public String getValue() {
   22.64 -    return Long.toString(val);
   22.65 -  }
   22.66 -}
    23.1 --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/tree/ObjectTreeNodeAdapter.java	Thu Feb 21 07:50:48 2013 -0500
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,216 +0,0 @@
    23.4 -/*
    23.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
    23.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 - *
    23.8 - * This code is free software; you can redistribute it and/or modify it
    23.9 - * under the terms of the GNU General Public License version 2 only, as
   23.10 - * published by the Free Software Foundation.
   23.11 - *
   23.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 - * version 2 for more details (a copy is included in the LICENSE file that
   23.16 - * accompanied this code).
   23.17 - *
   23.18 - * You should have received a copy of the GNU General Public License version
   23.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 - *
   23.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   23.23 - * or visit www.oracle.com if you need additional information or have any
   23.24 - * questions.
   23.25 - *
   23.26 - */
   23.27 -
   23.28 -package sun.jvm.hotspot.bugspot.tree;
   23.29 -
   23.30 -import java.io.*;
   23.31 -import sun.jvm.hotspot.debugger.*;
   23.32 -import sun.jvm.hotspot.debugger.cdbg.*;
   23.33 -import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
   23.34 -
   23.35 -/** An adapter class which allows C/C++ objects to be displayed in a
   23.36 -    tree via the SimpleTreeNode interface. */
   23.37 -
   23.38 -public class ObjectTreeNodeAdapter extends FieldTreeNodeAdapter {
   23.39 -  // Address of object
   23.40 -  private Address addr;
   23.41 -
   23.42 -  /** The address may be null (for object fields of objcets which are
   23.43 -      null). The FieldIdentifier should not be null. treeTableMode
   23.44 -      defaults to false. */
   23.45 -  public ObjectTreeNodeAdapter(Address addr, FieldIdentifier id) {
   23.46 -    this(addr, id, false);
   23.47 -  }
   23.48 -
   23.49 -  /** The address may be null (for object fields of objcets which are
   23.50 -      null). The FieldIdentifier should not be null. */
   23.51 -  public ObjectTreeNodeAdapter(Address addr, FieldIdentifier id, boolean treeTableMode) {
   23.52 -    super(id, treeTableMode);
   23.53 -    this.addr = addr;
   23.54 -  }
   23.55 -
   23.56 -  public int getChildCount() {
   23.57 -    if (addr == null) {
   23.58 -      return 0;
   23.59 -    }
   23.60 -
   23.61 -    Counter c = new Counter();
   23.62 -    getType().iterateObject(addr, c);
   23.63 -    return c.getNumFields();
   23.64 -  }
   23.65 -
   23.66 -  public SimpleTreeNode getChild(int index) {
   23.67 -    if (addr == null) {
   23.68 -      return null;
   23.69 -    }
   23.70 -
   23.71 -    Fetcher f = new Fetcher(index);
   23.72 -    getType().iterateObject(addr, f);
   23.73 -    return f.getChild();
   23.74 -  }
   23.75 -
   23.76 -  public boolean isLeaf() {
   23.77 -    return (addr == null);
   23.78 -  }
   23.79 -
   23.80 -  public int getIndexOfChild(SimpleTreeNode child) {
   23.81 -    FieldIdentifier id = ((FieldTreeNodeAdapter) child).getID();
   23.82 -    Finder f = new Finder(id);
   23.83 -    getType().iterateObject(addr, f);
   23.84 -    return f.getIndex();
   23.85 -  }
   23.86 -
   23.87 -  public String getValue() {
   23.88 -    if (addr != null) {
   23.89 -      return addr.toString();
   23.90 -    }
   23.91 -    return "NULL";
   23.92 -  }
   23.93 -
   23.94 -  /** Should be used only once, then have the number of fields
   23.95 -      fetched. */
   23.96 -  static class Counter extends DefaultObjectVisitor {
   23.97 -    private int numFields;
   23.98 -
   23.99 -    public int getNumFields() {
  23.100 -      return numFields;
  23.101 -    }
  23.102 -
  23.103 -    public void doBit(FieldIdentifier f, long val)                   { ++numFields; }
  23.104 -    public void doInt(FieldIdentifier f, long val)                   { ++numFields; }
  23.105 -    public void doEnum(FieldIdentifier f, long val, String enumName) { ++numFields; }
  23.106 -    public void doFloat(FieldIdentifier f, float val)                { ++numFields; }
  23.107 -    public void doDouble(FieldIdentifier f, double val)              { ++numFields; }
  23.108 -    public void doPointer(FieldIdentifier f, Address val)            { ++numFields; }
  23.109 -    public void doArray(FieldIdentifier f, Address val)              { ++numFields; }
  23.110 -    public void doRef(FieldIdentifier f, Address val)                { ++numFields; }
  23.111 -    public void doCompound(FieldIdentifier f, Address addr)          { ++numFields; }
  23.112 -  }
  23.113 -
  23.114 -  /** Creates a new SimpleTreeNode for the given field. */
  23.115 -  class Fetcher extends DefaultObjectVisitor {
  23.116 -    private int index;
  23.117 -    private int curField;
  23.118 -    private SimpleTreeNode child;
  23.119 -
  23.120 -    public Fetcher(int index) {
  23.121 -      this.index = index;
  23.122 -    }
  23.123 -
  23.124 -    public SimpleTreeNode getChild() {
  23.125 -      return child;
  23.126 -    }
  23.127 -
  23.128 -    public void doBit(FieldIdentifier f, long val) {
  23.129 -      if (curField == index) {
  23.130 -        child = new LongTreeNodeAdapter(val, f, getTreeTableMode());
  23.131 -      }
  23.132 -      ++curField;
  23.133 -    }
  23.134 -
  23.135 -    public void doInt(FieldIdentifier f, long val) {
  23.136 -      if (curField == index) {
  23.137 -        child = new LongTreeNodeAdapter(val, f, getTreeTableMode());
  23.138 -      }
  23.139 -      ++curField;
  23.140 -    }
  23.141 -
  23.142 -    public void doEnum(FieldIdentifier f, long val, String enumName) {
  23.143 -      if (curField == index) {
  23.144 -        child = new EnumTreeNodeAdapter(enumName, val, f, getTreeTableMode());
  23.145 -      }
  23.146 -      ++curField;
  23.147 -    }
  23.148 -
  23.149 -    public void doFloat(FieldIdentifier f, float val) {
  23.150 -      if (curField == index) {
  23.151 -        child = new FloatTreeNodeAdapter(val, f, getTreeTableMode());
  23.152 -      }
  23.153 -      ++curField;
  23.154 -    }
  23.155 -
  23.156 -    public void doDouble(FieldIdentifier f, double val) {
  23.157 -      if (curField == index) {
  23.158 -        child = new DoubleTreeNodeAdapter(val, f, getTreeTableMode());
  23.159 -      }
  23.160 -      ++curField;
  23.161 -    }
  23.162 -
  23.163 -    public void doPointer(FieldIdentifier f, Address val) {
  23.164 -      if (curField == index) {
  23.165 -        child = new AddressTreeNodeAdapter(val, f, getTreeTableMode());
  23.166 -      }
  23.167 -      ++curField;
  23.168 -    }
  23.169 -
  23.170 -    public void doArray(FieldIdentifier f, Address val) {
  23.171 -      if (curField == index) {
  23.172 -        child = new AddressTreeNodeAdapter(val, f, getTreeTableMode());
  23.173 -      }
  23.174 -      ++curField;
  23.175 -    }
  23.176 -
  23.177 -    public void doRef(FieldIdentifier f, Address val) {
  23.178 -      if (curField == index) {
  23.179 -        child = new AddressTreeNodeAdapter(val, f, getTreeTableMode());
  23.180 -      }
  23.181 -      ++curField;
  23.182 -    }
  23.183 -
  23.184 -    public void doCompound(FieldIdentifier f, Address val) {
  23.185 -      if (curField == index) {
  23.186 -        child = new ObjectTreeNodeAdapter(val, f, getTreeTableMode());
  23.187 -      }
  23.188 -      ++curField;
  23.189 -    }
  23.190 -  }
  23.191 -
  23.192 -  /** Finds the index of the given FieldIdentifier. */
  23.193 -  static class Finder extends DefaultObjectVisitor {
  23.194 -    private FieldIdentifier id;
  23.195 -    private int curField;
  23.196 -    private int index = -1;
  23.197 -
  23.198 -    public Finder(FieldIdentifier id) {
  23.199 -      this.id = id;
  23.200 -    }
  23.201 -
  23.202 -    /** Returns -1 if not found */
  23.203 -    public int getIndex() {
  23.204 -      return index;
  23.205 -    }
  23.206 -
  23.207 -    public void doBit(FieldIdentifier f, long val)        { if (f.equals(id)) { index = curField; } ++curField; }
  23.208 -    public void doInt(FieldIdentifier f, long val)        { if (f.equals(id)) { index = curField; } ++curField; }
  23.209 -    public void doEnum(FieldIdentifier f, long val,
  23.210 -                       String enumName)                   { if (f.equals(id)) { index = curField; } ++curField; }
  23.211 -    public void doFloat(FieldIdentifier f, float val)     { if (f.equals(id)) { index = curField; } ++curField; }
  23.212 -    public void doDouble(FieldIdentifier f, double val)   { if (f.equals(id)) { index = curField; } ++curField; }
  23.213 -    public void doPointer(FieldIdentifier f, Address val) { if (f.equals(id)) { index = curField; } ++curField; }
  23.214 -    public void doArray(FieldIdentifier f, Address val)   { if (f.equals(id)) { index = curField; } ++curField; }
  23.215 -    public void doRef(FieldIdentifier f, Address val)     { if (f.equals(id)) { index = curField; } ++curField; }
  23.216 -    public void doCompound(FieldIdentifier f,
  23.217 -                           Address val)                   { if (f.equals(id)) { index = curField; } ++curField; }
  23.218 -  }
  23.219 -}
    24.1 --- a/agent/src/share/classes/sun/jvm/hotspot/livejvm/BreakpointEvent.java	Thu Feb 21 07:50:48 2013 -0500
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,51 +0,0 @@
    24.4 -/*
    24.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    24.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.7 - *
    24.8 - * This code is free software; you can redistribute it and/or modify it
    24.9 - * under the terms of the GNU General Public License version 2 only, as
   24.10 - * published by the Free Software Foundation.
   24.11 - *
   24.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   24.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   24.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   24.15 - * version 2 for more details (a copy is included in the LICENSE file that
   24.16 - * accompanied this code).
   24.17 - *
   24.18 - * You should have received a copy of the GNU General Public License version
   24.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   24.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   24.21 - *
   24.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   24.23 - * or visit www.oracle.com if you need additional information or have any
   24.24 - * questions.
   24.25 - *
   24.26 - */
   24.27 -
   24.28 -package sun.jvm.hotspot.livejvm;
   24.29 -
   24.30 -import sun.jvm.hotspot.oops.*;
   24.31 -import sun.jvm.hotspot.runtime.*;
   24.32 -
   24.33 -public class BreakpointEvent extends Event {
   24.34 -  private Oop thread;
   24.35 -  private Oop clazz;
   24.36 -  private JNIid method;
   24.37 -  private int location;
   24.38 -
   24.39 -  public BreakpointEvent(Oop thread,
   24.40 -                         Oop clazz,
   24.41 -                         JNIid method,
   24.42 -                         int location) {
   24.43 -    super(Event.Type.BREAKPOINT);
   24.44 -    this.thread = thread;
   24.45 -    this.clazz = clazz;
   24.46 -    this.method = method;
   24.47 -    this.location = location;
   24.48 -  }
   24.49 -
   24.50 -  public Oop thread()     { return thread;   }
   24.51 -  public Oop clazz()      { return clazz;    }
   24.52 -  public JNIid methodID() { return method;   }
   24.53 -  public int location()   { return location; }
   24.54 -}
    25.1 --- a/agent/src/share/classes/sun/jvm/hotspot/livejvm/CIntegerAccessor.java	Thu Feb 21 07:50:48 2013 -0500
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,47 +0,0 @@
    25.4 -/*
    25.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    25.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 - *
    25.8 - * This code is free software; you can redistribute it and/or modify it
    25.9 - * under the terms of the GNU General Public License version 2 only, as
   25.10 - * published by the Free Software Foundation.
   25.11 - *
   25.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 - * version 2 for more details (a copy is included in the LICENSE file that
   25.16 - * accompanied this code).
   25.17 - *
   25.18 - * You should have received a copy of the GNU General Public License version
   25.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 - *
   25.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 - * or visit www.oracle.com if you need additional information or have any
   25.24 - * questions.
   25.25 - *
   25.26 - */
   25.27 -
   25.28 -package sun.jvm.hotspot.livejvm;
   25.29 -
   25.30 -import sun.jvm.hotspot.debugger.*;
   25.31 -
   25.32 -class CIntegerAccessor {
   25.33 -  private Address addr;
   25.34 -  private long numBytes;
   25.35 -  private boolean isUnsigned;
   25.36 -
   25.37 -  CIntegerAccessor(Address addr, long numBytes, boolean isUnsigned) {
   25.38 -    this.addr = addr;
   25.39 -    this.numBytes = numBytes;
   25.40 -    this.isUnsigned = isUnsigned;
   25.41 -  }
   25.42 -
   25.43 -  long getValue() {
   25.44 -    return addr.getCIntegerAt(0, numBytes, isUnsigned);
   25.45 -  }
   25.46 -
   25.47 -  void setValue(long value) {
   25.48 -    addr.setCIntegerAt(0, numBytes, value);
   25.49 -  }
   25.50 -}
    26.1 --- a/agent/src/share/classes/sun/jvm/hotspot/livejvm/CStringAccessor.java	Thu Feb 21 07:50:48 2013 -0500
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,69 +0,0 @@
    26.4 -/*
    26.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    26.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 - *
    26.8 - * This code is free software; you can redistribute it and/or modify it
    26.9 - * under the terms of the GNU General Public License version 2 only, as
   26.10 - * published by the Free Software Foundation.
   26.11 - *
   26.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 - * version 2 for more details (a copy is included in the LICENSE file that
   26.16 - * accompanied this code).
   26.17 - *
   26.18 - * You should have received a copy of the GNU General Public License version
   26.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 - *
   26.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 - * or visit www.oracle.com if you need additional information or have any
   26.24 - * questions.
   26.25 - *
   26.26 - */
   26.27 -
   26.28 -package sun.jvm.hotspot.livejvm;
   26.29 -
   26.30 -import java.io.UnsupportedEncodingException;
   26.31 -import sun.jvm.hotspot.debugger.*;
   26.32 -
   26.33 -class CStringAccessor {
   26.34 -  private Address addr;
   26.35 -  private int bufLen;
   26.36 -
   26.37 -  CStringAccessor(Address addr, int bufLen) {
   26.38 -    this.addr = addr;
   26.39 -    this.bufLen = bufLen;
   26.40 -  }
   26.41 -
   26.42 -  String getValue() throws DebuggerException {
   26.43 -    int len = 0;
   26.44 -    while ((addr.getCIntegerAt(len, 1, true) != 0) && (len < bufLen)) {
   26.45 -      ++len;
   26.46 -    }
   26.47 -    byte[] res = new byte[len];
   26.48 -    for (int i = 0; i < len; i++) {
   26.49 -      res[i] = (byte) addr.getCIntegerAt(i, 1, true);
   26.50 -    }
   26.51 -    try {
   26.52 -      return new String(res, "US-ASCII");
   26.53 -    } catch (UnsupportedEncodingException e) {
   26.54 -      throw new DebuggerException("Unable to use US-ASCII encoding");
   26.55 -    }
   26.56 -  }
   26.57 -
   26.58 -  void setValue(String value) throws DebuggerException {
   26.59 -    try {
   26.60 -      byte[] data = value.getBytes("US-ASCII");
   26.61 -      if (data.length >= bufLen) {
   26.62 -        throw new DebuggerException("String too long");
   26.63 -      }
   26.64 -      for (int i = 0; i < data.length; i++) {
   26.65 -        addr.setCIntegerAt(i, 1, data[i]);
   26.66 -      }
   26.67 -      addr.setCIntegerAt(data.length, 1, 0);
   26.68 -    } catch (UnsupportedEncodingException e) {
   26.69 -      throw new DebuggerException("Unable to use US-ASCII encoding");
   26.70 -    }
   26.71 -  }
   26.72 -}
    27.1 --- a/agent/src/share/classes/sun/jvm/hotspot/livejvm/Event.java	Thu Feb 21 07:50:48 2013 -0500
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,41 +0,0 @@
    27.4 -/*
    27.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    27.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.7 - *
    27.8 - * This code is free software; you can redistribute it and/or modify it
    27.9 - * under the terms of the GNU General Public License version 2 only, as
   27.10 - * published by the Free Software Foundation.
   27.11 - *
   27.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   27.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   27.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   27.15 - * version 2 for more details (a copy is included in the LICENSE file that
   27.16 - * accompanied this code).
   27.17 - *
   27.18 - * You should have received a copy of the GNU General Public License version
   27.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   27.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   27.21 - *
   27.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   27.23 - * or visit www.oracle.com if you need additional information or have any
   27.24 - * questions.
   27.25 - *
   27.26 - */
   27.27 -
   27.28 -package sun.jvm.hotspot.livejvm;
   27.29 -
   27.30 -public class Event {
   27.31 -  public static class Type {
   27.32 -    private Type() {}
   27.33 -    public static final Type BREAKPOINT = new Type();
   27.34 -    public static final Type EXCEPTION  = new Type();
   27.35 -  }
   27.36 -
   27.37 -  private Type type;
   27.38 -
   27.39 -  public Event(Type type) {
   27.40 -    this.type = type;
   27.41 -  }
   27.42 -
   27.43 -  public Type getType() { return type; }
   27.44 -}
    28.1 --- a/agent/src/share/classes/sun/jvm/hotspot/livejvm/ExceptionEvent.java	Thu Feb 21 07:50:48 2013 -0500
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,67 +0,0 @@
    28.4 -/*
    28.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    28.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.7 - *
    28.8 - * This code is free software; you can redistribute it and/or modify it
    28.9 - * under the terms of the GNU General Public License version 2 only, as
   28.10 - * published by the Free Software Foundation.
   28.11 - *
   28.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   28.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   28.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   28.15 - * version 2 for more details (a copy is included in the LICENSE file that
   28.16 - * accompanied this code).
   28.17 - *
   28.18 - * You should have received a copy of the GNU General Public License version
   28.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   28.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   28.21 - *
   28.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   28.23 - * or visit www.oracle.com if you need additional information or have any
   28.24 - * questions.
   28.25 - *
   28.26 - */
   28.27 -
   28.28 -package sun.jvm.hotspot.livejvm;
   28.29 -
   28.30 -import sun.jvm.hotspot.oops.*;
   28.31 -import sun.jvm.hotspot.runtime.*;
   28.32 -
   28.33 -public class ExceptionEvent extends Event {
   28.34 -  private Oop thread;
   28.35 -  private Oop clazz;
   28.36 -  private JNIid method;
   28.37 -  private int location;
   28.38 -  private Oop exception;
   28.39 -  private Oop catchClass;
   28.40 -  private JNIid catchMethod;
   28.41 -  private int catchLocation;
   28.42 -
   28.43 -  public ExceptionEvent(Oop thread,
   28.44 -                        Oop clazz,
   28.45 -                        JNIid method,
   28.46 -                        int location,
   28.47 -                        Oop exception,
   28.48 -                        Oop catchClass,
   28.49 -                        JNIid catchMethod,
   28.50 -                        int catchLocation) {
   28.51 -    super(Event.Type.EXCEPTION);
   28.52 -    this.thread        = thread;
   28.53 -    this.clazz         = clazz;
   28.54 -    this.method        = method;
   28.55 -    this.location      = location;
   28.56 -    this.exception     = exception;
   28.57 -    this.catchClass    = catchClass;
   28.58 -    this.catchMethod   = catchMethod;
   28.59 -    this.catchLocation = catchLocation;
   28.60 -  }
   28.61 -
   28.62 -  public Oop   thread()        { return thread;        }
   28.63 -  public Oop   clazz()         { return clazz;         }
   28.64 -  public JNIid methodID()      { return method;        }
   28.65 -  public int   location()      { return location;      }
   28.66 -  public Oop   exception()     { return exception;     }
   28.67 -  public Oop   catchClass()    { return catchClass;    }
   28.68 -  public JNIid catchMethodID() { return catchMethod;   }
   28.69 -  public int   catchLocation() { return catchLocation; }
   28.70 -}
    29.1 --- a/agent/src/share/classes/sun/jvm/hotspot/livejvm/JNIHandleAccessor.java	Thu Feb 21 07:50:48 2013 -0500
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,54 +0,0 @@
    29.4 -/*
    29.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    29.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 - *
    29.8 - * This code is free software; you can redistribute it and/or modify it
    29.9 - * under the terms of the GNU General Public License version 2 only, as
   29.10 - * published by the Free Software Foundation.
   29.11 - *
   29.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   29.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.15 - * version 2 for more details (a copy is included in the LICENSE file that
   29.16 - * accompanied this code).
   29.17 - *
   29.18 - * You should have received a copy of the GNU General Public License version
   29.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   29.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.21 - *
   29.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.23 - * or visit www.oracle.com if you need additional information or have any
   29.24 - * questions.
   29.25 - *
   29.26 - */
   29.27 -
   29.28 -package sun.jvm.hotspot.livejvm;
   29.29 -
   29.30 -import sun.jvm.hotspot.debugger.*;
   29.31 -import sun.jvm.hotspot.oops.*;
   29.32 -import sun.jvm.hotspot.utilities.*;
   29.33 -
   29.34 -class JNIHandleAccessor {
   29.35 -  private Address addr;
   29.36 -  private ObjectHeap heap;
   29.37 -
   29.38 -  JNIHandleAccessor(Address addr, ObjectHeap heap) {
   29.39 -    this.addr = addr;
   29.40 -    this.heap = heap;
   29.41 -  }
   29.42 -
   29.43 -  Oop getValue() {
   29.44 -    // Accessing the contents of the JNIHandle is a double dereference
   29.45 -    Address handle = addr.getAddressAt(0);
   29.46 -    if (handle == null) return null;
   29.47 -    return heap.newOop(handle.getOopHandleAt(0));
   29.48 -  }
   29.49 -
   29.50 -  void setValue(Oop value) {
   29.51 -    Address handle = addr.getAddressAt(0);
   29.52 -    if (Assert.ASSERTS_ENABLED) {
   29.53 -      Assert.that(handle != null, "Must have valid global JNI handle for setting");
   29.54 -    }
   29.55 -    handle.setOopHandleAt(0, value.getHandle());
   29.56 -  }
   29.57 -}
    30.1 --- a/agent/src/share/classes/sun/jvm/hotspot/livejvm/ServiceabilityAgentJVMDIModule.java	Thu Feb 21 07:50:48 2013 -0500
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,415 +0,0 @@
    30.4 -/*
    30.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    30.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 - *
    30.8 - * This code is free software; you can redistribute it and/or modify it
    30.9 - * under the terms of the GNU General Public License version 2 only, as
   30.10 - * published by the Free Software Foundation.
   30.11 - *
   30.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 - * version 2 for more details (a copy is included in the LICENSE file that
   30.16 - * accompanied this code).
   30.17 - *
   30.18 - * You should have received a copy of the GNU General Public License version
   30.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 - *
   30.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 - * or visit www.oracle.com if you need additional information or have any
   30.24 - * questions.
   30.25 - *
   30.26 - */
   30.27 -
   30.28 -package sun.jvm.hotspot.livejvm;
   30.29 -
   30.30 -import sun.jvm.hotspot.debugger.*;
   30.31 -import sun.jvm.hotspot.oops.*;
   30.32 -import sun.jvm.hotspot.runtime.*;
   30.33 -
   30.34 -/** Provides Java programming language-level interaction with a live
   30.35 -    Java HotSpot VM via the use of the SA's JVMDI module. This is an
   30.36 -    experimental mechanism. The BugSpot debugger should be converted
   30.37 -    to use the JVMDI/JDWP-based JDI implementation for live process
   30.38 -    interaction once the JDI binding for the SA is complete. */
   30.39 -
   30.40 -public class ServiceabilityAgentJVMDIModule {
   30.41 -  private Debugger dbg;
   30.42 -  private String[] saLibNames;
   30.43 -  private String   saLibName;
   30.44 -  private boolean  attached;
   30.45 -
   30.46 -  private boolean  suspended;
   30.47 -
   30.48 -  private static final int JVMDI_EVENT_BREAKPOINT = 2;
   30.49 -  private static final int JVMDI_EVENT_EXCEPTION = 4;
   30.50 -
   30.51 -  private static long timeoutMillis = 3000;
   30.52 -
   30.53 -  // Values in target process
   30.54 -  // Events sent from VM to SA
   30.55 -  private CIntegerAccessor saAttached;
   30.56 -  private CIntegerAccessor saEventPending;
   30.57 -  private CIntegerAccessor saEventKind;
   30.58 -  // Exception events
   30.59 -  private JNIHandleAccessor saExceptionThread;
   30.60 -  private JNIHandleAccessor saExceptionClass;
   30.61 -  private JNIid             saExceptionMethod;
   30.62 -  private CIntegerAccessor  saExceptionLocation;
   30.63 -  private JNIHandleAccessor saExceptionException;
   30.64 -  private JNIHandleAccessor saExceptionCatchClass;
   30.65 -  private JNIid             saExceptionCatchMethod;
   30.66 -  private CIntegerAccessor  saExceptionCatchLocation;
   30.67 -  // Breakpoint events
   30.68 -  private JNIHandleAccessor saBreakpointThread;
   30.69 -  private JNIHandleAccessor saBreakpointClass;
   30.70 -  private JNIid             saBreakpointMethod;
   30.71 -  private CIntegerAccessor  saBreakpointLocation;
   30.72 -  // Commands sent by the SA to the VM
   30.73 -  private int               SA_CMD_SUSPEND_ALL;
   30.74 -  private int               SA_CMD_RESUME_ALL;
   30.75 -  private int               SA_CMD_TOGGLE_BREAKPOINT;
   30.76 -  private int               SA_CMD_BUF_SIZE;
   30.77 -  private CIntegerAccessor  saCmdPending;
   30.78 -  private CIntegerAccessor  saCmdType;
   30.79 -  private CIntegerAccessor  saCmdResult;
   30.80 -  private CStringAccessor   saCmdResultErrMsg;
   30.81 -  // Toggle breakpoint command arguments
   30.82 -  private CStringAccessor   saCmdBkptSrcFileName;
   30.83 -  private CStringAccessor   saCmdBkptPkgName;
   30.84 -  private CIntegerAccessor  saCmdBkptLineNumber;
   30.85 -  private CIntegerAccessor  saCmdBkptResWasError;
   30.86 -  private CIntegerAccessor  saCmdBkptResLineNumber;
   30.87 -  private CIntegerAccessor  saCmdBkptResBCI;
   30.88 -  private CIntegerAccessor  saCmdBkptResWasSet;
   30.89 -  private CStringAccessor   saCmdBkptResMethodName;
   30.90 -  private CStringAccessor   saCmdBkptResMethodSig;
   30.91 -
   30.92 -  public ServiceabilityAgentJVMDIModule(Debugger dbg, String[] saLibNames) {
   30.93 -    this.dbg = dbg;
   30.94 -    this.saLibNames = saLibNames;
   30.95 -  }
   30.96 -
   30.97 -  /** Indicates whether a call to attach() should complete without an
   30.98 -      exception. */
   30.99 -  public boolean canAttach() {
  30.100 -    return setupLookup("SA_CMD_SUSPEND_ALL");
  30.101 -  }
  30.102 -
  30.103 -  /** Attempt to initiate a connection with the JVMDI module in the
  30.104 -      target VM. */
  30.105 -  public void attach() throws DebuggerException {
  30.106 -    if (!canAttach()) {
  30.107 -      throw new DebuggerException("Unable to initiate symbol lookup in SA's JVMDI module");
  30.108 -    }
  30.109 -
  30.110 -    if (attached) {
  30.111 -      throw new DebuggerException("Already attached");
  30.112 -    }
  30.113 -
  30.114 -    // Attempt to look up well-known symbols in the target VM.
  30.115 -    SA_CMD_SUSPEND_ALL      = lookupConstInt("SA_CMD_SUSPEND_ALL");
  30.116 -    SA_CMD_RESUME_ALL       = lookupConstInt("SA_CMD_RESUME_ALL");
  30.117 -    SA_CMD_TOGGLE_BREAKPOINT = lookupConstInt("SA_CMD_TOGGLE_BREAKPOINT");
  30.118 -    SA_CMD_BUF_SIZE         = lookupConstInt("SA_CMD_BUF_SIZE");
  30.119 -
  30.120 -    saAttached              = lookupCInt("saAttached");
  30.121 -    saEventPending          = lookupCInt("saEventPending");
  30.122 -    saEventKind             = lookupCInt("saEventKind");
  30.123 -    saCmdPending            = lookupCInt("saCmdPending");
  30.124 -    saCmdType               = lookupCInt("saCmdType");
  30.125 -    saCmdResult             = lookupCInt("saCmdResult");
  30.126 -    saCmdResultErrMsg       = lookupCString("saCmdResultErrMsg", SA_CMD_BUF_SIZE);
  30.127 -    // Toggling of breakpoints
  30.128 -    saCmdBkptSrcFileName    = lookupCString("saCmdBkptSrcFileName", SA_CMD_BUF_SIZE);
  30.129 -    saCmdBkptPkgName        = lookupCString("saCmdBkptPkgName", SA_CMD_BUF_SIZE);
  30.130 -    saCmdBkptLineNumber     = lookupCInt("saCmdBkptLineNumber");
  30.131 -    saCmdBkptResWasError    = lookupCInt("saCmdBkptResWasError");
  30.132 -    saCmdBkptResLineNumber  = lookupCInt("saCmdBkptResLineNumber");
  30.133 -    saCmdBkptResBCI         = lookupCInt("saCmdBkptResBCI");
  30.134 -    saCmdBkptResWasSet      = lookupCInt("saCmdBkptResWasSet");
  30.135 -    saCmdBkptResMethodName  = lookupCString("saCmdBkptResMethodName", SA_CMD_BUF_SIZE);
  30.136 -    saCmdBkptResMethodSig   = lookupCString("saCmdBkptResMethodSig", SA_CMD_BUF_SIZE);
  30.137 -
  30.138 -    // Check for existence of symbols needed later
  30.139 -    // FIXME: should probably cache these since we can't support the
  30.140 -    // -Xrun module or the VM getting unloaded anyway
  30.141 -    lookup("saExceptionThread");
  30.142 -    lookup("saExceptionClass");
  30.143 -    lookup("saExceptionMethod");
  30.144 -    lookup("saExceptionLocation");
  30.145 -    lookup("saExceptionException");
  30.146 -    lookup("saExceptionCatchClass");
  30.147 -    lookup("saExceptionCatchMethod");
  30.148 -    lookup("saExceptionCatchLocation");
  30.149 -    lookup("saBreakpointThread");
  30.150 -    lookup("saBreakpointClass");
  30.151 -    lookup("saBreakpointMethod");
  30.152 -    lookup("saBreakpointLocation");
  30.153 -
  30.154 -    saAttached.setValue(1);
  30.155 -    attached = true;
  30.156 -  }
  30.157 -
  30.158 -  public void detach() {
  30.159 -    saAttached.setValue(0);
  30.160 -    attached = false;
  30.161 -    saLibName = null;
  30.162 -  }
  30.163 -
  30.164 -  /** Set the timeout value (in milliseconds) for the VM to reply to
  30.165 -      commands. Once this timeout has elapsed, the VM is assumed to
  30.166 -      have disconnected. Defaults to 3000 milliseconds (3 seconds). */
  30.167 -  public void setCommandTimeout(long millis) {
  30.168 -    timeoutMillis = millis;
  30.169 -  }
  30.170 -
  30.171 -  /** Get the timeout value (in milliseconds) for the VM to reply to
  30.172 -      commands. Once this timeout has elapsed, the VM is assumed to
  30.173 -      have disconnected. Defaults to 3000 milliseconds (3 seconds). */
  30.174 -  public long getCommandTimeout() {
  30.175 -    return timeoutMillis;
  30.176 -  }
  30.177 -
  30.178 -  /** Indicates whether a Java debug event is pending */
  30.179 -  public boolean eventPending() {
  30.180 -    return (saEventPending.getValue() != 0);
  30.181 -  }
  30.182 -
  30.183 -  /** Poll for event; returns null if none pending. */
  30.184 -  public Event eventPoll() {
  30.185 -    if (saEventPending.getValue() == 0) {
  30.186 -      return null;
  30.187 -    }
  30.188 -
  30.189 -    int kind = (int) saEventKind.getValue();
  30.190 -    switch (kind) {
  30.191 -    case JVMDI_EVENT_EXCEPTION: {
  30.192 -      JNIHandleAccessor thread = lookupJNIHandle("saExceptionThread");
  30.193 -      JNIHandleAccessor clazz = lookupJNIHandle("saExceptionClass");
  30.194 -      JNIid method = lookupJNIid("saExceptionMethod");
  30.195 -      CIntegerAccessor location = lookupCInt("saExceptionLocation");
  30.196 -      JNIHandleAccessor exception = lookupJNIHandle("saExceptionException");
  30.197 -      JNIHandleAccessor catchClass = lookupJNIHandle("saExceptionCatchClass");
  30.198 -      JNIid catchMethod = lookupJNIid("saExceptionCatchMethod");
  30.199 -      CIntegerAccessor catchLocation = lookupCInt("saExceptionCatchLocation");
  30.200 -      return new ExceptionEvent(thread.getValue(), clazz.getValue(), method,
  30.201 -                                (int) location.getValue(), exception.getValue(),
  30.202 -                                catchClass.getValue(), catchMethod, (int) catchLocation.getValue());
  30.203 -    }
  30.204 -
  30.205 -    case JVMDI_EVENT_BREAKPOINT: {
  30.206 -      JNIHandleAccessor thread = lookupJNIHandle("saBreakpointThread");
  30.207 -      JNIHandleAccessor clazz = lookupJNIHandle("saBreakpointClass");
  30.208 -      JNIid method = lookupJNIid("saBreakpointMethod");
  30.209 -      CIntegerAccessor location = lookupCInt("saBreakpointLocation");
  30.210 -      return new BreakpointEvent(thread.getValue(), clazz.getValue(),
  30.211 -                                 method, (int) location.getValue());
  30.212 -    }
  30.213 -
  30.214 -    default:
  30.215 -      throw new DebuggerException("Unsupported event type " + kind);
  30.216 -    }
  30.217 -  }
  30.218 -
  30.219 -  /** Continue past current event */
  30.220 -  public void eventContinue() {
  30.221 -    saEventPending.setValue(0);
  30.222 -  }
  30.223 -
  30.224 -  /** Suspend all Java threads in the target VM. Throws
  30.225 -      DebuggerException if the VM disconnected. */
  30.226 -  public void suspend() {
  30.227 -    saCmdType.setValue(SA_CMD_SUSPEND_ALL);
  30.228 -    saCmdPending.setValue(1);
  30.229 -    waitForCommandCompletion();
  30.230 -    suspended = true;
  30.231 -  }
  30.232 -
  30.233 -  /** Resume all Java threads in the target VM. Throws
  30.234 -      DebuggerException if the VM disconnected. */
  30.235 -  public void resume() {
  30.236 -    saCmdType.setValue(SA_CMD_RESUME_ALL);
  30.237 -    saCmdPending.setValue(1);
  30.238 -    waitForCommandCompletion();
  30.239 -    suspended = false;
  30.240 -  }
  30.241 -
  30.242 -  /** Indicates whether all Java threads have been suspended via this
  30.243 -      interface. */
  30.244 -  public boolean isSuspended() {
  30.245 -    return suspended;
  30.246 -  }
  30.247 -
  30.248 -  /** Information about toggling of breakpoints */
  30.249 -  public static class BreakpointToggleResult {
  30.250 -    private boolean success;
  30.251 -    private String errMsg;
  30.252 -    private int lineNumber;
  30.253 -    private int bci;
  30.254 -    private boolean wasSet;
  30.255 -    private String methodName;
  30.256 -    private String methodSig;
  30.257 -
  30.258 -    /** Success constructor */
  30.259 -    public BreakpointToggleResult(int lineNumber, int bci, boolean wasSet,
  30.260 -                                  String methodName, String methodSig) {
  30.261 -      this.lineNumber = lineNumber;
  30.262 -      this.bci = bci;
  30.263 -      this.wasSet = wasSet;
  30.264 -      this.methodName = methodName;
  30.265 -      this.methodSig = methodSig;
  30.266 -      success = true;
  30.267 -    }
  30.268 -
  30.269 -    /** Failure constructor */
  30.270 -    public BreakpointToggleResult(String errMsg) {
  30.271 -      this.errMsg = errMsg;
  30.272 -      success = false;
  30.273 -    }
  30.274 -
  30.275 -    /** Indicates whether this represents a successful return or not */
  30.276 -    public boolean getSuccess() { return success; }
  30.277 -
  30.278 -    /** Valid only if getSuccess() returns false */
  30.279 -    public String getErrMsg() { return errMsg; }
  30.280 -
  30.281 -    /** Line number at which breakpoint toggle occurred; valid only if
  30.282 -        getSuccess() returns true. */
  30.283 -    public int getLineNumber() { return lineNumber; }
  30.284 -
  30.285 -    /** BCI at which breakpoint toggle occurred; valid only if
  30.286 -        getSuccess() returns true. */
  30.287 -    public int getBCI() { return bci; }
  30.288 -
  30.289 -    /** Indicates whether the breakpoint toggle was the set of a
  30.290 -        breakpoint or not; valid only if getSuccess() returns true. */
  30.291 -    public boolean getWasSet() { return wasSet; }
  30.292 -
  30.293 -    /** Method name in which the breakpoint toggle occurred; valid
  30.294 -        only if getSuccess() returns true. */
  30.295 -    public String getMethodName() { return methodName; }
  30.296 -
  30.297 -    /** Method signature in which the breakpoint toggle occurred;
  30.298 -        valid only if getSuccess() returns true. */
  30.299 -    public String getMethodSignature() { return methodSig; }
  30.300 -  }
  30.301 -
  30.302 -  /** Toggle a breakpoint. Throws DebuggerException if a real error
  30.303 -      occurred; otherwise returns non-null BreakpointToggleResult. The
  30.304 -      work of scanning the loaded classes is done in the target VM
  30.305 -      because it turns out to be significantly faster than scanning
  30.306 -      through the system dictionary from the SA, and interactivity
  30.307 -      when setting breakpoints is important. */
  30.308 -  public BreakpointToggleResult toggleBreakpoint(String srcFileName,
  30.309 -                                                 String pkgName,
  30.310 -                                                 int lineNo) {
  30.311 -    saCmdBkptSrcFileName.setValue(srcFileName);
  30.312 -    saCmdBkptPkgName.setValue(pkgName);
  30.313 -    saCmdBkptLineNumber.setValue(lineNo);
  30.314 -    saCmdType.setValue(SA_CMD_TOGGLE_BREAKPOINT);
  30.315 -    saCmdPending.setValue(1);
  30.316 -    if (waitForCommandCompletion(true)) {
  30.317 -      return new BreakpointToggleResult((int) saCmdBkptResLineNumber.getValue(),
  30.318 -                                        (int) saCmdBkptResBCI.getValue(),
  30.319 -                                        (saCmdBkptResWasSet.getValue() != 0),
  30.320 -                                        saCmdBkptResMethodName.getValue(),
  30.321 -                                        saCmdBkptResMethodSig.getValue());
  30.322 -    } else {
  30.323 -      return new BreakpointToggleResult(saCmdResultErrMsg.getValue());
  30.324 -    }
  30.325 -  }
  30.326 -
  30.327 -
  30.328 -  //----------------------------------------------------------------------
  30.329 -  // Internals only below this point
  30.330 -  //
  30.331 -
  30.332 -  private CIntegerAccessor lookupCInt(String symbolName) {
  30.333 -    return new CIntegerAccessor(lookup(symbolName), 4, false);
  30.334 -  }
  30.335 -
  30.336 -  private CStringAccessor lookupCString(String symbolName, int bufLen) {
  30.337 -    return new CStringAccessor(lookup(symbolName), bufLen);
  30.338 -  }
  30.339 -
  30.340 -  private JNIHandleAccessor lookupJNIHandle(String symbolName) {
  30.341 -    return new JNIHandleAccessor(lookup(symbolName), VM.getVM().getObjectHeap());
  30.342 -  }
  30.343 -
  30.344 -  private JNIid lookupJNIid(String symbolName) {
  30.345 -    Address idAddr = lookup(symbolName).getAddressAt(0);
  30.346 -    if (idAddr == null) {
  30.347 -      return null;
  30.348 -    }
  30.349 -    return new JNIid(idAddr, VM.getVM().getObjectHeap());
  30.350 -  }
  30.351 -
  30.352 -  private int lookupConstInt(String symbolName) {
  30.353 -    Address addr = lookup(symbolName);
  30.354 -    return (int) addr.getCIntegerAt(0, 4, false);
  30.355 -  }
  30.356 -
  30.357 -  private boolean setupLookup(String symbolName) {
  30.358 -    if (saLibName == null) {
  30.359 -      for (int i = 0; i < saLibNames.length; i++) {
  30.360 -        Address addr = dbg.lookup(saLibNames[i], symbolName);
  30.361 -        if (addr != null) {
  30.362 -          saLibName = saLibNames[i];
  30.363 -          return true;
  30.364 -        }
  30.365 -      }
  30.366 -      return false;
  30.367 -    }
  30.368 -    return true;
  30.369 -  }
  30.370 -
  30.371 -  private Address lookup(String symbolName) {
  30.372 -    if (saLibName == null) {
  30.373 -      for (int i = 0; i < saLibNames.length; i++) {
  30.374 -        Address addr = dbg.lookup(saLibNames[i], symbolName);
  30.375 -        if (addr != null) {
  30.376 -          saLibName = saLibNames[i];
  30.377 -          return addr;
  30.378 -        }
  30.379 -      }
  30.380 -      throw new DebuggerException("Unable to find symbol " + symbolName + " in any of the known names for the SA");
  30.381 -    }
  30.382 -
  30.383 -    Address addr = dbg.lookup(saLibName, symbolName);
  30.384 -    if (addr == null) {
  30.385 -      throw new DebuggerException("Unable to find symbol " + symbolName + " in " + saLibName);
  30.386 -    }
  30.387 -    return addr;
  30.388 -  }
  30.389 -
  30.390 -  private void waitForCommandCompletion() {
  30.391 -    waitForCommandCompletion(false);
  30.392 -  }
  30.393 -
  30.394 -  /** Returns true if command succeeded, false if not */
  30.395 -  private boolean waitForCommandCompletion(boolean forBreakpoint) {
  30.396 -    long start = System.currentTimeMillis();
  30.397 -    long cur = start;
  30.398 -    while ((saCmdPending.getValue() != 0) &&
  30.399 -           (cur - start < timeoutMillis)) {
  30.400 -      try {
  30.401 -        java.lang.Thread.currentThread().sleep(10);
  30.402 -      } catch (InterruptedException e) {
  30.403 -      }
  30.404 -      cur = System.currentTimeMillis();
  30.405 -    }
  30.406 -    if (saCmdPending.getValue() != 0) {
  30.407 -      detach();
  30.408 -      throw new DebuggerException("VM appears to have died");
  30.409 -    }
  30.410 -    boolean succeeded = saCmdResult.getValue() == 0;
  30.411 -    if (!succeeded &&
  30.412 -        (!forBreakpoint || saCmdBkptResWasError.getValue() != 0)) {
  30.413 -      String err = saCmdResultErrMsg.getValue();
  30.414 -      throw new DebuggerException("Error executing JVMDI command: " + err);
  30.415 -    }
  30.416 -    return succeeded;
  30.417 -  }
  30.418 -}
    31.1 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java	Thu Feb 21 07:50:48 2013 -0500
    31.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java	Fri Feb 22 10:03:02 2013 +0100
    31.3 @@ -58,10 +58,6 @@
    31.4        }
    31.5     }
    31.6  
    31.7 -   protected boolean requiresVM() {
    31.8 -      return false;
    31.9 -   }
   31.10 -
   31.11     public static void main(String[] args) throws Exception {
   31.12        PMap t = new PMap();
   31.13        t.start(args);
    32.1 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java	Thu Feb 21 07:50:48 2013 -0500
    32.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java	Fri Feb 22 10:03:02 2013 +0100
    32.3 @@ -50,29 +50,23 @@
    32.4  
    32.5     public void run(PrintStream out) {
    32.6        Debugger dbg = getAgent().getDebugger();
    32.7 -      run(out, dbg, getAgent().isJavaMode());
    32.8 +      run(out, dbg);
    32.9     }
   32.10  
   32.11     public void run(PrintStream out, Debugger dbg) {
   32.12 -      run(out, dbg, true);
   32.13 -   }
   32.14 -
   32.15 -   private void run(PrintStream out, Debugger dbg, final boolean isJava) {
   32.16        CDebugger cdbg = dbg.getCDebugger();
   32.17        if (cdbg != null) {
   32.18           ConcurrentLocksPrinter concLocksPrinter = null;
   32.19 -         if (isJava) {
   32.20 -            // compute and cache java Vframes.
   32.21 -            initJFrameCache();
   32.22 -            if (concurrentLocks) {
   32.23 -               concLocksPrinter = new ConcurrentLocksPrinter();
   32.24 -            }
   32.25 -            // print Java level deadlocks
   32.26 -            try {
   32.27 -               DeadlockDetector.print(out);
   32.28 -            } catch (Exception exp) {
   32.29 -               out.println("can't print deadlock information: " + exp.getMessage());
   32.30 -            }
   32.31 +         // compute and cache java Vframes.
   32.32 +         initJFrameCache();
   32.33 +         if (concurrentLocks) {
   32.34 +            concLocksPrinter = new ConcurrentLocksPrinter();
   32.35 +         }
   32.36 +         // print Java level deadlocks
   32.37 +         try {
   32.38 +            DeadlockDetector.print(out);
   32.39 +         } catch (Exception exp) {
   32.40 +            out.println("can't print deadlock information: " + exp.getMessage());
   32.41           }
   32.42  
   32.43           List l = cdbg.getThreadList();
   32.44 @@ -100,63 +94,59 @@
   32.45                       }
   32.46                       out.println();
   32.47                    } else {
   32.48 -                     if (isJava) {
   32.49 -                        // look for one or more java frames
   32.50 -                        String[] names = null;
   32.51 -                        // check interpreter frame
   32.52 -                        Interpreter interp = VM.getVM().getInterpreter();
   32.53 -                        if (interp.contains(pc)) {
   32.54 -                           names = getJavaNames(th, f.localVariableBase());
   32.55 -                           // print codelet name if we can't determine method
   32.56 -                           if (names == null || names.length == 0) {
   32.57 -                              out.print("<interpreter> ");
   32.58 -                              InterpreterCodelet ic = interp.getCodeletContaining(pc);
   32.59 -                              if (ic != null) {
   32.60 -                                 String desc = ic.getDescription();
   32.61 -                                 if (desc != null) out.print(desc);
   32.62 -                              }
   32.63 -                              out.println();
   32.64 -                           }
   32.65 -                        } else {
   32.66 -                           // look for known code blobs
   32.67 -                           CodeCache c = VM.getVM().getCodeCache();
   32.68 -                           if (c.contains(pc)) {
   32.69 -                              CodeBlob cb = c.findBlobUnsafe(pc);
   32.70 -                              if (cb.isNMethod()) {
   32.71 -                                 names = getJavaNames(th, f.localVariableBase());
   32.72 -                                 // just print compiled code, if can't determine method
   32.73 -                                 if (names == null || names.length == 0) {
   32.74 -                                    out.println("<Unknown compiled code>");
   32.75 -                                 }
   32.76 -                              } else if (cb.isBufferBlob()) {
   32.77 -                                 out.println("<StubRoutines>");
   32.78 -                              } else if (cb.isRuntimeStub()) {
   32.79 -                                 out.println("<RuntimeStub>");
   32.80 -                              } else if (cb.isDeoptimizationStub()) {
   32.81 -                                 out.println("<DeoptimizationStub>");
   32.82 -                              } else if (cb.isUncommonTrapStub()) {
   32.83 -                                 out.println("<UncommonTrap>");
   32.84 -                              } else if (cb.isExceptionStub()) {
   32.85 -                                 out.println("<ExceptionStub>");
   32.86 -                              } else if (cb.isSafepointStub()) {
   32.87 -                                 out.println("<SafepointStub>");
   32.88 -                              } else {
   32.89 -                                 out.println("<Unknown code blob>");
   32.90 -                              }
   32.91 -                           } else {
   32.92 -                              printUnknown(out);
   32.93 -                           }
   32.94 -                        }
   32.95 -                        // print java frames, if any
   32.96 -                        if (names != null && names.length != 0) {
   32.97 -                           // print java frame(s)
   32.98 -                           for (int i = 0; i < names.length; i++) {
   32.99 -                               out.println(names[i]);
  32.100 -                           }
  32.101 -                        }
  32.102 -                     } else {
  32.103 -                        printUnknown(out);
  32.104 -                     }
  32.105 +                      // look for one or more java frames
  32.106 +                      String[] names = null;
  32.107 +                      // check interpreter frame
  32.108 +                      Interpreter interp = VM.getVM().getInterpreter();
  32.109 +                      if (interp.contains(pc)) {
  32.110 +                         names = getJavaNames(th, f.localVariableBase());
  32.111 +                         // print codelet name if we can't determine method
  32.112 +                         if (names == null || names.length == 0) {
  32.113 +                            out.print("<interpreter> ");
  32.114 +                            InterpreterCodelet ic = interp.getCodeletContaining(pc);
  32.115 +                            if (ic != null) {
  32.116 +                               String desc = ic.getDescription();
  32.117 +                               if (desc != null) out.print(desc);
  32.118 +                            }
  32.119 +                            out.println();
  32.120 +                         }
  32.121 +                      } else {
  32.122 +                         // look for known code blobs
  32.123 +                         CodeCache c = VM.getVM().getCodeCache();
  32.124 +                         if (c.contains(pc)) {
  32.125 +                            CodeBlob cb = c.findBlobUnsafe(pc);
  32.126 +                            if (cb.isNMethod()) {
  32.127 +                               names = getJavaNames(th, f.localVariableBase());
  32.128 +                               // just print compiled code, if can't determine method
  32.129 +                               if (names == null || names.length == 0) {
  32.130 +                                  out.println("<Unknown compiled code>");
  32.131 +                               }
  32.132 +                            } else if (cb.isBufferBlob()) {
  32.133 +                               out.println("<StubRoutines>");
  32.134 +                            } else if (cb.isRuntimeStub()) {
  32.135 +                               out.println("<RuntimeStub>");
  32.136 +                            } else if (cb.isDeoptimizationStub()) {
  32.137 +                               out.println("<DeoptimizationStub>");
  32.138 +                            } else if (cb.isUncommonTrapStub()) {
  32.139 +                               out.println("<UncommonTrap>");
  32.140 +                            } else if (cb.isExceptionStub()) {
  32.141 +                               out.println("<ExceptionStub>");
  32.142 +                            } else if (cb.isSafepointStub()) {
  32.143 +                               out.println("<SafepointStub>");
  32.144 +                            } else {
  32.145 +                               out.println("<Unknown code blob>");
  32.146 +                            }
  32.147 +                         } else {
  32.148 +                            printUnknown(out);
  32.149 +                         }
  32.150 +                      }
  32.151 +                      // print java frames, if any
  32.152 +                      if (names != null && names.length != 0) {
  32.153 +                         // print java frame(s)
  32.154 +                         for (int i = 0; i < names.length; i++) {
  32.155 +                             out.println(names[i]);
  32.156 +                         }
  32.157 +                      }
  32.158                    }
  32.159                    f = f.sender(th);
  32.160                 }
  32.161 @@ -164,7 +154,7 @@
  32.162                 exp.printStackTrace();
  32.163                 // continue, may be we can do a better job for other threads
  32.164              }
  32.165 -            if (isJava && concurrentLocks) {
  32.166 +            if (concurrentLocks) {
  32.167                 JavaThread jthread = (JavaThread) proxyToThread.get(th);
  32.168                 if (jthread != null) {
  32.169                     concLocksPrinter.print(jthread, out);
  32.170 @@ -180,10 +170,6 @@
  32.171        }
  32.172     }
  32.173  
  32.174 -   protected boolean requiresVM() {
  32.175 -      return false;
  32.176 -   }
  32.177 -
  32.178     public static void main(String[] args) throws Exception {
  32.179        PStack t = new PStack();
  32.180        t.start(args);
    33.1 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java	Thu Feb 21 07:50:48 2013 -0500
    33.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java	Fri Feb 22 10:03:02 2013 +0100
    33.3 @@ -27,7 +27,6 @@
    33.4  import java.io.PrintStream;
    33.5  import java.util.Hashtable;
    33.6  import sun.jvm.hotspot.*;
    33.7 -import sun.jvm.hotspot.bugspot.*;
    33.8  import sun.jvm.hotspot.runtime.*;
    33.9  import sun.jvm.hotspot.debugger.*;
   33.10  
   33.11 @@ -35,7 +34,7 @@
   33.12  // override run & code main as shown below.
   33.13  
   33.14  public abstract class Tool implements Runnable {
   33.15 -   private BugSpotAgent agent;
   33.16 +   private HotSpotAgent agent;
   33.17     private int debugeeType;
   33.18  
   33.19     // debugeeType is one of constants below
   33.20 @@ -51,12 +50,7 @@
   33.21        return true;
   33.22     }
   33.23  
   33.24 -   // whether this tool requires debuggee to be java process or core?
   33.25 -   protected boolean requiresVM() {
   33.26 -      return true;
   33.27 -   }
   33.28 -
   33.29 -   protected void setAgent(BugSpotAgent a) {
   33.30 +   protected void setAgent(HotSpotAgent a) {
   33.31        agent = a;
   33.32     }
   33.33  
   33.34 @@ -64,7 +58,7 @@
   33.35        debugeeType = dt;
   33.36     }
   33.37  
   33.38 -   protected BugSpotAgent getAgent() {
   33.39 +   protected HotSpotAgent getAgent() {
   33.40        return agent;
   33.41     }
   33.42  
   33.43 @@ -155,7 +149,7 @@
   33.44             usage();
   33.45        }
   33.46  
   33.47 -      agent = new BugSpotAgent();
   33.48 +      agent = new HotSpotAgent();
   33.49        try {
   33.50          switch (debugeeType) {
   33.51            case DEBUGEE_PID:
   33.52 @@ -198,33 +192,24 @@
   33.53  
   33.54        err.println("Debugger attached successfully.");
   33.55  
   33.56 -      boolean isJava = agent.isJavaMode();
   33.57 -      if (isJava) {
   33.58 -         VM vm = VM.getVM();
   33.59 -         if (vm.isCore()) {
   33.60 -           err.println("Core build detected.");
   33.61 -         } else if (vm.isClientCompiler()) {
   33.62 -           err.println("Client compiler detected.");
   33.63 -         } else if (vm.isServerCompiler()) {
   33.64 -           err.println("Server compiler detected.");
   33.65 -         } else {
   33.66 -           throw new RuntimeException("Fatal error: " +
   33.67 -                                 "should have been able to detect core/C1/C2 build");
   33.68 -         }
   33.69 +      VM vm = VM.getVM();
   33.70 +      if (vm.isCore()) {
   33.71 +        err.println("Core build detected.");
   33.72 +      } else if (vm.isClientCompiler()) {
   33.73 +        err.println("Client compiler detected.");
   33.74 +      } else if (vm.isServerCompiler()) {
   33.75 +        err.println("Server compiler detected.");
   33.76 +      } else {
   33.77 +        throw new RuntimeException("Fatal error: "
   33.78 +            + "should have been able to detect core/C1/C2 build");
   33.79 +      }
   33.80  
   33.81 -         String version = vm.getVMRelease();
   33.82 -         if (version != null) {
   33.83 -            err.print("JVM version is ");
   33.84 -            err.println(version);
   33.85 -         }
   33.86 +      String version = vm.getVMRelease();
   33.87 +      if (version != null) {
   33.88 +        err.print("JVM version is ");
   33.89 +        err.println(version);
   33.90 +      }
   33.91  
   33.92 -         run();
   33.93 -      } else { // not a java process or core
   33.94 -         if (requiresVM()) {
   33.95 -            err.println(getName() + " requires a java VM process/core!");
   33.96 -         } else {
   33.97 -            run();
   33.98 -         }
   33.99 -      }
  33.100 +      run();
  33.101     }
  33.102  }
    34.1 --- a/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java	Thu Feb 21 07:50:48 2013 -0500
    34.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java	Fri Feb 22 10:03:02 2013 +0100
    34.3 @@ -50,7 +50,7 @@
    34.4  /**
    34.5   * This base class encapsulates many of the events that are fired from
    34.6   * the various panels in this directory so they can easily be plugged
    34.7 - * in to different containing frameworks (HSDB, BugSpot).
    34.8 + * in to different containing frameworks (HSDB).
    34.9   */
   34.10  public class SAPanel extends JPanel {
   34.11      protected List listeners = new ArrayList();
    35.1 --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js	Thu Feb 21 07:50:48 2013 -0500
    35.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js	Fri Feb 22 10:03:02 2013 +0100
    35.3 @@ -31,7 +31,6 @@
    35.4  
    35.5  sapkg.hotspot = Packages.sun.jvm.hotspot;
    35.6  sapkg.asm = sapkg.hotspot.asm;
    35.7 -sapkg.bugspot = sapkg.hotspot.bugspot;
    35.8  sapkg.c1 = sapkg.hotspot.c1;
    35.9  sapkg.code = sapkg.hotspot.code;
   35.10  sapkg.compiler = sapkg.hotspot.compiler;
   35.11 @@ -40,7 +39,6 @@
   35.12  // sapkg.debugger = sapkg.hotspot.debugger;
   35.13  
   35.14  sapkg.interpreter = sapkg.hotspot.interpreter;
   35.15 -sapkg.livejvm = sapkg.hotspot.livejvm;
   35.16  sapkg.jdi = sapkg.hotspot.jdi;
   35.17  sapkg.memory = sapkg.hotspot.memory;
   35.18  sapkg.oops = sapkg.hotspot.oops;
    36.1 --- a/agent/src/share/native/jvmdi/sa.cpp	Thu Feb 21 07:50:48 2013 -0500
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,601 +0,0 @@
    36.4 -/*
    36.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    36.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    36.7 - *
    36.8 - * This code is free software; you can redistribute it and/or modify it
    36.9 - * under the terms of the GNU General Public License version 2 only, as
   36.10 - * published by the Free Software Foundation.
   36.11 - *
   36.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   36.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   36.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   36.15 - * version 2 for more details (a copy is included in the LICENSE file that
   36.16 - * accompanied this code).
   36.17 - *
   36.18 - * You should have received a copy of the GNU General Public License version
   36.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   36.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   36.21 - *
   36.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   36.23 - * or visit www.oracle.com if you need additional information or have any
   36.24 - * questions.
   36.25 - *
   36.26 - */
   36.27 -
   36.28 -#include <stdio.h>
   36.29 -#include <stdarg.h>
   36.30 -#include <stdlib.h>
   36.31 -#include <vector>
   36.32 -#include "sa.hpp"
   36.33 -#include "jni.h"
   36.34 -#include "jvmdi.h"
   36.35 -
   36.36 -#ifndef WIN32
   36.37 - #include <inttypes.h>
   36.38 -#else
   36.39 - typedef int int32_t;
   36.40 -#endif
   36.41 -
   36.42 -#ifdef WIN32
   36.43 - #include <windows.h>
   36.44 - #define YIELD() Sleep(0)
   36.45 - #define SLEEP() Sleep(10)
   36.46 - #define vsnprintf _vsnprintf
   36.47 -#else
   36.48 - Error: please port YIELD() and SLEEP() macros to your platform
   36.49 -#endif
   36.50 -
   36.51 -using namespace std;
   36.52 -
   36.53 -//////////////////////////////////////////////////////////////////////
   36.54 -//                                                                  //
   36.55 -// Exported "interface" for Java language-level interaction between //
   36.56 -// the SA and the VM. Note that the SA knows about the layout of    //
   36.57 -// certain VM data structures and that knowledge is taken advantage //
   36.58 -// of in this code, although this interfaces with the VM via JVMDI. //
   36.59 -//                                                                  //
   36.60 -//////////////////////////////////////////////////////////////////////
   36.61 -
   36.62 -extern "C" {
   36.63 -  /////////////////////////////////////
   36.64 -  //                                 //
   36.65 -  // Events sent by the VM to the SA //
   36.66 -  //                                 //
   36.67 -  /////////////////////////////////////
   36.68 -
   36.69 -  // Set by the SA when it attaches. Indicates that events should be
   36.70 -  // posted via these exported variables, and that the VM should wait
   36.71 -  // for those events to be acknowledged by the SA (via its setting
   36.72 -  // saEventPending to 0).
   36.73 -  JNIEXPORT volatile int32_t saAttached     = 0;
   36.74 -
   36.75 -  // Set to nonzero value by the VM when an event has been posted; set
   36.76 -  // back to 0 by the SA when it has processed that event.
   36.77 -  JNIEXPORT volatile int32_t saEventPending = 0;
   36.78 -
   36.79 -  // Kind of the event (from jvmdi.h)
   36.80 -  JNIEXPORT volatile int32_t saEventKind    = 0;
   36.81 -
   36.82 -  //
   36.83 -  // Exception events
   36.84 -  //
   36.85 -  JNIEXPORT jthread   saExceptionThread;
   36.86 -  JNIEXPORT jclass    saExceptionClass;
   36.87 -  JNIEXPORT jmethodID saExceptionMethod;
   36.88 -  JNIEXPORT int32_t   saExceptionLocation;
   36.89 -  JNIEXPORT jobject   saExceptionException;
   36.90 -  JNIEXPORT jclass    saExceptionCatchClass;
   36.91 -  JNIEXPORT jmethodID saExceptionCatchMethod;
   36.92 -  JNIEXPORT int32_t   saExceptionCatchLocation;
   36.93 -
   36.94 -  //
   36.95 -  // Breakpoint events
   36.96 -  //
   36.97 -  JNIEXPORT jthread   saBreakpointThread;
   36.98 -  JNIEXPORT jclass    saBreakpointClass;
   36.99 -  JNIEXPORT jmethodID saBreakpointMethod;
  36.100 -  JNIEXPORT jlocation saBreakpointLocation;
  36.101 -
  36.102 -  ///////////////////////////////////////
  36.103 -  //                                   //
  36.104 -  // Commands sent by the SA to the VM //
  36.105 -  //                                   //
  36.106 -  ///////////////////////////////////////
  36.107 -
  36.108 -  extern JNIEXPORT const int32_t SA_CMD_SUSPEND_ALL       = 0;
  36.109 -  extern JNIEXPORT const int32_t SA_CMD_RESUME_ALL        = 1;
  36.110 -  extern JNIEXPORT const int32_t SA_CMD_TOGGLE_BREAKPOINT = 2;
  36.111 -  extern JNIEXPORT const int32_t SA_CMD_BUF_SIZE          = 1024;
  36.112 -
  36.113 -  // SA sets this to a nonzero value when it is requesting a command
  36.114 -  // to be processed; VM sets it back to 0 when the command has been
  36.115 -  // executed
  36.116 -  JNIEXPORT volatile int32_t saCmdPending   = 0;
  36.117 -
  36.118 -  // SA sets this to one of the manifest constants above to indicate
  36.119 -  // the kind of command to be executed
  36.120 -  JNIEXPORT volatile int32_t saCmdType      = 0;
  36.121 -
  36.122 -  // VM sets this to 0 if the last command succeeded or a nonzero
  36.123 -  // value if it failed
  36.124 -  JNIEXPORT volatile int32_t saCmdResult    = 0;
  36.125 -
  36.126 -  // If last command failed, this buffer will contain a descriptive
  36.127 -  // error message
  36.128 -  JNIEXPORT char             saCmdResultErrMsg[SA_CMD_BUF_SIZE];
  36.129 -
  36.130 -  //
  36.131 -  // Toggling of breakpoint command arguments.
  36.132 -  //
  36.133 -  // Originally there were separate set/clear breakpoint commands
  36.134 -  // taking a class name, method name and signature, and the iteration
  36.135 -  // through the debug information was done in the SA. It turns out
  36.136 -  // that doing this work in the target VM is significantly faster,
  36.137 -  // and since interactivity when setting and clearing breakpoints is
  36.138 -  // important, the solution which resulted in more C/C++ code was used.
  36.139 -  //
  36.140 -
  36.141 -  // Source file name
  36.142 -  JNIEXPORT char    saCmdBkptSrcFileName[SA_CMD_BUF_SIZE];
  36.143 -
  36.144 -  // Package name ('/' as separator instead of '.')
  36.145 -  JNIEXPORT char    saCmdBkptPkgName[SA_CMD_BUF_SIZE];
  36.146 -
  36.147 -  // Line number
  36.148 -  JNIEXPORT int32_t saCmdBkptLineNumber;
  36.149 -
  36.150 -  // Output back to SA: indicator whether the last failure of a
  36.151 -  // breakpoint toggle command was really an error or just a lack of
  36.152 -  // debug information covering the requested line. 0 if not error.
  36.153 -  // Valid only if saCmdResult != 0.
  36.154 -  JNIEXPORT int32_t saCmdBkptResWasError;
  36.155 -
  36.156 -  // Output back to SA: resulting line number at which the breakpoint
  36.157 -  // was set or cleared (valid only if saCmdResult == 0)
  36.158 -  JNIEXPORT int32_t saCmdBkptResLineNumber;
  36.159 -
  36.160 -  // Output back to SA: resulting byte code index at which the
  36.161 -  // breakpoint was set or cleared (valid only if saCmdResult == 0)
  36.162 -  JNIEXPORT int32_t saCmdBkptResBCI;
  36.163 -
  36.164 -  // Output back to SA: indicator whether the breakpoint operation
  36.165 -  // resulted in a set or cleared breakpoint; nonzero if set, zero if
  36.166 -  // cleared (valid only if saCmdResult == 0)
  36.167 -  JNIEXPORT int32_t saCmdBkptResWasSet;
  36.168 -
  36.169 -  // Output back to SA: method name the breakpoint was set in (valid
  36.170 -  // only if saCmdResult == 0)
  36.171 -  JNIEXPORT char    saCmdBkptResMethodName[SA_CMD_BUF_SIZE];
  36.172 -
  36.173 -  // Output back to SA: method signature (JNI style) the breakpoint
  36.174 -  // was set in (valid only if saCmdResult == 0)
  36.175 -  JNIEXPORT char    saCmdBkptResMethodSig[SA_CMD_BUF_SIZE];
  36.176 -}
  36.177 -
  36.178 -// Internal state
  36.179 -static JavaVM* jvm = NULL;
  36.180 -static JVMDI_Interface_1* jvmdi = NULL;
  36.181 -static jthread debugThreadObj = NULL;
  36.182 -static bool suspended = false;
  36.183 -static vector<jthread> suspendedThreads;
  36.184 -static JVMDI_RawMonitor eventLock = NULL;
  36.185 -
  36.186 -class MonitorLocker {
  36.187 -private:
  36.188 -  JVMDI_RawMonitor lock;
  36.189 -public:
  36.190 -  MonitorLocker(JVMDI_RawMonitor lock) {
  36.191 -    this->lock = lock;
  36.192 -    if (lock != NULL) {
  36.193 -      jvmdi->RawMonitorEnter(lock);
  36.194 -    }
  36.195 -  }
  36.196 -  ~MonitorLocker() {
  36.197 -    if (lock != NULL) {
  36.198 -      jvmdi->RawMonitorExit(lock);
  36.199 -    }
  36.200 -  }
  36.201 -};
  36.202 -
  36.203 -class JvmdiDeallocator {
  36.204 -private:
  36.205 -  void* ptr;
  36.206 -public:
  36.207 -  JvmdiDeallocator(void* ptr) {
  36.208 -    this->ptr = ptr;
  36.209 -  }
  36.210 -  ~JvmdiDeallocator() {
  36.211 -    jvmdi->Deallocate((jbyte*) ptr);
  36.212 -  }
  36.213 -};
  36.214 -
  36.215 -class JvmdiRefListDeallocator {
  36.216 -private:
  36.217 -  JNIEnv* env;
  36.218 -  jobject* refList;
  36.219 -  jint refCount;
  36.220 -public:
  36.221 -  JvmdiRefListDeallocator(JNIEnv* env, jobject* refList, jint refCount) {
  36.222 -    this->env = env;
  36.223 -    this->refList = refList;
  36.224 -    this->refCount = refCount;
  36.225 -  }
  36.226 -  ~JvmdiRefListDeallocator() {
  36.227 -    for (int i = 0; i < refCount; i++) {
  36.228 -      env->DeleteGlobalRef(refList[i]);
  36.229 -    }
  36.230 -    jvmdi->Deallocate((jbyte*) refList);
  36.231 -  }
  36.232 -};
  36.233 -
  36.234 -static void
  36.235 -stop(char* msg) {
  36.236 -  fprintf(stderr, "%s", msg);
  36.237 -  fprintf(stderr, "\n");
  36.238 -  exit(1);
  36.239 -}
  36.240 -
  36.241 -// This fills in the command result error message, sets the command
  36.242 -// result to -1, and clears the pending command flag
  36.243 -static void
  36.244 -reportErrorToSA(const char* str, ...) {
  36.245 -  va_list varargs;
  36.246 -  va_start(varargs, str);
  36.247 -  vsnprintf(saCmdResultErrMsg, sizeof(saCmdResultErrMsg), str, varargs);
  36.248 -  va_end(varargs);
  36.249 -  saCmdResult = -1;
  36.250 -  saCmdPending = 0;
  36.251 -}
  36.252 -
  36.253 -static bool
  36.254 -packageNameMatches(char* clazzName, char* pkg) {
  36.255 -  int pkgLen = strlen(pkg);
  36.256 -  int clazzNameLen = strlen(clazzName);
  36.257 -
  36.258 -  if (pkgLen >= clazzNameLen + 1) {
  36.259 -    return false;
  36.260 -  }
  36.261 -
  36.262 -  if (strncmp(clazzName, pkg, pkgLen)) {
  36.263 -    return false;
  36.264 -  }
  36.265 -
  36.266 -  // Ensure that '/' is the next character if non-empty package name
  36.267 -  int l = pkgLen;
  36.268 -  if (l > 0) {
  36.269 -    if (clazzName[l] != '/') {
  36.270 -      return false;
  36.271 -    }
  36.272 -    l++;
  36.273 -  }
  36.274 -  // Ensure that there are no more trailing slashes
  36.275 -  while (l < clazzNameLen) {
  36.276 -    if (clazzName[l++] == '/') {
  36.277 -      return false;
  36.278 -    }
  36.279 -  }
  36.280 -  return true;
  36.281 -}
  36.282 -
  36.283 -static void
  36.284 -executeOneCommand(JNIEnv* env) {
  36.285 -  switch (saCmdType) {
  36.286 -  case SA_CMD_SUSPEND_ALL: {
  36.287 -    if (suspended) {
  36.288 -      reportErrorToSA("Target process already suspended");
  36.289 -      return;
  36.290 -    }
  36.291 -
  36.292 -    // We implement this by getting all of the threads and calling
  36.293 -    // SuspendThread on each one, except for the thread object
  36.294 -    // corresponding to this thread. Each thread for which the call
  36.295 -    // succeeded (i.e., did not return JVMDI_ERROR_INVALID_THREAD)
  36.296 -    // is added to a list which is remembered for later resumption.
  36.297 -    // Note that this currently has race conditions since a thread
  36.298 -    // might be started after we call GetAllThreads and since a
  36.299 -    // thread for which we got an error earlier might be resumed by
  36.300 -    // the VM while we are busy suspending other threads. We could
  36.301 -    // solve this by looping until there are no more threads we can
  36.302 -    // suspend, but a more robust and scalable solution is to add
  36.303 -    // this functionality to the JVMDI interface (i.e.,
  36.304 -    // "suspendAll"). Probably need to provide an exclude list for
  36.305 -    // such a routine.
  36.306 -    jint threadCount;
  36.307 -    jthread* threads;
  36.308 -    if (jvmdi->GetAllThreads(&threadCount, &threads) != JVMDI_ERROR_NONE) {
  36.309 -      reportErrorToSA("Error while getting thread list");
  36.310 -      return;
  36.311 -    }
  36.312 -
  36.313 -
  36.314 -    for (int i = 0; i < threadCount; i++) {
  36.315 -      jthread thr = threads[i];
  36.316 -      if (!env->IsSameObject(thr, debugThreadObj)) {
  36.317 -        jvmdiError err = jvmdi->SuspendThread(thr);
  36.318 -        if (err == JVMDI_ERROR_NONE) {
  36.319 -          // Remember this thread and do not free it
  36.320 -          suspendedThreads.push_back(thr);
  36.321 -          continue;
  36.322 -        } else {
  36.323 -          fprintf(stderr, " SA: Error %d while suspending thread\n", err);
  36.324 -          // FIXME: stop, resume all threads, report error
  36.325 -        }
  36.326 -      }
  36.327 -      env->DeleteGlobalRef(thr);
  36.328 -    }
  36.329 -
  36.330 -    // Free up threads
  36.331 -    jvmdi->Deallocate((jbyte*) threads);
  36.332 -
  36.333 -    // Suspension is complete
  36.334 -    suspended = true;
  36.335 -    break;
  36.336 -  }
  36.337 -
  36.338 -  case SA_CMD_RESUME_ALL: {
  36.339 -    if (!suspended) {
  36.340 -      reportErrorToSA("Target process already suspended");
  36.341 -      return;
  36.342 -    }
  36.343 -
  36.344 -    saCmdResult = 0;
  36.345 -    bool errorOccurred = false;
  36.346 -    jvmdiError firstError;
  36.347 -    for (int i = 0; i < suspendedThreads.size(); i++) {
  36.348 -      jthread thr = suspendedThreads[i];
  36.349 -      jvmdiError err = jvmdi->ResumeThread(thr);
  36.350 -      env->DeleteGlobalRef(thr);
  36.351 -      if (err != JVMDI_ERROR_NONE) {
  36.352 -        if (!errorOccurred) {
  36.353 -          errorOccurred = true;
  36.354 -          firstError = err;
  36.355 -        }
  36.356 -      }
  36.357 -    }
  36.358 -    suspendedThreads.clear();
  36.359 -    suspended = false;
  36.360 -    if (errorOccurred) {
  36.361 -      reportErrorToSA("Error %d while resuming threads", firstError);
  36.362 -      return;
  36.363 -    }
  36.364 -    break;
  36.365 -  }
  36.366 -
  36.367 -  case SA_CMD_TOGGLE_BREAKPOINT: {
  36.368 -    saCmdBkptResWasError = 1;
  36.369 -
  36.370 -    // Search line number info for all loaded classes
  36.371 -    jint classCount;
  36.372 -    jclass* classes;
  36.373 -
  36.374 -    jvmdiError glcRes = jvmdi->GetLoadedClasses(&classCount, &classes);
  36.375 -    if (glcRes != JVMDI_ERROR_NONE) {
  36.376 -      reportErrorToSA("Error %d while getting loaded classes", glcRes);
  36.377 -      return;
  36.378 -    }
  36.379 -    JvmdiRefListDeallocator rld(env, (jobject*) classes, classCount);
  36.380 -
  36.381 -    bool done = false;
  36.382 -    bool gotOne = false;
  36.383 -    jclass targetClass;
  36.384 -    jmethodID targetMethod;
  36.385 -    jlocation targetLocation;
  36.386 -    jint targetLineNumber;
  36.387 -
  36.388 -    for (int i = 0; i < classCount && !done; i++) {
  36.389 -      fflush(stderr);
  36.390 -      jclass clazz = classes[i];
  36.391 -      char* srcName;
  36.392 -      jvmdiError sfnRes = jvmdi->GetSourceFileName(clazz, &srcName);
  36.393 -      if (sfnRes == JVMDI_ERROR_NONE) {
  36.394 -        JvmdiDeallocator de1(srcName);
  36.395 -        if (!strcmp(srcName, saCmdBkptSrcFileName)) {
  36.396 -          // Got a match. Now see whether the package name of the class also matches
  36.397 -          char* clazzName;
  36.398 -          jvmdiError sigRes = jvmdi->GetClassSignature(clazz, &clazzName);
  36.399 -          if (sigRes != JVMDI_ERROR_NONE) {
  36.400 -            reportErrorToSA("Error %d while getting a class's signature", sigRes);
  36.401 -            return;
  36.402 -          }
  36.403 -          JvmdiDeallocator de2(clazzName);
  36.404 -          if (packageNameMatches(clazzName + 1, saCmdBkptPkgName)) {
  36.405 -            // Iterate through all methods
  36.406 -            jint methodCount;
  36.407 -            jmethodID* methods;
  36.408 -            if (jvmdi->GetClassMethods(clazz, &methodCount, &methods) != JVMDI_ERROR_NONE) {
  36.409 -              reportErrorToSA("Error while getting methods of class %s", clazzName);
  36.410 -              return;
  36.411 -            }
  36.412 -            JvmdiDeallocator de3(methods);
  36.413 -            for (int j = 0; j < methodCount && !done; j++) {
  36.414 -              jmethodID m = methods[j];
  36.415 -              jint entryCount;
  36.416 -              JVMDI_line_number_entry* table;
  36.417 -              jvmdiError lnRes = jvmdi->GetLineNumberTable(clazz, m, &entryCount, &table);
  36.418 -              if (lnRes == JVMDI_ERROR_NONE) {
  36.419 -                JvmdiDeallocator de4(table);
  36.420 -                // Look for line number greater than or equal to requested line
  36.421 -                for (int k = 0; k < entryCount && !done; k++) {
  36.422 -                  JVMDI_line_number_entry& entry = table[k];
  36.423 -                  if (entry.line_number >= saCmdBkptLineNumber &&
  36.424 -                      (!gotOne || entry.line_number < targetLineNumber)) {
  36.425 -                    gotOne = true;
  36.426 -                    targetClass = clazz;
  36.427 -                    targetMethod = m;
  36.428 -                    targetLocation = entry.start_location;
  36.429 -                    targetLineNumber = entry.line_number;
  36.430 -                    done = (targetLineNumber == saCmdBkptLineNumber);
  36.431 -                  }
  36.432 -                }
  36.433 -              } else if (lnRes != JVMDI_ERROR_ABSENT_INFORMATION) {
  36.434 -                reportErrorToSA("Unexpected error %d while fetching line number table", lnRes);
  36.435 -                return;
  36.436 -              }
  36.437 -            }
  36.438 -          }
  36.439 -        }
  36.440 -      } else if (sfnRes != JVMDI_ERROR_ABSENT_INFORMATION) {
  36.441 -        reportErrorToSA("Unexpected error %d while fetching source file name", sfnRes);
  36.442 -        return;
  36.443 -      }
  36.444 -    }
  36.445 -
  36.446 -    bool wasSet = true;
  36.447 -    if (gotOne) {
  36.448 -      // Really toggle this breakpoint
  36.449 -      jvmdiError bpRes;
  36.450 -      bpRes = jvmdi->SetBreakpoint(targetClass, targetMethod, targetLocation);
  36.451 -      if (bpRes == JVMDI_ERROR_DUPLICATE) {
  36.452 -        bpRes = jvmdi->ClearBreakpoint(targetClass, targetMethod, targetLocation);
  36.453 -        wasSet = false;
  36.454 -      }
  36.455 -      if (bpRes != JVMDI_ERROR_NONE) {
  36.456 -        reportErrorToSA("Unexpected error %d while setting or clearing breakpoint at bci %d, line %d",
  36.457 -                        bpRes, targetLocation, targetLineNumber);
  36.458 -        return;
  36.459 -      }
  36.460 -    } else {
  36.461 -      saCmdBkptResWasError = 0;
  36.462 -      reportErrorToSA("No debug information found covering this line");
  36.463 -      return;
  36.464 -    }
  36.465 -
  36.466 -    // Provide result
  36.467 -    saCmdBkptResLineNumber = targetLineNumber;
  36.468 -    saCmdBkptResBCI        = targetLocation;
  36.469 -    saCmdBkptResWasSet     = (wasSet ? 1 : 0);
  36.470 -    {
  36.471 -      char* methodName;
  36.472 -      char* methodSig;
  36.473 -      if (jvmdi->GetMethodName(targetClass, targetMethod, &methodName, &methodSig)
  36.474 -          == JVMDI_ERROR_NONE) {
  36.475 -        JvmdiDeallocator mnd(methodName);
  36.476 -        JvmdiDeallocator msd(methodSig);
  36.477 -        strncpy(saCmdBkptResMethodName, methodName, SA_CMD_BUF_SIZE);
  36.478 -        strncpy(saCmdBkptResMethodSig,  methodSig, SA_CMD_BUF_SIZE);
  36.479 -      } else {
  36.480 -        strncpy(saCmdBkptResMethodName, "<error>", SA_CMD_BUF_SIZE);
  36.481 -        strncpy(saCmdBkptResMethodSig,  "<error>", SA_CMD_BUF_SIZE);
  36.482 -      }
  36.483 -    }
  36.484 -    break;
  36.485 -  }
  36.486 -
  36.487 -  default:
  36.488 -    reportErrorToSA("Command %d not yet supported", saCmdType);
  36.489 -    return;
  36.490 -  }
  36.491 -
  36.492 -  // Successful command execution
  36.493 -  saCmdResult = 0;
  36.494 -  saCmdPending = 0;
  36.495 -}
  36.496 -
  36.497 -static void
  36.498 -saCommandThread(void *arg) {
  36.499 -  JNIEnv* env = NULL;
  36.500 -  if (jvm->GetEnv((void **) &env, JNI_VERSION_1_2) != JNI_OK) {
  36.501 -    stop("Error while starting Serviceability Agent "
  36.502 -         "command thread: could not get JNI environment");
  36.503 -  }
  36.504 -
  36.505 -  while (1) {
  36.506 -    // Wait for command
  36.507 -    while (!saCmdPending) {
  36.508 -      SLEEP();
  36.509 -    }
  36.510 -
  36.511 -    executeOneCommand(env);
  36.512 -  }
  36.513 -}
  36.514 -
  36.515 -static void
  36.516 -saEventHook(JNIEnv *env, JVMDI_Event *event)
  36.517 -{
  36.518 -  MonitorLocker ml(eventLock);
  36.519 -
  36.520 -  saEventKind = event->kind;
  36.521 -
  36.522 -  if (event->kind == JVMDI_EVENT_VM_INIT) {
  36.523 -    // Create event lock
  36.524 -    if (jvmdi->CreateRawMonitor("Serviceability Agent Event Lock", &eventLock)
  36.525 -        != JVMDI_ERROR_NONE) {
  36.526 -      stop("Unable to create Serviceability Agent's event lock");
  36.527 -    }
  36.528 -    // Start thread which receives commands from the SA.
  36.529 -    jclass threadClass = env->FindClass("java/lang/Thread");
  36.530 -    if (threadClass == NULL) stop("Unable to find class java/lang/Thread");
  36.531 -    jstring threadName = env->NewStringUTF("Serviceability Agent Command Thread");
  36.532 -    if (threadName == NULL) stop("Unable to allocate debug thread name");
  36.533 -    jmethodID ctor = env->GetMethodID(threadClass, "<init>", "(Ljava/lang/String;)V");
  36.534 -    if (ctor == NULL) stop("Unable to find appropriate constructor for java/lang/Thread");
  36.535 -    // Allocate thread object
  36.536 -    jthread thr = (jthread) env->NewObject(threadClass, ctor, threadName);
  36.537 -    if (thr == NULL) stop("Unable to allocate debug thread's java/lang/Thread instance");
  36.538 -    // Remember which thread this is
  36.539 -    debugThreadObj = env->NewGlobalRef(thr);
  36.540 -    if (debugThreadObj == NULL) stop("Unable to allocate global ref for debug thread object");
  36.541 -    // Start thread
  36.542 -    jvmdiError err;
  36.543 -    if ((err = jvmdi->RunDebugThread(thr, &saCommandThread, NULL, JVMDI_THREAD_NORM_PRIORITY))
  36.544 -        != JVMDI_ERROR_NONE) {
  36.545 -      char buf[256];
  36.546 -      sprintf(buf, "Error %d while starting debug thread", err);
  36.547 -      stop(buf);
  36.548 -    }
  36.549 -    // OK, initialization is done
  36.550 -    return;
  36.551 -  }
  36.552 -
  36.553 -  if (!saAttached) {
  36.554 -    return;
  36.555 -  }
  36.556 -
  36.557 -  switch (event->kind) {
  36.558 -  case JVMDI_EVENT_EXCEPTION: {
  36.559 -    fprintf(stderr, "SA: Exception thrown -- ignoring\n");
  36.560 -    saExceptionThread        = event->u.exception.thread;
  36.561 -    saExceptionClass         = event->u.exception.clazz;
  36.562 -    saExceptionMethod        = event->u.exception.method;
  36.563 -    saExceptionLocation      = event->u.exception.location;
  36.564 -    saExceptionException     = event->u.exception.exception;
  36.565 -    saExceptionCatchClass    = event->u.exception.catch_clazz;
  36.566 -    saExceptionCatchClass    = event->u.exception.catch_clazz;
  36.567 -    saExceptionCatchMethod   = event->u.exception.catch_method;
  36.568 -    saExceptionCatchLocation = event->u.exception.catch_location;
  36.569 -    //    saEventPending = 1;
  36.570 -    break;
  36.571 -  }
  36.572 -
  36.573 -  case JVMDI_EVENT_BREAKPOINT: {
  36.574 -    saBreakpointThread       = event->u.breakpoint.thread;
  36.575 -    saBreakpointClass        = event->u.breakpoint.clazz;
  36.576 -    saBreakpointMethod       = event->u.breakpoint.method;
  36.577 -    saBreakpointLocation     = event->u.breakpoint.location;
  36.578 -    saEventPending = 1;
  36.579 -    break;
  36.580 -  }
  36.581 -
  36.582 -  default:
  36.583 -    break;
  36.584 -  }
  36.585 -
  36.586 -  while (saAttached && saEventPending) {
  36.587 -    SLEEP();
  36.588 -  }
  36.589 -}
  36.590 -
  36.591 -extern "C" {
  36.592 -JNIEXPORT jint JNICALL
  36.593 -JVM_OnLoad(JavaVM *vm, char *options, void *reserved)
  36.594 -{
  36.595 -  jvm = vm;
  36.596 -  if (jvm->GetEnv((void**) &jvmdi, JVMDI_VERSION_1) != JNI_OK) {
  36.597 -    return -1;
  36.598 -  }
  36.599 -  if (jvmdi->SetEventHook(&saEventHook) != JVMDI_ERROR_NONE) {
  36.600 -    return -1;
  36.601 -  }
  36.602 -  return 0;
  36.603 -}
  36.604 -};
    37.1 --- a/agent/src/share/native/jvmdi/sa.dsp	Thu Feb 21 07:50:48 2013 -0500
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,105 +0,0 @@
    37.4 -# Microsoft Developer Studio Project File - Name="sa" - Package Owner=<4>
    37.5 -# Microsoft Developer Studio Generated Build File, Format Version 6.00
    37.6 -# ** DO NOT EDIT **
    37.7 -
    37.8 -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
    37.9 -
   37.10 -CFG=sa - Win32 Debug
   37.11 -!MESSAGE This is not a valid makefile. To build this project using NMAKE,
   37.12 -!MESSAGE use the Export Makefile command and run
   37.13 -!MESSAGE 
   37.14 -!MESSAGE NMAKE /f "sa.mak".
   37.15 -!MESSAGE 
   37.16 -!MESSAGE You can specify a configuration when running NMAKE
   37.17 -!MESSAGE by defining the macro CFG on the command line. For example:
   37.18 -!MESSAGE 
   37.19 -!MESSAGE NMAKE /f "sa.mak" CFG="sa - Win32 Debug"
   37.20 -!MESSAGE 
   37.21 -!MESSAGE Possible choices for configuration are:
   37.22 -!MESSAGE 
   37.23 -!MESSAGE "sa - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
   37.24 -!MESSAGE "sa - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
   37.25 -!MESSAGE 
   37.26 -
   37.27 -# Begin Project
   37.28 -# PROP AllowPerConfigDependencies 0
   37.29 -# PROP Scc_ProjName ""
   37.30 -# PROP Scc_LocalPath ""
   37.31 -CPP=cl.exe
   37.32 -MTL=midl.exe
   37.33 -RSC=rc.exe
   37.34 -
   37.35 -!IF  "$(CFG)" == "sa - Win32 Release"
   37.36 -
   37.37 -# PROP BASE Use_MFC 0
   37.38 -# PROP BASE Use_Debug_Libraries 0
   37.39 -# PROP BASE Output_Dir "Release"
   37.40 -# PROP BASE Intermediate_Dir "Release"
   37.41 -# PROP BASE Target_Dir ""
   37.42 -# PROP Use_MFC 0
   37.43 -# PROP Use_Debug_Libraries 0
   37.44 -# PROP Output_Dir "Release"
   37.45 -# PROP Intermediate_Dir "Release"
   37.46 -# PROP Target_Dir ""
   37.47 -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SA_EXPORTS" /YX /FD /c
   37.48 -# ADD CPP /nologo /MT /W3 /GX /O2 /I "D:\jdk1.4\include" /I "D:\jdk1.4\include\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SA_EXPORTS" /YX /FD /c
   37.49 -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
   37.50 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
   37.51 -# ADD BASE RSC /l 0x409 /d "NDEBUG"
   37.52 -# ADD RSC /l 0x409 /d "NDEBUG"
   37.53 -BSC32=bscmake.exe
   37.54 -# ADD BASE BSC32 /nologo
   37.55 -# ADD BSC32 /nologo
   37.56 -LINK32=link.exe
   37.57 -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
   37.58 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
   37.59 -
   37.60 -!ELSEIF  "$(CFG)" == "sa - Win32 Debug"
   37.61 -
   37.62 -# PROP BASE Use_MFC 0
   37.63 -# PROP BASE Use_Debug_Libraries 1
   37.64 -# PROP BASE Output_Dir "Debug"
   37.65 -# PROP BASE Intermediate_Dir "Debug"
   37.66 -# PROP BASE Target_Dir ""
   37.67 -# PROP Use_MFC 0
   37.68 -# PROP Use_Debug_Libraries 1
   37.69 -# PROP Output_Dir "Debug"
   37.70 -# PROP Intermediate_Dir "Debug"
   37.71 -# PROP Target_Dir ""
   37.72 -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SA_EXPORTS" /YX /FD /GZ  /c
   37.73 -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "D:\jdk1.4\include" /I "D:\jdk1.4\include\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SA_EXPORTS" /YX /FD /GZ  /c
   37.74 -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
   37.75 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
   37.76 -# ADD BASE RSC /l 0x409 /d "_DEBUG"
   37.77 -# ADD RSC /l 0x409 /d "_DEBUG"
   37.78 -BSC32=bscmake.exe
   37.79 -# ADD BASE BSC32 /nologo
   37.80 -# ADD BSC32 /nologo
   37.81 -LINK32=link.exe
   37.82 -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
   37.83 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
   37.84 -
   37.85 -!ENDIF 
   37.86 -
   37.87 -# Begin Target
   37.88 -
   37.89 -# Name "sa - Win32 Release"
   37.90 -# Name "sa - Win32 Debug"
   37.91 -# Begin Group "Source Files"
   37.92 -
   37.93 -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
   37.94 -# Begin Source File
   37.95 -
   37.96 -SOURCE=.\sa.cpp
   37.97 -# End Source File
   37.98 -# End Group
   37.99 -# Begin Group "Header Files"
  37.100 -
  37.101 -# PROP Default_Filter "h;hpp;hxx;hm;inl"
  37.102 -# End Group
  37.103 -# Begin Group "Resource Files"
  37.104 -
  37.105 -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
  37.106 -# End Group
  37.107 -# End Target
  37.108 -# End Project
    38.1 --- a/agent/src/share/native/jvmdi/sa.dsw	Thu Feb 21 07:50:48 2013 -0500
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,29 +0,0 @@
    38.4 -Microsoft Developer Studio Workspace File, Format Version 6.00
    38.5 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
    38.6 -
    38.7 -###############################################################################
    38.8 -
    38.9 -Project: "sa"=.\sa.dsp - Package Owner=<4>
   38.10 -
   38.11 -Package=<5>
   38.12 -{{{
   38.13 -}}}
   38.14 -
   38.15 -Package=<4>
   38.16 -{{{
   38.17 -}}}
   38.18 -
   38.19 -###############################################################################
   38.20 -
   38.21 -Global:
   38.22 -
   38.23 -Package=<5>
   38.24 -{{{
   38.25 -}}}
   38.26 -
   38.27 -Package=<3>
   38.28 -{{{
   38.29 -}}}
   38.30 -
   38.31 -###############################################################################
   38.32 -
    39.1 --- a/agent/src/share/native/jvmdi/sa.hpp	Thu Feb 21 07:50:48 2013 -0500
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,30 +0,0 @@
    39.4 -/*
    39.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
    39.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 - *
    39.8 - * This code is free software; you can redistribute it and/or modify it
    39.9 - * under the terms of the GNU General Public License version 2 only, as
   39.10 - * published by the Free Software Foundation.
   39.11 - *
   39.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   39.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.15 - * version 2 for more details (a copy is included in the LICENSE file that
   39.16 - * accompanied this code).
   39.17 - *
   39.18 - * You should have received a copy of the GNU General Public License version
   39.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   39.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.21 - *
   39.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   39.23 - * or visit www.oracle.com if you need additional information or have any
   39.24 - * questions.
   39.25 - *
   39.26 - */
   39.27 -
   39.28 -#include "jni.h"
   39.29 -
   39.30 -extern "C" {
   39.31 -JNIEXPORT jint JNICALL
   39.32 -JVM_OnLoad(JavaVM *vm, char *options, void *reserved);
   39.33 -}
    40.1 --- a/make/sa.files	Thu Feb 21 07:50:48 2013 -0500
    40.2 +++ b/make/sa.files	Fri Feb 22 10:03:02 2013 +0100
    40.3 @@ -24,10 +24,7 @@
    40.4  
    40.5  # This filelist macro is included in platform specific sa.make
    40.6  # included all packages/*.java. package list can be generated by
    40.7 -# $(GAMMADIR)/agent/make/build-pkglist. Then manually removed all 
    40.8 -# classes in sun.jvm.hotspot.ui (and subpackages),  all ui classes 
    40.9 -# in sun.jvm.hotspot.bugspot/hotspot and SPARC and x86 disassembler 
   40.10 -# classes and sun.jvm.hotspot.utilities.soql.
   40.11 +# $(GAMMADIR)/agent/make/build-pkglist. 
   40.12  
   40.13  # define AGENT_DIR before including this file in sa.make
   40.14  
   40.15 @@ -40,8 +37,6 @@
   40.16  $(AGENT_SRC_DIR)/sun/jvm/hotspot/*.java \
   40.17  $(AGENT_SRC_DIR)/sun/jvm/hotspot/asm/*.java \
   40.18  $(AGENT_SRC_DIR)/sun/jvm/hotspot/asm/sparc/*.java \
   40.19 -$(AGENT_SRC_DIR)/sun/jvm/hotspot/bugspot/*.java \
   40.20 -$(AGENT_SRC_DIR)/sun/jvm/hotspot/bugspot/tree/*.java \
   40.21  $(AGENT_SRC_DIR)/sun/jvm/hotspot/c1/*.java \
   40.22  $(AGENT_SRC_DIR)/sun/jvm/hotspot/ci/*.java \
   40.23  $(AGENT_SRC_DIR)/sun/jvm/hotspot/code/*.java \
   40.24 @@ -82,7 +77,6 @@
   40.25  $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_interface/*.java \
   40.26  $(AGENT_SRC_DIR)/sun/jvm/hotspot/interpreter/*.java \
   40.27  $(AGENT_SRC_DIR)/sun/jvm/hotspot/jdi/*.java \
   40.28 -$(AGENT_SRC_DIR)/sun/jvm/hotspot/livejvm/*.java \
   40.29  $(AGENT_SRC_DIR)/sun/jvm/hotspot/memory/*.java \
   40.30  $(AGENT_SRC_DIR)/sun/jvm/hotspot/oops/*.java \
   40.31  $(AGENT_SRC_DIR)/sun/jvm/hotspot/opto/*.java \

mercurial