diff --git a/org.ntlab.traceCollector/META-INF/MANIFEST.MF b/org.ntlab.traceCollector/META-INF/MANIFEST.MF index 34a0c53..25e1def 100644 --- a/org.ntlab.traceCollector/META-INF/MANIFEST.MF +++ b/org.ntlab.traceCollector/META-INF/MANIFEST.MF @@ -16,3 +16,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ClassPath: javassist.jar, . +Export-Package: org.ntlab.traceCollector, + org.ntlab.traceCollector.tracer.trace diff --git a/org.ntlab.traceCollector/plugin.xml b/org.ntlab.traceCollector/plugin.xml index 1821ea1..5fc6cdd 100644 --- a/org.ntlab.traceCollector/plugin.xml +++ b/org.ntlab.traceCollector/plugin.xml @@ -1,6 +1,7 @@ + diff --git a/org.ntlab.traceCollector/schema/additionalClasspaths.exsd b/org.ntlab.traceCollector/schema/additionalClasspaths.exsd new file mode 100644 index 0000000..f06ad85 --- /dev/null +++ b/org.ntlab.traceCollector/schema/additionalClasspaths.exsd @@ -0,0 +1,102 @@ + + + + + + + + + To specify additional class paths used to launch the target program + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/Activator.java b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/Activator.java index 075cce7..b367329 100644 --- a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/Activator.java +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/Activator.java @@ -14,10 +14,13 @@ // The shared instance private static Activator plugin; + private ExtensionLoader loader; + /** * The constructor */ public Activator() { + loader = new ExtensionLoader(); } /* @@ -29,6 +32,10 @@ plugin = this; } + public ExtensionLoader getLoader() { + return loader; + } + /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) diff --git a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/ExtensionLoader.java b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/ExtensionLoader.java new file mode 100644 index 0000000..b91466a --- /dev/null +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/ExtensionLoader.java @@ -0,0 +1,43 @@ +package org.ntlab.traceCollector; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; + +public class ExtensionLoader { + private static final String EXTENSION_POINT_ID = Activator.PLUGIN_ID + ".additionalClasspaths"; //�g���|�C���gID + private List list; + + public List getAdditionalLaunchConfigurations() { + if (list != null) { + return list; + } + + IExtensionRegistry registory = Platform.getExtensionRegistry(); + IExtensionPoint point = registory.getExtensionPoint(EXTENSION_POINT_ID); + if (point == null) { + throw new IllegalStateException(EXTENSION_POINT_ID); + } + + list = new ArrayList(); + for (IExtension extension : point.getExtensions()) { + for (IConfigurationElement element : extension.getConfigurationElements()) { + try { + Object obj = element.createExecutableExtension("class"); //class���� + if (obj instanceof IAdditionalLaunchConfiguration) { + list.add((IAdditionalLaunchConfiguration) obj); + } + } catch (CoreException e) { + Activator.getDefault().getLog().log(e.getStatus()); + } + } + } + return list; + } +} diff --git a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/IAdditionalLaunchConfiguration.java b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/IAdditionalLaunchConfiguration.java new file mode 100644 index 0000000..531e5d2 --- /dev/null +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/IAdditionalLaunchConfiguration.java @@ -0,0 +1,5 @@ +package org.ntlab.traceCollector; + +public interface IAdditionalLaunchConfiguration { + public String[] getAdditionalClasspath(); +} diff --git a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/TracerLaunchConfigurationDelegate.java b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/TracerLaunchConfigurationDelegate.java index 6a3c161..2618e02 100644 --- a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/TracerLaunchConfigurationDelegate.java +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/TracerLaunchConfigurationDelegate.java @@ -2,10 +2,13 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.debug.core.ILaunch; @@ -28,7 +31,7 @@ public class TracerLaunchConfigurationDelegate extends org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate { @Override public void launch(ILaunchConfiguration configuration, String mode, - ILaunch launch, IProgressMonitor monitor) throws CoreException { + ILaunch launch, IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor = new NullProgressMonitor(); } @@ -68,10 +71,26 @@ try { String bundlePath = FileLocator.resolve(Activator.getDefault().getBundle().getEntry("/")).getPath(); String tracerClassPath = FileLocator.resolve(this.getClass().getClassLoader().getResource(Tracer.TRACER_CLASS_PATH)).getPath(); - classpath = new String[configClasspath.length + 2]; + + ExtensionLoader loader = Activator.getDefault().getLoader(); + List additionalClasspathList = new ArrayList<>(); + for (IAdditionalLaunchConfiguration config : loader.getAdditionalLaunchConfigurations()) { + for (String additionalClasspath : config.getAdditionalClasspath()) { + additionalClasspathList.add(additionalClasspath); + } + } + String[] additionalClasspaths = additionalClasspathList.toArray(new String[additionalClasspathList.size()]); + + classpath = new String[configClasspath.length + 2 + additionalClasspaths.length]; System.arraycopy(configClasspath, 0, classpath, 0, configClasspath.length); classpath[configClasspath.length] = tracerClassPath.substring(1, tracerClassPath.length() - Tracer.TRACER_CLASS_PATH.length()); classpath[configClasspath.length + 1] = bundlePath.substring(1) + Tracer.JAVASSIST_LIBRARY; + System.arraycopy(additionalClasspaths, 0, classpath, configClasspath.length + 2, additionalClasspaths.length); + + for (int i = 0; i < classpath.length; i++) { + classpath[i] = classpath[i].replace("/", File.separator); + System.out.println(String.format("classpath[%d] = %s", i, classpath[i])); + } } catch (IOException e) { classpath = configClasspath; } diff --git a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/TraceJSON.java b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/TraceJSON.java index bcaa443..b0664f9 100644 --- a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/TraceJSON.java +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/TraceJSON.java @@ -895,14 +895,14 @@ return null; } - private static TracePoint getRecentlyFieldUpdate(TracePoint tp) { - Statement statement = tp.getStatement(); - if (statement instanceof FieldAccess) { - FieldAccess fa = (FieldAccess)statement; - return getFieldUpdateTracePoint(fa.getContainerObjId(), fa.getFieldName(), tp); - } - return null; - } +// private static TracePoint getRecentlyFieldUpdate(TracePoint tp) { +// Statement statement = tp.getStatement(); +// if (statement instanceof FieldAccess) { +// FieldAccess fa = (FieldAccess)statement; +// return getFieldUpdateTracePoint(fa.getContainerObjId(), fa.getFieldName(), tp); +// } +// return null; +// } /** * �����Ŏw�肵���R���e�i�̎��“���̃t�B�[���h���Ō�ɍX�V���ꂽstatement���t�����ɒT�����āA
@@ -958,14 +958,14 @@ return null; } - private static TracePoint getRecentlyArrayUpdate(TracePoint tp) { - Statement statement = tp.getStatement(); - if (statement instanceof ArrayAccess) { - ArrayAccess aa = (ArrayAccess)statement; - return getArrayUpdateTracePoint(aa.getArrayObjectId(), aa.getIndex(), tp); - } - return null; - } +// private static TracePoint getRecentlyArrayUpdate(TracePoint tp) { +// Statement statement = tp.getStatement(); +// if (statement instanceof ArrayAccess) { +// ArrayAccess aa = (ArrayAccess)statement; +// return getArrayUpdateTracePoint(aa.getArrayObjectId(), aa.getIndex(), tp); +// } +// return null; +// } /** * �����Ŏw�肵���z��ŁA���Žw�肵���C���f�b�N�X���Ō�ɍX�V���ꂽstatement���t�����ɒT�����āA
@@ -999,186 +999,192 @@ return null; } - public static ArrayList findAllStartAlias(MethodExecution me) { - ArrayList startAliasList = new ArrayList<>(); - List statements = me.getStatements(); - String[] primitives = {"byte", "short", "int", "long", "float", "double", "char", "boolean"}; - List primitiveList = Arrays.asList(primitives); - for (int i = 0; i < statements.size(); i++) { - TracePoint tp = me.getTracePoint(i); - Statement statement = statements.get(i); - if (statement instanceof FieldAccess) { - FieldAccess fa = (FieldAccess)statement; - String objId = fa.getContainerObjId(); - if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fa.getContainerClassName()))) { - startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_CONTAINER)); - } - objId = fa.getValueObjId(); - if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fa.getValueClassName()))) { - startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_FIELD)); - } - } else if (statement instanceof FieldUpdate) { - FieldUpdate fu = (FieldUpdate)statement; - String objId = fu.getContainerObjId(); - if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fu.getContainerClassName()))) { - startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_CONTAINER)); - } - objId = fu.getValueObjId(); - if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fu.getValueClassName()))) { - startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_FIELD)); - } - } else if (statement instanceof ArrayAccess) { - ArrayAccess aa = (ArrayAccess)statement; - String valueObjId = aa.getValueObjectId(); - if (valueObjId != null && !(valueObjId.equals("0")) && !(primitiveList.contains(aa.getValueClassName()))) { - startAliasList.add(new Alias(valueObjId, tp, Alias.OCCURRENCE_EXP_ARRAY)); - } - } else if (statement instanceof ArrayUpdate) { - ArrayUpdate au = (ArrayUpdate)statement; - String valueObjId = au.getValueObjectId(); - if (valueObjId != null && !(valueObjId.equals("0")) && !(primitiveList.contains(au.getValueClassName()))) { - startAliasList.add(new Alias(valueObjId, tp, Alias.OCCURRENCE_EXP_ARRAY)); - } - } else if (statement instanceof ArrayCreate) { - ArrayCreate ac = (ArrayCreate)statement; - String arrayObjId = ac.getArrayObjectId(); - if (arrayObjId != null && !(arrayObjId.equals("0")) && !(primitiveList.contains(ac.getArrayClassName()))) { - startAliasList.add(new Alias(arrayObjId, tp, Alias.OCCURRENCE_EXP_RETURN)); - } - } else if (statement instanceof MethodInvocation) { - MethodExecution calledMe = ((MethodInvocation)statement).getCalledMethodExecution(); - String thisObjId = calledMe.getThisObjId(); - if (thisObjId != null && !(thisObjId.equals("0"))) { - startAliasList.add(new Alias(thisObjId, tp, Alias.OCCURRENCE_EXP_RECEIVER)); - } - List args = calledMe.getArguments(); - for (int j = 0; j < args.size(); j++) { - ObjectReference arg = args.get(j); - String argValueId = arg.getId(); - if (argValueId != null && !(argValueId.equals("0")) && !(primitiveList.contains(arg.getActualType()))) { - startAliasList.add(new Alias(argValueId, tp, (j + Alias.OCCURRENCE_EXP_FIRST_ARG))); - } - } - ObjectReference returnValue = calledMe.getReturnValue(); - if (returnValue != null) { - String returnValueId = returnValue.getId(); - if (returnValueId != null && !(returnValueId.equals("0") && !(primitiveList.contains(returnValue.getActualType())))) { - startAliasList.add(new Alias(returnValueId, tp, Alias.OCCURRENCE_EXP_RETURN)); - } - } - } - } - return startAliasList; - } - - public static Alias getAlias(String objectId, TracePoint occurrencePoint, int occurrenceExp) { - return new Alias(objectId, occurrencePoint, occurrenceExp); - } - - public static ArrayList> getObjectFlow(Alias startAlias) { - ArrayList> aliasLists = new ArrayList<>(); - ArrayList aliasList = new ArrayList<>(); - aliasLists.add(aliasList); -// aliasList.add(alias); - String objId = startAlias.getObjectId(); - TracePoint tp = startAlias.getOccurrencePoint().duplicate(); - ArrayList> resultLists = getObjectFlow(aliasLists, objId, tp, 0); -// for (int i = 0; i < resultLists.size(); i++) { -// ArrayList resultList = resultLists.get(i); -// System.out.println("---------------------------------------------------------"); // �m�F�p -// for (Alias alias : resultList) System.out.println(alias); // �m�F�p -// int lastAliasOccurrenceEXP = resultList.get(resultList.size() - 1).getOccurrenceExp(); -// if (lastAliasOccurrenceEXP != Alias.OCCURRENCE_EXP_RETURN) { -// resultLists.remove(resultList); // �����̃G�C���A�X���z�񐶐���R���X�g���N�^�Ăяo���ł͂Ȃ����X�g���폜���� +// public static ArrayList findAllStartAlias(MethodExecution me) { +// ArrayList startAliasList = new ArrayList<>(); +// List statements = me.getStatements(); +// String[] primitives = {"byte", "short", "int", "long", "float", "double", "char", "boolean"}; +// List primitiveList = Arrays.asList(primitives); +// for (int i = 0; i < statements.size(); i++) { +// TracePoint tp = me.getTracePoint(i); +// Statement statement = statements.get(i); +// if (statement instanceof FieldAccess) { +// FieldAccess fa = (FieldAccess)statement; +// String objId = fa.getContainerObjId(); +// if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fa.getContainerClassName()))) { +// startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_CONTAINER)); +// } +// objId = fa.getValueObjId(); +// if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fa.getValueClassName()))) { +// startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_FIELD)); +// } +// } else if (statement instanceof FieldUpdate) { +// FieldUpdate fu = (FieldUpdate)statement; +// String objId = fu.getContainerObjId(); +// if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fu.getContainerClassName()))) { +// startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_CONTAINER)); +// } +// objId = fu.getValueObjId(); +// if (objId != null && !(objId.equals("0")) && !(primitiveList.contains(fu.getValueClassName()))) { +// startAliasList.add(new Alias(objId, tp, Alias.OCCURRENCE_EXP_FIELD)); +// } +// } else if (statement instanceof ArrayAccess) { +// ArrayAccess aa = (ArrayAccess)statement; +// String valueObjId = aa.getValueObjectId(); +// if (valueObjId != null && !(valueObjId.equals("0")) && !(primitiveList.contains(aa.getValueClassName()))) { +// startAliasList.add(new Alias(valueObjId, tp, Alias.OCCURRENCE_EXP_ARRAY)); +// } +// } else if (statement instanceof ArrayUpdate) { +// ArrayUpdate au = (ArrayUpdate)statement; +// String valueObjId = au.getValueObjectId(); +// if (valueObjId != null && !(valueObjId.equals("0")) && !(primitiveList.contains(au.getValueClassName()))) { +// startAliasList.add(new Alias(valueObjId, tp, Alias.OCCURRENCE_EXP_ARRAY)); +// } +// } else if (statement instanceof ArrayCreate) { +// ArrayCreate ac = (ArrayCreate)statement; +// String arrayObjId = ac.getArrayObjectId(); +// if (arrayObjId != null && !(arrayObjId.equals("0")) && !(primitiveList.contains(ac.getArrayClassName()))) { +// startAliasList.add(new Alias(arrayObjId, tp, Alias.OCCURRENCE_EXP_RETURN)); +// } +// } else if (statement instanceof MethodInvocation) { +// MethodExecution calledMe = ((MethodInvocation)statement).getCalledMethodExecution(); +// String thisObjId = calledMe.getThisObjId(); +// if (thisObjId != null && !(thisObjId.equals("0"))) { +// startAliasList.add(new Alias(thisObjId, tp, Alias.OCCURRENCE_EXP_RECEIVER)); +// } +// List args = calledMe.getArguments(); +// for (int j = 0; j < args.size(); j++) { +// ObjectReference arg = args.get(j); +// String argValueId = arg.getId(); +// if (argValueId != null && !(argValueId.equals("0")) && !(primitiveList.contains(arg.getActualType()))) { +// startAliasList.add(new Alias(argValueId, tp, (j + Alias.OCCURRENCE_EXP_FIRST_ARG))); +// } +// } +// ObjectReference returnValue = calledMe.getReturnValue(); +// if (returnValue != null) { +// String returnValueId = returnValue.getId(); +// if (returnValueId != null && !(returnValueId.equals("0") && !(primitiveList.contains(returnValue.getActualType())))) { +// startAliasList.add(new Alias(returnValueId, tp, Alias.OCCURRENCE_EXP_RETURN)); +// } +// } // } // } - return resultLists; - } - - private static ArrayList> getObjectFlow(ArrayList> aliasLists, - String objId, TracePoint tp, int side) { - ArrayList aliasList = aliasLists.get(aliasLists.size() - 1); // ����getObjectFlow���\�b�h���s���Ō��‚������G�C���A�X�����Ă������X�g - do { - Statement statement = tp.getStatement(); - if (statement instanceof FieldAccess) { - // �t�B�[���h�Q�Ƃ̏ꍇ - FieldAccess fa = (FieldAccess)statement; - if (fa.getValueObjId().equals(objId)) { - // ���Y�n�_�ł̃G�C���A�X�����X�g�ɒlj��������, �t�B�[���h�ŏI�X�V�ɔ�ԃp�^�[���Ƃ��̂܂ܑk��p�^�[���Ƃŕ��� - aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_FIELD)); - aliasList = new ArrayList<>(aliasList); // ���X�g���̂��f�B�[�v�R�s�[���Ă���(�t�B�[���h�ŏI�X�V�ɔ�ԍċA�����I�����, ���̂܂ܑk��p�^�[���ŗp����) - TracePoint fieldUpdateTp = getRecentlyFieldUpdate(tp); - aliasLists = getObjectFlow(aliasLists, objId, fieldUpdateTp, 0); - aliasLists.add(aliasList); // �ċA�����ɓ���O�Ƀf�B�[�v�R�s�[���Ă������X�g���Ō���ɒlj� (�ȍ~�̑k��ɂ���Č��‚����G�C���A�X�͂��̃��X�g�ɓ������) - } - } else if (statement instanceof ArrayAccess) { - // �z��v�f�Q�Ƃ̏ꍇ - ArrayAccess aa = (ArrayAccess)statement; - if (aa.getValueObjectId().equals(objId)) { - aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_ARRAY)); - aliasList = new ArrayList<>(aliasList); - TracePoint arrayUpdateTp = getRecentlyArrayUpdate(tp); - aliasLists = getObjectFlow(aliasLists, objId, arrayUpdateTp, 0); - aliasLists.add(aliasList); - } - } else if (statement instanceof ArrayCreate) { - // �z�񐶐��̏ꍇ - ArrayCreate ac = (ArrayCreate)statement; - if (ac.getArrayObjectId().equals(objId)) { - aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_RETURN)); // �z�񐶐��� new �^��[] �̖߂�l - return aliasLists; // �z�񐶐��ӏ��̓G�C���A�X�̋N���Ȃ̂ł���ȑO�ɂ͂����Ȃ��͂� - } - } else if (statement instanceof MethodInvocation) { - // ���\�b�h�Ăяo���̏ꍇ - MethodExecution calledMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); - ObjectReference returnValue = calledMethodExecution.getReturnValue(); - if (returnValue.getId().equals(objId)) { - // �߂�l�ɃG�C���A�X�̃I�u�W�F�N�gID����v�����ꍇ - aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_RETURN)); - if (calledMethodExecution.isConstructor()) { - return aliasLists; // �R���X�g���N�^�Ăяo���ӏ��̓G�C���A�X�̋N���Ȃ̂ł���ȑO�ɂ͂����Ȃ��͂� - } - TracePoint exitTp = calledMethodExecution.getExitPoint(); // �Ăяo�����\�b�h���s�̍ŏI�X�e�[�g�����g���w��tp���擾 - aliasLists = getObjectFlow(aliasLists, objId, exitTp, side + 1); // �Ăяo����̃��\�b�h���s�ɐ��� - aliasList = aliasLists.get(aliasLists.size() - 1); - } - } - } while (tp.stepBackOver()); // �Ăяo�����ɖ߂邩����ȏ�H��Ȃ��Ȃ�܂Ń��[�v - if (!tp.isValid()) { - return aliasLists; // ����ȏチ�\�b�h���s��k��Ȃ��ꍇ(main���\�b�h�̂���ɑO�Ȃ�)�͂��̎��_�ŏI�� - } - // --- ���̎��_�� tracePoint�� �Ăяo�������w���Ă��� (���O�܂ők���Ă������\�b�h���s�ɂ‚��Ẵ��\�b�h�Ăяo�����w���Ă���) --- - MethodExecution calledMethodExecution = ((MethodInvocation)tp.getStatement()).getCalledMethodExecution(); - ArrayList args = calledMethodExecution.getArguments(); - for (int i = 0; i < args.size(); i++) { - if (args.get(i).getId().equals(objId)) { - // ���\�b�h�Ăяo���̎������ɃG�C���A�X�̃I�u�W�F�N�gID����v�����ꍇ - aliasList.add(new Alias(objId, tp.duplicate(), (i + Alias.OCCURRENCE_EXP_FIRST_ARG))); - if (side == 0) { - // �T���J�n���\�b�h���s�܂��̓t�B�[���h��z��v�f�̍ŏI�X�V�T���Ŕ�񂾐�̃��\�b�h���s����, �X�^�b�N�g���[�X�ł��ǂ��S���\�b�h���s�̏ꍇ - TracePoint previousTp = tp.duplicate(); - previousTp.stepBackOver(); - aliasLists = getObjectFlow(aliasLists, objId, previousTp, 0); // �Ăяo�����̃��\�b�h���s�ɖ߂� - } - } - } - return aliasLists; - } +// return startAliasList; +// } +// +// public static Alias getAlias(String objectId, TracePoint occurrencePoint, int occurrenceExp) { +// return new Alias(objectId, occurrencePoint, occurrenceExp); +// } +// +// public static ArrayList> getObjectFlow(Alias startAlias) { +// ArrayList> aliasLists = new ArrayList<>(); +// ArrayList aliasList = new ArrayList<>(); +// aliasLists.add(aliasList); +//// aliasList.add(alias); +// String objId = startAlias.getObjectId(); +// TracePoint tp = startAlias.getOccurrencePoint().duplicate(); +// ArrayList> resultLists = getObjectFlow(aliasLists, objId, tp, 0); +//// for (int i = 0; i < resultLists.size(); i++) { +//// ArrayList resultList = resultLists.get(i); +//// System.out.println("---------------------------------------------------------"); // �m�F�p +//// for (Alias alias : resultList) System.out.println(alias); // �m�F�p +//// int lastAliasOccurrenceEXP = resultList.get(resultList.size() - 1).getOccurrenceExp(); +//// if (lastAliasOccurrenceEXP != Alias.OCCURRENCE_EXP_RETURN) { +//// resultLists.remove(resultList); // �����̃G�C���A�X���z�񐶐���R���X�g���N�^�Ăяo���ł͂Ȃ����X�g���폜���� +//// } +//// } +// return resultLists; +// } +// +// private static ArrayList> getObjectFlow(ArrayList> aliasLists, +// String objId, TracePoint tp, int side) { +// ArrayList aliasList = aliasLists.get(aliasLists.size() - 1); // ����getObjectFlow���\�b�h���s���Ō��‚������G�C���A�X�����Ă������X�g +// do { +// Statement statement = tp.getStatement(); +// if (statement instanceof FieldAccess) { +// // �t�B�[���h�Q�Ƃ̏ꍇ +// FieldAccess fa = (FieldAccess)statement; +// if (fa.getValueObjId().equals(objId)) { +// // ���Y�n�_�ł̃G�C���A�X�����X�g�ɒlj��������, �t�B�[���h�ŏI�X�V�ɔ�ԃp�^�[���Ƃ��̂܂ܑk��p�^�[���Ƃŕ��� +// aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_FIELD)); +// aliasList = new ArrayList<>(aliasList); // ���X�g���̂��f�B�[�v�R�s�[���Ă���(�t�B�[���h�ŏI�X�V�ɔ�ԍċA�����I�����, ���̂܂ܑk��p�^�[���ŗp����) +// TracePoint fieldUpdateTp = getRecentlyFieldUpdate(tp); +// aliasLists = getObjectFlow(aliasLists, objId, fieldUpdateTp, 0); +// aliasLists.add(aliasList); // �ċA�����ɓ���O�Ƀf�B�[�v�R�s�[���Ă������X�g���Ō���ɒlj� (�ȍ~�̑k��ɂ���Č��‚����G�C���A�X�͂��̃��X�g�ɓ������) +// } +// } else if (statement instanceof ArrayAccess) { +// // �z��v�f�Q�Ƃ̏ꍇ +// ArrayAccess aa = (ArrayAccess)statement; +// if (aa.getValueObjectId().equals(objId)) { +// aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_ARRAY)); +// aliasList = new ArrayList<>(aliasList); +// TracePoint arrayUpdateTp = getRecentlyArrayUpdate(tp); +// aliasLists = getObjectFlow(aliasLists, objId, arrayUpdateTp, 0); +// aliasLists.add(aliasList); +// } +// } else if (statement instanceof ArrayCreate) { +// // �z�񐶐��̏ꍇ +// ArrayCreate ac = (ArrayCreate)statement; +// if (ac.getArrayObjectId().equals(objId)) { +// aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_RETURN)); // �z�񐶐��� new �^��[] �̖߂�l +// return aliasLists; // �z�񐶐��ӏ��̓G�C���A�X�̋N���Ȃ̂ł���ȑO�ɂ͂����Ȃ��͂� +// } +// } else if (statement instanceof MethodInvocation) { +// // ���\�b�h�Ăяo���̏ꍇ +// MethodExecution calledMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); +// ObjectReference returnValue = calledMethodExecution.getReturnValue(); +// if (returnValue.getId().equals(objId)) { +// // �߂�l�ɃG�C���A�X�̃I�u�W�F�N�gID����v�����ꍇ +// aliasList.add(new Alias(objId, tp.duplicate(), Alias.OCCURRENCE_EXP_RETURN)); +// if (calledMethodExecution.isConstructor()) { +// return aliasLists; // �R���X�g���N�^�Ăяo���ӏ��̓G�C���A�X�̋N���Ȃ̂ł���ȑO�ɂ͂����Ȃ��͂� +// } +// TracePoint exitTp = calledMethodExecution.getExitPoint(); // �Ăяo�����\�b�h���s�̍ŏI�X�e�[�g�����g���w��tp���擾 +// aliasLists = getObjectFlow(aliasLists, objId, exitTp, side + 1); // �Ăяo����̃��\�b�h���s�ɐ��� +// aliasList = aliasLists.get(aliasLists.size() - 1); +// } +// } +// } while (tp.stepBackOver()); // �Ăяo�����ɖ߂邩����ȏ�H��Ȃ��Ȃ�܂Ń��[�v +// if (!tp.isValid()) { +// return aliasLists; // ����ȏチ�\�b�h���s��k��Ȃ��ꍇ(main���\�b�h�̂���ɑO�Ȃ�)�͂��̎��_�ŏI�� +// } +// // --- ���̎��_�� tracePoint�� �Ăяo�������w���Ă��� (���O�܂ők���Ă������\�b�h���s�ɂ‚��Ẵ��\�b�h�Ăяo�����w���Ă���) --- +// MethodExecution calledMethodExecution = ((MethodInvocation)tp.getStatement()).getCalledMethodExecution(); +// ArrayList args = calledMethodExecution.getArguments(); +// for (int i = 0; i < args.size(); i++) { +// if (args.get(i).getId().equals(objId)) { +// // ���\�b�h�Ăяo���̎������ɃG�C���A�X�̃I�u�W�F�N�gID����v�����ꍇ +// aliasList.add(new Alias(objId, tp.duplicate(), (i + Alias.OCCURRENCE_EXP_FIRST_ARG))); +// if (side == 0) { +// // �T���J�n���\�b�h���s�܂��̓t�B�[���h��z��v�f�̍ŏI�X�V�T���Ŕ�񂾐�̃��\�b�h���s����, �X�^�b�N�g���[�X�ł��ǂ��S���\�b�h���s�̏ꍇ +// TracePoint previousTp = tp.duplicate(); +// previousTp.stepBackOver(); +// aliasLists = getObjectFlow(aliasLists, objId, previousTp, 0); // �Ăяo�����̃��\�b�h���s�ɖ߂� +// } +// } +// } +// return aliasLists; +// } +// +// public static int countMethodExecutionInTraceCollector(List methodExecutions, String targetSignature, int count, String indent) { +// if (methodExecutions == null || methodExecutions.isEmpty()) { +// return count; +// } +// for (int i = 0; i < methodExecutions.size(); i++) { +// MethodExecution me = methodExecutions.get(i); +// String signature = me.getSignature(); +//// System.out.println(indent + signature); +// if (targetSignature.equals(signature)) { +// count++; +// } +// List children = me.getChildren(); +// count = countMethodExecutionInTraceCollector(children, targetSignature, count, indent + "--------"); +// } +// return count; +// } - public static int countMethodExecutionInTraceCollector(List methodExecutions, String targetSignature, int count, String indent) { - if (methodExecutions == null || methodExecutions.isEmpty()) { - return count; - } - for (int i = 0; i < methodExecutions.size(); i++) { - MethodExecution me = methodExecutions.get(i); - String signature = me.getSignature(); -// System.out.println(indent + signature); - if (targetSignature.equals(signature)) { - count++; - } - List children = me.getChildren(); - count = countMethodExecutionInTraceCollector(children, targetSignature, count, indent + "--------"); - } - return count; + public static void test() { + System.out.println("Hello TraceJSON"); + System.out.println(getInstance().classes); + System.out.println("Bye TraceJSON"); } }