diff --git a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/Variables.java b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/Variables.java index c7776de..e3d1cb3 100644 --- a/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/Variables.java +++ b/org.ntlab.reverseDebugger/src/org/ntlab/reverseDebugger/Variables.java @@ -67,8 +67,7 @@ mc.changeReceiver(statements); int lastOrder = ((IntegerValue)mc.callInstanceMethod("size")).value() - 1; mc.changeReceiver(method); - ObjectReference tp = (ObjectReference)mc.callInstanceMethod("getTracePoint", vm.mirrorOf(lastOrder)); -// methodExecution.getTracePoint(methodExecution.getStatements().size() - 1); + ObjectReference tp = (ObjectReference)mc.callInstanceMethod("getTracePoint", vm.mirrorOf(lastOrder)); getAllObjectData(vm, thread, method, tp); } catch (InvalidTypeException | ClassNotLoadedException @@ -151,41 +150,45 @@ thisObjData.addChild(fieldData); // �擾�����t�B�[���h���I�u�W�F�N�g��z��̏ꍇ�ɁA���̃I�u�W�F�N�g��z�񂪎��ƒt�B�[���h�ɂ‚��Ă̏������s�� - callDeepHierarchyFieldState(vm, thread, fieldData, tp, (indent + " ")); + switch (checkDeepHierarchy(fieldData)) { + case NONE: break; + case FIELD: getFieldsState(vm, thread, fieldData, tp, indent); break; + case ARRAY: getArrayState(vm, thread, fieldData, tp, indent); break; + } } } catch (JavaModelException e) { e.printStackTrace(); } } - + /** * �����œn�����t�B�[���h���Q�ƌ^�̏ꍇ��A�z��̏ꍇ�ɁA
* ���̎Q�ƌ^�I�u�W�F�N�g�������Ă���t�B�[���h��A�z��̊e�v�f�̃I�u�W�F�N�g�ɂ‚��āA
* ���ꂼ��ɑΉ��������\�b�h������ɌĂяo�� (���̃��\�b�h�ƑΉ����\�b�h�Ƃ̑��ݍċA) */ - private void callDeepHierarchyFieldState(VirtualMachine vm, ThreadReference thread, VariableData thisObjData, Value tp, String indent) - throws InvalidTypeException, ClassNotLoadedException, InvocationException, IncompatibleThreadStateException { + private DeepHierarchy checkDeepHierarchy(VariableData objData) { // �t�B�[���h��ID��Type���Ȃ��ꍇ��AType(=ActualType)��"---"�̏ꍇ�͉������Ȃ� - if (thisObjData.getId() == null || thisObjData.getId().isEmpty() - || thisObjData.getClassName() == null || thisObjData.getClassName().isEmpty()) { - return; + if (objData.getId() == null || objData.getId().isEmpty() + || objData.getClassName() == null || objData.getClassName().isEmpty()) { + return DeepHierarchy.NONE; } final String NULL_ACTUAL_TYPE = "---"; // �t�B�[���h�ɑ΂��Ė����I��null����ꂽ�ꍇ��ActualType�̎擾������ - if (thisObjData.getClassName().equals(NULL_ACTUAL_TYPE)) return; + if (objData.getClassName().equals(NULL_ACTUAL_TYPE)) return DeepHierarchy.NONE; final String ARRAY_SIGNATURE_HEAD = "["; // �z��̃V�O�l�`���̐擪�́A�z��̎��������� [ ���A�Ȃ� - if (thisObjData.getClassName().startsWith(ARRAY_SIGNATURE_HEAD)) { + if (objData.getClassName().startsWith(ARRAY_SIGNATURE_HEAD)) { // �t�B�[���h��Type���z��^(�@[ �Ŏn�܂�@)�ꍇ (���̔z�񂪎��Še�v�f�ɂ‚��Ă���Ȃ�f�[�^�擾�������Ăяo��) - getArrayState(vm, thread, thisObjData, tp, indent); + return DeepHierarchy.ARRAY; } else { String[] primitives = {"byte", "short", "int", "long", "float", "double", "char", "boolean"}; - if (!Arrays.asList(primitives).contains(thisObjData.getClassName())) { + if (!Arrays.asList(primitives).contains(objData.getClassName())) { // �t�B�[���h��Type���Q�ƌ^(=�I�u�W�F�N�g)�̏ꍇ (���̃I�u�W�F�N�g�������Ă���t�B�[���h�ɂ‚��Ă���Ȃ�f�[�^�擾�������Ăяo��) - getFieldsState(vm, thread, thisObjData, tp, indent); + return DeepHierarchy.FIELD; } } + return DeepHierarchy.NONE; } - + private void getArrayState(VirtualMachine vm, ThreadReference thread, VariableData arrayData, Value tp, String indent) throws InvalidTypeException, ClassNotLoadedException, InvocationException, IncompatibleThreadStateException { JDIInstanceMethodCaller mc = new JDIInstanceMethodCaller(vm, thread, null); @@ -210,7 +213,11 @@ arrayData.addChild(arrayIndexData); // �擾�����z��v�f���I�u�W�F�N�g��z��̏ꍇ�ɁA���̃I�u�W�F�N�g��z�񂪎��ƒt�B�[���h�ɂ‚��Ă̏������s�� - callDeepHierarchyFieldState(vm, thread, arrayIndexData, tp, (indent + " ")); + switch (checkDeepHierarchy(arrayIndexData)) { + case NONE: break; + case FIELD: getFieldsState(vm, thread, arrayIndexData, tp, indent); break; + case ARRAY: getArrayState(vm, thread, arrayIndexData, tp, indent); break; + } } } @@ -236,7 +243,11 @@ String argType = ((StringReference)mc.callInstanceMethod("getActualType")).value(); VariableData argData = new VariableData(argName, argType, argId); argsData.add(argData); - callDeepHierarchyFieldState(vm, thread, argData, tp, (indent + " ")); + switch (checkDeepHierarchy(argData)) { + case NONE: break; + case FIELD: getFieldsState(vm, thread, argData, tp, indent); break; + case ARRAY: getArrayState(vm, thread, argData, tp, indent); break; + } } } } @@ -281,6 +292,10 @@ printObjData(child, indent + " "); } } + + private enum DeepHierarchy { + NONE, FIELD, ARRAY; + } } class VariableData {