1 22 23 package org.aspectj.debugger.request; 24 25 import org.aspectj.debugger.base.*; 26 27 import com.sun.jdi.*; 28 import com.sun.jdi.request.*; 29 import com.sun.jdi.event.*; 30 import org.aspectj.tools.ide.SourceLine; 31 import java.util.*; 32 33 import org.aspectj.util.LineNumberTableMapper; 34 import java.io.File ; 35 36 44 45 public abstract class ClassLineBreakpointRequestAction extends ClassBreakpointRequestAction { 46 47 private int line; 48 49 ClassLineBreakpointRequestAction(Debugger debugger, String className, int line) { 50 super(debugger, className); 51 System.err.println(">> breakpoint request, class: " + className + ", line: " + line); 52 this.line = line; 53 } 54 55 public String getProto() { 56 SourceLine sl = ajdbg().getSourceLineFromClass(getClassName(), getLine()); 57 int newLine = line; 58 if (sl == null) { 59 System.err.println("sl is null for " + getClassName() + ":" + line); 60 } else { 61 newLine = sl.line; 62 } 63 return getClassName() + ":" + newLine; 64 } 65 66 public String getErrorMessage() { 67 return "No code at line " + line + " in " + getClassName(); 68 } 69 70 Location findLocation() 71 throws NoVMException, 72 MultipleLocationsException, 73 UnableToSetRequestException { 74 75 System.err.println(">>> resolving class-line breakpoint, class: " + className); 76 77 80 81 83 try { 84 85 Iterator it = vm().classesByName(className).iterator(); 86 ReferenceType refType = null; 87 while (it.hasNext()) { 88 refType = (ReferenceType) it.next(); System.err.println(">> refType: " + refType.sourceName()); 90 } 91 if (refType != null) { 92 String attrib = refType.sourceName(); 93 String pkg = className.substring(0, className.lastIndexOf('.')).replace('.', '/'); 94 String srcPath = org.aspectj.debugger.base.AJDebugger.INSTANCE.getSourcePath(); 95 File srcRoot = new File (srcPath); 96 97 System.err.println(">> findMethod attrib: " + attrib + ", pkg: " + pkg + ", src: " + srcPath); 98 99 LineNumberTableMapper mapper = new LineNumberTableMapper(attrib, pkg, srcRoot); 100 System.err.println(">>> mapper: " + mapper.toString()); 101 System.err.println(">> mapped: " + mapper.getCorrespondingFile(line).getPath() + " : " + mapper.getCorrespondingLineNumber(line)); 102 103 Iterator linesIter = refType.allLineLocations().iterator(); 104 while (linesIter.hasNext()) { 108 Location loc = (Location)linesIter.next(); 109 if (loc.lineNumber() == mapper.getCorrespondingLineNumber(line)) { 110 return loc; 111 } 112 } 113 } else { 119 throw new AbsentInformationException(); 120 } 121 } catch (AbsentInformationException aie) { 122 System.err.println("> ERROR: in class line breakpoint request"); 123 aie.printStackTrace(); 124 } 125 return null; 126 } 145 146 public int getLine() { 147 return line; 148 } 149 150 public boolean equals(Object other) { 151 if (other == null || !(other instanceof ClassLineBreakpointRequestAction)) { 152 return super.equals(other); 153 } 154 ClassLineBreakpointRequestAction ra = (ClassLineBreakpointRequestAction) other; 155 return (getClassName().equals(ra.getClassName()) && 156 getLine() == ra.getLine()); 157 } 158 } 159 | Popular Tags |