diff --git a/org.ntlab.traceAnalyzer/src/org/ntlab/deltaExtractor/DeltaExtractor.java b/org.ntlab.traceAnalyzer/src/org/ntlab/deltaExtractor/DeltaExtractor.java index 54b2399..47cb66d 100644 --- a/org.ntlab.traceAnalyzer/src/org/ntlab/deltaExtractor/DeltaExtractor.java +++ b/org.ntlab.traceAnalyzer/src/org/ntlab/deltaExtractor/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()) { diff --git a/org.ntlab.traceAnalyzer/src/org/ntlab/trace/MethodExecution.java b/org.ntlab.traceAnalyzer/src/org/ntlab/trace/MethodExecution.java index 35d6479..67a35b7 100644 --- a/org.ntlab.traceAnalyzer/src/org/ntlab/trace/MethodExecution.java +++ b/org.ntlab.traceAnalyzer/src/org/ntlab/trace/MethodExecution.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; public class MethodExecution { private String signature; @@ -175,6 +176,49 @@ } /** + * ���̃��\�b�h���ŎQ�Ƃ��ꂽ�I�u�W�F�N�g�Ƃ��̃I�u�W�F�N�g�����\�b�h���ōŏ��ɎQ�Ƃ������s���_�̃��X�g���A�I�u�W�F�N�g�̌^���w�肵�Ď擾���� + * @param actualTypeName �I�u�W�F�N�g�̌^ + * @return ���̃��\�b�h���ŎQ�Ƃ��ꂽ actualTypeName �̃C���X�^���X�Ƃ��̃C���X�^���X���ŏ��ɎQ�Ƃ������s���_�̃��X�g + */ + public Map getObjectReferences(String actualTypeName) { + Map objectRefMap = new HashMap<>(); + TracePoint tp = getExitPoint(); + if (tp != null) { + do { + Statement s = tp.getStatement(); + if (s instanceof FieldAccess) { + FieldAccess f = (FieldAccess) s; + if (f.getValueClassName().equals(actualTypeName)) { + objectRefMap.put(new ObjectReference(f.getValueObjId(), f.getValueClassName()), tp.duplicate()); + } + } else if (s instanceof ArrayAccess) { + ArrayAccess a = (ArrayAccess) s; + if (a.getValueClassName().equals(actualTypeName)) { + objectRefMap.put(new ObjectReference(a.getValueObjectId(), a.getValueClassName()), tp.duplicate()); + } + } else if (s instanceof ArrayCreate) { + ArrayCreate a = (ArrayCreate) s; + if (a.getArrayClassName().equals(actualTypeName)) { + objectRefMap.put(new ObjectReference(a.getArrayObjectId(), a.getArrayClassName()), tp.duplicate()); + } + } else if (s instanceof MethodInvocation) { + MethodInvocation m = (MethodInvocation) s; + ObjectReference ret = m.getCalledMethodExecution().getReturnValue(); + if (ret.getActualType().equals(actualTypeName)) { + objectRefMap.put(ret, tp.duplicate()); + } + } + } while (tp.stepBackOver()); + } + for (ObjectReference arg: getArguments()) { + if (arg.getActualType().equals(actualTypeName)) { + objectRefMap.put(arg, getEntryPoint().duplicate()); + } + } + return objectRefMap; + } + + /** * ���̃��\�b�h���s����т��̑S�Ăяo������Ăяo���؂̒��ŋt�����ɒT������(�������Avisitor �� true ��Ԃ��܂�) * @param visitor �r�W�^�[ * @return�@true -- �T���𒆒f����, false -- �Ō�܂ŒT������ diff --git a/org.ntlab.traceAnalyzer/src/org/ntlab/trace/TracePoint.java b/org.ntlab.traceAnalyzer/src/org/ntlab/trace/TracePoint.java index 380b846..ae65e14 100644 --- a/org.ntlab.traceAnalyzer/src/org/ntlab/trace/TracePoint.java +++ b/org.ntlab.traceAnalyzer/src/org/ntlab/trace/TracePoint.java @@ -159,6 +159,15 @@ return false; } + /** + * �������\�b�h���ŏ�������1�i�߂�B�Ăяo����ɂ��Ăяo�����ɂ��s���Ȃ��B + * @return false:���\�b�h�𔲂��o���ꍇ, true: ����ȊO + */ + public boolean stepNext() { + order++; + return (order < methodExecution.getStatements().size()); + } + public boolean isValid() { if (methodExecution == null || order == -1 || order >= methodExecution.getStatements().size()) return false; return true; @@ -172,4 +181,12 @@ if (order < 0) return true; return false; } + + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof TracePoint)) return false; + if (methodExecution != ((TracePoint) other).methodExecution) return false; + if (order != ((TracePoint) other).order) return false; + return true; + } }