use of com.sun.jdi.Location in project kotlin by JetBrains.
the class AbstractPositionManagerTest method assertBreakpointIsHandledCorrectly.
private static void assertBreakpointIsHandledCorrectly(Breakpoint breakpoint, PositionManager positionManager) throws NoDataException {
SourcePosition position = SourcePosition.createFromLine(breakpoint.file, breakpoint.lineNumber);
List<ReferenceType> classes = positionManager.getAllClasses(position);
assertNotNull(classes);
assertEquals(1, classes.size());
ReferenceType type = classes.get(0);
assertTrue("Type name " + type.name() + " doesn't match " + breakpoint.classNameRegexp + " for line " + (breakpoint.lineNumber + 1), type.name().matches(breakpoint.classNameRegexp));
// JDI names are of form "package.Class$InnerClass"
ReferenceType typeWithFqName = new MockReferenceType(type.name().replace('/', '.'));
Location location = new MockLocation(typeWithFqName, breakpoint.file.getName(), breakpoint.lineNumber + 1);
SourcePosition actualPosition = positionManager.getSourcePosition(location);
assertNotNull(actualPosition);
assertEquals(position.getFile(), actualPosition.getFile());
assertEquals(position.getLine(), actualPosition.getLine());
}
use of com.sun.jdi.Location 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.Location in project intellij-community by JetBrains.
the class ContextUtil method getSourcePosition.
@Nullable
public static SourcePosition getSourcePosition(@Nullable final StackFrameContext context) {
if (context == null) {
return null;
}
DebugProcessImpl debugProcess = (DebugProcessImpl) context.getDebugProcess();
if (debugProcess == null) {
return null;
}
final StackFrameProxy frameProxy = context.getFrameProxy();
if (frameProxy == null) {
return null;
}
Location location = null;
try {
location = frameProxy.location();
} catch (Throwable e) {
LOG.debug(e);
}
if (location == null) {
return null;
}
return debugProcess.getPositionManager().getSourcePosition(location);
}
use of com.sun.jdi.Location in project intellij-community by JetBrains.
the class NodeManagerImpl method getContextKeyForFrame.
@Nullable
public static String getContextKeyForFrame(final StackFrameProxyImpl frame) {
if (frame == null) {
return null;
}
try {
final Location location = frame.location();
final Method method = DebuggerUtilsEx.getMethod(location);
if (method == null) {
return null;
}
final ReferenceType referenceType = location.declaringType();
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
return builder.append(referenceType.signature()).append("#").append(method.name()).append(method.signature()).toString();
} finally {
StringBuilderSpinAllocator.dispose(builder);
}
} catch (EvaluateException ignored) {
} catch (InternalException ie) {
if (ie.errorCode() != 23) {
// INVALID_METHODID
throw ie;
}
}
return null;
}
use of com.sun.jdi.Location 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);
}
}
Aggregations