diff --git a/src/org/ntlab/traceDebugger/BreakPointView.java b/src/org/ntlab/traceDebugger/BreakPointView.java index e2e91e7..aa45fba 100644 --- a/src/org/ntlab/traceDebugger/BreakPointView.java +++ b/src/org/ntlab/traceDebugger/BreakPointView.java @@ -36,6 +36,7 @@ private IAction stepIntoAction; private IAction stepOverAction; private IAction stepReturnAction; + private IAction stepNextAction; private IAction resumeAction; private IAction stepBackIntoAction; private IAction stepBackOverAction; @@ -181,6 +182,15 @@ }; stepReturnAction.setText("Step Return"); stepReturnAction.setToolTipText("Step Return"); + + stepNextAction = new Action() { + @Override + public void run() { + debuggingController.stepNextAction(); + } + }; + stepNextAction.setText("Step Next"); + stepNextAction.setToolTipText("Step Next"); resumeAction = new Action() { @Override @@ -237,6 +247,7 @@ mgr.add(stepIntoAction); mgr.add(stepOverAction); mgr.add(stepReturnAction); + mgr.add(stepNextAction); mgr.add(stepBackIntoAction); mgr.add(stepBackOverAction); mgr.add(stepBackReturnAction); @@ -252,6 +263,7 @@ mgr.add(stepIntoAction); mgr.add(stepOverAction); mgr.add(stepReturnAction); + mgr.add(stepNextAction); mgr.add(stepBackIntoAction); mgr.add(stepBackOverAction); mgr.add(stepBackReturnAction); diff --git a/src/org/ntlab/traceDebugger/DebuggingController.java b/src/org/ntlab/traceDebugger/DebuggingController.java index 5c9f800..503b2a7 100644 --- a/src/org/ntlab/traceDebugger/DebuggingController.java +++ b/src/org/ntlab/traceDebugger/DebuggingController.java @@ -60,13 +60,14 @@ MessageDialog.openInformation(null, "Error", "Trace file was not found"); return false; } +// InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "void E.setC(C)", null); +// InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "void _arraySample.D.setC(_arraySample.C)", null); // InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "void Company.pay(Money,Person)", null); // InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "void worstCase.P.setM(worstCase.M)", null); // InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "public void org.jhotdraw.draw.DefaultDrawingView.addToSelection(org.jhotdraw.draw.Figure)", null); // InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "protected void org.tigris.gef.base.SelectionManager.addFig(org.tigris.gef.presentation.Fig)", null); - InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "public static org.tigris.gef.base.Selection org.tigris.gef.base.SelectionManager.makeSelectionFor(org.tigris.gef.presentation.Fig)", null); -// InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "void E.setC(C)", null); -// InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "void _arraySample.D.setC(_arraySample.C)", null); +// InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "public static org.tigris.gef.base.Selection org.tigris.gef.base.SelectionManager.makeSelectionFor(org.tigris.gef.presentation.Fig)", null); + InputDialog inputDialog = new InputDialog(null, "method signature dialog", "Input method signature", "public void org.argouml.uml.diagram.ui.ActionRemoveFromDiagram.actionPerformed(java.awt.event.ActionEvent)", null); if (inputDialog.open() != InputDialog.OK) return false; String methodSignature = inputDialog.getValue(); inputDialog = new InputDialog(null, "line No dialog", "Input line no", "", null); @@ -170,6 +171,24 @@ return true; } + public boolean stepNextAction() { + if (debuggingTp == null) return false; + TracePoint previousTp = debuggingTp; + debuggingTp = debuggingTp.duplicate(); + boolean isReturned = false; + debuggingTp.stepNext(); + if (debuggingTp.getStatement() instanceof BlockEnter) { + debuggingTp.stepFull(); + } + if (!debuggingTp.isValid()) { + terminateAction(); + MessageDialog.openInformation(null, "Terminate", "This trace is terminated"); + return false; + } + refresh(previousTp, debuggingTp, isReturned); + return true; + } + public boolean resumeAction() { if (debuggingTp == null) return false; long currentTime = debuggingTp.getStatement().getTimeStamp(); diff --git a/src/org/ntlab/traceDebugger/RadioButtonDialog.java b/src/org/ntlab/traceDebugger/RadioButtonDialog.java new file mode 100644 index 0000000..ca8059e --- /dev/null +++ b/src/org/ntlab/traceDebugger/RadioButtonDialog.java @@ -0,0 +1,55 @@ +package org.ntlab.traceDebugger; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +public class RadioButtonDialog extends Dialog { + private int selectedIndex = 0; + private String title; + private String[] texts; + + protected RadioButtonDialog(Shell parentShell, String title, String[] texts) { + super(parentShell); + this.title = title; + this.texts = texts; + } + + @Override + public void create() { + super.create(); + getShell().setText(title); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite)super.createDialogArea(parent); + Button[] buttons = new Button[texts.length]; + for (int i = 0; i < texts.length; i++) { + final int index = i; + buttons[i] = new Button(parent, SWT.RADIO); +// buttons[i].setLayoutData(new GridData(GridData.FILL_BOTH)); + buttons[i].setAlignment(SWT.CENTER); + buttons[i].setText(texts[i]); + buttons[i].addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + selectedIndex = index; + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + return composite; + } + + public String getValue() { + return texts[selectedIndex]; + } +} diff --git a/src/org/ntlab/traceDebugger/VariableView.java b/src/org/ntlab/traceDebugger/VariableView.java index 51c297c..ab720e4 100644 --- a/src/org/ntlab/traceDebugger/VariableView.java +++ b/src/org/ntlab/traceDebugger/VariableView.java @@ -149,7 +149,15 @@ deltaAction = new Action() { @Override public void run() { - delta(selectedVariable, !false); + if (selectedVariable.getVariableName().equals(Variables.RETURN_VARIABLE_NAME)) { + String[] texts = {"Caller to Callee", "This to Another"}; + RadioButtonDialog dialog = new RadioButtonDialog(null, "Which patterns?", texts); + if (dialog.open() != InputDialog.OK) return; + String selectionType = dialog.getValue(); + delta(selectedVariable, true, selectionType.startsWith("This")); + } else { + delta(selectedVariable, true, false); + } } }; deltaAction.setText("Extract Delta"); @@ -169,8 +177,8 @@ String valueId = selectedVariable.getId(); String valueType = selectedVariable.getClassName(); TracePoint tp = DebuggingController.getInstance().getCurrentTp(); - Variable variable = new Variable("tmp", containerType, containerId, valueType, valueId, tp, false); - delta(variable, true); + Variable variable = new Variable("tmp", containerType, containerId, valueType, valueId, tp, false); + delta(variable, true, false); } }; deltaActionForCollection.setText("Extract Delta for Collection"); @@ -208,7 +216,7 @@ viewer.refresh(); } - private void delta(Variable variable, boolean isCollection) { + private void delta(Variable variable, boolean isCollection, boolean isForThisToAnother) { AbstractAnalyzer analyzer = TraceDebuggerPlugin.getAnalyzer(); if (analyzer instanceof DeltaExtractionAnalyzer) { DeltaExtractionAnalyzer deltaAnalyzer = (DeltaExtractionAnalyzer)analyzer; @@ -218,7 +226,11 @@ // note: ����r���[�𕡐��J���e�X�g String subIdWithNewView = deltaAnalyzer.getNextDeltaMarkerSubId(); DeltaMarkerView newDeltaMarkerView = (DeltaMarkerView)workbenchPage.showView(DeltaMarkerView.ID, subIdWithNewView, IWorkbenchPage.VIEW_ACTIVATE); - deltaAnalyzer.extractDelta(variable, isCollection, newDeltaMarkerView, subIdWithNewView); + if (isForThisToAnother) { + deltaAnalyzer.extractDeltaForThisToAnother(variable, isCollection, newDeltaMarkerView, subIdWithNewView); + } else { + deltaAnalyzer.extractDelta(variable, isCollection, newDeltaMarkerView, subIdWithNewView); + } TracePoint coordinatorPoint = newDeltaMarkerView.getCoordinatorPoint(); TracePoint creationPoint = newDeltaMarkerView.getCreationPoint(); DebuggingController controller = DebuggingController.getInstance(); @@ -250,11 +262,6 @@ viewer.setInput(variables.getVariablesTreeNodes()); } -// public void updateVariablesByTracePoint(TracePoint tp, boolean isReturned) { -// variables.updateAllObjectDataByTracePoint(tp, isReturned); -// viewer.setInput(variables.getVariablesTreeNodes()); -// } - public void markAndExpandVariablesByDeltaMarkers(Map> markers) { List srcSideDeltaMarkers = markers.get(DeltaMarkerManager.SRC_SIDE_DELTA_MARKER); List dstSideDeltaMarkers = markers.get(DeltaMarkerManager.DST_SIDE_DELTA_MARKER); @@ -326,4 +333,4 @@ throw new RuntimeException(e); } } -} \ No newline at end of file +} diff --git a/src/org/ntlab/traceDebugger/Variables.java b/src/org/ntlab/traceDebugger/Variables.java index 613dbcc..b0c5bfd 100644 --- a/src/org/ntlab/traceDebugger/Variables.java +++ b/src/org/ntlab/traceDebugger/Variables.java @@ -18,6 +18,7 @@ public class Variables { private static final Variables theInstance = new Variables(); private List roots = new ArrayList<>(); + public static final String RETURN_VARIABLE_NAME = "return"; public static Variables getInstance() { return theInstance; @@ -85,7 +86,7 @@ String returnValueId = ref.getId(); String thisObjId = me.getThisObjId(); String thisClassName = me.getThisClassName(); - Variable variable = new Variable("Return", thisClassName, thisObjId, returnValueClassName, returnValueId, from, isReturned); + Variable variable = new Variable(RETURN_VARIABLE_NAME, thisClassName, thisObjId, returnValueClassName, returnValueId, from, isReturned); roots.add(variable); variable.createNextHierarchyState(); } diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java index ca75cad..fb65830 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java @@ -47,15 +47,15 @@ return extractedStructure; } - public void extractDelta(Variable variable, boolean isColection, DeltaMarkerView deltaMarkerView, String deltaMarkerViewSubId) { + public void extractDelta(Variable variable, boolean isCollection, DeltaMarkerView deltaMarkerView, String deltaMarkerViewSubId) { addDeltaMarkerView(deltaMarkerViewSubId, deltaMarkerView); String srcId = variable.getContainerId(); String srcClassName = variable.getContainerClassName(); String dstId = variable.getId(); String dstClassName = variable.getClassName(); - TracePoint before = variable.getBeforeTracePoint(); + TracePoint before = variable.getBeforeTracePoint(); Reference reference = new Reference(srcId, dstId, srcClassName, dstClassName); - reference.setCollection(isColection); + reference.setCollection(isCollection); // true�ɂ���ƃR���N�V�����ȊO���o�ł��Ȃ��Ȃ� // �f���^���o DeltaRelatedAliasCollector aliasCollector = new DeltaRelatedAliasCollector(srcId, dstId); @@ -69,6 +69,39 @@ mark(mgr, coordinator, aliasCollector, bottomPoint, reference); deltaMarkerView.update(); } + + public void extractDeltaForThisToAnother(Variable variable, boolean isCollection, DeltaMarkerView deltaMarkerView, String deltaMarkerViewSubId) { + addDeltaMarkerView(deltaMarkerViewSubId, deltaMarkerView); + TracePoint before = variable.getBeforeTracePoint(); + String srcId = before.getMethodExecution().getThisObjId(); + String srcClassName = before.getMethodExecution().getThisClassName(); + String dstId = variable.getId(); + String dstClassName = variable.getClassName(); + MethodExecution me = before.getMethodExecution(); + Map references = me.getObjectReferences(dstClassName); + ObjectReference objectReference = null; + TracePoint tp = null; + for (Map.Entry entry : references.entrySet()) { + ObjectReference key = entry.getKey(); + if (key.getId().equals(dstId)) { + objectReference = key; + tp = entry.getValue(); + break; + } + } + + // �f���^���o + DeltaRelatedAliasCollector aliasCollector = new DeltaRelatedAliasCollector(srcId, dstId); + extractedStructure = deltaExtractor.extract(tp, objectReference, aliasCollector); + MethodExecution coordinator = extractedStructure.getCoordinator(); + TracePoint bottomPoint = before.duplicate(); + + // �f���^���o�̌��ʂ����Ƀ\�[�X�R�[�h�𔽓]�\������ + DeltaMarkerManager mgr = deltaMarkerView.getDeltaMarkerManager(); + Reference reference = new Reference(srcId, dstId, srcClassName, dstClassName); + mark(mgr, coordinator, aliasCollector, bottomPoint, reference); + deltaMarkerView.update(); + } private TracePoint findTracePoint(Reference reference, MethodExecution methodExecution, long beforeTime) { List statements = methodExecution.getStatements(); diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java index 0a60157..7743db9 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java @@ -785,7 +785,7 @@ } /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * �Q�ƌ��I�u�W�F�N�g�ƎQ�Ɛ�I�u�W�F�N�g���֘A�t�����f���^���A�Q�Ƃ��w�肵�Ē��o���� * @param targetRef �ΏۂƂȂ�Q�� * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) * @return ���o���� @@ -795,7 +795,7 @@ } /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * �Q�ƌ��I�u�W�F�N�g�ƎQ�Ɛ�I�u�W�F�N�g���֘A�t�����f���^���A�Q�Ƃ��w�肵�Ē��o���� * @param targetRef �ΏۂƂȂ�Q�� * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i @@ -824,7 +824,7 @@ } /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * �Q�ƌ��I�u�W�F�N�g�ƎQ�Ɛ�I�u�W�F�N�g���֘A�t�����f���^���A�I�u�W�F�N�g�ԎQ�Ƃ��������ꂽ�g���[�X�|�C���g���w�肵�Ē��o���� * @param creationTracePoint �I�u�W�F�N�g�ԎQ�Ɛ����g���[�X�|�C���g(�t�B�[���h�ւ̑��) * @return ���o���� */ @@ -840,7 +840,7 @@ } /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * �Q�ƌ��I�u�W�F�N�g�ƎQ�Ɛ�I�u�W�F�N�g���֘A�t�����f���^���A�I�u�W�F�N�g�ԎQ�Ƃ��������ꂽ�g���[�X�|�C���g���w�肵�Ē��o���� * @param creationTracePoint �I�u�W�F�N�g�ԎQ�Ɛ����g���[�X�|�C���g(�t�B�[���h�ւ̑��) * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i * @return ���o���� @@ -877,29 +877,65 @@ return extractSub2(creationTracePoint, objList, aliasCollector); } - public ExtractedStructure extract(TracePoint tracePoint, ObjectReference argObj) { - return extract(tracePoint, argObj, defaultAliasCollector); + /** + * �Ăяo�����I�u�W�F�N�g�ƌĂяo����I�u�W�F�N�g���֘A�t�����f���^���A�Ăяo���惁�\�b�h���s���w�肵�Ē��o���� + * @param calledMethodExecution �Ăяo���惁�\�b�h���s + * @return�@���o���� + */ + public ExtractedStructure extract(MethodExecution calledMethodExecution) { + return extract(calledMethodExecution, defaultAliasCollector); + } + + /** + * �Ăяo�����I�u�W�F�N�g�ƌĂяo����I�u�W�F�N�g���֘A�t�����f���^���A�Ăяo���惁�\�b�h���s���w�肵�Ē��o���� + * @param calledMethodExecution �Ăяo���惁�\�b�h���s + * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i + * @return�@���o���� + */ + public ExtractedStructure extract(MethodExecution calledMethodExecution, IAliasCollector aliasCollector) { + ObjectReference callee = new ObjectReference(calledMethodExecution.getThisObjId(), calledMethodExecution.getThisClassName()); + return extract(calledMethodExecution.getCallerTracePoint(), callee, aliasCollector); } - public ExtractedStructure extract(TracePoint tracePoint, ObjectReference argObj, IAliasCollector aliasCollector) { - MethodExecution methodExecution = tracePoint.getMethodExecution(); + /** + * �����ithis�I�u�W�F�N�g�j�Ǝ��������\�b�h���ŎQ�Ƃ����I�u�W�F�N�g���֘A�t�����f���^�𒊏o���� + * @param thisTracePoint �Q�Ƃ������������_ + * @param anotherObj �Q�Ƃ����I�u�W�F�N�g + * @return ���o���� + */ + public ExtractedStructure extract(TracePoint thisTracePoint, ObjectReference anotherObj) { + return extract(thisTracePoint, anotherObj, defaultAliasCollector); + } + + /** + * �����ithis�I�u�W�F�N�g�j�ƃ��\�b�h���ŎQ�Ƃ��ꂽ�I�u�W�F�N�g���֘A�t�����f���^�𒊏o���� + * @param thisTracePoint �Q�Ƃ������������_ + * @param anotherObj �Q�Ƃ����I�u�W�F�N�g + * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i + * @return ���o���� + */ + public ExtractedStructure extract(TracePoint thisTracePoint, ObjectReference anotherObj, IAliasCollector aliasCollector) { + MethodExecution methodExecution = thisTracePoint.getMethodExecution(); + if (!thisTracePoint.isMethodEntry()) { + thisTracePoint.stepNext(); + } eStructure = new ExtractedStructure(); ArrayList objList = new ArrayList(); String thisObjectId = methodExecution.getThisObjId(); objList.add(thisObjectId); - objList.add(argObj.getId()); + objList.add(anotherObj.getId()); srcObject = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); - dstObject = argObj; + dstObject = anotherObj; if (DEBUG1) { - System.out.println("extract delta of:" + methodExecution.getSignature() + " -> " + argObj.getActualType() + "(" + argObj.getId() + ")"); + System.out.println("extract delta of:" + methodExecution.getSignature() + " -> " + anotherObj.getActualType() + "(" + anotherObj.getId() + ")"); } - return extractSub2(tracePoint, objList, aliasCollector); + return extractSub2(thisTracePoint, objList, aliasCollector); } - private ExtractedStructure extractSub2(TracePoint creationTracePoint, ArrayList objList, IAliasCollector aliasCollector) { - eStructure.setCreationMethodExecution(creationTracePoint.getMethodExecution()); - MethodExecution coordinator = callerSearch(trace, creationTracePoint, objList, null, aliasCollector); + private ExtractedStructure extractSub2(TracePoint tracePoint, ArrayList objList, IAliasCollector aliasCollector) { + eStructure.setCreationMethodExecution(tracePoint.getMethodExecution()); + MethodExecution coordinator = callerSearch(trace, tracePoint, objList, null, aliasCollector); eStructure.setCoordinator(coordinator); if (DEBUG2) { if (((DeltaAugmentationInfo)coordinator.getAugmentation()).isCoodinator()) {