diff --git a/org.ntlab.sampleAnalyzer/log.csv b/org.ntlab.sampleAnalyzer/log.csv index e2600a8..3085616 100644 --- a/org.ntlab.sampleAnalyzer/log.csv +++ b/org.ntlab.sampleAnalyzer/log.csv @@ -1,4 +1,4 @@ -!SESSION 2018-09-25 12:48:51.296 ----------------------------------------------- +!SESSION 2018-10-12 11:27:37.661 ----------------------------------------------- eclipse.buildId=4.4.2.M20150204-1700 java.version=1.8.0_144 java.vendor=Oracle Corporation @@ -6,7 +6,7 @@ Framework arguments: -product org.eclipse.platform.ide Command-line arguments: -product org.eclipse.platform.ide -data C:\Users\student\workspace/../runtime-EclipseApplication -dev file:C:/Users/student/workspace/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -!ENTRY org.eclipse.egit.ui 2 0 2018-09-25 12:49:12.415 +!ENTRY org.eclipse.egit.ui 2 0 2018-10-12 11:27:56.955 !MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory. The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in @@ -14,26 +14,18 @@ Team > Git > Configuration preference page's 'System Settings' tab. This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. -!ENTRY org.eclipse.egit.ui 2 0 2018-09-25 12:49:12.415 +!ENTRY org.eclipse.egit.ui 2 0 2018-10-12 11:27:56.959 !MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git user global configuration and to define the default location to store repositories: 'C:\Users\student'. If this is not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and EGit might behave differently since they see different configuration options. This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. -C:/Users/student/runtime-EclipseApplication/ObjectFlowTest2/bin:A -C:/Users/student/runtime-EclipseApplication/ObjectFlowTest2/bin:B -C:/Users/student/runtime-EclipseApplication/ObjectFlowTest2/bin:Main -classpath[0] = C:\Users\student\runtime-EclipseApplication\ObjectFlowTest2\bin -classpath[1] = C:\Users\student\Downloads\eclipse-rcp-luna-SR2-win32-x86_64\eclipse\..\..\..\git\org.ntlab.traceCollector\org.ntlab.traceCollector\bin\ -classpath[2] = C:\Users\student\Downloads\eclipse-rcp-luna-SR2-win32-x86_64\eclipse\..\..\..\git\org.ntlab.traceCollector\org.ntlab.traceCollector\javassist.jar -classpath[3] = C:\Users\student\Downloads\eclipse-rcp-luna-SR2-win32-x86_64\eclipse\..\..\..\git\org.ntlab.reverseDebugger\org.ntlab.reverseDebugger\bin\ -classpath[4] = C:\Users\student\Downloads\eclipse-rcp-luna-SR2-win32-x86_64\eclipse\..\..\..\git\org.ntlab.sampleAnalyzer\org.ntlab.sampleAnalyzer\bin\ -Main (4):org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget@adabe38SampleAnalyzer OK! -targetSignature: public B Main.getB() -Exp (Target),45171289 -Main (4):org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget@adabe38SampleAnalyzer OK! -targetSignature: public B Main.getB() -Exp (Target),2762511 -Main (4):org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget@adabe38SampleAnalyzer OK! -targetSignature: public B Main.getB() -Exp (Target),2548553 +11:29:06.168 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\student\runtime-EclipseApplication\.recommenders\repository\http___download_eclipse_org_recommenders_models_luna_ +11:29:07.805 [Worker-6] DEBUG o.e.a.i.i.DefaultTransporterProvider - Using transporter HttpTransporter from org.eclipse.osgi.internal.loader.EquinoxClassLoader@64903a20[org.eclipse.aether.transport.http:1.0.1.v20141111(id=60)] with priority 5.0 for http://download.eclipse.org/recommenders/models/luna/ +11:29:07.808 [Worker-6] DEBUG o.e.a.i.i.DefaultRepositoryConnectorProvider - Using connector BasicRepositoryConnector from org.eclipse.osgi.internal.loader.EquinoxClassLoader@2ba0b7cf[org.eclipse.aether.connector.basic:1.0.1.v20141111(id=55)] with priority 0.0 for http://download.eclipse.org/recommenders/models/luna/ +11:29:08.736 [Worker-6] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Writing tracking file C:\Users\student\runtime-EclipseApplication\.recommenders\repository\http___download_eclipse_org_recommenders_models_luna_\org\eclipse\recommenders\index\0.0.0-SNAPSHOT\resolver-status.properties +11:29:08.766 [Worker-4] DEBUG o.e.a.i.i.DefaultTransporterProvider - Using transporter HttpTransporter from org.eclipse.osgi.internal.loader.EquinoxClassLoader@64903a20[org.eclipse.aether.transport.http:1.0.1.v20141111(id=60)] with priority 5.0 for http://download.eclipse.org/recommenders/models/luna/ +11:29:08.767 [Worker-4] DEBUG o.e.a.i.i.DefaultRepositoryConnectorProvider - Using connector BasicRepositoryConnector from org.eclipse.osgi.internal.loader.EquinoxClassLoader@2ba0b7cf[org.eclipse.aether.connector.basic:1.0.1.v20141111(id=55)] with priority 0.0 for http://download.eclipse.org/recommenders/models/luna/ +11:29:09.313 [Worker-4] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Writing tracking file C:\Users\student\runtime-EclipseApplication\.recommenders\repository\http___download_eclipse_org_recommenders_models_luna_\jre\jre\1.0.0-SNAPSHOT\resolver-status.properties +11:54:05.565 [main] DEBUG o.e.r.c.r.p.ProposalCollectingCompletionRequestor - Pb(623) The method getPasswordAuthentication() of type jEdit.FirewallAuthenticator must override a superclass method +11:54:06.101 [Worker-13] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Skipped remote request for jre:jre:1.0.0-SNAPSHOT/maven-metadata.xml, locally cached metadata up-to-date. diff --git a/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/SampleAnalyzeAction.java b/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/SampleAnalyzeAction.java index 297cda6..c45355f 100644 --- a/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/SampleAnalyzeAction.java +++ b/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/SampleAnalyzeAction.java @@ -2,8 +2,10 @@ import java.util.List; +import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.dom.Message; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; @@ -20,6 +22,8 @@ import com.sun.jdi.IntegerValue; import com.sun.jdi.InvalidTypeException; import com.sun.jdi.InvocationException; +import com.sun.jdi.Location; +import com.sun.jdi.Method; import com.sun.jdi.ObjectReference; import com.sun.jdi.StringReference; import com.sun.jdi.ThreadReference; @@ -62,29 +66,52 @@ } - public void countMethodExecutionTest(VirtualMachine vm, ThreadReference thread) { + private void countMethodExecutionTest(VirtualMachine vm, ThreadReference thread) { JDIInstanceMethodCaller mc = new JDIInstanceMethodCaller(vm, thread, null); try { StringReference threadId = mc.getVm().mirrorOf(String.valueOf(mc.getThreadId())); ObjectReference threadInstance = (ObjectReference)mc.callStaticMethod(SampleAnalyzerLaunchConfiguration.TRACE, "TraceJSON", "getThreadInstance", threadId); ObjectReference roots = (ObjectReference)mc.changeReceiver(threadInstance).callInstanceMethod("getRoot"); - ObjectReference currentMe = (ObjectReference)mc.callInstanceMethod("getCurrentMethodExecution"); - String targetSignature = ((StringReference)mc.changeReceiver(currentMe).callInstanceMethod("getSignature")).value(); - - System.out.println("targetSignature: " + targetSignature); -// test(mc, roots, targetSignature, SpeedTestType.ANALYZER); // �ꎟ��͂��A�i���C�U���ōs�� - test(mc, roots, targetSignature, SpeedTestType.TARGET); // �ꎟ��͂�Ώۃv���O�������ōs�� + + Method method = thread.frame(0).location().method(); + String targetSignature = createMethodSignature(method); + System.out.println("targetSignature: " + targetSignature); + test(vm, thread, roots, targetSignature, SpeedTestType.TARGET); // �ꎟ��͂�Ώۃv���O�������ōs�� + test(vm, thread, roots, targetSignature, SpeedTestType.ANALYZER); // �ꎟ��͂��A�i���C�U���ōs�� } catch (InvalidTypeException | ClassNotLoadedException | InvocationException | IncompatibleThreadStateException e) { e.printStackTrace(); } } + + private String createMethodSignature(Method method) { + String fqcn = method.declaringType().name(); + String methodName = method.name(); + String signature = Signature.toString(method.signature()); + String[] signatureSplit = signature.split("\\s+", 2); // �߂�l�̌^�ƈ������X�g(���[�Ɋ��ʂ‚�)�ɕ��� + String returnType = signatureSplit[0]; + String args = signatureSplit[1].replace("/", ".").replace(" ", ""); // ������FQCN�̋�؂�̒u����, ��ˆ�‚̈����̊Ԃɂ���X�y�[�X���Ȃ��� + + StringBuilder methodSignature = new StringBuilder(); + if (method.isPublic()) methodSignature.append("public "); + else if (method.isPrivate()) methodSignature.append("private "); + else if (method.isProtected()) methodSignature.append("protected "); + if (method.isStatic()) methodSignature.append("static "); + if (method.isFinal()) methodSignature.append("final "); + if (method.isSynchronized()) methodSignature.append("synchronized "); + + if (!(method.isConstructor())) methodSignature.append(returnType + " "); + methodSignature.append(fqcn); + if (!(method.isConstructor())) methodSignature.append("." + methodName); + methodSignature.append(args); + return methodSignature.toString(); + } - private void test(JDIInstanceMethodCaller mc, ObjectReference roots, String targetSignature, SpeedTestType type) + private void test(VirtualMachine vm, ThreadReference thread, ObjectReference roots, String targetSignature, SpeedTestType type) throws InvalidTypeException, ClassNotLoadedException, InvocationException, IncompatibleThreadStateException { int count = 0; long beforeTime = 0, afterTime = 0; - mc.changeReceiver(roots); + JDIInstanceMethodCaller mc = new JDIInstanceMethodCaller(vm, thread, roots); switch (type) { case ANALYZER: beforeTime = System.nanoTime(); @@ -102,12 +129,12 @@ StringBuilder result = new StringBuilder(); String lineSeparator = System.lineSeparator(); String title = "Sample Analyze Result"; - result.append(title); result.append(lineSeparator); + result.append(title); result.append(lineSeparator); result.append("(executed within " + type.getTypeName() + ")"); result.append(lineSeparator); result.append(System.lineSeparator()); - result.append("signature: " + targetSignature); result.append(lineSeparator); - result.append("count: " + count); result.append(lineSeparator); - result.append("time: " + executionTime + " nsec"); result.append(lineSeparator); + result.append("signature: " + targetSignature); result.append(lineSeparator); + result.append("count: " + count); result.append(lineSeparator); + result.append("time: " + executionTime + " nsec"); result.append(lineSeparator); MessageDialog.openInformation(null, title, result.toString()); } @@ -134,7 +161,7 @@ IntegerValue index = vm.mirrorOf(i); ObjectReference methodExecution = (ObjectReference)mc.changeReceiver(methodExecutions).callInstanceMethod("get", index); String signature = ((StringReference)mc.changeReceiver(methodExecution).callInstanceMethod("getSignature")).value(); -// System.out.println(indent + signature); + System.out.println(indent + signature); if (targetSignature.equals(signature)) { count++; } diff --git a/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/analyzerProvider/SampleAnalyzer.java b/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/analyzerProvider/SampleAnalyzer.java index bcf6039..c317aed 100644 --- a/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/analyzerProvider/SampleAnalyzer.java +++ b/org.ntlab.sampleAnalyzer/src/org/ntlab/sampleanalyzer/analyzerProvider/SampleAnalyzer.java @@ -13,7 +13,7 @@ for (int i = 0; i < methodExecutions.size(); i++) { MethodExecution me = methodExecutions.get(i); String signature = me.getSignature(); -// System.out.println(indent + signature); + System.out.println(indent + signature); if (targetSignature.equals(signature)) { count++; }