From 444dd946c86cf87a35e1cc6f1350182f339871a6 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Wed, 1 Nov 2006 18:20:19 +0000 Subject: Location.java: New file. * gnu/gcj/jvmti/Location.java: New file. * gnu/gcj/jvmti/BreakpointManager.java: New file. * jvmti.cc (_Jv_JVMTI_SetBreakpoint): New function. (_Jv_JVMTI_ClearBreakpoint): New function. (_Jv_JVMTI_Interface): Define SetBreakpoint and ClearBreakpoint. * sources.am: Regenerated. * Makefile.in: Regenerated. From-SVN: r118391 --- libjava/gnu/gcj/jvmti/BreakpointManager.java | 76 ++++++++++++++++++++++++++++ libjava/gnu/gcj/jvmti/Location.java | 60 ++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 libjava/gnu/gcj/jvmti/BreakpointManager.java create mode 100644 libjava/gnu/gcj/jvmti/Location.java (limited to 'libjava/gnu') diff --git a/libjava/gnu/gcj/jvmti/BreakpointManager.java b/libjava/gnu/gcj/jvmti/BreakpointManager.java new file mode 100644 index 0000000..205bf6d --- /dev/null +++ b/libjava/gnu/gcj/jvmti/BreakpointManager.java @@ -0,0 +1,76 @@ +// BreakpointManager.java - A convenience class for dealing with breakpoints + +/* Copyright (C) 2006 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.jvmti; + +import java.util.Hashtable; + +/** + * A class which manages breakpoints in the VM interpreter engine. + * + * BreakpointManager is a location manager that the interpreter + * uses to lookup the original instruction for any given installed + * breakpoint. JVMTI does not allow multiple breakpoints to be set + * at any given location. + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class BreakpointManager +{ + private static BreakpointManager _instance = new BreakpointManager (); + + // List of breakpoints indexed by Location + private Hashtable _breakpoints; + + private BreakpointManager () + { + _breakpoints = new Hashtable (); + } + + /** + * Creates a new breakpoint. SetBreakpoint will verify the validity + * of the arguments. + * + * @param method method in which to set breakpoint (a jmethodID) + * @param location index where the breakpoint is to be set (a jlocation) + */ + public static Breakpoint newBreakpoint (long method, long location) + { + Breakpoint bp = new Breakpoint (method, location); + Location loc = new Location (method, location); + _instance._breakpoints.put (loc, bp); + return bp; + } + + /** + * Deletes the breakpoint at the given Location + * + * @param method method in which to clear breakpoint + * @param location index of breakpoint in method + */ + public static void deleteBreakpoint (long method, long location) + { + Location loc = new Location (method, location); + _instance._breakpoints.remove (loc); + } + + /** + * Returns the breakpoint at the given location or null if none installed + * at location + * + * @param method the jmethodID of the breakpoint location + * @param location the index in the method + */ + public static Breakpoint getBreakpoint (long method, long location) + { + Location loc = new Location (method, location); + return (Breakpoint) _instance._breakpoints.get (loc); + } +} diff --git a/libjava/gnu/gcj/jvmti/Location.java b/libjava/gnu/gcj/jvmti/Location.java new file mode 100644 index 0000000..8fae4dd --- /dev/null +++ b/libjava/gnu/gcj/jvmti/Location.java @@ -0,0 +1,60 @@ +// Location.java - a wrapper class for breakpoint locations in JVMTI + +/* Copyright (C) 2006 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.jvmti; + +import java.lang.Long; + +/** + * This class represents a breakpoint location (pair). + * BreakpointManager uses this class as a key in the Map of installed + * breakpoints. + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class Location +{ + // method (a jmethodID in JVMTI) + private long method; + + // index (a jlocation in JVMTI) + private long location; + + /** + * Constructor + * + * @param method the method defined by this location (a jmethodID) + * @param location the integer index of the insn in the method (a jlocation) + */ + public Location (long method, long location) + { + this.method = method; + this.location = location; + } + + public int hashCode () + { + return toString ().hashCode (); + } + + public boolean equals (Object obj) + { + Location loc = (Location) obj; + return (loc.method == method && loc.location == location); + } + + /** + * Converts the Location to a String + */ + public String toString () + { + return Long.toHexString (method) + "." + Long.toString (location); + } +} -- cgit v1.1