diff --git a/org.ntlab.reverseDebugger/META-INF/MANIFEST.MF b/org.ntlab.reverseDebugger/META-INF/MANIFEST.MF index b3d7708..6ada18c 100644 --- a/org.ntlab.reverseDebugger/META-INF/MANIFEST.MF +++ b/org.ntlab.reverseDebugger/META-INF/MANIFEST.MF @@ -10,6 +10,8 @@ org.eclipse.jdt.debug, org.eclipse.jdt.core;bundle-version="3.10.2", org.eclipse.jdt.ui;bundle-version="3.10.2", - org.ntlab.traceAnalysisPlatform;bundle-version="1.0.0" + org.ntlab.traceAnalysisPlatform;bundle-version="1.0.0", + org.eclipse.ui.editors;bundle-version="3.11.100", + org.eclipse.jface.text;bundle-version="3.13.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackView.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackView.java index 1fc480e..bac8744 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackView.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackView.java @@ -46,10 +46,11 @@ if (element instanceof TreeNode) { Object value = ((TreeNode)element).getValue(); if (value instanceof CallStackModel) { - JDIInstanceMethodCaller methodExecution = ((CallStackModel)value).getMethodCaller(); + CallStackModel callStackModel = (CallStackModel)value; + JDIInstanceMethodCaller methodExecution = callStackModel.getMethodCaller(); SeedAliasView.createSeedAliasesByMethodExecution(methodExecution); SeedAliasView.refresh(); - javaEditorOperator.openSrcFileOfMethodExecution(methodExecution); + javaEditorOperator.openSrcFileOfMethodExecution(methodExecution, callStackModel.getCallLineNo()); } } } @@ -93,7 +94,7 @@ public static void refresh() { if (callStackModels.getCallStackModels().isEmpty()) { - JDIInstanceMethodCaller currentMe = SeedAliasView.getDebuggerStopMethodExecution(); + JDIInstanceMethodCaller currentMe = SeedAliasView.getDebuggingMethodExecution(); callStackModels.updateByDebuggerStopMethodExecution(currentMe); } TreeNode[] nodes = callStackModels.getCallStackModelsTreeNodes(); diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java index 90e695c..682f842 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java @@ -14,12 +14,20 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.ui.JavaUI; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.texteditor.IDocumentProvider; +import org.eclipse.ui.texteditor.ITextEditor; import org.ntlab.onlineAccessor.JDIInstanceMethodCaller; import com.sun.jdi.ClassNotLoadedException; import com.sun.jdi.IncompatibleThreadStateException; +import com.sun.jdi.IntegerValue; import com.sun.jdi.InvalidTypeException; import com.sun.jdi.InvocationException; import com.sun.jdi.ObjectReference; @@ -33,7 +41,8 @@ try { ObjectReference methodExecution = (ObjectReference)alias.callInstanceMethod("getMethodExecution"); JDIInstanceMethodCaller meCaller = new JDIInstanceMethodCaller(alias.getVm(), alias.getThread(), methodExecution); - openSrcFileOfMethodExecution(meCaller); + int lineNo = ((IntegerValue)alias.callInstanceMethod("getLineNo")).value(); + openSrcFileOfMethodExecution(meCaller, lineNo); } catch (InvalidTypeException | ClassNotLoadedException | InvocationException | IncompatibleThreadStateException e) { e.printStackTrace(); @@ -44,16 +53,18 @@ * �����œn����meCaller���ɂ���methodExecution����`����Ă���N���X�̃\�[�X�R�[�h��Ώ�Eclipse�̃G�f�B�^�ŊJ������ * * @param meCaller + * @param highlightLineNo */ - public void openSrcFileOfMethodExecution(JDIInstanceMethodCaller meCaller) { + public void openSrcFileOfMethodExecution(JDIInstanceMethodCaller meCaller, int highlightLineNo) { try { IType type = findIType(meCaller); if (type != null) { IMethod method = findIMethod(meCaller, type); if (method != null) { openSrcFileOfIMethod(type, method); + highlight(highlightLineNo); } - } + } } catch (InvalidTypeException | ClassNotLoadedException | InvocationException | IncompatibleThreadStateException e) { e.printStackTrace(); @@ -61,6 +72,27 @@ } /** + * ���݃G�f�B�^�ŊJ����Ă���t�@�C���̎w�肵���s�Ƀn�C���C�g�������� + * @param lineNo �n�C���C�g��������s�� + */ + public void highlight(int lineNo) { + if (lineNo < 1) return; + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IEditorPart editorPart = window.getActivePage().getActiveEditor(); + if (editorPart instanceof ITextEditor) { + ITextEditor editor = (ITextEditor)editorPart; + IDocumentProvider provider = editor.getDocumentProvider(); + IDocument document = provider.getDocument(editor.getEditorInput()); + try { + editor.selectAndReveal(document.getLineOffset(lineNo - 1), document.getLineLength(lineNo - 1)); + } catch (BadLocationException e) { + e.printStackTrace(); + } + } + } + + /** * �����œn����IType��IMethod�ɑΉ�����\�[�X�R�[�h��Ώ�Eclipse�̃G�f�B�^�ŊJ������ * * @param type diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliasView.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliasView.java index 88c879b..d78affe 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliasView.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliasView.java @@ -146,8 +146,8 @@ getSite().registerContextMenu(menuMgr, viewer); } - public static JDIInstanceMethodCaller getDebuggerStopMethodExecution() { - return seedAliases.getDebuggerStopMethodExecution(); + public static JDIInstanceMethodCaller getDebuggingMethodExecution() { + return seedAliases.getDebuggingMethodExecution(); } public static void createSeedAliasesByAlias(JDIInstanceMethodCaller alias) { @@ -163,9 +163,11 @@ public static void refresh() { if (seedAliases.getSeedAliases().isEmpty()) { seedAliases.initSeedAliases(); - javaEditorOperator.openSrcFileOfMethodExecution(seedAliases.getDebuggerStopMethodExecution()); + JDIInstanceMethodCaller debuggingMethodExecution = seedAliases.getDebuggingMethodExecution(); + int debuggingLineNo = seedAliases.getDebuggingLineNo(); + javaEditorOperator.openSrcFileOfMethodExecution(debuggingMethodExecution, debuggingLineNo); CallStackView.reset(); - VariableView.updateVariablesByMethodExecution(seedAliases.getDebuggerStopMethodExecution()); + VariableView.updateVariablesByMethodExecution(debuggingMethodExecution); } viewer.refresh(); } diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java index a775d34..31bb379 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java @@ -24,7 +24,7 @@ @SuppressWarnings("restriction") public class SeedAliases { - private JDIInstanceMethodCaller debuggerStopMethodExecution = null; + private JDIInstanceMethodCaller debuggingMethodExecution = null; private List seedAliases = new ArrayList<>(); private static final String TRACER = "org.ntlab.traceAnalysisPlatform.tracer.trace"; @@ -32,8 +32,17 @@ initSeedAliases(); } - public JDIInstanceMethodCaller getDebuggerStopMethodExecution() { - return debuggerStopMethodExecution; + public JDIInstanceMethodCaller getDebuggingMethodExecution() { + return debuggingMethodExecution; + } + + public int getDebuggingLineNo() { + try { + ThreadReference thread = debuggingMethodExecution.getThread(); + return thread.frame(0).location().lineNumber(); + } catch (IncompatibleThreadStateException e) { + throw new RuntimeException(e); + } } public List getSeedAliases() { @@ -54,8 +63,7 @@ createSeedAliases(vm, thread); } } - } catch (NotExecutedException | NotSuspendedException - | NotDebuggedException e) { + } catch (NotExecutedException | NotSuspendedException | NotDebuggedException e) { e.printStackTrace(); } } @@ -76,9 +84,10 @@ // threadId�ɑΉ�����ThreadInstance���擾 ObjectReference threadInstance = (ObjectReference)mc.callStaticMethod(TRACER, "TraceJSON", "getThreadInstance", threadId); Value methodExecution = mc.changeReceiver(threadInstance).callInstanceMethod("getCurrentMethodExecution"); - debuggerStopMethodExecution = new JDIInstanceMethodCaller(vm, thread, (ObjectReference)methodExecution); + debuggingMethodExecution = new JDIInstanceMethodCaller(vm, thread, (ObjectReference)methodExecution); findAllSeedAlias(vm, thread, methodExecution); - } catch (InvalidTypeException | ClassNotLoadedException | InvocationException | IncompatibleThreadStateException e) { + } catch (InvalidTypeException | ClassNotLoadedException + | InvocationException | IncompatibleThreadStateException e) { e.printStackTrace(); } } diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/VariableView.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/VariableView.java index 8b35044..0c45893 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/VariableView.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/VariableView.java @@ -43,7 +43,7 @@ } viewer.setContentProvider(new TreeNodeContentProvider()); viewer.setLabelProvider(new VariableLabelProvider()); - JDIInstanceMethodCaller methodExecution = SeedAliasView.getDebuggerStopMethodExecution(); + JDIInstanceMethodCaller methodExecution = SeedAliasView.getDebuggingMethodExecution(); if (methodExecution != null) { variables.getAllObjectDataByMethodExecution(methodExecution); viewer.setInput(variables.getVariablesTreeNodes());