diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIInstanceMethodCaller.java b/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIInstanceMethodCaller.java index 6b188da..ae279eb 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIInstanceMethodCaller.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIInstanceMethodCaller.java @@ -43,6 +43,6 @@ ClassType type = (ClassType)receiver.type(); List methodsByName = type.methodsByName(methodName); List argList = Arrays.asList(args); // ���\�b�h�ɓn�������̃��X�g - return receiver.invokeMethod(thread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED); // �f�o�b�O���̃v���O�������̃��\�b�h���Ăяo�� + return receiver.invokeMethod(onlineAnalysisThread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED); // �f�o�b�O���̃v���O�������̃��\�b�h���Ăяo�� } } diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIStaticMethodCaller.java b/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIStaticMethodCaller.java index 29d469e..311515a 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIStaticMethodCaller.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/onlineAccessor/JDIStaticMethodCaller.java @@ -19,11 +19,13 @@ @SuppressWarnings("restriction") public class JDIStaticMethodCaller { protected VirtualMachine vm; - protected ThreadReference thread; + protected ThreadReference targetThread; + protected static ThreadReference onlineAnalysisThread; public JDIStaticMethodCaller(VirtualMachine vm, ThreadReference thread) { this.vm = vm; - this.thread = thread; + this.targetThread = thread; +// this.targetThread = null; } public VirtualMachine getVm() { @@ -31,21 +33,30 @@ } public ThreadReference getThread() { - return thread; + return targetThread; +// return onlineAnalysisThread; } - + public long getThreadId() { - ClassType type = (ClassType)thread.type(); + ClassType type = (ClassType)targetThread.type(); List methodsByName = type.methodsByName("getId"); List argList = new ArrayList<>(); try { - return ((LongValue)thread.invokeMethod(thread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED)).value(); + return ((LongValue)targetThread.invokeMethod(onlineAnalysisThread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED)).value(); } catch (InvalidTypeException | ClassNotLoadedException | IncompatibleThreadStateException | InvocationException e) { e.printStackTrace(); } throw new IllegalStateException(); } + + public static ThreadReference getOnlineAnalysisThread() { + return onlineAnalysisThread; + } + + public static void setOnlineAnalysisThread(ThreadReference onlineAnalysisThread) { + JDIStaticMethodCaller.onlineAnalysisThread = onlineAnalysisThread; + } /** * �p�b�P�[�W���ƃN���X���ƃ��\�b�h���ƈ������w�肵�Ă��̃N���X���\�b�h���Ăяo�� @@ -67,12 +78,12 @@ List methodsByName = type.methodsByName("forName"); List argList = new ArrayList<>(); argList.add(vm.mirrorOf(fqcn)); - type.invokeMethod(thread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED); + type.invokeMethod(onlineAnalysisThread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED); classes = vm.classesByName(fqcn); // �N���X�� (���S����N���X��) } ClassType type = (ClassType)classes.get(0); List methodsByName = type.methodsByName(methodName); List argList = Arrays.asList(args); // ���\�b�h�ɓn�������̃��X�g - return type.invokeMethod(thread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED); // �f�o�b�O���̃v���O�������̃��\�b�h���Ăяo�� + return type.invokeMethod(onlineAnalysisThread, methodsByName.get(0), argList, ThreadReference.INVOKE_SINGLE_THREADED); // �f�o�b�O���̃v���O�������̃��\�b�h���Ăяo�� } } diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModel.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModel.java index 938c655..b796011 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModel.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModel.java @@ -29,10 +29,6 @@ return methodExecutionMc.getVm(); } - public ThreadReference getThread() { - return methodExecutionMc.getThread(); - } - public JDIInstanceMethodCaller getMethodCaller() { return methodExecutionMc; } diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModels.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModels.java index c7d6956..22571e6 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModels.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/CallStackModels.java @@ -146,7 +146,11 @@ mc.changeReceiver(iterator); boolean hasNext = ((BooleanValue)mc.callInstanceMethod("hasNext")).value(); while (hasNext) { StringReference threadId = (StringReference)mc.callInstanceMethod("next"); - if (threadId.value().equals(debuggingThreadId)) continue; + if (threadId.value().equals(debuggingThreadId)) { + mc.changeReceiver(iterator); + hasNext = ((BooleanValue)mc.callInstanceMethod("hasNext")).value(); + continue; + } ObjectReference start = getStart(vm, thread, allThreads, threadId); mc.changeReceiver(traceJSON); diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java index 55780c9..a4c4dd9 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/JavaEditorOperator.java @@ -140,7 +140,7 @@ JDIInstanceMethodCaller classInfoMethodCaller = new JDIInstanceMethodCaller(meCaller.getVm(), meCaller.getThread(), classInfo); String path = ((StringReference)classInfoMethodCaller.callInstanceMethod("getPath")).value(); String declaringClassNameString = declaringClassName.value().replace(".", "/"); - loaderPath = path.substring(0, path.indexOf(declaringClassNameString)); // path����N���X�̊��S���薼�ȍ~��S�ĊO�������̂�projectPath�ɂ��Ă݂� + loaderPath = path.substring(0, path.lastIndexOf(declaringClassNameString)); // path����N���X�̊��S���薼�ȍ~��S�ĊO�������̂�projectPath�ɂ��Ă݂� } return loaderPath; } diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java index 31bb379..96963c2 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/SeedAliases.java @@ -5,6 +5,7 @@ import org.ntlab.onlineAccessor.JDIDebuggingVirtualMachine; import org.ntlab.onlineAccessor.JDIInstanceMethodCaller; +import org.ntlab.onlineAccessor.JDIStaticMethodCaller; import org.ntlab.onlineAccessor.NotDebuggedException; import org.ntlab.onlineAccessor.NotExecutedException; import org.ntlab.onlineAccessor.NotSuspendedException; @@ -52,34 +53,60 @@ public void reset() { seedAliases.clear(); } - + public void initSeedAliases() { try { VirtualMachine vm = JDIDebuggingVirtualMachine.getDebuggineVirtualMachine(); List allThreads = vm.allThreads(); + ThreadReference onlineAnalysisThread = null; + ThreadReference targetThread = null; for (int i = 0; i < allThreads.size(); i++) { ThreadReference thread = allThreads.get(i); - if (thread.isSuspended() && !(thread.name().equals("OnlineAnalysisThread"))) { - createSeedAliases(vm, thread); + if (thread.isSuspended()) { + if (thread.name().equals("OnlineAnalysisThread")) { + onlineAnalysisThread = thread; + JDIStaticMethodCaller.setOnlineAnalysisThread(onlineAnalysisThread); + } else if (targetThread == null) { + targetThread = thread; + } } - } + if (onlineAnalysisThread != null && targetThread != null) { + System.out.println("createSeedAliases"); + createSeedAliases(vm, targetThread); + break; + } + } } catch (NotExecutedException | NotSuspendedException | NotDebuggedException e) { e.printStackTrace(); } } + +// public void initSeedAliases() { +// try { +// VirtualMachine vm = JDIDebuggingVirtualMachine.getDebuggineVirtualMachine(); +// List allThreads = vm.allThreads(); +// for (int i = 0; i < allThreads.size(); i++) { +// ThreadReference thread = allThreads.get(i); +// if (thread.isSuspended() && !(thread.name().equals("OnlineAnalysisThread"))) { +// createSeedAliases(vm, thread); +// } +// } +// } catch (NotExecutedException | NotSuspendedException | NotDebuggedException e) { +// e.printStackTrace(); +// } +// } /** * ���݃f�o�b�K�Ŏ~�܂��Ă���n�_�ł̃��\�b�h���s���̑S�V�[�h�G�C���A�X�ꗗ���Z�b�g���� * @param vm - * @param thread + * @param onlineAnalysisThread */ private void createSeedAliases(VirtualMachine vm, ThreadReference thread) { JDIInstanceMethodCaller mc = new JDIInstanceMethodCaller(vm, thread, thread); try { // threadId�̎擾��StringReference�^�ւ̕ϊ� -// Value threadIdValue = mc.changeReceiver(thread).callInstanceMethod("getId"); - Value threadIdValue = vm.mirrorOf(mc.getThreadId()); - StringReference threadId = vm.mirrorOf(String.valueOf(((LongValue)threadIdValue).value())); + long threadIdValue = ((LongValue)mc.callInstanceMethod("getId")).value(); + StringReference threadId = vm.mirrorOf(String.valueOf(threadIdValue)); // threadId�ɑΉ�����ThreadInstance���擾 ObjectReference threadInstance = (ObjectReference)mc.callStaticMethod(TRACER, "TraceJSON", "getThreadInstance", threadId);