我正在尝试以编程方式在我的 Eclipse 插件中设置断点。似乎工作正常;标记被添加到编辑器侧边栏,断点条目也被添加到断点视图。但是当我调试程序时,虚拟机并没有在断点处挂起。此外,如果我在调用
getNormalFlowFunction
之前暂停 VM,然后尝试进入
方法,VM突然恢复运行,直到程序结束。不幸的是,没有错误消息。
我假设我的参数有问题,但从我发现的文档和示例代码中,我无法判断出了什么问题。有什么想法吗?
这是我设置断点的方式
IJavaMethodBreakpoint breakpoint = JDIDebugModel.createMethodBreakpoint(resource, className, methodName, methodSignature, entry, exit, nativeOnly, lineNumber, charStart, charEnd, hitCount, register, attrs);
我使用这些参数值:
resource: L/code/src/code/Main.java
class: Main
method: getNormalFlowFunction
signature: (QString;)QString;
resource: L/code/src/code/Main.java
entry: true
exit: false
nativeOnly: false
line: 12
charStart: 248
charEnd: 405
hit count: 0
register: true
attrs: {}
目标类看起来像这样:
package code;
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Bla");
String outSet = getNormalFlowFunction("Hallo");
System.out.println(outSet);
anotherMethod();
}
public static String getNormalFlowFunction(String inSet) {
System.out.println("getNormalFlowFunction");
String outSet = inSet + inSet;
return outSet;
}
public static void anotherMethod() {
System.out.println("Another method");
}
}
编辑: 我还注意到,当我在启动调试器之前手动设置断点时,手动设置的断点会得到一个小复选标记,但我以编程方式设置的断点却没有。
事实证明,我的参数有几个问题。我不得不调试到 JDT 中以找出参数必须是什么样子
这是更新的参数列表:
resource: L/code/src/code/Main.java
class: code.Main
method: getNormalFlowFunction
signature: (Ljava/lang/String;)Ljava/lang/String;
resource: L/code/src/code/Main.java
entry: true
exit: true
nativeOnly: false
line: 12
charStart: 269
charEnd: 290
hit count: 0
register: true
attrs: null