use of com.sun.jdi.request.BreakpointRequest in project gravel by gravel-st.
the class VMTargetStarter method installHaltPoint.
private void installHaltPoint(VirtualMachine vm) {
List<ReferenceType> targetClasses = vm.classesByName(VMLocalTarget.class.getName());
ReferenceType classRef = targetClasses.get(0);
Method meth = classRef.methodsByName("haltPoint").get(0);
BreakpointRequest req = vm.eventRequestManager().createBreakpointRequest(meth.location());
req.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
req.enable();
}
use of com.sun.jdi.request.BreakpointRequest in project otertool by wuntee.
the class Testing method addIntentBreakpoints.
@SuppressWarnings("restriction")
public static void addIntentBreakpoints(VirtualMachine vm) {
EventRequestManager mgr = vm.eventRequestManager();
com.sun.jdi.ReferenceType intentClass = vm.classesByName("android.content.Intent").get(0);
for (Method m : intentClass.methodsByName("<init>")) {
System.out.println("Breakpoint: " + m.toString());
Location location = m.location();
BreakpointRequest bpr = mgr.createBreakpointRequest(location);
bpr.enable();
}
for (Method m : intentClass.methodsByName("putExtra")) {
System.out.println("Breakpoint: " + m.toString());
Location location = m.location();
BreakpointRequest bpr = mgr.createBreakpointRequest(location);
bpr.enable();
}
}
use of com.sun.jdi.request.BreakpointRequest in project jdk8u_jdk by JetBrains.
the class VirtualMachineImpl method redefineClasses.
public void redefineClasses(Map<? extends ReferenceType, byte[]> classToBytes) {
int cnt = classToBytes.size();
JDWP.VirtualMachine.RedefineClasses.ClassDef[] defs = new JDWP.VirtualMachine.RedefineClasses.ClassDef[cnt];
validateVM();
if (!canRedefineClasses()) {
throw new UnsupportedOperationException();
}
Iterator<?> it = classToBytes.entrySet().iterator();
for (int i = 0; it.hasNext(); i++) {
Map.Entry<?, ?> entry = (Map.Entry) it.next();
ReferenceTypeImpl refType = (ReferenceTypeImpl) entry.getKey();
validateMirror(refType);
defs[i] = new JDWP.VirtualMachine.RedefineClasses.ClassDef(refType, (byte[]) entry.getValue());
}
// flush caches and disable caching until the next suspend
vm.state().thaw();
try {
JDWP.VirtualMachine.RedefineClasses.process(vm, defs);
} catch (JDWPException exc) {
switch(exc.errorCode()) {
case JDWP.Error.INVALID_CLASS_FORMAT:
throw new ClassFormatError("class not in class file format");
case JDWP.Error.CIRCULAR_CLASS_DEFINITION:
throw new ClassCircularityError("circularity has been detected while initializing a class");
case JDWP.Error.FAILS_VERIFICATION:
throw new VerifyError("verifier detected internal inconsistency or security problem");
case JDWP.Error.UNSUPPORTED_VERSION:
throw new UnsupportedClassVersionError("version numbers of class are not supported");
case JDWP.Error.ADD_METHOD_NOT_IMPLEMENTED:
throw new UnsupportedOperationException("add method not implemented");
case JDWP.Error.SCHEMA_CHANGE_NOT_IMPLEMENTED:
throw new UnsupportedOperationException("schema change not implemented");
case JDWP.Error.HIERARCHY_CHANGE_NOT_IMPLEMENTED:
throw new UnsupportedOperationException("hierarchy change not implemented");
case JDWP.Error.DELETE_METHOD_NOT_IMPLEMENTED:
throw new UnsupportedOperationException("delete method not implemented");
case JDWP.Error.CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
throw new UnsupportedOperationException("changes to class modifiers not implemented");
case JDWP.Error.METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
throw new UnsupportedOperationException("changes to method modifiers not implemented");
case JDWP.Error.NAMES_DONT_MATCH:
throw new NoClassDefFoundError("class names do not match");
default:
throw exc.toJDIException();
}
}
// Delete any record of the breakpoints
List<BreakpointRequest> toDelete = new ArrayList<BreakpointRequest>();
EventRequestManager erm = eventRequestManager();
it = erm.breakpointRequests().iterator();
while (it.hasNext()) {
BreakpointRequest req = (BreakpointRequest) it.next();
if (classToBytes.containsKey(req.location().declaringType())) {
toDelete.add(req);
}
}
erm.deleteEventRequests(toDelete);
// Invalidate any information cached for the classes just redefined.
it = classToBytes.keySet().iterator();
while (it.hasNext()) {
ReferenceTypeImpl rti = (ReferenceTypeImpl) it.next();
rti.noticeRedefineClass();
}
}
Aggregations