diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java index 06dc2dc..2ea2ea6 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractor.java @@ -1,6 +1,7 @@ package org.ntlab.traceDebugger.analyzerProvider; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import org.ntlab.traceAnalysisPlatform.tracer.trace.FieldAccess; @@ -12,7 +13,7 @@ import org.ntlab.traceAnalysisPlatform.tracer.trace.Statement; import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; - + /** * �f���^���o�A���S���Y��(�z��ւ̃A�N�Z�X�𐄑�����]���̃o�[�W����) * extract(...)���\�b�h�Q�Œ��o����B @@ -53,7 +54,7 @@ public DeltaExtractor(String traceFile) { trace = new Trace(traceFile); } - + public DeltaExtractor(Trace trace) { this.trace = trace; } @@ -102,11 +103,11 @@ /** * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j * @param trace�@��͑Ώۃg���[�X - * @param methodExecution �T�����郁�\�b�h���s - * @param objList�@�ǐՒ��̃I�u�W�F�N�g + * @param methodExecution �T�����n�߂郁�\�b�h���s + * @param objList�@�ǐՒ��̃I�u�W�F�N�g�̃��X�g * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s + * @param aliasCollector �G�C���A�X�����W���邽�߂̃r�W�^�[ * @return ���‚������R�[�f�B�l�[�^ - * @throws TraceFileException */ protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution, IAliasTracker aliasCollector) { MethodExecution methodExecution = tracePoint.getMethodExecution(); @@ -123,6 +124,9 @@ ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); + HashMap srcAliasList = new HashMap<>(); + HashMap dstAliasList = new HashMap<>(); + if (childMethodExecution == null) { // �T���J�n���͈�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� @@ -135,6 +139,19 @@ // �I�u�W�F�N�g���Ăяo���̂Ƃ��݈̂�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + // �I�u�W�F�N�g���Ăяo���̏ꍇ [case 1] + aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, childMethodExecution.getThisObjId(), tracePoint.duplicate())); + } else if (!childMethodExecution.isConstructor()) { + // �I�u�W�F�N�g�Ԃ̔�R���X�g���N�^�Ăяo���̏ꍇ [case 2] + aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, childMethodExecution.getThisObjId(), tracePoint.duplicate())); + } + } + + if (childMethodExecution != null) { + for (String objId : objList) { + if (!objId.equals(childMethodExecution.getThisObjId())) { + aliasCollector.addAlias(new Alias(Alias.AliasType.ACTUAL_ARGUMENT, -1, objId, tracePoint.duplicate())); // �����ԍ����킩��Ȃ� + } } } @@ -146,6 +163,14 @@ removeList.add(childMethodExecution.getThisObjId()); existsInFields++; removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + if (!thisObjectId.equals(childMethodExecution.getThisObjId())) { + // �I�u�W�F�N�g�Ԃ̃R���X�g���N�^�Ăяo���̏ꍇl [case 3] + if (childMethodExecution.getThisObjId().equals(srcObject.getId())) { + srcAliasList.put(childMethodExecution.getThisObjId(), new DeltaAlias(Alias.AliasType.RECEIVER, 0, childMethodExecution.getThisObjId(), tracePoint.duplicate(), true)); + } else if (childMethodExecution.getThisObjId().equals(dstObject.getId())) { + dstAliasList.put(childMethodExecution.getThisObjId(), new DeltaAlias(Alias.AliasType.RECEIVER, 0, childMethodExecution.getThisObjId(), tracePoint.duplicate(), false)); + } + } } } @@ -161,33 +186,45 @@ } } + // callerSearch �̃��C�����[�v�D���݂̃��\�b�h�̃X�e�[�g�����g�̎��s�����s�Ƌt�����ɒT�������D // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch���ċA�Ăяo�� while (tracePoint.stepBackOver()) { Statement statement = tracePoint.getStatement(); - // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� if (statement instanceof FieldAccess) { + // ���s�����t�B�[���h�Q�Ƃ������ꍇ FieldAccess fs = (FieldAccess)statement; String refObjectId = fs.getValueObjId(); int index = objList.indexOf(refObjectId); if (index != -1) { String ownerObjectId = fs.getContainerObjId(); if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ + // �����̃t�B�[���h�̎Q�Ƃ̏ꍇ removeList.add(refObjectId); - existsInFields++; // set�������get�����o���Ă���”\�������� removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + if (refObjectId.equals(srcObject.getId())) { + srcAliasList.put(refObjectId, new DeltaAlias(Alias.AliasType.FIELD, 0, refObjectId, tracePoint.duplicate(), true)); + } else if (refObjectId.equals(dstObject.getId())) { + dstAliasList.put(refObjectId, new DeltaAlias(Alias.AliasType.FIELD, 0, refObjectId, tracePoint.duplicate(), false)); + } + existsInFields++; // set�������get�����o���Ă���”\�������� } else { - // ���ڎQ�Ƃ̏ꍇ + // ���̃I�u�W�F�N�g�̃t�B�[���h�̎Q�Ƃ̏ꍇ + boolean isSrcSideChanged = false; if (refObjectId.equals(srcObject.getId())) { eStructure.addSrcSide(new Reference(ownerObjectId, refObjectId, fs.getContainerClassName(), srcObject.getActualType())); srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + isSrcSideChanged = true; } else if(refObjectId.equals(dstObject.getId())) { eStructure.addDstSide(new Reference(ownerObjectId, refObjectId, fs.getContainerClassName(), dstObject.getActualType())); dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + isSrcSideChanged = false; } objList.set(index, ownerObjectId); + aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, refObjectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(refObjectId, ownerObjectId, isSrcSideChanged); // �ǐՑΏۂ��t�B�[���h�ɂ��Q�Ɛ�I�u�W�F�N�g����Q�ƌ��I�u�W�F�N�g�i�R���e�i�j�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.CONTAINER, 0, ownerObjectId, tracePoint.duplicate())); } } else { // �ŏI�I�ɃI�u�W�F�N�g�̗R�������‚���Ȃ������ꍇ�ɁA�����ŎQ�Ƃ����z������̗v�f�ɗR�����Ă���”\�������� @@ -211,6 +248,11 @@ // �t�B�[���h�Q�Ƃ̏ꍇ�i���ɗR���̉”\�����Ȃ��Ƃ킩�������_�ŁA���̔z��̗v�f�ɗR�����Ă�����̂Ɛ�������B�j fieldArrays.add(new ObjectReference(refObjectId, refObjType)); fieldArrayElements.add(trackingObj); + if (trackingObj.getId().equals(srcObject.getId())) { + srcAliasList.put(trackingObj.getId(), new DeltaAlias(Alias.AliasType.ARRAY_ELEMENT, 0, trackingObj.getId(), tracePoint.duplicate(), true)); + } else if (trackingObj.getId().equals(dstObject.getId())) { + dstAliasList.put(trackingObj.getId(), new DeltaAlias(Alias.AliasType.ARRAY_ELEMENT, 0, trackingObj.getId(), tracePoint.duplicate(), false)); + } } else { // ���ڎQ�Ƃ̏ꍇ(�{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u��������ׂ������A // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� @@ -220,6 +262,7 @@ } } } else if (statement instanceof MethodInvocation) { + // ���s�������\�b�h�Ăяo���������ꍇ MethodExecution prevChildMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); if (!prevChildMethodExecution.equals(childMethodExecution)) { // �߂�l @@ -236,13 +279,23 @@ creationList.add(newObjId); removeList.add(newObjId); existsInFields++; - // objList.remove(callTree.getThisObjId()); removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(newObjId)); // �ǐՑΏ� - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setSetterSide(false); // getter�Ăяo���Ɠ��l + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(newObjId)); // �ǐՑΏ� + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setSetterSide(false); // �Q�Ƒ��̌Ăяo���Ɠ��l + if (newObjId.equals(srcObject.getId())) { + srcAliasList.put(newObjId, new DeltaAlias(Alias.AliasType.CONSTRACTOR_INVOCATION, 0, newObjId, tracePoint.duplicate(), true)); + } else if (newObjId.equals(dstObject.getId())) { + dstAliasList.put(newObjId, new DeltaAlias(Alias.AliasType.CONSTRACTOR_INVOCATION, 0, newObjId, tracePoint.duplicate(), false)); + } continue; } String retObj = objList.get(retIndex); + if (retObj.equals(srcObject.getId())) { + isSrcSide = true; + } else if (retObj.equals(dstObject.getId())) { + isSrcSide = false; + } + aliasCollector.addAlias(new Alias(Alias.AliasType.METHOD_INVOCATION, 0, retObj, tracePoint.duplicate())); if (removeList.contains(retObj)) { // ��xget�Ō��o���ăt�B�[���h�Ɉˑ����Ă���Ɣ��f�������{���̗R�����߂�l���������Ƃ����������̂ŁA�t�B�[���h�ւ̈ˑ����L�����Z������ removeList.remove(retObj); @@ -251,15 +304,21 @@ removeList.remove(thisObjectId); } } - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(retObj)); // �ǐՑΏ� + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(retObj)); // �ǐՑΏ� TracePoint prevChildTracePoint = tracePoint.duplicate(); prevChildTracePoint.stepBackNoReturn(); - calleeSearch(trace, prevChildTracePoint, objList, prevChildMethodExecution.isStatic(), retIndex, aliasCollector); // �Ăяo�����T�� - if (objList.get(retIndex) != null && objList.get(retIndex).equals(prevChildMethodExecution.getThisObjId()) - && thisObjectId.equals(prevChildMethodExecution.getThisObjId())) { - // �Ăяo����Ńt�B�[���h�Ɉˑ����Ă����ꍇ�̏��� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + calleeSearch(trace, prevChildTracePoint, objList, prevChildMethodExecution.isStatic(), retIndex, aliasCollector); // �Ăяo���惁�\�b�h���s�̒T���̂��ߍċA�Ăяo�� + if (objList.get(retIndex) != null && objList.get(retIndex).equals(prevChildMethodExecution.getThisObjId())) { + if (thisObjectId.equals(prevChildMethodExecution.getThisObjId())) { + // �Ăяo����Ńt�B�[���h�Ɉˑ����Ă����ꍇ�̏��� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + } + if (isSrcSide) { + aliasCollector.addAlias(new DeltaAlias(Alias.AliasType.RECEIVER, 0, objList.get(retIndex), tracePoint.duplicate(), true)); + } else { + aliasCollector.addAlias(new DeltaAlias(Alias.AliasType.RECEIVER, 0, objList.get(retIndex), tracePoint.duplicate(), false)); + } } if (isLost) { checkList.add(objList.get(retIndex)); @@ -297,16 +356,16 @@ // �R���N�V�����^�Ή� if (methodExecution.isCollectionType()) { objList.add(thisObjectId); - } + } // �����̎擾 - ArrayList argments = methodExecution.getArguments(); + ArrayList arguments = methodExecution.getArguments(); - // �����ƃt�B�[���h�ɓ���ID�̃I�u�W�F�N�g������ꍇ��z�� + // �����ƃt�B�[���h�ɓ���ID�̃I�u�W�F�N�g������ꍇ��z��i�R���Ƃ��Ĉ����ƃt�B�[���h�̗������^����ꍇ�j Reference r; for (int i = 0; i < removeList.size(); i++) { String removeId = removeList.get(i); - if (argments.contains(new ObjectReference(removeId))) { + if (arguments.contains(new ObjectReference(removeId))) { removeList.remove(removeId); // �t�B�[���h�ƈ����̗����ɒǐՑΏۂ����݂����ꍇ�A������D�� } else if(objList.contains(removeId)) { // �t�B�[���h�ɂ����Ȃ������ꍇ(�������A�I�u�W�F�N�g�̐������t�B�[���h�Ɠ��l�Ɉ���) @@ -319,28 +378,41 @@ eStructure.addSrcSide(r); srcObject = thisObj; isSrcSide = true; + if (srcAliasList.containsKey(removeId)) { + aliasCollector.addAlias(srcAliasList.get(removeId)); + aliasCollector.changeTrackingObject(removeId, thisObjectId, isSrcSide); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, srcAliasList.get(removeId).getOccurrencePoint())); + srcAliasList.remove(removeId); + } } else if (removeId.equals(dstObject.getId())) { r = new Reference(thisObj, dstObject); r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? eStructure.addDstSide(r); dstObject = thisObj; isSrcSide = false; + if (dstAliasList.containsKey(removeId)) { + aliasCollector.addAlias(dstAliasList.get(removeId)); + aliasCollector.changeTrackingObject(removeId, thisObjectId, isSrcSide); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, dstAliasList.get(removeId).getOccurrencePoint())); + dstAliasList.remove(removeId); + } } } } } // --- ���̎��_�� this ���ǐՑΏۂł������Ƃ��Ă� objList �̒����炢������폜����Ă��� --- - // �����T�� + // �R���Ƃ��Ĉ�����T�� boolean existsInAnArgument = false; for (int i = 0; i < objList.size(); i++) { String objectId = objList.get(i); if (objectId != null) { ObjectReference trackingObj = new ObjectReference(objectId); - if (argments.contains(trackingObj)) { + if (arguments.contains(trackingObj)) { // �������R�������� existsInAnArgument = true; ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); + aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(trackingObj), trackingObj.getId(), methodExecution.getEntryPoint())); } else { // �R�����ǂ��ɂ����‚���Ȃ����� boolean isSrcSide2 = true; @@ -354,8 +426,8 @@ } if (trackingObj != null) { // �܂��z������̗v�f��R���Ƃ��ċ^��(������D��) - for (int j = 0; j < argments.size(); j++) { - ObjectReference argArray = argments.get(j); + for (int j = 0; j < arguments.size(); j++) { + ObjectReference argArray = arguments.get(j); if (argArray.getActualType().startsWith("[L") && (trackingObj.getActualType() != null && (argArray.getActualType().endsWith(trackingObj.getActualType() + ";")) || (trackingObj.getCalleeType() != null && argArray.getActualType().endsWith(trackingObj.getCalleeType() + ";")) @@ -376,6 +448,10 @@ dstObject = new ObjectReference(argArray.getId(), argArray.getActualType()); } objectId = null; + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_ELEMENT, 0, trackingObj.getId(), methodExecution.getEntryPoint())); // �z��v�f�̓��\�b�h�̐擪�Ŏ擾���ꂽ�Ɖ��肷�� + aliasCollector.changeTrackingObject(trackingObj.getId(), argArray.getId(), isSrcSide2); // �ǐՑΏۂ�z��v�f����z��ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, argArray.getId(), methodExecution.getEntryPoint())); // �z��̓��\�b�h�̐擪�ŃA�N�Z�X���ꂽ�Ɖ��肷�� + aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(argArray), trackingObj.getId(), methodExecution.getEntryPoint())); break; } } @@ -395,13 +471,27 @@ eStructure.addSrcSide(new Reference(thisObjectId, fieldArray.getId(), methodExecution.getThisClassName(), fieldArray.getActualType())); srcObject = thisObj; - isSrcSide = true; + if (srcAliasList.containsKey(trackingObj.getId())) { + aliasCollector.addAlias(srcAliasList.get(trackingObj.getId())); + aliasCollector.changeTrackingObject(trackingObj.getId(), fieldArray.getId(), isSrcSide2); // �ǐՑΏۂ�z��v�f����z��t�B�[���h�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, fieldArray.getId(), srcAliasList.get(trackingObj.getId()).getOccurrencePoint())); + aliasCollector.changeTrackingObject(fieldArray.getId(), thisObjectId, isSrcSide2); // �ǐՑΏۂ�z��t�B�[���h����this�I�u�W�F�N�g�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, srcAliasList.get(trackingObj.getId()).getOccurrencePoint())); + srcAliasList.remove(trackingObj.getId()); + } } else { eStructure.addDstSide(r); eStructure.addDstSide(new Reference(thisObjectId, fieldArray.getId(), methodExecution.getThisClassName(), fieldArray.getActualType())); dstObject = thisObj; - isSrcSide = false; + if (dstAliasList.containsKey(trackingObj.getId())) { + aliasCollector.addAlias(dstAliasList.get(trackingObj.getId())); + aliasCollector.changeTrackingObject(trackingObj.getId(), fieldArray.getId(), isSrcSide2); // �ǐՑΏۂ�z��v�f����z��t�B�[���h�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, fieldArray.getId(), dstAliasList.get(trackingObj.getId()).getOccurrencePoint())); + aliasCollector.changeTrackingObject(fieldArray.getId(), thisObjectId, isSrcSide2); // �ǐՑΏۂ�z��t�B�[���h����this�I�u�W�F�N�g�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, dstAliasList.get(trackingObj.getId()).getOccurrencePoint())); + dstAliasList.remove(trackingObj.getId()); + } } } } @@ -412,13 +502,14 @@ eStructure.addSrcSide(new Reference(thisObjectId, trackingObj.getId(), methodExecution.getThisClassName(), trackingObj.getActualType())); srcObject = thisObj; - isSrcSide = true; } else { eStructure.addDstSide(new Reference(thisObjectId, trackingObj.getId(), methodExecution.getThisClassName(), trackingObj.getActualType())); dstObject = thisObj; - isSrcSide = false; } + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_CREATE, 0, trackingObj.getId(), methodExecution.getEntryPoint())); // �z��̓��\�b�h�̐擪�Ő������ꂽ���̂Ɖ��肷�� + aliasCollector.changeTrackingObject(trackingObj.getId(), thisObjectId, isSrcSide2); // �ǐՑΏۂ�z�񂩂�this�I�u�W�F�N�g�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, methodExecution.getEntryPoint())); // �z��̓��\�b�h�̐擪�Ő������ꂽ���̂Ɖ��肷�� } } } @@ -444,7 +535,7 @@ // } if (tracePoint.isValid()) { finalCount = 0; - return callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� + return callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�����邽�ߍċA�Ăяo�� } } @@ -459,8 +550,8 @@ finalCount++; if (finalCount <= LOST_DECISION_EXTENSION) { // final�ϐ����Q�Ƃ��Ă���ꍇ�R���������ł��Ȃ��”\��������̂ŁA�ǐՂ������I�������P�\���Ԃ�݂��� - if (tracePoint.isValid()) { - MethodExecution c = callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� + if (tracePoint.isValid()) { + MethodExecution c = callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�����邽�ߍċA�Ăяo�� if (((DeltaAugmentationInfo)c.getAugmentation()).isCoodinator()) { methodExecution = c; // �ǐՂ𑱂������ʃR�[�f�B�l�[�^�����‚����� } @@ -513,8 +604,9 @@ * @param objList �ǐՒ��̃I�u�W�F�N�g * @param isStatic�@�ÓI���\�b�h���ۂ� * @param index�@objList���̂ǂ̃I�u�W�F�N�g��ǐՂ��Ă��̃��\�b�h���s�ɓ����Ă����̂� - * @throws TraceFileException + * @param aliasCollector �G�C���A�X�����W���邽�߂̃r�W�^�[ */ + @Deprecated protected void calleeSearch(Trace trace, TracePoint tracePoint, ArrayList objList, Boolean isStatic, int index, IAliasTracker aliasCollector) { MethodExecution methodExecution = tracePoint.getMethodExecution(); Boolean isResolved = false; @@ -526,9 +618,14 @@ Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(false); // ��{�I��getter�Ăяo���̂͂������A���� - ArrayList argments = methodExecution.getArguments(); + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(false); // ��{�I�ɎQ�Ɛ摤�̌Ăяo���̂͂������A���� + ArrayList arguments = methodExecution.getArguments(); ObjectReference trackingObj = null; + + HashMap srcAliasList = new HashMap<>(); + HashMap dstAliasList = new HashMap<>(); + + aliasCollector.addAlias(new Alias(Alias.AliasType.RETURN_VALUE, 0, objectId, tracePoint.duplicate())); //static���o�R�����null�������Ă��鎞������ if (objectId != null) { String returnType = Trace.getReturnType(methodExecution.getSignature()); @@ -543,42 +640,55 @@ } Reference r; + // calleeSearch �̃��C�����[�v�D���݂̃��\�b�h�̃X�e�[�g�����g�̎��s�����s�Ƌt�����ɒT�������D // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch�Ăяo�� do { if (!tracePoint.isValid()) break; Statement statement = tracePoint.getStatement(); - // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� if (statement instanceof FieldAccess) { + // ���s�����t�B�[���h�Q�Ƃ������ꍇ FieldAccess fs = (FieldAccess)statement; if (objectId != null && objectId.equals(fs.getValueObjId())) { String ownerObjectId = fs.getContainerObjId(); - if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ + if (ownerObjectId.equals(thisObjectId)) { + // �����̃t�B�[���h�̎Q�Ƃ̏ꍇ + boolean isSrcSideChanged = false; if (objectId.equals(srcObject.getId())) { eStructure.addSrcSide(new Reference(thisObj, srcObject)); srcObject = thisObj; trackingObj = srcObject; + isSrcSideChanged = true; } else if(objectId.equals(dstObject.getId())) { eStructure.addDstSide(new Reference(thisObj, dstObject)); dstObject = thisObj; trackingObj = dstObject; + isSrcSideChanged = false; } + aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, objectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(objectId, ownerObjectId, isSrcSideChanged); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, ownerObjectId, tracePoint.duplicate())); if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ else objectId = thisObjectId; objList.set(index, objectId); } else { - // ���ڎQ�Ƃ̏ꍇ + // ���̃I�u�W�F�N�g�̃t�B�[���h�̎Q�Ƃ̏ꍇ + boolean isSrcSideChanged = false; if (objectId.equals(srcObject.getId())) { eStructure.addSrcSide(new Reference(ownerObjectId, objectId, fs.getContainerClassName(), srcObject.getActualType())); srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); trackingObj = srcObject; + isSrcSideChanged = true; } else if(objectId.equals(dstObject.getId())) { eStructure.addDstSide(new Reference(ownerObjectId, objectId, fs.getContainerClassName(), dstObject.getActualType())); dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); trackingObj = dstObject; + isSrcSideChanged = false; } + aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, objectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(objectId, ownerObjectId, isSrcSideChanged); + aliasCollector.addAlias(new Alias(Alias.AliasType.CONTAINER, 0, ownerObjectId, tracePoint.duplicate())); if (Trace.isNull(ownerObjectId)) objectId = null; // static�ϐ��̏ꍇ else objectId = ownerObjectId; objList.set(index, objectId); @@ -598,6 +708,11 @@ // �t�B�[���h�Q�Ƃ̏ꍇ�i���ɗR���̉”\�����Ȃ��Ƃ킩�������_�ŁA���̔z��̗v�f�ɗR�����Ă�����̂Ɛ�������B�j fieldArrays.add(new ObjectReference(fs.getValueObjId(), refObjType)); fieldArrayElements.add(trackingObj); + if (objectId.equals(srcObject.getId())) { + srcAliasList.put(objectId, new DeltaAlias(Alias.AliasType.ARRAY_ELEMENT, 0, objectId, tracePoint.duplicate(), true)); + } else if(objectId.equals(dstObject.getId())) { + dstAliasList.put(objectId, new DeltaAlias(Alias.AliasType.ARRAY_ELEMENT, 0, objectId, tracePoint.duplicate(), false)); + } } else { // ���ڎQ�Ƃ̏ꍇ(�{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u��������ׂ������A // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� @@ -607,7 +722,7 @@ } } } else if (statement instanceof MethodInvocation) { - // �߂�l + // ���s�������\�b�h�Ăяo���������ꍇ MethodExecution childMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); ObjectReference ret = childMethodExecution.getReturnValue(); if (ret != null && objectId != null && objectId.equals(ret.getId())) { @@ -615,7 +730,12 @@ ((DeltaAugmentationInfo)childMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); TracePoint childTracePoint = tracePoint.duplicate(); childTracePoint.stepBackNoReturn(); - calleeSearch(trace, childTracePoint, objList, childMethodExecution.isStatic(), index, aliasCollector); // �Ăяo���������ɒT�� + if (!childMethodExecution.isConstructor()) { + aliasCollector.addAlias(new Alias(Alias.AliasType.METHOD_INVOCATION, 0, ret.getId(), tracePoint.duplicate())); + calleeSearch(trace, childTracePoint, objList, childMethodExecution.isStatic(), index, aliasCollector); // �Ăяo���������ɒT�����邽�ߍċA�Ăяo�� + } else { + aliasCollector.addAlias(new Alias(Alias.AliasType.CONSTRACTOR_INVOCATION, 0, ret.getId(), tracePoint.duplicate())); + } if (childMethodExecution.isConstructor()) { // �R���X�g���N�^�Ăяo���������ꍇ if (objectId.equals(srcObject.getId())) { @@ -624,12 +744,16 @@ eStructure.addSrcSide(r); srcObject = thisObj; trackingObj = srcObject; + aliasCollector.changeTrackingObject(objectId, thisObjectId, true); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); } else if (objectId.equals(dstObject.getId())) { r = new Reference(thisObj, dstObject); r.setCreation(true); eStructure.addDstSide(r); dstObject = thisObj; trackingObj = dstObject; + aliasCollector.changeTrackingObject(objectId, thisObjectId, false); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); } if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ else objectId = thisObjectId; @@ -652,6 +776,11 @@ checkList.add(objList.get(index)); isLost = false; } + if (objectId != null) { + if (childMethodExecution.getThisObjId().equals(objectId)) { + aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, objectId, tracePoint.duplicate())); + } + } } else { // �I�u�W�F�N�g�̗R�������ڌ��‚���Ȃ������ꍇ�ł��A�ǂ����̔z��̗v�f�ɗR�����Ă���”\�������� String retType = ret.getActualType(); @@ -669,14 +798,15 @@ } } while (tracePoint.stepBackOver()); - //�����T�� - if (argments.contains(new ObjectReference(objectId))) { + // �����T�� + if (arguments.contains(new ObjectReference(objectId))) { ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(true); // �������K�v? isResolved = true; + aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(new ObjectReference(objectId)), objectId, methodExecution.getEntryPoint())); } } - //�R���N�V�����^�Ή� + // �R���N�V�����^�Ή� Reference r; if (methodExecution.isCollectionType()) { if (objectId != null) { @@ -686,11 +816,15 @@ r.setCollection(true); eStructure.addSrcSide(r); srcObject = thisObj; + aliasCollector.changeTrackingObject(objectId, thisObjectId, true); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); } else if(objectId.equals(dstObject.getId())) { r = new Reference(thisObj, dstObject); r.setCollection(true); eStructure.addDstSide(r); dstObject =thisObj; + aliasCollector.changeTrackingObject(objectId, thisObjectId, false); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); } } objList.set(index, methodExecution.getThisObjId()); @@ -707,8 +841,8 @@ } if (trackingObj != null) { // �܂��z������̗v�f��R���Ƃ��ċ^��(�������D��) - for (int i = 0; i < argments.size(); i++) { - ObjectReference argArray = argments.get(i); + for (int i = 0; i < arguments.size(); i++) { + ObjectReference argArray = arguments.get(i); if (argArray.getActualType().startsWith("[L") && ((trackingObj.getActualType() != null && argArray.getActualType().endsWith(trackingObj.getActualType() + ";")) || (trackingObj.getCalleeType() != null && argArray.getActualType().endsWith(trackingObj.getCalleeType() + ";")) @@ -728,6 +862,10 @@ dstObject = new ObjectReference(argArray.getId(), argArray.getActualType()); } objectId = null; + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_ELEMENT, 0, trackingObj.getId(), methodExecution.getEntryPoint())); // �z��v�f�̓��\�b�h�̐擪�Ŏ擾���ꂽ���̂Ɖ��肷�� + aliasCollector.changeTrackingObject(trackingObj.getId(), argArray.getId(), isSrcSide); // �ǐՑΏۂ�z��v�f����z��ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, argArray.getId(), methodExecution.getEntryPoint())); // �z��̓��\�b�h�̐擪�ŃA�N�Z�X���ꂽ���̂Ɖ��肷�� + aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(argArray), trackingObj.getId(), methodExecution.getEntryPoint())); break; } } @@ -747,11 +885,23 @@ eStructure.addSrcSide(new Reference(thisObjectId, fieldArray.getId(), methodExecution.getThisClassName(), fieldArray.getActualType())); srcObject = thisObj; + aliasCollector.addAlias(srcAliasList.get(trackingObj.getId())); + aliasCollector.changeTrackingObject(trackingObj.getId(), fieldArray.getId(), isSrcSide); // �ǐՑΏۂ�z��v�f����z��t�B�[���h�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, fieldArray.getId(), srcAliasList.get(trackingObj.getId()).getOccurrencePoint())); + aliasCollector.changeTrackingObject(fieldArray.getId(), thisObjectId, isSrcSide); // �ǐՑΏۂ�z��t�B�[���h����this�I�u�W�F�N�g�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, srcAliasList.get(trackingObj.getId()).getOccurrencePoint())); + srcAliasList.remove(trackingObj.getId()); } else { eStructure.addDstSide(r); eStructure.addDstSide(new Reference(thisObjectId, fieldArray.getId(), methodExecution.getThisClassName(), fieldArray.getActualType())); dstObject = thisObj; + aliasCollector.addAlias(dstAliasList.get(trackingObj.getId())); + aliasCollector.changeTrackingObject(trackingObj.getId(), fieldArray.getId(), isSrcSide); // �ǐՑΏۂ�z��v�f����z��t�B�[���h�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, fieldArray.getId(), dstAliasList.get(trackingObj.getId()).getOccurrencePoint())); + aliasCollector.changeTrackingObject(fieldArray.getId(), thisObjectId, isSrcSide); // �ǐՑΏۂ�z��t�B�[���h����this�I�u�W�F�N�g�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, dstAliasList.get(trackingObj.getId()).getOccurrencePoint())); + dstAliasList.remove(trackingObj.getId()); } } } @@ -768,6 +918,9 @@ methodExecution.getThisClassName(), trackingObj.getActualType())); dstObject = thisObj; } + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_CREATE, 0, trackingObj.getId(), methodExecution.getEntryPoint())); // �z��̓��\�b�h�̐擪�Ő������ꂽ���̂Ɖ��肷�� + aliasCollector.changeTrackingObject(trackingObj.getId(), thisObjectId, isSrcSide); // �ǐՑΏۂ�z�񂩂�this�I�u�W�F�N�g�ɒu������ + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, methodExecution.getEntryPoint())); // �z��̓��\�b�h�̐擪�Ő������ꂽ���̂Ɖ��肷�� } } } @@ -860,7 +1013,7 @@ return null; } } - + private ExtractedStructure extractSub(TracePoint creationTracePoint, Reference targetRef, IAliasTracker aliasCollector) { eStructure = new ExtractedStructure(); eStructure.setRelatedTracePoint(creationTracePoint.duplicate()); @@ -902,7 +1055,7 @@ ObjectReference callee = new ObjectReference(calledMethodExecution.getThisObjId(), calledMethodExecution.getThisClassName()); return extract(calledMethodExecution.getCallerTracePoint(), callee, aliasCollector); } - + /** * �����ithis�I�u�W�F�N�g�j�Ǝ��������\�b�h���ŎQ�Ƃ����I�u�W�F�N�g���֘A�t�����f���^�𒊏o���� * @param thisTracePoint �Q�Ƃ������������_ @@ -912,7 +1065,7 @@ 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�Ƃ������������_ @@ -924,9 +1077,7 @@ eStructure = new ExtractedStructure(); eStructure.setRelatedTracePoint(thisTracePoint.duplicate()); MethodExecution methodExecution = thisTracePoint.getMethodExecution(); - if (!thisTracePoint.isMethodEntry()) { - thisTracePoint.stepNext(); - } + thisTracePoint.stepNext(); ArrayList objList = new ArrayList(); String thisObjectId = methodExecution.getThisObjId(); objList.add(thisObjectId); @@ -1028,7 +1179,7 @@ public MethodExecution getCurrentMethodExecution(Thread thread) { return trace.getCurrentMethodExecution(thread); } - + /** * methodSignature �ɑO����v���郁�\�b�h�������ƒ��\�b�h�̍Ō�̎��s * @param methodSignature ���\�b�h��(�O����v�Ō�������) @@ -1037,7 +1188,7 @@ public MethodExecution getLastMethodExecution(String methodSignature) { return trace.getLastMethodExecution(methodSignature); } - + /** * methodSignature �ɑO����v���郁�\�b�h�������ƒ��\�b�h�� before �ȑO�̍Ō�̎��s * @param methodSignature ���\�b�h��(�O����v�Ō�������) @@ -1047,7 +1198,7 @@ public MethodExecution getLastMethodExecution(String methodSignature, TracePoint before) { return trace.getLastMethodExecution(methodSignature, before); } - + public ArrayList getMethodExecutions(String methodSignature) { return trace.getMethodExecutions(methodSignature); } @@ -1155,4 +1306,4 @@ //} // return eStructure; // } -} \ No newline at end of file +}