diff --git a/src/org/ntlab/traceDebugger/CallStackView.java b/src/org/ntlab/traceDebugger/CallStackView.java index 7379fc1..c9cddc2 100644 --- a/src/org/ntlab/traceDebugger/CallStackView.java +++ b/src/org/ntlab/traceDebugger/CallStackView.java @@ -32,7 +32,7 @@ public class CallStackView extends ViewPart { private TreeViewer viewer; - private IAction refreshAction; +// private IAction refreshAction; private IAction deltaAction; private CallStackModel selectionCallStackModel; private CallStackModels callStackModels = new CallStackModels(); @@ -69,8 +69,9 @@ CallTreeView callTreeView = (CallTreeView)TraceDebuggerPlugin.getActiveView(CallTreeView.ID); callTreeView.highlight(methodExecution); + TracePoint debuggingTp = DebuggingController.getInstance().getCurrentTp(); VariableView variableView = (VariableView)TraceDebuggerPlugin.getActiveView(VariableView.ID); - variableView.updateVariablesByTracePoint(tp, false); + variableView.updateVariablesByTracePoint(tp, false, debuggingTp); AbstractAnalyzer analyzer = TraceDebuggerPlugin.getAnalyzer(); if (analyzer instanceof DeltaExtractionAnalyzer) { DeltaMarkerView deltaMarkerView = (DeltaMarkerView)TraceDebuggerPlugin.getActiveView(DeltaMarkerView.ID); @@ -103,15 +104,15 @@ } private void createActions() { - refreshAction = new Action() { - @Override - public void run() { - refresh(); - } - }; - refreshAction.setText("refresh"); - refreshAction.setToolTipText("refresh"); - refreshAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED)); +// refreshAction = new Action() { +// @Override +// public void run() { +// refresh(); +// } +// }; +// refreshAction.setText("refresh"); +// refreshAction.setToolTipText("refresh"); +// refreshAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED)); deltaAction = new Action() { @Override @@ -136,12 +137,12 @@ private void createToolBar() { IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); - mgr.add(refreshAction); +// mgr.add(refreshAction); } private void createMenuBar() { IMenuManager mgr = getViewSite().getActionBars().getMenuManager(); - mgr.add(refreshAction); +// mgr.add(refreshAction); } private void createPopupMenu() { @@ -175,6 +176,7 @@ public void updateByTracePoint(TracePoint tp) { callStackModels.updateByTracePoint(tp); refresh(); + selectionCallStackModel = null; } public void refresh() { @@ -193,6 +195,21 @@ refresh(); } + public CallStackModel getSelectionCallStackModel() { + return selectionCallStackModel; + } + + public boolean isSelectionOnTop() { + if (selectionCallStackModel == null) return false; + TreeNode[] nodes = callStackModels.getAllCallStacksTree(); + if (nodes == null || nodes[0] == null) return false; + TreeNode[] children = nodes[0].getChildren(); + Object obj = children[0].getValue(); + if (!(obj instanceof CallStackModel)) return false; + CallStackModel topCallStackModel = (CallStackModel)obj; + return topCallStackModel.equals(selectionCallStackModel); + } + public Map> getCallStackModels() { return callStackModels.getAllCallStacks(); } diff --git a/src/org/ntlab/traceDebugger/DebuggingController.java b/src/org/ntlab/traceDebugger/DebuggingController.java index 648b70f..723e2cf 100644 --- a/src/org/ntlab/traceDebugger/DebuggingController.java +++ b/src/org/ntlab/traceDebugger/DebuggingController.java @@ -2,8 +2,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.Set; - import org.eclipse.core.filebuffers.FileBuffers; import org.eclipse.core.filebuffers.ITextFileBuffer; import org.eclipse.core.filebuffers.ITextFileBufferManager; @@ -20,7 +18,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewPart; import org.ntlab.traceAnalysisPlatform.tracer.trace.ArrayUpdate; import org.ntlab.traceAnalysisPlatform.tracer.trace.BlockEnter; import org.ntlab.traceAnalysisPlatform.tracer.trace.FieldUpdate; @@ -173,6 +170,10 @@ public boolean stepIntoAction() { if (!isRunning) return false; if (debuggingTp == null) return false; + TracePoint callStackTp = getTracePointSelectedOnCallStack(); + if (callStackTp != null && !(callStackTp.equals(debuggingTp))) { + debuggingTp = callStackTp; + } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); debuggingTp.stepFull(); @@ -191,6 +192,10 @@ public boolean stepOverAction() { if (!isRunning) return false; if (debuggingTp == null) return false; + TracePoint callStackTp = getTracePointSelectedOnCallStack(); + if (callStackTp != null && !(callStackTp.equals(debuggingTp))) { + debuggingTp = callStackTp; + } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); int currentLineNo = debuggingTp.getStatement().getLineNo(); @@ -232,6 +237,10 @@ public boolean stepReturnAction() { if (!isRunning) return false; if (debuggingTp == null) return false; + TracePoint callStackTp = getTracePointSelectedOnCallStack(); + if (callStackTp != null && !(callStackTp.equals(debuggingTp))) { + debuggingTp = callStackTp; + } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); while (debuggingTp.stepOver()); @@ -247,6 +256,10 @@ public boolean stepNextAction() { if (!isRunning) return false; if (debuggingTp == null) return false; + TracePoint callStackTp = getTracePointSelectedOnCallStack(); + if (callStackTp != null && !(callStackTp.equals(debuggingTp))) { + debuggingTp = callStackTp; + } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); TracePoint startTp = debuggingTp.duplicate(); @@ -297,6 +310,10 @@ public boolean stepBackIntoAction() { if (!isRunning) return false; if (debuggingTp == null) return false; + TracePoint callStackTp = getTracePointSelectedOnCallStack(); + if (callStackTp != null && !(callStackTp.equals(debuggingTp))) { + debuggingTp = callStackTp; + } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); debuggingTp.stepBackFull(); @@ -312,6 +329,10 @@ public boolean stepBackOverAction() { if (!isRunning) return false; if (debuggingTp == null) return false; + TracePoint callStackTp = getTracePointSelectedOnCallStack(); + if (callStackTp != null && !(callStackTp.equals(debuggingTp))) { + debuggingTp = callStackTp; + } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); int currentLineNo = debuggingTp.getStatement().getLineNo(); @@ -331,6 +352,10 @@ public boolean stepBackReturnAction() { if (!isRunning) return false; if (debuggingTp == null) return false; + TracePoint callStackTp = getTracePointSelectedOnCallStack(); + if (callStackTp != null && !(callStackTp.equals(debuggingTp))) { + debuggingTp = callStackTp; + } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); while (debuggingTp.stepBackOver()); @@ -436,5 +461,20 @@ e.printStackTrace(); } return currentLineMarker; - } + } + + private TracePoint getTracePointSelectedOnCallStack() { + CallStackView callStackView = (CallStackView)TraceDebuggerPlugin.getActiveView(CallStackView.ID); + CallStackModel callStackModel = callStackView.getSelectionCallStackModel(); + if (callStackModel != null) { + return callStackModel.getTracePoint(); + } + return null; +// if (!(callStackView.isSelectionOnTop())) { +// CallStackModel selectionCallStackModel = callStackView.getSelectionCallStackModel(); +// if (selectionCallStackModel != null) { +// debuggingTp = selectionCallStackModel.getTracePoint(); +// } +// } + } } diff --git a/src/org/ntlab/traceDebugger/VariableView.java b/src/org/ntlab/traceDebugger/VariableView.java index ac9683b..3220c87 100644 --- a/src/org/ntlab/traceDebugger/VariableView.java +++ b/src/org/ntlab/traceDebugger/VariableView.java @@ -301,11 +301,19 @@ } public void updateVariablesByTracePoint(TracePoint tp, boolean isReturned) { - updateVariablesByTracePoint(null, tp, isReturned); + updateVariablesByTracePoint(tp, isReturned, null); + } + + public void updateVariablesByTracePoint(TracePoint tp, boolean isReturned, TracePoint before) { + updateVariablesByTracePoint(null, tp, isReturned, before); + } + + public void updateVariablesByTracePoint(TracePoint from, TracePoint to, boolean isReturned) { + updateVariablesByTracePoint(from, to, isReturned, null); } - public void updateVariablesByTracePoint(TracePoint from, TracePoint to, boolean isReturned) { - variables.updateAllObjectDataByTracePoint(from, to, isReturned); + public void updateVariablesByTracePoint(TracePoint from, TracePoint to, boolean isReturned, TracePoint before) { + variables.updateAllObjectDataByTracePoint(from, to, isReturned, before); viewer.setInput(variables.getVariablesTreeNodesList()); } diff --git a/src/org/ntlab/traceDebugger/Variables.java b/src/org/ntlab/traceDebugger/Variables.java index f15c5e8..e8c3754 100644 --- a/src/org/ntlab/traceDebugger/Variables.java +++ b/src/org/ntlab/traceDebugger/Variables.java @@ -51,18 +51,18 @@ List statements = methodExecution.getStatements(); int lastOrder = statements.size() - 1; TracePoint tp = methodExecution.getTracePoint(lastOrder); - updateAllObjectData(null, tp, false); + updateAllObjectData(null, tp, false, null); } - public void updateAllObjectDataByTracePoint(TracePoint from, TracePoint to, boolean isReturned) { - updateAllObjectData(from, to, isReturned); + public void updateAllObjectDataByTracePoint(TracePoint from, TracePoint to, boolean isReturned, TracePoint before) { + updateAllObjectData(from, to, isReturned, before); } - private void updateAllObjectData(TracePoint from, TracePoint to, boolean isReturned) { + private void updateAllObjectData(TracePoint from, TracePoint to, boolean isReturned, TracePoint before) { resetData(); MethodExecution me = to.getMethodExecution(); - updateRootThisState(me, to, isReturned); - updateArgsState(me, to, isReturned); + updateRootThisState(me, to, isReturned, before); + updateArgsState(me, to, isReturned, before); for (int i = 0; i < roots.size(); i++) { Variable rootVariableData = roots.get(i); createVariablesTreeNodeList(null, rootTreeNodes, i, rootVariableData); @@ -70,17 +70,19 @@ createSpecialVariables(from, to, isReturned); } - private void updateRootThisState(MethodExecution methodExecution, TracePoint tp, boolean isReturned) { + private void updateRootThisState(MethodExecution methodExecution, TracePoint tp, boolean isReturned, TracePoint before) { String thisObjId = methodExecution.getThisObjId(); String thisClassName = methodExecution.getThisClassName(); - Variable variable = new Variable("this", null, null, thisClassName, thisObjId, tp, isReturned); + if (before == null) before = tp; + Variable variable = new Variable("this", null, null, thisClassName, thisObjId, before, isReturned); roots.add(variable); variable.createNextHierarchyState(); } - private void updateArgsState(MethodExecution methodExecution, TracePoint tp, boolean isReturned) { + private void updateArgsState(MethodExecution methodExecution, TracePoint tp, boolean isReturned, TracePoint before) { // methodExecution������arguments���擾(ArrayList)���A����arguments�̃T�C�Y���擾(int) List args = methodExecution.getArguments(); + if (before == null) before = tp; if (args.size() > 0) { IType type = JavaElementFinder.findIType(methodExecution); String methodSignature = methodExecution.getSignature(); @@ -91,7 +93,7 @@ ObjectReference arg = args.get(i); String argId = arg.getId(); String argType = arg.getActualType(); - Variable argData = new Variable(argName, null, null, argType, argId, tp, isReturned, VariableType.PARAMETER); + Variable argData = new Variable(argName, null, null, argType, argId, before, isReturned, VariableType.PARAMETER); argData.createNextHierarchyState(); roots.add(argData); }