com.sun.jdi.Location Java Examples
The following examples show how to use
com.sun.jdi.Location.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SourceMapper.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #2
Source File: SourceMapper.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #3
Source File: SourceMapper.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #4
Source File: GetObjectLockCount.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void addBreakpoint(VirtualMachine vm, ReferenceType refType) { Location breakpointLocation = null; List<Location> locs; try { locs = refType.allLineLocations(); for (Location loc: locs) { if (loc.method().name().equals(METHOD_NAME)) { breakpointLocation = loc; break; } } } catch (AbsentInformationException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (breakpointLocation != null) { EventRequestManager evtReqMgr = vm.eventRequestManager(); BreakpointRequest bReq = evtReqMgr.createBreakpointRequest(breakpointLocation); bReq.setSuspendPolicy(BreakpointRequest.SUSPEND_ALL); bReq.enable(); } }
Example #5
Source File: StepRequestHandler.java From java-debug with Eclipse Public License 1.0 | 6 votes |
/** * Check if the current top stack is same as the original top stack. * * @throws IncompatibleThreadStateException * if the thread is not suspended in the target VM. */ private boolean shouldDoExtraStepInto(int originalStackDepth, Location originalLocation, int currentStackDepth, Location currentLocation) throws IncompatibleThreadStateException { if (originalStackDepth != currentStackDepth) { return false; } if (originalLocation == null) { return false; } Method originalMethod = originalLocation.method(); Method currentMethod = currentLocation.method(); if (!originalMethod.equals(currentMethod)) { return false; } if (originalLocation.lineNumber() != currentLocation.lineNumber()) { return false; } return true; }
Example #6
Source File: SourceMapper.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #7
Source File: StackTraceRequestHandler.java From java-debug with Eclipse Public License 1.0 | 6 votes |
private Types.StackFrame convertDebuggerStackFrameToClient(StackFrame stackFrame, int frameId, IDebugAdapterContext context) throws URISyntaxException, AbsentInformationException { Location location = stackFrame.location(); Method method = location.method(); Types.Source clientSource = this.convertDebuggerSourceToClient(location, context); String methodName = formatMethodName(method, true, true); int lineNumber = AdapterUtils.convertLineNumber(location.lineNumber(), context.isDebuggerLinesStartAt1(), context.isClientLinesStartAt1()); // Line number returns -1 if the information is not available; specifically, always returns -1 for native methods. if (lineNumber < 0) { if (method.isNative()) { // For native method, display a tip text "native method" in the Call Stack View. methodName += "[native method]"; } else { // For other unavailable method, such as lambda expression's built-in methods run/accept/apply, // display "Unknown Source" in the Call Stack View. clientSource = null; } } return new Types.StackFrame(frameId, methodName, clientSource, lineNumber, context.isClientColumnsStartAt1() ? 1 : 0); }
Example #8
Source File: StackTraceRequestHandler.java From java-debug with Eclipse Public License 1.0 | 6 votes |
private Types.Source convertDebuggerSourceToClient(Location location, IDebugAdapterContext context) throws URISyntaxException { final String fullyQualifiedName = location.declaringType().name(); String sourceName = ""; String relativeSourcePath = ""; try { // When the .class file doesn't contain source information in meta data, // invoking Location#sourceName() would throw AbsentInformationException. sourceName = location.sourceName(); relativeSourcePath = location.sourcePath(); } catch (AbsentInformationException e) { String enclosingType = AdapterUtils.parseEnclosingType(fullyQualifiedName); sourceName = enclosingType.substring(enclosingType.lastIndexOf('.') + 1) + ".java"; relativeSourcePath = enclosingType.replace('.', File.separatorChar) + ".java"; } return convertDebuggerSourceToClient(fullyQualifiedName, sourceName, relativeSourcePath, context); }
Example #9
Source File: JPDAStepImpl.java From netbeans with Apache License 2.0 | 6 votes |
/** * Test whether the method is considered to be synthetic * @param m The method * @param loc The current location in that method * @return 0 when not synthetic * positive when suggested step depth is returned * negative when is synthetic and no further step depth is suggested. */ public static int isSyntheticMethod(Method m, Location loc) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper { String name = TypeComponentWrapper.name(m); if (name.startsWith("lambda$")) { // NOI18N int lineNumber = LocationWrapper.lineNumber(loc); if (lineNumber == 1) { // We're in the initialization of the Lambda. We need to step over it. return StepRequest.STEP_OVER; } return 0; // Do not treat Lambda methods as synthetic, because they contain user code. } else { // Do check the class for being Lambda synthetic class: ReferenceType declaringType = LocationWrapper.declaringType(loc); try { String className = ReferenceTypeWrapper.name(declaringType); if (className.contains("$$Lambda$")) { // NOI18N // Lambda synthetic class return -1; } } catch (ObjectCollectedExceptionWrapper ex) { } } return TypeComponentWrapper.isSynthetic(m) ? -1 : 0; }
Example #10
Source File: JdtUtils.java From java-debug with Eclipse Public License 1.0 | 6 votes |
/** * Given a stack frame, find the target java project that the associated source file belongs to. * * @param stackFrame * the stack frame. * @param containers * the source container list. * @return the java project. */ public static IJavaProject findProject(StackFrame stackFrame, ISourceContainer[] containers) { Location location = stackFrame.location(); try { Object sourceElement = findSourceElement(location.sourcePath(), containers); if (sourceElement instanceof IResource) { return JavaCore.create(((IResource) sourceElement).getProject()); } else if (sourceElement instanceof IClassFile) { IJavaProject javaProject = ((IClassFile) sourceElement).getJavaProject(); if (javaProject != null) { return javaProject; } } } catch (AbsentInformationException e) { // When the compiled .class file doesn't contain debug source information, return null. } return null; }
Example #11
Source File: SourceMapper.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #12
Source File: SourceMapper.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #13
Source File: SourceMapper.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #14
Source File: SourceMapper.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #15
Source File: JPDAMethodChooserUtils.java From netbeans with Apache License 2.0 | 6 votes |
public static void doStepInto(final JPDADebuggerImpl debugger, final EditorContext.Operation operation, final Location location, final ExpressionPool.Interval expressionLines) { final String name = operation.getMethodName(); final boolean isNative = operation.isNative(); final String methodClassType = operation.getMethodClassType(); debugger.getRequestProcessor().post(new Runnable() { @Override public void run() { RunIntoMethodActionSupport.doAction(debugger, name, methodClassType, isNative, location, expressionLines, true, MethodEntry.SELECTED); } }); }
Example #16
Source File: SourceMapper.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #17
Source File: JPDAThreadImpl.java From netbeans with Apache License 2.0 | 6 votes |
private void submitCheckForMonitorEntered(ObjectReference waitingMonitor) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, IllegalThreadStateExceptionWrapper { try { ThreadReferenceWrapper.suspend(threadReference); logger.fine("submitCheckForMonitorEntered(): suspending "+threadName); ObjectReference monitor = ThreadReferenceWrapper.currentContendedMonitor(threadReference); if (monitor == null) return ; Location loc = StackFrameWrapper.location(ThreadReferenceWrapper.frame(threadReference, 0)); loc = MethodWrapper.locationOfCodeIndex(LocationWrapper.method(loc), LocationWrapper.codeIndex(loc) + 1); if (loc == null) return; BreakpointRequest br = EventRequestManagerWrapper.createBreakpointRequest( VirtualMachineWrapper.eventRequestManager(MirrorWrapper.virtualMachine(threadReference)), loc); BreakpointRequestWrapper.addThreadFilter(br, threadReference); submitMonitorEnteredRequest(br); } catch (IncompatibleThreadStateException itex) { Exceptions.printStackTrace(itex); } catch (InvalidStackFrameExceptionWrapper isex) { Exceptions.printStackTrace(isex); } finally { logger.fine("submitCheckForMonitorEntered(): resuming "+threadName); ThreadReferenceWrapper.resume(threadReference); } }
Example #18
Source File: SourceMapper.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #19
Source File: DynamothCollector.java From astor with GNU General Public License v2.0 | 6 votes |
private void processClassPrepareEvent() throws AbsentInformationException { EventRequestManager erm = vm.eventRequestManager(); List<ReferenceType> referenceTypes = vm.classesByName(this.location.getContainingClassName()); // List listOfLocations = // referenceTypes.get(0).locationsOfLine(this.location.getLineNumber()); int loc = this.location.getLineNumber(); List listOfLocations = null; do { listOfLocations = referenceTypes.get(0).locationsOfLine(loc); loc--; } while (loc > 0 && listOfLocations.isEmpty()); if (listOfLocations.size() == 0) { throw new RuntimeException("Buggy class not found " + this.location); } com.sun.jdi.Location jdiLocation = (com.sun.jdi.Location) listOfLocations.get(0); this.buggyMethod = jdiLocation.method().name(); breakpointSuspicious = erm.createBreakpointRequest(jdiLocation); breakpointSuspicious.setEnabled(true); initSpoon(); this.initExecutionTime = System.currentTimeMillis(); }
Example #20
Source File: SourceMapper.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #21
Source File: SourceMapper.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #22
Source File: SourceMapper.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Return a File cooresponding to the source of this location. * Return null if not available. */ File sourceFile(Location loc) { try { String filename = loc.sourceName(); String refName = loc.declaringType().name(); int iDot = refName.lastIndexOf('.'); String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : ""; String full = pkgName.replace('.', File.separatorChar) + filename; for (int i= 0; i < dirs.length; ++i) { File path = new File(dirs[i], full); if (path.exists()) { return path; } } return null; } catch (AbsentInformationException e) { return null; } }
Example #23
Source File: Breakpoint.java From java-debug with Eclipse Public License 1.0 | 5 votes |
private static List<Location> collectLocations(List<ReferenceType> refTypes, int lineNumber, boolean includeNestedTypes) { List<Location> locations = new ArrayList<>(); try { refTypes.forEach(refType -> { List<Location> newLocations = collectLocations(refType, lineNumber); if (!newLocations.isEmpty()) { locations.addAll(newLocations); } else if (includeNestedTypes) { // ReferenceType.nestedTypes() will invoke vm.allClasses() to list all loaded classes, // should avoid using nestedTypes for performance. for (ReferenceType nestedType : refType.nestedTypes()) { List<Location> nestedLocations = collectLocations(nestedType, lineNumber); if (!nestedLocations.isEmpty()) { locations.addAll(nestedLocations); break; } } } }); } catch (VMDisconnectedException ex) { // collect locations operation may be executing while JVM is terminating, thus the VMDisconnectedException may be // possible, in case of VMDisconnectedException, this method will return an empty array which turns out a valid // response in vscode, causing no error log in trace. } return locations; }
Example #24
Source File: SourceMapper.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Return a BufferedReader cooresponding to the source * of this location. * Return null if not available. * Note: returned reader must be closed. */ BufferedReader sourceReader(Location loc) { File sourceFile = sourceFile(loc); if (sourceFile == null) { return null; } try { return new BufferedReader(new FileReader(sourceFile)); } catch(IOException exc) { } return null; }
Example #25
Source File: JDIExampleDebugger.java From tutorials with MIT License | 5 votes |
/** * Sets the break points at the line numbers mentioned in breakPointLines array * @param vm * @param event * @throws AbsentInformationException */ public void setBreakPoints(VirtualMachine vm, ClassPrepareEvent event) throws AbsentInformationException { ClassType classType = (ClassType) event.referenceType(); for(int lineNumber: breakPointLines) { Location location = classType.locationsOfLine(lineNumber).get(0); BreakpointRequest bpReq = vm.eventRequestManager().createBreakpointRequest(location); bpReq.enable(); } }
Example #26
Source File: StepRequestHandler.java From java-debug with Eclipse Public License 1.0 | 5 votes |
/** * Return true if the StepEvent's location is a Method that the user has indicated to filter. * * @throws IncompatibleThreadStateException * if the thread is not suspended in the target VM. */ private boolean shouldFilterLocation(Location originalLocation, Location currentLocation, IDebugAdapterContext context) throws IncompatibleThreadStateException { if (originalLocation == null || currentLocation == null) { return false; } return !shouldFilterMethod(originalLocation.method(), context) && shouldFilterMethod(currentLocation.method(), context); }
Example #27
Source File: SourceMapper.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Return a BufferedReader cooresponding to the source * of this location. * Return null if not available. * Note: returned reader must be closed. */ BufferedReader sourceReader(Location loc) { File sourceFile = sourceFile(loc); if (sourceFile == null) { return null; } try { return new BufferedReader(new FileReader(sourceFile)); } catch(IOException exc) { } return null; }
Example #28
Source File: SourceMapper.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Return a BufferedReader cooresponding to the source * of this location. * Return null if not available. * Note: returned reader must be closed. */ BufferedReader sourceReader(Location loc) { File sourceFile = sourceFile(loc); if (sourceFile == null) { return null; } try { return new BufferedReader(new FileReader(sourceFile)); } catch(IOException exc) { } return null; }
Example #29
Source File: SourceMapper.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Return a BufferedReader cooresponding to the source * of this location. * Return null if not available. * Note: returned reader must be closed. */ BufferedReader sourceReader(Location loc) { File sourceFile = sourceFile(loc); if (sourceFile == null) { return null; } try { return new BufferedReader(new FileReader(sourceFile)); } catch(IOException exc) { } return null; }
Example #30
Source File: SourceMapper.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Return a BufferedReader cooresponding to the source * of this location. * Return null if not available. * Note: returned reader must be closed. */ BufferedReader sourceReader(Location loc) { File sourceFile = sourceFile(loc); if (sourceFile == null) { return null; } try { return new BufferedReader(new FileReader(sourceFile)); } catch(IOException exc) { } return null; }