sa-jdi

amBugSpot) {}
  
  public void doLineNumber(LineNumberInfo info)
  {
    System.err.println("  Source file \"" + info.getSourceFileName() + "\", line number " + info.getLineNumber() + ", PC range [" + info.getStartPC() + ", " + info.getEndPC() + ")");
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.18
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import javax.swing.JOptionPane;

final class BugSpot$19
  implements Runnable
{
  private final BugSpot this$0;
  
  BugSpot$19(BugSpot paramBugSpot, String paramString1, String paramString2, int paramInt) {}
  
  public void run()
  {
    if (BugSpot.access$1700(this$0)) {
      JOptionPane.showInternalMessageDialog(BugSpot.access$1800(this$0), val$message, val$title, val$jOptionPaneKind);
    } else {
      JOptionPane.showMessageDialog(null, val$message, val$title, val$jOptionPaneKind);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.19
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class BugSpot$2
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$2(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    BugSpot.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.debugger.cdbg.LineNumberInfo;
import sun.jvm.hotspot.debugger.cdbg.LineNumberVisitor;

final class BugSpot$20
  implements LineNumberVisitor
{
  private final BugSpot this$0;
  
  BugSpot$20(BugSpot paramBugSpot, Map paramMap) {}
  
  public void doLineNumber(LineNumberInfo info)
  {
    String name = info.getSourceFileName();
    if (name != null)
    {
      List val = (List)val$map.get(name);
      if (val == null)
      {
        val = new ArrayList();
        val$map.put(name, val);
      }
      val.add(info);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.20
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.util.Comparator;
import sun.jvm.hotspot.debugger.cdbg.LineNumberInfo;

final class BugSpot$21
  implements Comparator
{
  private final BugSpot this$0;
  
  BugSpot$21(BugSpot paramBugSpot) {}
  
  public int compare(Object o1, Object o2)
  {
    LineNumberInfo l1 = (LineNumberInfo)o1;
    LineNumberInfo l2 = (LineNumberInfo)o2;
    int n1 = l1.getLineNumber();
    int n2 = l2.getLineNumber();
    if (n1 < n2) {
      return -1;
    }
    if (n1 == n2) {
      return 0;
    }
    return 1;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.21
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class BugSpot$3
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$3(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.showAttachDialog();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.3
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class BugSpot$4
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$4(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    BugSpot.access$200(this$0);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.4
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class BugSpot$5
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$5(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    BugSpot.access$200(this$0);
    System.exit(0);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.5
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class BugSpot$6
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$6(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    if (!BugSpot.access$300(this$0)) {
      return;
    }
    if (!BugSpot.access$400(this$0)) {
      return;
    }
    BugSpot.access$500(this$0);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.6
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;

final class BugSpot$7
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$7(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    if (!BugSpot.access$300(this$0))
    {
      System.err.println("Not attached");
      return;
    }
    if (BugSpot.access$400(this$0))
    {
      System.err.println("Already suspended");
      return;
    }
    BugSpot.access$600(this$0);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.7
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class BugSpot$8
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$8(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.showThreadsDialog();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.8
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class BugSpot$9
  implements ActionListener
{
  private final BugSpot this$0;
  
  BugSpot$9(BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.showMemoryDialog();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.9
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

class BugSpot$BreakpointResult
{
  private boolean success;
  private boolean set;
  private int lineNo;
  private String why;
  
  BugSpot$BreakpointResult(boolean success, boolean set, int lineNo)
  {
    this(success, set, lineNo, null);
  }
  
  BugSpot$BreakpointResult(boolean success, boolean set, int lineNo, String why)
  {
    this.success = success;
    this.set = set;
    this.lineNo = lineNo;
    this.why = why;
  }
  
  public boolean succeeded()
  {
    return success;
  }
  
  public boolean set()
  {
    return set;
  }
  
  public int getLine()
  {
    return lineNo;
  }
  
  public String getWhy()
  {
    return why;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.BreakpointResult
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import sun.jvm.hotspot.ui.EditorCommands;
import sun.jvm.hotspot.ui.FrameWrapper;

final class BugSpot$DefaultEditor$1
  implements ActionListener
{
  private final BugSpot.DefaultEditor this$1;
  
  BugSpot$DefaultEditor$1(BugSpot.DefaultEditor paramDefaultEditor, BugSpot paramBugSpot, EditorCommands paramEditorCommands) {}
  
  public void actionPerformed(ActionEvent e)
  {
    val$comm.windowClosed(this$1);
    BugSpot.access$1000(BugSpot.DefaultEditor.access$2200(this$1), BugSpot.DefaultEditor.access$2100(this$1));
    BugSpot.DefaultEditor.access$2100(this$1).dispose();
    BugSpot.DefaultEditor.access$2300(this$1).editorClosed(this$1);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.DefaultEditor.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import sun.jvm.hotspot.ui.SourceCodePanel;

final class BugSpot$DefaultEditor$2
  implements ActionListener
{
  private final BugSpot.DefaultEditor this$1;
  
  BugSpot$DefaultEditor$2(BugSpot.DefaultEditor paramDefaultEditor, BugSpot paramBugSpot) {}
  
  public void actionPerformed(ActionEvent e)
  {
    BugSpot.DefaultEditor.access$2300(this$1).makeEditorCurrent(this$1);
    BugSpot.DefaultEditor.access$2400(this$1).requestFocus();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.DefaultEditor.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import sun.jvm.hotspot.ui.Editor;
import sun.jvm.hotspot.ui.EditorCommands;
import sun.jvm.hotspot.ui.FrameWrapper;
import sun.jvm.hotspot.ui.GraphicsUtilities;
import sun.jvm.hotspot.ui.SourceCodePanel;

class BugSpot$DefaultEditor
  implements Editor
{
  private BugSpot.DefaultEditorFactory factory;
  private FrameWrapper editorFrame;
  private String filename;
  private SourceCodePanel code;
  private boolean shown;
  private Object userData;
  private final BugSpot this$0;
  
  public BugSpot$DefaultEditor(final BugSpot paramBugSpot, BugSpot.DefaultEditorFactory fact, String filename, final EditorCommands comm)
  {
    this.filename = filename;
    factory = fact;
    editorFrame = BugSpot.access$1900(paramBugSpot, filename);
    code = new SourceCodePanel();
    
    code.setFont(BugSpot.access$2000(paramBugSpot));
    editorFrame.getContentPane().add(code);
    editorFrame.setClosable(true);
    editorFrame.setResizable(true);
    editorFrame.setClosingActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        comm.windowClosed(BugSpot.DefaultEditor.this);
        BugSpot.access$1000(this$0, editorFrame);
        editorFrame.dispose();
        factory.editorClosed(BugSpot.DefaultEditor.this);
      }
    });
    editorFrame.setActivatedActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        factory.makeEditorCurrent(BugSpot.DefaultEditor.this);
        code.requestFocus();
      }
    });
    code.setEditorCommands(comm, this);
  }
  
  public boolean openFile()
  {
    return code.openFile(filename);
  }
  
  public String getSourceFileName()
  {
    return filename;
  }
  
  public int getCurrentLineNumber()
  {
    return code.getCurrentLineNumber();
  }
  
  public void showLineNumber(int lineNo)
  {
    if (!shown)
    {
      BugSpot.access$2500(this$0, editorFrame);
      GraphicsUtilities.reshapeToAspectRatio(editorFrame.getComponent(), 1.0F, 0.85F, BugSpot.access$2600(this$0, editorFrame.getComponent()));
      
      editorFrame.setVisible(true);
      shown = true;
    }
    code.showLineNumber(lineNo);
    editorFrame.toFront();
  }
  
  public void highlightLineNumber(int lineNo)
  {
    code.highlightLineNumber(lineNo);
  }
  
  public void showBreakpointAtLine(int lineNo)
  {
    code.showBreakpointAtLine(lineNo);
  }
  
  public boolean hasBreakpointAtLine(int lineNo)
  {
    return code.hasBreakpointAtLine(lineNo);
  }
  
  public void clearBreakpointAtLine(int lineNo)
  {
    code.clearBreakpointAtLine(lineNo);
  }
  
  public void clearBreakpoints()
  {
    code.clearBreakpoints();
  }
  
  public void setUserData(Object o)
  {
    userData = o;
  }
  
  public Object getUserData()
  {
    return userData;
  }
  
  public void toFront()
  {
    editorFrame.toFront();
    factory.makeEditorCurrent(this);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.DefaultEditor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.util.LinkedList;
import sun.jvm.hotspot.ui.Editor;
import sun.jvm.hotspot.ui.EditorCommands;
import sun.jvm.hotspot.ui.EditorFactory;

class BugSpot$DefaultEditorFactory
  implements EditorFactory
{
  private LinkedList editors = new LinkedList();
  private final BugSpot this$0;
  
  BugSpot$DefaultEditorFactory(BugSpot paramBugSpot) {}
  
  public Editor openFile(String filename, EditorCommands commands)
  {
    BugSpot.DefaultEditor editor = new BugSpot.DefaultEditor(this$0, this, filename, BugSpot.access$2700(this$0));
    if (!editor.openFile()) {
      return null;
    }
    return editor;
  }
  
  public Editor getCurrentEditor()
  {
    if (editors.isEmpty()) {
      return null;
    }
    return (Editor)editors.getFirst();
  }
  
  void editorClosed(Editor editor)
  {
    editors.remove(editor);
  }
  
  void makeEditorCurrent(Editor editor)
  {
    editors.remove(editor);
    editors.addFirst(editor);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.DefaultEditorFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.io.File;
import javax.swing.filechooser.FileFilter;

class BugSpot$JavaFileFilter
  extends FileFilter
{
  private String packageName;
  private String fileName;
  
  BugSpot$JavaFileFilter(String packageName, String fileName)
  {
    this.packageName = packageName;
    this.fileName = fileName;
  }
  
  public boolean accept(File f)
  {
    if (f.isDirectory()) {
      return true;
    }
    if (!f.getName().equals(fileName)) {
      return false;
    }
    PackageScanner scanner = new PackageScanner();
    String pkg = scanner.scan(f);
    if (!pkg.equals(packageName)) {
      return false;
    }
    return true;
  }
  
  public String getDescription()
  {
    return "Java source files";
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.JavaFileFilter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

class BugSpot$JavaUserData
{
  private String packageName;
  private String sourceFileName;
  
  BugSpot$JavaUserData(String packageName, String sourceFileName)
  {
    this.packageName = packageName;
    this.sourceFileName = sourceFileName;
  }
  
  String packageName()
  {
    return packageName;
  }
  
  String sourceFileName()
  {
    return sourceFileName;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.bugspot.BugSpot.JavaUserData
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.bugspot;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDesktopPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.filechooser.FileFilter;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.debugger.Debugger;
import sun.jvm.hotspot.debugger.DebuggerException;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.debugger.MachineDescription;
import sun.jvm.hotspot.debugger.MachineDescriptionIntelX86;
import sun.jvm.hotspot.debugger.ProcessInfo;
import sun.jvm.hotspot.debugger.ThreadProxy;
import sun.jvm.hotspot.debugger.cdbg.CDebugInfoDataBase;
import sun.jvm.hotspot.debugger.cdbg.CDebugger;
import sun.jvm.hotspot.debugger.cdbg.CFrame;
import sun.jvm.hotspot.debugger.cdbg.DebugEvent;
import sun.jvm.hotspot.debugger.cdbg.DebugEvent.Type;
import sun.jvm.hotspot.debugger.cdbg.LineNumberInfo;
import sun.jvm.hotspot.debugger.cdbg.LineNumberVisitor;
import sun.jvm.hotspot.debugger.cdbg.LoadObject;
import sun.jvm.hotspot.debugger.cdbg.ProcessControl;
import sun.jvm.hotspot.debugger.win32.Win32DebuggerLocal;
import sun.jvm.hotspot.livejvm.BreakpointEvent;
import sun.jvm.hotspot.livejvm.Event;
import sun.jvm.hotspot.livejvm.Event.Type;
import sun.jvm.hotspot.livejvm.ExceptionEvent;
import sun.jvm.hotspot.livejvm.ServiceabilityAgentJVMDIModule.BreakpointToggleResult;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.runtime.JNIid;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.JavaVFrame;
import sun.jvm.hotspot.runtime.Threads;
import sun.jvm.hotspot.runtime.VFrame;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.ui.Editor;
import sun.jvm.hotspot.ui.EditorCommands;
import sun.jvm.hotspot.ui.EditorFactory;
import sun.jvm.hotspot.ui.FrameWrapper;
import sun.jvm.hotspot.ui.GraphicsUtilities;
import sun.jvm.hotspot.ui.JFrameWrapper;
import sun.jvm.hotspot.ui.JInternalFrameWrapper;
import sun.jvm.hotspot.ui.MemoryViewer;
import sun.jvm.hotspot.ui.ProcessListPanel;
import sun.jvm.hotspot.ui.SourceCodePanel;
import sun.jvm.hotspot.utilities.Assert;
import sun.jvm.hotspot.utilities.PlatformInfo;
import sun.jvm.hotspot.utilities.WorkerThread;

public class BugSpot
  extends JPanel
{
  private WorkerThread workerThread;
  private boolean mdiMode;
  private JVMDebugger localDebugger;
  
  public BugSpot()
  {
    Runtime.getRuntime().addShutdownHook(new Thread()
    {
      public void run()
      {
        BugSpot.this.detachDebugger();
      }
    });
  }
  
  public void setMDIMode(boolean onOrOff)
  {
    mdiMode = onOrOff;
  }
  
  public boolean getMDIMode()
  {
    return mdiMode;
  }
  
  public void build()
  {
    setLayout(new BorderLayout());
    
    menuBar = new JMenuBar();
    
    attachMenuItems = new ArrayList();
    detachMenuItems = new ArrayList();
    debugMenuItems = new ArrayList();
    suspendDebugMenuItems = new ArrayList();
    resumeDebugMenuItems = new ArrayList();
    
    JMenu menu = createMenu("File", 'F', 0);
    
    JMenuItem item = createMenuItem("Open source file...", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        BugSpot.this.openSourceFile();
      }
    }, 79, 2, 'O', 0);
    
    menu.add(item);
    detachMenuItems.add(item);
    
    menu.addSeparator();
    
    item = createMenuItem("Attach to process...", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        showAttachDialog();
      }
    }, 'A', 0);
    
    menu.add(item);
    attachMenuItems.add(item);
    
    item = createMenuItem("Detach", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        BugSpot.this.detach();
      }
    }, 'D', 0);
    
    menu.add(item);
    detachMenuItems.add(item);
    
    setMenuItemsEnabled(detachMenuItems, false);
    
    menu.addSeparator();
    
    menu.add(createMenuItem("Exit", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        BugSpot.this.detach();
        System.exit(0);
      }
    }, 'x', 1));
    
    menuBar.add(menu);
    
    debugMenu = createMenu("Debug", 'D', 0);
    item = createMenuItem("Go", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        if (!attached) {
          return;
        }
        if (!BugSpot.this.isSuspended()) {
          return;
        }
        BugSpot.this.resume();
      }
    }, 116, 0, 'G', 0);
    
    debugMenu.add(item);
    resumeDebugMenuItems.add(item);
    
    item = createMenuItem("Break", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        if (!attached)
        {
          System.err.println("Not attached");
          return;
        }
        if (BugSpot.this.isSuspended())
        {
          System.err.println("Already suspended");
          return;
        }
        BugSpot.this.suspend();
      }
    }, 'B', 0);
    
    debugMenu.add(item);
    suspendDebugMenuItems.add(item);
    
    debugMenu.addSeparator();
    
    item = createMenuItem("Threads...", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        showThreadsDialog();
      }
    }, 'T', 0);
    
    debugMenu.add(item);
    debugMenuItems.add(item);
    
    item = createMenuItem("Memory", new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        showMemoryDialog();
      }
    }, 'M', 0);
    
    debugMenu.add(item);
    debugMenuItems.add(item);
    
    debugMenu.setEnabled(false);
    menuBar.add(debugMenu);
    if (mdiMode)
    {
      desktop = new JDesktopPane();
      add(desktop, "Center");
    }
    fixedWidthFont = GraphicsUtilities.lookupFont("Courier");
    
    debugEventTimer = new Timer(100, new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        BugSpot.this.pollForDebugEvent();
      }
    });
  }
  
  public JMenuBar getMenuBar()
  {
    return menuBar;
  }
  
  public void showAttachDialog()
  {
    setMenuItemsEnabled(attachMenuItems, false);
    final FrameWrapper attachDialog = newFrame("Attach to process");
    attachDialog.getContentPane().setLayout(new BorderLayout());
    attachDialog.setClosable(true);
    attachDialog.setResizable(true);
    
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setBorder(GraphicsUtilities.newBorder(5));
    attachDialog.setBackground(panel.getBackground());
    
    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BorderLayout());
    final ProcessListPanel plist = new ProcessListPanel(getLocalDebugger());
    panel.add(plist, "Center");
    JCheckBox check = new JCheckBox("Update list continuously");
    check.addItemListener(new ItemListener()
    {
      public void itemStateChanged(ItemEvent e)
      {
        if (e.getStateChange() == 1) {
          plist.start();
        } else {
          plist.stop();
        }
      }
    });
    listPanel.add(plist, "Center");
    listPanel.add(check, "South");
    panel.add(listPanel, "Center");
    attachDialog.getContentPane().add(panel, "Center");
    attachDialog.setClosingActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        plist.stop();
        BugSpot.this.setMenuItemsEnabled(attachMenuItems, true);
      }
    });
    ActionListener attacher = new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        plist.stop();
        attachDialog.setVisible(false);
        BugSpot.this.removeFrame(attachDialog);
        ProcessInfo info = plist.getSelectedProcess();
        if (info != null) {
          BugSpot.this.attach(info.getPid());
        }
      }
    };
    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createGlue());
    JButton button = new JButton("OK");
    button.addActionListener(attacher);
    hbox.add(button);
    hbox.add(Box.createHorizontalStrut(20));
    button = new JButton("Cancel");
    button.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        plist.stop();
        attachDialog.setVisible(false);
        BugSpot.this.removeFrame(attachDialog);
        BugSpot.this.setMenuItemsEnabled(attachMenuItems, true);
      }
    });
    hbox.add(button);
    hbox.add(Box.createGlue());
    panel = new JPanel();
    panel.setBorder(GraphicsUtilities.newBorder(5));
    panel.add(hbox);
    
    attachDialog.getContentPane().add(panel, "South");
    
    addFrame(attachDialog);
    attachDialog.pack();
    attachDialog.setSize(400, 300);
    GraphicsUtilities.centerInContainer(attachDialog.getComponent(), getParentDimension(attachDialog.getComponent()));
    
    attachDialog.setVisible(true);
  }
  
  public void showThreadsDialog()
  {
    FrameWrapper threadsDialog = newFrame("Threads");
    threadsDialog.getContentPane().setLayout(new BorderLayout());
    threadsDialog.setClosable(true);
    threadsDialog.setResizable(true);
    
    ThreadListPanel threads = new ThreadListPanel(getCDebugger(), getAgent().isJavaMode());
    threads.addListener(new ThreadListPanel.Listener()
    {
      public void setFocus(ThreadProxy thread, JavaThread jthread)
      {
        BugSpot.this.setCurrentThread(thread);
        
        System.err.println("Focus changed to thread " + thread);
      }
    });
    threads.setBorder(GraphicsUtilities.newBorder(5));
    threadsDialog.getContentPane().add(threads);
    addFrame(threadsDialog);
    threadsDialog.pack();
    GraphicsUtilities.reshapeToAspectRatio(threadsDialog.getComponent(), 3.0F, 0.9F, getParentDimension(threadsDialog.getComponent()));
    
    GraphicsUtilities.centerInContainer(threadsDialog.getComponent(), getParentDimension(threadsDialog.getComponent()));
    
    threadsDialog.setVisible(true);
  }
  
  public void showMemoryDialog()
  {
    FrameWrapper memoryDialog = newFrame("Memory");
    memoryDialog.getContentPane().setLayout(new BorderLayout());
    memoryDialog.setClosable(true);
    memoryDialog.setResizable(true);
    
    memoryDialog.getContentPane().add(new MemoryViewer(getDebugger(), getDebugger().getMachineDescription().getAddressSize() == 8L), "Center");
    
    addFrame(memoryDialog);
    memoryDialog.pack();
    GraphicsUtilities.reshapeToAspectRatio(memoryDialog.getComponent(), 1.0F, 0.7F, getParentDimension(memoryDialog.getComponent()));
    
    GraphicsUtilities.centerInContainer(memoryDialog.getComponent(), getParentDimension(memoryDialog.getComponent()));
    
    memoryDialog.setVisible(true);
  }
  
  public void setEditorFactory(EditorFactory fact)
  {
    if (fact != null) {
      editorFact = fact;
    } else {
      editorFact = new DefaultEditorFactory();
    }
  }
  
  private BugSpotAgent agent = new BugSpotAgent();
  private JMenuBar menuBar;
  private List attachMenuItems;
  private List detachMenuItems;
  private List debugMenuItems;
  private List suspendDebugMenuItems;
  private List resumeDebugMenuItems;
  private FrameWrapper stackFrame;
  private VariablePanel localsPanel;
  private StackTracePanel stackTracePanel;
  private FrameWrapper registerFrame;
  private RegisterPanel registerPanel;
  private Map threadToJavaThreadMap;
  private JMenu debugMenu;
  private JDesktopPane desktop;
  private boolean attached;
  private boolean suspended;
  private Font fixedWidthFont;
  private Map sourceFileToLineNumberInfoMap;
  private Map fileToBreakpointMap;
  private Timer debugEventTimer;
  private boolean javaEventPending;
  private Map editors;
  
  static class BreakpointResult
  {
    private boolean success;
    private boolean set;
    private int lineNo;
    private String why;
    
    BreakpointResult(boolean success, boolean set, int lineNo)
    {
      this(success, set, lineNo, null);
    }
    
    BreakpointResult(boolean success, boolean set, int lineNo, String why)
    {
      this.success = success;
      this.set = set;
      this.lineNo = lineNo;
      this.why = why;
    }
    
    public boolean succeeded()
    {
      return success;
    }
    
    public boolean set()
    {
      return set;
    }
    
    public int getLine()
    {
      return lineNo;
    }
    
    public String getWhy()
    {
      return why;
    }
  }
  
  private EditorFactory editorFact = new DefaultEditorFactory();
  private EditorCommands editorComm = new EditorCommands()
  {
    public void windowClosed(Editor editor)
    {
      editors.remove(editor.getSourceFileName());
    }
    
    public void toggleBreakpointAtLine(Editor editor, int lineNumber)
    {
      BugSpot.BreakpointResult res = BugSpot.this.handleBreakpointToggle(editor, lineNumber);
      if (res.succeeded())
      {
        if (res.set()) {
          editor.showBreakpointAtLine(res.getLine());
        } else {
          editor.clearBreakpointAtLine(res.getLine());
        }
      }
      else
      {
        String why = res.getWhy();
        if (why == null) {
          why = "";
        } else {
          why = ": " + why;
        }
        BugSpot.this.showMessageDialog("Unable to toggle breakpoint" + why, "Unable to toggle breakpoint", 2);
      }
    }
  };
  
  private void attach(int pid)
  {
    try
    {
      getAgent().attach(pid);
      setMenuItemsEnabled(detachMenuItems, true);
      setMenuItemsEnabled(suspendDebugMenuItems, false);
      setMenuItemsEnabled(resumeDebugMenuItems, true);
      debugMenu.setEnabled(true);
      attached = true;
      suspended = true;
      if (getAgent().isJavaMode()) {
        System.err.println("Java HotSpot(TM) virtual machine detected.");
      } else {
        System.err.println("(No Java(TM) virtual machine detected)");
      }
      editors = new HashMap();
      
      fileToBreakpointMap = new HashMap();
      
      JPanel framePanel = new JPanel();
      framePanel.setLayout(new BorderLayout());
      framePanel.setBorder(GraphicsUtilities.newBorder(5));
      localsPanel = new VariablePanel();
      JTabbedPane tab = new JTabbedPane();
      tab.addTab("Locals", localsPanel);
      tab.setTabPlacement(3);
      framePanel.add(tab, "Center");
      JPanel stackPanel = new JPanel();
      stackPanel.setLayout(new BoxLayout(stackPanel, 0));
      stackPanel.add(new JLabel("Context:"));
      stackPanel.add(Box.createHorizontalStrut(5));
      stackTracePanel = new StackTracePanel();
      stackTracePanel.addListener(new StackTracePanel.Listener()
      {
        public void frameChanged(CFrame fr, JavaVFrame jfr)
        {
          BugSpot.this.setCurrentFrame(fr, jfr);
        }
      });
      stackPanel.add(stackTracePanel);
      framePanel.add(stackPanel, "North");
      stackFrame = newFrame("Stack");
      stackFrame.getContentPane().setLayout(new BorderLayout());
      stackFrame.getContentPane().add(framePanel, "Center");
      stackFrame.setResizable(true);
      stackFrame.setClosable(false);
      addFrame(stackFrame);
      stackFrame.setSize(400, 200);
      GraphicsUtilities.moveToInContainer(stackFrame.getComponent(), 0.0F, 1.0F, 0, 20);
      stackFrame.setVisible(true);
      
      registerPanel = new RegisterPanel();
      registerPanel.setFont(fixedWidthFont);
      registerFrame = newFrame("Registers");
      registerFrame.getContentPane().setLayout(new BorderLayout());
      registerFrame.getContentPane().add(registerPanel, "Center");
      addFrame(registerFrame);
      registerFrame.setResizable(true);
      registerFrame.setClosable(false);
      registerFrame.setSize(225, 200);
      GraphicsUtilities.moveToInContainer(registerFrame.getComponent(), 1.0F, 0.0F, 0, 0);
      
      registerFrame.setVisible(true);
      
      resetCurrentThread();
    }
    catch (DebuggerException e)
    {
      String errMsg = formatMessage(e.getMessage(), 80);
      setMenuItemsEnabled(attachMenuItems, true);
      showMessageDialog("Unable to connect to process ID " + pid + ":\n\n" + errMsg, "Unable to Connect", 2);
      
      getAgent().detach();
    }
  }
  
  private synchronized void detachDebugger()
  {
    if (!attached) {
      return;
    }
    if (isSuspended()) {
      resume();
    }
    getAgent().detach();
    
    sourceFileToLineNumberInfoMap = null;
    fileToBreakpointMap = null;
    threadToJavaThreadMap = null;
    editors = null;
    attached = false;
  }
  
  private synchronized void detach()
  {
    detachDebugger();
    setMenuItemsEnabled(attachMenuItems, true);
    setMenuItemsEnabled(detachMenuItems, false);
    debugMenu.setEnabled(false);
    if (mdiMode)
    {
      desktop.removeAll();
      desktop.invalidate();
      desktop.validate();
      desktop.repaint();
    }
    debugEventTimer.stop();
  }
  
  private Debugger getLocalDebugger()
  {
    if (localDebugger == null)
    {
      String os = PlatformInfo.getOS();
      String cpu = PlatformInfo.getCPU();
      if (os.equals("win32"))
      {
        if (!cpu.equals("x86")) {
          throw new DebuggerException("Unsupported CPU \"" + cpu + "\" for Windows");
        }
        localDebugger = new Win32DebuggerLocal(new MachineDescriptionIntelX86(), true);
      }
      else
      {
        if (os.equals("linux"))
        {
          if (!cpu.equals("x86")) {
            throw new DebuggerException("Unsupported CPU \"" + cpu + "\" for Linux");
          }
          throw new RuntimeException("FIXME: figure out how to specify path to debugger module");
        }
        throw new DebuggerException("Unsupported OS \"" + os + "\"");
      }
      localDebugger.configureJavaPrimitiveTypeSizes(1L, 1L, 2L, 8L, 4L, 4L, 8L, 2L);
    }
    return localDebugger;
  }
  
  private BugSpotAgent getAgent()
  {
    return agent;
  }
  
  private Debugger getDebugger()
  {
    return getAgent().getDebugger();
  }
  
  private CDebugger getCDebugger()
  {
    return getAgent().getCDebugger();
  }
  
  private void resetCurrentThread()
  {
    setCurrentThread((ThreadProxy)getCDebugger().getThreadList().get(0));
  }
  
  private void setCurrentThread(ThreadProxy t)
  {
    List trace = new ArrayList();
    CFrame fr = getCDebugger().topFrameForThread(t);
    while (fr != null)
    {
      trace.add(new StackTraceEntry(fr, getCDebugger()));
      try
      {
        fr = fr.sender(t);
      }
      catch (AddressException e)
      {
        e.printStackTrace();
        showMessageDialog("Error while walking stack; stack trace will be truncated\n(see console for details)", "Error walking stack", 2);
        
        fr = null;
      }
    }
    JavaThread jthread = javaThreadForProxy(t);
    if (jthread != null)
    {
      List javaTrace = new ArrayList();
      VFrame vf = jthread.getLastJavaVFrameDbg();
      while (vf != null) {
        if (vf.isJavaFrame())
        {
          javaTrace.add(new StackTraceEntry((JavaVFrame)vf));
          vf = vf.sender();
        }
      }
      List mergedTrace = new ArrayList();
      int c = 0;
      int j = 0;
      while (c < trace.size())
      {
        StackTraceEntry entry = (StackTraceEntry)trace.get(c);
        if (entry.isUnknownCFrame())
        {
          boolean gotJavaFrame = false;
          while (j < javaTrace.size())
          {
            StackTraceEntry javaEntry = (StackTraceEntry)javaTrace.get(j);
            JavaVFrame jvf = javaEntry.getJavaFrame();
            Method m = jvf.getMethod();
            if ((m.isNative()) && (gotJavaFrame)) {
              break;
            }
            gotJavaFrame = true;
            mergedTrace.add(javaEntry);
            j++;
          }
          if (gotJavaFrame)
          {
            while ((c < trace.size()) && (entry.isUnknownCFrame()))
            {
              c++;
              if (c < trace.size()) {
                entry = (StackTraceEntry)trace.get(c);
              }
            }
            continue;
          }
        }
        mergedTrace.add(entry);
        c++;
      }
      trace = mergedTrace;
    }
    stackTracePanel.setTrace(trace);
    
    registerPanel.update(t);
  }
  
  private void setCurrentFrame(CFrame fr, JavaVFrame jfr)
  {
    localsPanel.clear();
    if (fr != null)
    {
      localsPanel.update(fr);
      
      LoadObject lo = getCDebugger().loadObjectContainingPC(fr.pc());
      if (lo != null)
      {
        CDebugInfoDataBase db = lo.getDebugInfoDataBase();
        if (db != null)
        {
          LineNumberInfo info = db.lineNumberForPC(fr.pc());
          if (info != null)
          {
            System.err.println("PC " + fr.pc() + ": Source file \"" + info.getSourceFileName() + "\", line number " + info.getLineNumber() + ", PC range [" + info.getStartPC() + ", " + info.getEndPC() + ")");
            
            showLineNumber(null, info.getSourceFileName(), info.getLineNumber());
          }
          else
          {
            System.err.println("(No line number information for PC " + fr.pc() + ")");
            
            db.iterate(new LineNumberVisitor()
            {
              public void doLineNumber(LineNumberInfo info)
              {
                System.err.println("  Source file \"" + info.getSourceFileName() + "\", line number " + info.getLineNumber() + ", PC range [" + info.getStartPC() + ", " + info.getEndPC() + ")");
              }
            });
          }
        }
      }
    }
    else
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(jfr != null, "Must have either C or Java frame");
      }
      localsPanel.update(jfr);
      
      Method m = jfr.getMethod();
      Symbol sfn = ((InstanceKlass)m.getMethodHolder()).getSourceFileName();
      if (sfn != null)
      {
        int bci = jfr.getBCI();
        int lineNo = m.getLineNumberFromBCI(bci);
        if (lineNo >= 0) {
          showLineNumber(packageName(m.getMethodHolder().getName().asString()), sfn.asString(), lineNo);
        }
      }
    }
  }
  
  private String packageName(String str)
  {
    int idx = str.lastIndexOf('/');
    if (idx < 0) {
      return "";
    }
    return str.substring(0, idx).replace('/', '.');
  }
  
  private JavaThread javaThreadForProxy(ThreadProxy t)
  {
    if (!getAgent().isJavaMode()) {
      return null;
    }
    if (threadToJavaThreadMap == null)
    {
      threadToJavaThreadMap = new HashMap();
      Threads threads = VM.getVM().getThreads();
      for (JavaThread thr = threads.first(); thr != null; thr = thr.next()) {
        threadToJavaThreadMap.put(thr.getThreadProxy(), thr);
      }
    }
    return (JavaThread)threadToJavaThreadMap.get(t);
  }
  
  private static JMenu createMenu(String name, char mnemonic, int mnemonicPos)
  {
    JMenu menu = new JMenu(name);
    menu.setMnemonic(mnemonic);
    menu.setDisplayedMnemonicIndex(mnemonicPos);
    return menu;
  }
  
  private static JMenuItem createMenuItem(String name, ActionListener l)
  {
    JMenuItem item = new JMenuItem(name);
    item.addActionListener(l);
    return item;
  }
  
  private static JMenuItem createMenuItemInternal(String name, ActionListener l, int accelerator, int modifiers)
  {
    JMenuItem item = createMenuItem(name, l);
    item.setAccelerator(KeyStroke.getKeyStroke(accelerator, modifiers));
    return item;
  }
  
  private static JMenuItem createMenuItem(String name, ActionListener l, int accelerator)
  {
    return createMenuItemInternal(name, l, accelerator, 0);
  }
  
  private static JMenuItem createMenuItem(String name, ActionListener l, char mnemonic, int mnemonicPos)
  {
    JMenuItem item = createMenuItem(name, l);
    item.setMnemonic(mnemonic);
    item.setDisplayedMnemonicIndex(mnemonicPos);
    return item;
  }
  
  private static JMenuItem createMenuItem(String name, ActionListener l, int accelerator, int acceleratorMods, char mnemonic, int mnemonicPos)
  {
    JMenuItem item = createMenuItemInternal(name, l, accelerator, acceleratorMods);
    item.setMnemonic(mnemonic);
    item.setDisplayedMnemonicIndex(mnemonicPos);
    return item;
  }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd