1 // BreakpointManager.java - A convenience class for dealing with breakpoints
3 /* Copyright (C) 2006, 2007 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 package gnu.gcj.jvmti;
13 import java.util.Hashtable;
16 * A class which manages breakpoints in the VM interpreter engine.
18 * BreakpointManager is a location manager that the interpreter
19 * uses to lookup the original instruction for any given installed
20 * breakpoint. JVMTI does not allow multiple breakpoints to be set
21 * at any given location.
23 * @author Keith Seitz (keiths@redhat.com)
25 public class BreakpointManager
27 private static BreakpointManager _instance = new BreakpointManager ();
29 // List of breakpoints indexed by Location
30 private Hashtable _breakpoints;
32 private BreakpointManager ()
34 _breakpoints = new Hashtable ();
38 * Creates a new breakpoint. SetBreakpoint will verify the validity
41 * @param method method in which to set breakpoint (a jmethodID)
42 * @param location index where the breakpoint is to be set (a jlocation)
44 public static Breakpoint newBreakpoint (long method, long location)
46 Breakpoint bp = new Breakpoint (method, location);
47 Location loc = new Location (method, location);
49 _instance._breakpoints.put (loc, bp);
54 * Deletes the breakpoint at the given Location
56 * @param method method in which to clear breakpoint
57 * @param location index of breakpoint in method
59 public static void deleteBreakpoint (long method, long location)
61 Location loc = new Location (method, location);
62 Breakpoint bp = (Breakpoint) _instance._breakpoints.get (loc);
66 _instance._breakpoints.remove (loc);
71 * Returns the breakpoint at the given location or null if none installed
74 * @param method the jmethodID of the breakpoint location
75 * @param location the index in the method
77 public static Breakpoint getBreakpoint (long method, long location)
79 Location loc = new Location (method, location);
80 return (Breakpoint) _instance._breakpoints.get (loc);