use of com.sun.jdi.event.ExceptionEvent in project intellij-community by JetBrains.
the class JavaStackFrame method buildVariablesThreadAction.
// copied from DebuggerTree
private void buildVariablesThreadAction(DebuggerContextImpl debuggerContext, XValueChildrenList children, XCompositeNode node) {
try {
final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
if (evaluationContext == null) {
return;
}
if (!debuggerContext.isEvaluationPossible()) {
node.setErrorMessage(MessageDescriptor.EVALUATION_NOT_POSSIBLE.getLabel());
//myChildren.add(myNodeManager.createNode(MessageDescriptor.EVALUATION_NOT_POSSIBLE, evaluationContext));
}
final Location location = myDescriptor.getLocation();
final ObjectReference thisObjectReference = myDescriptor.getThisObject();
if (thisObjectReference != null) {
ValueDescriptorImpl thisDescriptor = myNodeManager.getThisDescriptor(null, thisObjectReference);
children.add(JavaValue.create(thisDescriptor, evaluationContext, myNodeManager));
} else if (location != null) {
StaticDescriptorImpl staticDecriptor = myNodeManager.getStaticDescriptor(myDescriptor, location.declaringType());
if (staticDecriptor.isExpandable()) {
children.addTopGroup(new JavaStaticGroup(staticDecriptor, evaluationContext, myNodeManager));
}
}
DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
return;
}
// add last method return value if any
final Pair<Method, Value> methodValuePair = debugProcess.getLastExecutedMethod();
if (methodValuePair != null && myDescriptor.getUiIndex() == 0) {
ValueDescriptorImpl returnValueDescriptor = myNodeManager.getMethodReturnValueDescriptor(myDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager));
}
// add context exceptions
Set<ObjectReference> exceptions = new HashSet<>();
for (Pair<Breakpoint, Event> pair : DebuggerUtilsEx.getEventDescriptors(debuggerContext.getSuspendContext())) {
Event debugEvent = pair.getSecond();
if (debugEvent instanceof ExceptionEvent) {
ObjectReference exception = ((ExceptionEvent) debugEvent).exception();
if (exception != null) {
exceptions.add(exception);
}
}
}
exceptions.forEach(e -> children.add(JavaValue.create(myNodeManager.getThrownExceptionObjectDescriptor(myDescriptor, e), evaluationContext, myNodeManager)));
try {
buildVariables(debuggerContext, evaluationContext, debugProcess, children, thisObjectReference, location);
//if (classRenderer.SORT_ASCENDING) {
// Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
//}
} catch (EvaluateException e) {
node.setErrorMessage(e.getMessage());
//myChildren.add(myNodeManager.createMessageNode(new MessageDescriptor(e.getMessage())));
}
} catch (InvalidStackFrameException e) {
LOG.info(e);
//myChildren.clear();
//notifyCancelled();
} catch (InternalException e) {
if (e.errorCode() == 35) {
node.setErrorMessage(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()));
//myChildren.add(
// myNodeManager.createMessageNode(new MessageDescriptor(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()))));
} else {
throw e;
}
}
}
use of com.sun.jdi.event.ExceptionEvent in project gravel by gravel-st.
the class VMRemoteTarget method eventLoop.
private void eventLoop() throws InterruptedException {
System.out.println("eventLoop started");
EventQueue eventQueue = vm.eventQueue();
boolean isRunning = true;
while (isRunning) {
EventSet eventSet = eventQueue.remove();
boolean mayResume = true;
for (Event event : eventSet) {
System.out.println(event);
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
isRunning = false;
} else if (event instanceof ExceptionEvent) {
mayResume = false;
}
}
if (mayResume)
eventSet.resume();
}
}
use of com.sun.jdi.event.ExceptionEvent in project intellij-community by JetBrains.
the class ExceptionBreakpoint method getEventMessage.
public String getEventMessage(LocatableEvent event) {
String exceptionName = (getQualifiedName() != null) ? getQualifiedName() : CommonClassNames.JAVA_LANG_THROWABLE;
String threadName = null;
if (event instanceof ExceptionEvent) {
ExceptionEvent exceptionEvent = (ExceptionEvent) event;
try {
exceptionName = exceptionEvent.exception().type().name();
threadName = exceptionEvent.thread().name();
} catch (Exception ignore) {
}
}
final Location location = event.location();
final String locationQName = DebuggerUtilsEx.getLocationMethodQName(location);
String locationFileName;
try {
locationFileName = location.sourceName();
} catch (AbsentInformationException e) {
locationFileName = "";
}
final int locationLine = Math.max(0, location.lineNumber());
if (threadName != null) {
return DebuggerBundle.message("exception.breakpoint.console.message.with.thread.info", exceptionName, threadName, locationQName, locationFileName, locationLine);
} else {
return DebuggerBundle.message("exception.breakpoint.console.message", exceptionName, locationQName, locationFileName, locationLine);
}
}
use of com.sun.jdi.event.ExceptionEvent in project jdk8u_jdk by JetBrains.
the class OomDebugTest method runTests.
@Override
protected void runTests() throws Exception {
try {
addListener(new TargetAdapter() {
@Override
public void exceptionThrown(ExceptionEvent event) {
String name = event.exception().referenceType().name();
System.err.println("DEBUG: Exception thrown in debuggee was: " + name);
}
});
/*
* Get to the top of entry()
* to determine targetClass and mainThread
*/
BreakpointEvent bpe = startTo("OomDebugTestTarget", "entry", "()V");
targetClass = bpe.location().declaringType();
mainThread = bpe.thread();
StackFrame frame = mainThread.frame(0);
thisObject = frame.thisObject();
java.lang.reflect.Method m = findTestMethod();
m.invoke(this);
} catch (NoSuchMethodException e) {
e.printStackTrace();
failure();
} catch (SecurityException e) {
e.printStackTrace();
failure();
}
/*
* resume the target, listening for events
*/
listenUntilVMDisconnect();
}
Aggregations