use of com.sun.jdi.NativeMethodException in project che by eclipse.
the class JavaDebugger method addBreakpoint.
@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
final String className = findFQN(breakpoint);
final int lineNumber = breakpoint.getLocation().getLineNumber();
List<ReferenceType> classes = vm.classesByName(className);
// it may mean that class doesn't loaded by a target JVM yet
if (classes.isEmpty()) {
deferBreakpoint(breakpoint);
throw new DebuggerException("Class not loaded");
}
ReferenceType clazz = classes.get(0);
List<com.sun.jdi.Location> locations;
try {
locations = clazz.locationsOfLine(lineNumber);
} catch (AbsentInformationException | ClassNotPreparedException e) {
throw new DebuggerException(e.getMessage(), e);
}
if (locations.isEmpty()) {
throw new DebuggerException("Line " + lineNumber + " not found in class " + className);
}
com.sun.jdi.Location location = locations.get(0);
if (location.method() == null) {
// Line is out of method.
throw new DebuggerException("Invalid line " + lineNumber + " in class " + className);
}
// Ignore new breakpoint if already have breakpoint at the same location.
EventRequestManager requestManager = getEventManager();
for (BreakpointRequest breakpointRequest : requestManager.breakpointRequests()) {
if (location.equals(breakpointRequest.location())) {
LOG.debug("Breakpoint at {} already set", location);
return;
}
}
try {
EventRequest breakPointRequest = requestManager.createBreakpointRequest(location);
breakPointRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
String expression = breakpoint.getCondition();
if (!(expression == null || expression.isEmpty())) {
ExpressionParser parser = ExpressionParser.newInstance(expression);
breakPointRequest.putProperty("org.eclipse.che.ide.java.debug.condition.expression.parser", parser);
}
breakPointRequest.setEnabled(true);
} catch (NativeMethodException | IllegalThreadStateException | InvalidRequestStateException e) {
throw new DebuggerException(e.getMessage(), e);
}
debuggerCallback.onEvent(new BreakpointActivatedEventImpl(new BreakpointImpl(breakpoint.getLocation(), true, breakpoint.getCondition())));
LOG.debug("Add breakpoint: {}", location);
}
use of com.sun.jdi.NativeMethodException in project intellij-community by JetBrains.
the class PopFrameAction method actionPerformed.
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final JavaStackFrame stackFrame = getStackFrame(e);
if (stackFrame == null || stackFrame.getStackFrameProxy().isBottom()) {
return;
}
try {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
return;
}
debugProcess.getSession().setSteppingThrough(stackFrame.getStackFrameProxy().threadProxy());
if (evaluateFinallyBlocks(project, UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), stackFrame, new XDebuggerEvaluator.XEvaluationCallback() {
@Override
public void evaluated(@NotNull XValue result) {
popFrame(debugProcess, debuggerContext, stackFrame);
}
@Override
public void errorOccurred(@NotNull final String errorMessage) {
ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(project, DebuggerBundle.message("error.executing.finally", errorMessage), UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), Messages.getErrorIcon()));
}
}))
return;
popFrame(debugProcess, debuggerContext, stackFrame);
} catch (NativeMethodException e2) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.native.method.exception"), UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), Messages.getErrorIcon());
} catch (InvalidStackFrameException | VMDisconnectedException ignored) {
}
}
use of com.sun.jdi.NativeMethodException in project che by eclipse.
the class JdiStackFrameImpl method getLocalVariables.
@Override
public JdiLocalVariable[] getLocalVariables() throws DebuggerException {
if (localVariables == null) {
try {
List<LocalVariable> targetVariables = stackFrame.visibleVariables();
localVariables = new JdiLocalVariable[targetVariables.size()];
int i = 0;
for (LocalVariable var : targetVariables) {
localVariables[i++] = new JdiLocalVariableImpl(stackFrame, var);
}
} catch (AbsentInformationException e) {
throw new DebuggerAbsentInformationException(e.getMessage(), e);
} catch (InvalidStackFrameException | NativeMethodException e) {
throw new DebuggerException(e.getMessage(), e);
}
}
return localVariables;
}
use of com.sun.jdi.NativeMethodException in project che by eclipse.
the class Evaluator method getLocalVariable.
public ExpressionValue getLocalVariable(String text) {
ExpressionValue value = null;
try {
StackFrame frame = thread.frame(0);
LocalVariable var = frame.visibleVariableByName(text);
if (var != null) {
value = new LocalValue(thread, var);
}
} catch (IncompatibleThreadStateException | AbsentInformationException | InvalidStackFrameException | NativeMethodException e) {
throw new ExpressionException(e.getMessage(), e);
}
LOG.debug("GET local variable {} {} ", text, value);
return value;
}
Aggregations