diff --git a/src/org/ntlab/traceDebugger/BreakPointLabelProvider.java b/src/org/ntlab/traceDebugger/BreakPointLabelProvider.java index 0712e66..c9bf97c 100644 --- a/src/org/ntlab/traceDebugger/BreakPointLabelProvider.java +++ b/src/org/ntlab/traceDebugger/BreakPointLabelProvider.java @@ -1,40 +1,39 @@ -package org.ntlab.traceDebugger; - -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; - -public class BreakPointLabelProvider extends LabelProvider implements ITableLabelProvider { - - @Override - public String getColumnText(Object element, int columnIndex) { - if (element instanceof TraceBreakPoint) { - TraceBreakPoint tbp = (TraceBreakPoint)element; - switch (columnIndex) { - case 0: -// return tbp.isAvailable() ? "True" : "False"; - return ""; - case 1: - return String.valueOf(tbp.getLineNo()); - case 2: - return tbp.getReadableSignature(); - } - } - return "�e�X�g�p�e�L�X�g" + columnIndex; - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0 && element instanceof TraceBreakPoint) { - TraceBreakPoint tbp = (TraceBreakPoint)element; - if (tbp.isAvailable()) { - return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT); - } else { - return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED); - } - } - return null; - } -} +package org.ntlab.traceDebugger; + +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +public class BreakPointLabelProvider extends LabelProvider implements ITableLabelProvider { + + @Override + public String getColumnText(Object element, int columnIndex) { + if (element instanceof TraceBreakPoint) { + TraceBreakPoint tbp = (TraceBreakPoint)element; + switch (columnIndex) { + case 0: + return ""; + case 1: + return String.valueOf(tbp.getLineNo()); + case 2: + return tbp.getReadableSignature(); + } + } + return "�e�X�g�p�e�L�X�g" + columnIndex; + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (columnIndex == 0 && element instanceof TraceBreakPoint) { + TraceBreakPoint tbp = (TraceBreakPoint)element; + if (tbp.isAvailable()) { + return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT); + } else { + return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED); + } + } + return null; + } +} diff --git a/src/org/ntlab/traceDebugger/BreakPointView.java b/src/org/ntlab/traceDebugger/BreakPointView.java index 925cb5b..ab1ffc4 100644 --- a/src/org/ntlab/traceDebugger/BreakPointView.java +++ b/src/org/ntlab/traceDebugger/BreakPointView.java @@ -50,7 +50,6 @@ protected IAction resumeAction; protected IAction importBreakpointAction; protected Shell shell; -// protected TraceBreakPoints traceBreakPoints; protected DebuggingController debuggingController = DebuggingController.getInstance(); public static final String ID = "org.ntlab.traceDebugger.breakPointView"; public static final String DEBUG_ELCL = "Debug_elcl"; @@ -323,10 +322,6 @@ viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); } - -// public TraceBreakPoints getTraceBreakPoints() { -// return traceBreakPoints; -// } public void reset() { viewer.setInput(new ArrayList()); @@ -336,7 +331,6 @@ } public void updateTraceBreakPoints(TraceBreakPoints traceBreakPoints) { -// this.traceBreakPoints = traceBreakPoints; viewer.setInput(traceBreakPoints.getAllTraceBreakPoints()); final Table table = viewer.getTable(); for (TableItem item : table.getItems()) { diff --git a/src/org/ntlab/traceDebugger/CallStackView.java b/src/org/ntlab/traceDebugger/CallStackView.java index 028eaa7..5d26e9e 100644 --- a/src/org/ntlab/traceDebugger/CallStackView.java +++ b/src/org/ntlab/traceDebugger/CallStackView.java @@ -98,7 +98,7 @@ TracePoint tp = selectedCallStackModel.getTracePoint(); TracePoint debuggingTp = DebuggingController.getInstance().getCurrentTp(); VariableView variableView = (VariableView)TraceDebuggerPlugin.getActiveView(VariableView.ID); - variableView.updateVariablesByTracePoint(tp, false, debuggingTp); + variableView.updateVariablesByTracePoints(tp, debuggingTp); } public void updateByTracePoint(TracePoint tp) { diff --git a/src/org/ntlab/traceDebugger/CallTreeModel.java b/src/org/ntlab/traceDebugger/CallTreeModel.java index 21278d3..eec8421 100644 --- a/src/org/ntlab/traceDebugger/CallTreeModel.java +++ b/src/org/ntlab/traceDebugger/CallTreeModel.java @@ -1,86 +1,77 @@ -package org.ntlab.traceDebugger; - -import java.util.ArrayList; -import java.util.List; - -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; -import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; - -public class CallTreeModel { - private MethodExecution methodExecution; - private boolean isHighlighting; - private CallTreeModel parent; - private List children = new ArrayList<>(); - - public CallTreeModel(MethodExecution methodExecution) { - this.methodExecution = methodExecution; - } - - public MethodExecution getMethodExecution() { - return methodExecution; - } - - public String getSignature() { - return methodExecution.getSignature(); - } - - public String getCallTreeSignature() { - String signature = ""; - signature = getSignature(); - String objectType = methodExecution.getThisClassName(); - objectType = objectType.substring(objectType.lastIndexOf(".") + 1); - boolean isConstructor = methodExecution.isConstructor(); - String declaringType = Trace.getDeclaringType(signature, isConstructor); - declaringType = declaringType.substring(declaringType.lastIndexOf(".") + 1); - String methodName = Trace.getMethodName(signature); - String args = "("; - String delimiter = ""; - String[] argArray = signature.split("\\(")[1].split(","); - for (String arg : argArray) { - args += (delimiter + arg.substring(arg.lastIndexOf(".") + 1)); - delimiter = ", "; - } - - StringBuilder sb = new StringBuilder(); - sb.append(objectType); - if (!declaringType.equals(objectType)) { - sb.append("(" + declaringType + ")"); - } - sb.append("." + methodName + args); - signature = sb.toString(); - return signature; - } - - public boolean isHighlighting() { - return isHighlighting; - } - - public void setHighlighting(boolean isHighlighting) { - this.isHighlighting = isHighlighting; - } - -// public List getChildren() { -// List children = methodExecution.getChildren(); -// List childrenCallTreeModels = new ArrayList<>(); -// for (MethodExecution child : children) { -// childrenCallTreeModels.add(new CallTreeModel(child)); -// } -// return childrenCallTreeModels; -// } - - public CallTreeModel getParent() { - return parent; - } - - public List getChildren() { - return children; - } - - public void setParent(CallTreeModel parent) { - this.parent = parent; - } - - public void addChildren(CallTreeModel child) { - this.children.add(child); - } -} +package org.ntlab.traceDebugger; + +import java.util.ArrayList; +import java.util.List; + +import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; +import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; + +public class CallTreeModel { + private MethodExecution methodExecution; + private boolean isHighlighting; + private CallTreeModel parent; + private List children = new ArrayList<>(); + + public CallTreeModel(MethodExecution methodExecution) { + this.methodExecution = methodExecution; + } + + public MethodExecution getMethodExecution() { + return methodExecution; + } + + public String getSignature() { + return methodExecution.getSignature(); + } + + public String getCallTreeSignature() { + String signature = ""; + signature = getSignature(); + String objectType = methodExecution.getThisClassName(); + objectType = objectType.substring(objectType.lastIndexOf(".") + 1); + boolean isConstructor = methodExecution.isConstructor(); + String declaringType = Trace.getDeclaringType(signature, isConstructor); + declaringType = declaringType.substring(declaringType.lastIndexOf(".") + 1); + String methodName = Trace.getMethodName(signature); + String args = "("; + String delimiter = ""; + String[] argArray = signature.split("\\(")[1].split(","); + for (String arg : argArray) { + args += (delimiter + arg.substring(arg.lastIndexOf(".") + 1)); + delimiter = ", "; + } + + StringBuilder sb = new StringBuilder(); + sb.append(objectType); + if (!declaringType.equals(objectType)) { + sb.append("(" + declaringType + ")"); + } + sb.append("." + methodName + args); + signature = sb.toString(); + return signature; + } + + public boolean isHighlighting() { + return isHighlighting; + } + + public void setHighlighting(boolean isHighlighting) { + this.isHighlighting = isHighlighting; + } + + public CallTreeModel getParent() { + return parent; + } + + public List getChildren() { + return children; + } + + public void setParent(CallTreeModel parent) { + this.parent = parent; + } + + public void addChildren(CallTreeModel child) { + this.children.add(child); + } +} diff --git a/src/org/ntlab/traceDebugger/DebuggingController.java b/src/org/ntlab/traceDebugger/DebuggingController.java index 755d204..8fcc9e2 100644 --- a/src/org/ntlab/traceDebugger/DebuggingController.java +++ b/src/org/ntlab/traceDebugger/DebuggingController.java @@ -25,10 +25,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; -import org.ntlab.traceAnalysisPlatform.tracer.trace.ArrayUpdate; -import org.ntlab.traceAnalysisPlatform.tracer.trace.FieldUpdate; import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; -import org.ntlab.traceAnalysisPlatform.tracer.trace.Statement; import org.ntlab.traceAnalysisPlatform.tracer.trace.TraceJSON; import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; import org.ntlab.traceDebugger.analyzerProvider.DeltaExtractionAnalyzer; @@ -122,7 +119,6 @@ TraceJSON trace = new TraceJSON(filePath); TraceDebuggerPlugin.setAnalyzer(new DeltaExtractionAnalyzer(trace)); VariableUpdatePointFinder.getInstance().setTrace(trace); -// final TraceBreakPoints traceBreakPoints = new TraceBreakPoints(trace); traceBreakPoints = new TraceBreakPoints(trace); // GUI�̑����GUI�̃C�x���g�f�B�X�p�b�`���s���Ă���X���b�h���炵������ł��Ȃ��̂ł������� @@ -166,7 +162,6 @@ : new InputDialog(null, "line Number dialog", "Input line number", "", null); if (inputDialog.open() != InputDialog.OK) return false; int lineNo = Integer.parseInt(inputDialog.getValue()); -// TraceBreakPoints traceBreakPoints = ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).getTraceBreakPoints(); boolean isSuccess = traceBreakPoints.addTraceBreakPoint(methodSignature, lineNo); if (!isSuccess) { if (TraceDebuggerPlugin.isJapanese()) { @@ -189,7 +184,6 @@ } return false; } -// TraceBreakPoints traceBreakPoints = ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).getTraceBreakPoints(); traceBreakPoints.importBreakpointFromEclipse(); ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).updateTraceBreakPoints(traceBreakPoints); return true; @@ -197,7 +191,6 @@ public boolean removeTraceBreakPointAction() { if (selectedTraceBreakPoint == null) return false; -// TraceBreakPoints traceBreakPoints = ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).getTraceBreakPoints(); traceBreakPoints.removeTraceBreakPoint(selectedTraceBreakPoint); ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).updateTraceBreakPoints(traceBreakPoints); return true; @@ -220,7 +213,6 @@ } return false; } -// TraceBreakPoints traceBreakPoints = ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).getTraceBreakPoints(); debuggingTp = traceBreakPoints.getFirstTracePoint(); if (debuggingTp == null) { if (TraceDebuggerPlugin.isJapanese()) { @@ -235,21 +227,6 @@ isRunning = true; return true; } - -// public void terminateAction() { -// debuggingTp = null; -// if (currentLineMarker != null) { -// try { -// currentLineMarker.delete(); -// } catch (CoreException e) { -// e.printStackTrace(); -// } -// } -// ((CallStackView)TraceDebuggerPlugin.getActiveView(CallStackView.ID)).reset(); -// ((VariableView)TraceDebuggerPlugin.getActiveView(VariableView.ID)).reset(); -// ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).updateImagesForDebug(false); -// isRunning = false; -// } public void terminateAction() { debuggingTp = null; @@ -285,7 +262,7 @@ refresh(null, debuggingTp, false); return true; } - + public boolean stepOverAction() { if (!isRunning) return false; if (debuggingTp == null) return false; @@ -298,28 +275,13 @@ int currentLineNo = debuggingTp.getStatement().getLineNo(); boolean isReturned = false; - // �X�e�b�v�I�[�o�[��p���ē��B�_�����‚��Ă��� - TracePoint startTp = debuggingTp.duplicate(); while (!(isReturned = !(debuggingTp.stepOver()))) { if (currentLineNo != debuggingTp.getStatement().getLineNo()) break; previousTp = debuggingTp.duplicate(); } - TracePoint goalTp = debuggingTp.duplicate(); - if (!isReturned) { - // �X�e�b�v�t����p���č��x�͌Ăяo����ɂ�����Ȃ���\�ߌ��‚��Ă��������B�_�܂Ői�܂��� (�ϐ������X�V�̂��ߓr���̃A�b�v�f�[�g��S�ďE��) - debuggingTp = startTp; - do { - Statement statement = debuggingTp.getStatement(); - if (statement.equals(goalTp.getStatement())) break; - if (statement instanceof FieldUpdate || statement instanceof ArrayUpdate) { - Variables.getInstance().addDifferentialUpdatePoint(debuggingTp); - } - } while (debuggingTp.stepFull()); - } else { - debuggingTp = goalTp; + if (isReturned) { while (!debuggingTp.stepOver()); // �Ăяo�����ł̎��̃X�e�[�g�����g�܂Ői�߂� } - if (debugExecutionIsTerminated(debuggingTp)) return false; refresh(previousTp, debuggingTp, isReturned, true); return true; @@ -345,7 +307,7 @@ refresh(previousTp, debuggingTp, true); return true; } - + public boolean stepNextAction() { if (!isRunning) return false; if (debuggingTp == null) return false; @@ -355,27 +317,13 @@ } TracePoint previousTp = debuggingTp; debuggingTp = debuggingTp.duplicate(); - TracePoint startTp = debuggingTp.duplicate(); boolean isReturned = !(debuggingTp.stepNext()); - TracePoint goalTp = debuggingTp.duplicate(); - if (!isReturned) { - // �X�e�b�v�t����p���č��x�͌Ăяo����ɂ�����Ȃ���\�ߌ��‚��Ă��������B�_�܂Ői�܂��� (�ϐ������X�V�̂��ߓr���̃A�b�v�f�[�g��S�ďE��) - debuggingTp = startTp; - do { - Statement statement = debuggingTp.getStatement(); - if (statement.equals(goalTp.getStatement())) break; - if (statement instanceof FieldUpdate || statement instanceof ArrayUpdate) { - Variables.getInstance().addDifferentialUpdatePoint(debuggingTp); - } - } while (debuggingTp.stepFull()); - } else { - debuggingTp = startTp; + if (isReturned) { while (!debuggingTp.stepOver()); // �Ăяo�����ł̎��̃X�e�[�g�����g�܂Ői�߂� } - if (debugExecutionIsTerminated(debuggingTp)) return false; refresh(previousTp, debuggingTp, isReturned, true); - return true; + return true; } public boolean resumeAction() { @@ -383,7 +331,6 @@ if (debuggingTp == null) return false; long currentTime = debuggingTp.getStatement().getTimeStamp(); TracePoint previousTp = debuggingTp; -// TraceBreakPoints traceBreakPoints = ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).getTraceBreakPoints(); debuggingTp = traceBreakPoints.getNextTracePoint(currentTime); if (debugExecutionIsTerminated(debuggingTp)) return false; refresh(null, debuggingTp, false); @@ -444,7 +391,6 @@ if (debuggingTp == null) return false; TracePoint previousTp = debuggingTp; long currentTime = debuggingTp.getStatement().getTimeStamp(); -// TraceBreakPoints traceBreakPoints = ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).getTraceBreakPoints(); debuggingTp = traceBreakPoints.getPreviousTracePoint(currentTime); if (debugExecutionIsTerminated(debuggingTp)) return false; refresh(null, debuggingTp, false); @@ -489,10 +435,9 @@ callStackView.updateByTracePoint(to); VariableView variableView = ((VariableView)TraceDebuggerPlugin.getActiveView(VariableView.ID)); if (!isReturned && canDifferentialUpdateVariables) { -// variableView.updateVariablesByTracePoint(from, to, isReturned); - variableView.updateVariablesForDifferential(from, to, isReturned); + variableView.updateVariablesForDifferential(from, to); } else { - variableView.updateVariablesByTracePoint(from, to, isReturned); + variableView.updateVariablesByTracePointsFromAToB(from, to); } if (TraceDebuggerPlugin.getActiveView(DeltaMarkerView.ID) != null) { refreshRelatedDelta(to); diff --git a/src/org/ntlab/traceDebugger/DeltaMarkerView.java b/src/org/ntlab/traceDebugger/DeltaMarkerView.java index 62e663e..62b620b 100644 --- a/src/org/ntlab/traceDebugger/DeltaMarkerView.java +++ b/src/org/ntlab/traceDebugger/DeltaMarkerView.java @@ -4,7 +4,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; diff --git a/src/org/ntlab/traceDebugger/JavaElementFinder.java b/src/org/ntlab/traceDebugger/JavaElementFinder.java index 5f087c4..a75085b 100644 --- a/src/org/ntlab/traceDebugger/JavaElementFinder.java +++ b/src/org/ntlab/traceDebugger/JavaElementFinder.java @@ -1,240 +1,233 @@ -package org.ntlab.traceDebugger; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.ntlab.traceAnalysisPlatform.tracer.trace.ClassInfo; -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; -import org.ntlab.traceAnalysisPlatform.tracer.trace.TraceJSON; - -public class JavaElementFinder { - - public static IFile findIFile(MethodExecution methodExecution) { - TraceJSON trace = (TraceJSON)TraceDebuggerPlugin.getAnalyzer().getTrace(); - String declaringClassName = methodExecution.getDeclaringClassName(); - declaringClassName = declaringClassName.replace(".", ""); - ClassInfo info = trace.getClassInfo(declaringClassName); - if (info == null) { - // �����N���X�̏ꍇ�͂��̊O�̃N���X����ClassInfo���擾���� (Java�̃\�[�X�t�@�C�����擾���邽��) - StringBuilder tmp = new StringBuilder(); - tmp.append(declaringClassName.substring(0, declaringClassName.lastIndexOf("."))); - info = trace.getClassInfo(tmp.toString()); - } - if (info == null) return null; - - String tmp = info.getPath(); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - String projectName = ""; - String srcForderName = "/src"; - String outputClassPath = null; - IPath projectOutputLocation = null; - boolean hasFoundSrcForderName = false; - for (IProject project : projects) { - projectName = project.getFullPath().toString(); - if (!(tmp.contains(projectName + "/"))) continue; - IJavaProject javaProject = JavaCore.create(project); - try { - projectOutputLocation = javaProject.getOutputLocation(); // �v���W�F�N�g�S�̂̏o�̓t�H���_ - for (IClasspathEntry entry : javaProject.getResolvedClasspath(true)) { - if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) continue; - IPath srcForderPath = entry.getPath(); - srcForderName = srcForderPath.toString(); - IPath outputLocation = entry.getOutputLocation(); // �\�[�X���̏o�̓t�H���_ - if (outputLocation != null) { - URI path = PathUtility.workspaceRelativePathToAbsoluteURI(outputLocation, workspace); - outputClassPath = PathUtility.URIPathToPath(path.getPath()); - } - hasFoundSrcForderName = true; - break; - } - } catch (JavaModelException e) { - e.printStackTrace(); - } - if (hasFoundSrcForderName) break; - } - if (outputClassPath == null && projectOutputLocation != null) { - URI path = PathUtility.workspaceRelativePathToAbsoluteURI(projectOutputLocation, workspace); - outputClassPath = PathUtility.URIPathToPath(path.getPath()); - } -// tmp = tmp.replace(tmp.substring(0, tmp.lastIndexOf(projectName)), ""); - if (outputClassPath != null && tmp.startsWith(outputClassPath)) { - tmp = srcForderName + tmp.substring(outputClassPath.length()); - } else { - tmp = tmp.replace(tmp.substring(0, tmp.indexOf(projectName)), ""); - tmp = tmp.replace("/bin", srcForderName.substring(srcForderName.lastIndexOf("/"))); - } - tmp = tmp.replace(".class", ".java"); - String filePath = tmp; - IPath path = new Path(filePath); - return ResourcesPlugin.getWorkspace().getRoot().getFile(path); - } - - public static IType findIType(MethodExecution methodExecution) { - String declaringClassName = methodExecution.getDeclaringClassName(); - declaringClassName = declaringClassName.replace(".", ""); - return findIType(methodExecution, declaringClassName); - } - - public static IType findIType(MethodExecution methodExecution, String declaringClassName) { - String projectPath = getLoaderPath(methodExecution, declaringClassName); -// if (projectPath == null) projectPath = previousJavaProjectPath; - if (projectPath != null) { - IJavaProject javaProject = findJavaProject(projectPath); - if (javaProject != null) { -// previousJavaProjectPath = projectPath; - try { - return javaProject.findType(declaringClassName); - } catch (JavaModelException e) { - e.printStackTrace(); - } - } - } - return null; - } - - private static String getLoaderPath(MethodExecution methodExecution, String declaringClassName) { - TraceJSON traceJSON = (TraceJSON)TraceDebuggerPlugin.getAnalyzer().getTrace(); - ClassInfo classInfo = traceJSON.getClassInfo(declaringClassName); - if (classInfo == null && methodExecution != null) { - declaringClassName = methodExecution.getThisClassName(); - classInfo = traceJSON.getClassInfo(declaringClassName); - } - String loaderPath = null; - if (classInfo != null) { - // �Ȃ���loaderPath���擾�ł��Ă��Ȃ����߁A���ۂɏo�͂����JSON�g���[�X���Q�l�ɂ���path����^���Ă݂� - String path = classInfo.getPath(); - String declaringClassNameString = declaringClassName.replace(".", "/"); - loaderPath = path.substring(0, path.lastIndexOf(declaringClassNameString)); // path����N���X�̊��S���薼�ȍ~��S�ĊO�������̂�projectPath�ɂ��Ă݂� - } - return loaderPath; - } - - private static IJavaProject findJavaProject(String projectPath) { - IJavaProject javaProject = null; - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject[] projects = root.getProjects(); - for (IProject project : projects) { - if (checkProjectPath(project, projectPath)) { - javaProject = JavaCore.create(project); - break; - } - } - return javaProject; - } - - private static boolean checkProjectPath(IProject project, String projectPath) { - String projectLocation = project.getLocation().toString(); -// if (projectPath.startsWith(projectLocation)) { -// String[] projectPathSplit = projectPath.split(projectLocation); -// return (projectPathSplit[1].charAt(0) == '/'); // �v���W�F�N�g���̑O����v�ɂ�鑼�v���W�F�N�g�Ƃ̌딻�������� -// } - if (projectPath.startsWith(projectLocation)) { - String[] projectPathSplit = projectPath.split(projectLocation); - return (projectPathSplit[1].charAt(0) == '/'); // �v���W�F�N�g���̑O����v�ɂ�鑼�v���W�F�N�g�Ƃ̌딻�������� - } else if (projectPath.startsWith(projectLocation.substring(1))) { - String[] projectPathSplit = projectPath.split(projectLocation.substring(1)); - return (projectPathSplit[1].charAt(0) == '/'); // �v���W�F�N�g���̑O����v�ɂ�鑼�v���W�F�N�g�Ƃ̌딻�������� - } - return false; - } - - public static IMethod findIMethod(MethodExecution methodExecution, IType type) { - IMethod method = null; - if (type != null) { - String methodSignature = methodExecution.getSignature(); - method = findIMethod(type, methodSignature); - } - return method; - } - - public static IMethod findIMethod(IType type, String methodSignature) { - try { - for (IMethod method : type.getMethods()) { - if (checkMethodSignature(type, method, methodSignature)) { - return method; - } - } - } catch (JavaModelException e) { - e.printStackTrace(); - } - return null; - } - - private static boolean checkMethodSignature(IType type, IMethod method, String methodSignature) { - String fqcn = type.getFullyQualifiedName(); - fqcn = fqcn.replace("$", "."); - try { - StringBuilder jdtMethodSignature = new StringBuilder(); - jdtMethodSignature.append((method.isConstructor()) ? (fqcn + "(") : (fqcn + "." + method.getElementName() + "(")); - if (methodSignature.contains(jdtMethodSignature)) { - // ������v���Ă����ꍇ�Ɍ���A�������X�g����������ł���v���邩�ǂ����𔻒� (�I�[�o�[���[�h�ɂ��딻��������) - jdtMethodSignature.append(String.join(",", parseFQCNParameters(type, method)) + ")"); // �S�����̃V�O�l�`�������S����N���X���ɕϊ�����,�ŋ�؂��������� - return methodSignature.contains(jdtMethodSignature); - } - } catch (JavaModelException e) { - e.printStackTrace(); - } - return false; - } - - public static String resolveType(IType type, String typeName) { - try { - String[][] resolveTypes = type.resolveType(typeName); - if (resolveTypes != null) { - if (resolveTypes[0][0].isEmpty()) { - return (resolveTypes[0][1]); // �f�t�H���g�p�b�P�[�W�̏ꍇ�̓p�b�P�[�W����.�͓���Ȃ� - } else { - return (resolveTypes[0][0] + "." + resolveTypes[0][1]); // ���S����N���X�� - } - } - } catch (JavaModelException e) { - e.printStackTrace(); - } - return null; - } - - /** - * IMethod����擾�ł���S�����̃V�O�l�`�������S����N���X���ɒu�������Ċi�[�������X�g��Ԃ� - * - * @param type - * @param method - * @return - */ - private static List parseFQCNParameters(IType type, IMethod method) throws JavaModelException { - List parameters = new ArrayList<>(); - for (String parameterType : method.getParameterTypes()) { - String readableType = Signature.toString(parameterType); // �V�O�l�`���̕�������^���̕�����ɕϊ� (�z��͌���[]���‚�) - String[] readableTypeSplit = { "", "" }; // �^����[]�̕����p - int firstBracketIndex = readableType.indexOf("[]"); - final int NO_BRACKET_INDEX = -1; - if (firstBracketIndex == NO_BRACKET_INDEX) { - readableTypeSplit[0] = readableType; // �^�� - } else { - readableTypeSplit[0] = readableType.substring(0, firstBracketIndex); // �^�� - readableTypeSplit[1] = readableType.substring(firstBracketIndex); // �^���̌���[]�S�� - } - String tmp = resolveType(type, readableTypeSplit[0]); - if (tmp != null) { - readableTypeSplit[0] = tmp; - } - parameters.add(readableTypeSplit[0] + readableTypeSplit[1]); - } - return parameters; - } -} +package org.ntlab.traceDebugger; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.Signature; +import org.ntlab.traceAnalysisPlatform.tracer.trace.ClassInfo; +import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; +import org.ntlab.traceAnalysisPlatform.tracer.trace.TraceJSON; + +public class JavaElementFinder { + + public static IFile findIFile(MethodExecution methodExecution) { + TraceJSON trace = (TraceJSON)TraceDebuggerPlugin.getAnalyzer().getTrace(); + String declaringClassName = methodExecution.getDeclaringClassName(); + declaringClassName = declaringClassName.replace(".", ""); + ClassInfo info = trace.getClassInfo(declaringClassName); + if (info == null) { + // �����N���X�̏ꍇ�͂��̊O�̃N���X����ClassInfo���擾���� (Java�̃\�[�X�t�@�C�����擾���邽��) + StringBuilder tmp = new StringBuilder(); + tmp.append(declaringClassName.substring(0, declaringClassName.lastIndexOf("."))); + info = trace.getClassInfo(tmp.toString()); + } + if (info == null) return null; + + String tmp = info.getPath(); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProject[] projects = workspace.getRoot().getProjects(); + String projectName = ""; + String srcForderName = "/src"; + String outputClassPath = null; + IPath projectOutputLocation = null; + boolean hasFoundSrcForderName = false; + for (IProject project : projects) { + projectName = project.getFullPath().toString(); + if (!(tmp.contains(projectName + "/"))) continue; + IJavaProject javaProject = JavaCore.create(project); + try { + projectOutputLocation = javaProject.getOutputLocation(); // �v���W�F�N�g�S�̂̏o�̓t�H���_ + for (IClasspathEntry entry : javaProject.getResolvedClasspath(true)) { + if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) continue; + IPath srcForderPath = entry.getPath(); + srcForderName = srcForderPath.toString(); + IPath outputLocation = entry.getOutputLocation(); // �\�[�X���̏o�̓t�H���_ + if (outputLocation != null) { + URI path = PathUtility.workspaceRelativePathToAbsoluteURI(outputLocation, workspace); + outputClassPath = PathUtility.URIPathToPath(path.getPath()); + } + hasFoundSrcForderName = true; + break; + } + } catch (JavaModelException e) { + e.printStackTrace(); + } + if (hasFoundSrcForderName) break; + } + if (outputClassPath == null && projectOutputLocation != null) { + URI path = PathUtility.workspaceRelativePathToAbsoluteURI(projectOutputLocation, workspace); + outputClassPath = PathUtility.URIPathToPath(path.getPath()); + } + if (outputClassPath != null && tmp.startsWith(outputClassPath)) { + tmp = srcForderName + tmp.substring(outputClassPath.length()); + } else { + tmp = tmp.replace(tmp.substring(0, tmp.indexOf(projectName)), ""); + tmp = tmp.replace("/bin", srcForderName.substring(srcForderName.lastIndexOf("/"))); + } + tmp = tmp.replace(".class", ".java"); + String filePath = tmp; + IPath path = new Path(filePath); + return ResourcesPlugin.getWorkspace().getRoot().getFile(path); + } + + public static IType findIType(MethodExecution methodExecution) { + String declaringClassName = methodExecution.getDeclaringClassName(); + declaringClassName = declaringClassName.replace(".", ""); + return findIType(methodExecution, declaringClassName); + } + + public static IType findIType(MethodExecution methodExecution, String declaringClassName) { + String projectPath = getLoaderPath(methodExecution, declaringClassName); + if (projectPath != null) { + IJavaProject javaProject = findJavaProject(projectPath); + if (javaProject != null) { + try { + return javaProject.findType(declaringClassName); + } catch (JavaModelException e) { + e.printStackTrace(); + } + } + } + return null; + } + + private static String getLoaderPath(MethodExecution methodExecution, String declaringClassName) { + TraceJSON traceJSON = (TraceJSON)TraceDebuggerPlugin.getAnalyzer().getTrace(); + ClassInfo classInfo = traceJSON.getClassInfo(declaringClassName); + if (classInfo == null && methodExecution != null) { + declaringClassName = methodExecution.getThisClassName(); + classInfo = traceJSON.getClassInfo(declaringClassName); + } + String loaderPath = null; + if (classInfo != null) { + // �Ȃ���loaderPath���擾�ł��Ă��Ȃ����߁A���ۂɏo�͂����JSON�g���[�X���Q�l�ɂ���path����^���Ă݂� + String path = classInfo.getPath(); + String declaringClassNameString = declaringClassName.replace(".", "/"); + loaderPath = path.substring(0, path.lastIndexOf(declaringClassNameString)); // path����N���X�̊��S���薼�ȍ~��S�ĊO�������̂�projectPath�ɂ��Ă݂� + } + return loaderPath; + } + + private static IJavaProject findJavaProject(String projectPath) { + IJavaProject javaProject = null; + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject[] projects = root.getProjects(); + for (IProject project : projects) { + if (checkProjectPath(project, projectPath)) { + javaProject = JavaCore.create(project); + break; + } + } + return javaProject; + } + + private static boolean checkProjectPath(IProject project, String projectPath) { + String projectLocation = project.getLocation().toString(); + if (projectPath.startsWith(projectLocation)) { + String[] projectPathSplit = projectPath.split(projectLocation); + return (projectPathSplit[1].charAt(0) == '/'); // �v���W�F�N�g���̑O����v�ɂ�鑼�v���W�F�N�g�Ƃ̌딻�������� + } else if (projectPath.startsWith(projectLocation.substring(1))) { + String[] projectPathSplit = projectPath.split(projectLocation.substring(1)); + return (projectPathSplit[1].charAt(0) == '/'); // �v���W�F�N�g���̑O����v�ɂ�鑼�v���W�F�N�g�Ƃ̌딻�������� + } + return false; + } + + public static IMethod findIMethod(MethodExecution methodExecution, IType type) { + IMethod method = null; + if (type != null) { + String methodSignature = methodExecution.getSignature(); + method = findIMethod(type, methodSignature); + } + return method; + } + + public static IMethod findIMethod(IType type, String methodSignature) { + try { + for (IMethod method : type.getMethods()) { + if (checkMethodSignature(type, method, methodSignature)) { + return method; + } + } + } catch (JavaModelException e) { + e.printStackTrace(); + } + return null; + } + + private static boolean checkMethodSignature(IType type, IMethod method, String methodSignature) { + String fqcn = type.getFullyQualifiedName(); + fqcn = fqcn.replace("$", "."); + try { + StringBuilder jdtMethodSignature = new StringBuilder(); + jdtMethodSignature.append((method.isConstructor()) ? (fqcn + "(") : (fqcn + "." + method.getElementName() + "(")); + if (methodSignature.contains(jdtMethodSignature)) { + // ������v���Ă����ꍇ�Ɍ���A�������X�g����������ł���v���邩�ǂ����𔻒� (�I�[�o�[���[�h�ɂ��딻��������) + jdtMethodSignature.append(String.join(",", parseFQCNParameters(type, method)) + ")"); // �S�����̃V�O�l�`�������S����N���X���ɕϊ�����,�ŋ�؂��������� + return methodSignature.contains(jdtMethodSignature); + } + } catch (JavaModelException e) { + e.printStackTrace(); + } + return false; + } + + public static String resolveType(IType type, String typeName) { + try { + String[][] resolveTypes = type.resolveType(typeName); + if (resolveTypes != null) { + if (resolveTypes[0][0].isEmpty()) { + return (resolveTypes[0][1]); // �f�t�H���g�p�b�P�[�W�̏ꍇ�̓p�b�P�[�W����.�͓���Ȃ� + } else { + return (resolveTypes[0][0] + "." + resolveTypes[0][1]); // ���S����N���X�� + } + } + } catch (JavaModelException e) { + e.printStackTrace(); + } + return null; + } + + /** + * IMethod����擾�ł���S�����̃V�O�l�`�������S����N���X���ɒu�������Ċi�[�������X�g��Ԃ� + * + * @param type + * @param method + * @return + */ + private static List parseFQCNParameters(IType type, IMethod method) throws JavaModelException { + List parameters = new ArrayList<>(); + for (String parameterType : method.getParameterTypes()) { + String readableType = Signature.toString(parameterType); // �V�O�l�`���̕�������^���̕�����ɕϊ� (�z��͌���[]���‚�) + String[] readableTypeSplit = { "", "" }; // �^����[]�̕����p + int firstBracketIndex = readableType.indexOf("[]"); + final int NO_BRACKET_INDEX = -1; + if (firstBracketIndex == NO_BRACKET_INDEX) { + readableTypeSplit[0] = readableType; // �^�� + } else { + readableTypeSplit[0] = readableType.substring(0, firstBracketIndex); // �^�� + readableTypeSplit[1] = readableType.substring(firstBracketIndex); // �^���̌���[]�S�� + } + String tmp = resolveType(type, readableTypeSplit[0]); + if (tmp != null) { + readableTypeSplit[0] = tmp; + } + parameters.add(readableTypeSplit[0] + readableTypeSplit[1]); + } + return parameters; + } +} diff --git a/src/org/ntlab/traceDebugger/RadioButtonDialog.java b/src/org/ntlab/traceDebugger/RadioButtonDialog.java deleted file mode 100644 index ca8059e..0000000 --- a/src/org/ntlab/traceDebugger/RadioButtonDialog.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.ntlab.traceDebugger; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -public class RadioButtonDialog extends Dialog { - private int selectedIndex = 0; - private String title; - private String[] texts; - - protected RadioButtonDialog(Shell parentShell, String title, String[] texts) { - super(parentShell); - this.title = title; - this.texts = texts; - } - - @Override - public void create() { - super.create(); - getShell().setText(title); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite)super.createDialogArea(parent); - Button[] buttons = new Button[texts.length]; - for (int i = 0; i < texts.length; i++) { - final int index = i; - buttons[i] = new Button(parent, SWT.RADIO); -// buttons[i].setLayoutData(new GridData(GridData.FILL_BOTH)); - buttons[i].setAlignment(SWT.CENTER); - buttons[i].setText(texts[i]); - buttons[i].addSelectionListener(new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent e) { - selectedIndex = index; - } - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - } - return composite; - } - - public String getValue() { - return texts[selectedIndex]; - } -} diff --git a/src/org/ntlab/traceDebugger/TraceBreakPoint.java b/src/org/ntlab/traceDebugger/TraceBreakPoint.java index 44b17f0..8855810 100644 --- a/src/org/ntlab/traceDebugger/TraceBreakPoint.java +++ b/src/org/ntlab/traceDebugger/TraceBreakPoint.java @@ -1,124 +1,101 @@ -package org.ntlab.traceDebugger; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodInvocation; -import org.ntlab.traceAnalysisPlatform.tracer.trace.Statement; -import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; -import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; - -public class TraceBreakPoint { - private List tracePoints = new ArrayList<>(); - private String methodSignature; - private String readableSignature; - private int lineNo; - private List methodExecutions = new ArrayList<>(); - private boolean isAvailable = false; - - private TraceBreakPoint(String methodSignature, int lineNo, boolean isAvailable, String readableSignature) { - this.methodSignature = methodSignature; - this.lineNo = lineNo; - this.isAvailable = isAvailable; - this.readableSignature = readableSignature; - } - - public static TraceBreakPoint createNewTraceBreakPoint(String methodSignature, int lineNo, boolean isAvailable, String readableSignature) - throws IllegalArgumentException { - TraceBreakPoint newTraceBreakPoint = new TraceBreakPoint(methodSignature, lineNo, isAvailable, readableSignature); - boolean isValid = newTraceBreakPoint.initTracePoints(methodSignature, lineNo); - if (!isValid) throw new IllegalArgumentException(); - return newTraceBreakPoint; - } - - private boolean initTracePoints(String methodSignature, int lineNo) { - Trace trace = TraceDebuggerPlugin.getAnalyzer().getTrace(); - methodExecutions = trace.getMethodExecutions(methodSignature); - if (methodExecutions.isEmpty()) return false; - tracePoints.clear(); - for (MethodExecution me : methodExecutions) { - int order = 0; - for (Statement statement : me.getStatements()) { - if (statement.getLineNo() == lineNo) { - tracePoints.add(me.getTracePoint(order)); - break; - } - order++; - } - } - if (tracePoints.isEmpty()) return false; - Collections.sort(tracePoints, new Comparator() { - @Override - public int compare(TracePoint o1, TracePoint o2) { - long o1Time = getTime(o1); - long o2Time = getTime(o2); - return (o1Time < o2Time) ? -1 : 1; - } - private long getTime(TracePoint tp) { - Statement statement = tp.getStatement(); - if (statement instanceof MethodInvocation) { - return ((MethodInvocation)statement).getCalledMethodExecution().getEntryTime(); - } - return statement.getTimeStamp(); - } - }); - return true; - } - - public String getMethodSignature() { - return methodSignature; - } - - public String getReadableSignature() { - return readableSignature; -// MethodExecution methodExecution = methodExecutions.iterator().next(); -// String signature = methodExecution.getSignature(); -// String objectType = methodExecution.getThisClassName(); -// objectType = objectType.substring(objectType.lastIndexOf(".") + 1); -// boolean isConstructor = methodExecution.isConstructor(); -// String declaringType = Trace.getDeclaringType(signature, isConstructor); -// declaringType = declaringType.substring(declaringType.lastIndexOf(".") + 1); -// String methodName = Trace.getMethodName(signature); -// String args = "("; -// String delimiter = ""; -// String[] argArray = signature.split("\\(")[1].split(","); -// for (String arg : argArray) { -// args += (delimiter + arg.substring(arg.lastIndexOf(".") + 1)); -// delimiter = ", "; -// } -// -// StringBuilder sb = new StringBuilder(); -// sb.append(objectType); -// if (!declaringType.equals(objectType)) { -// sb.append("(" + declaringType + ")"); -// } -// sb.append("." + methodName + args); -// return sb.toString(); - } - - public int getLineNo() { - return lineNo; - } - - public List getMethodExecutions() { - return methodExecutions; - } - - public List getTracePoints() { - return tracePoints; - } - - public boolean isAvailable() { - return isAvailable; - } - - public void setAvailable(boolean isAvailable) { - this.isAvailable = isAvailable; - } - - public void changeAvailable() { - isAvailable = !isAvailable; - } -} +package org.ntlab.traceDebugger; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; +import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodInvocation; +import org.ntlab.traceAnalysisPlatform.tracer.trace.Statement; +import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; +import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; + +public class TraceBreakPoint { + private List tracePoints = new ArrayList<>(); + private String methodSignature; + private String readableSignature; + private int lineNo; + private List methodExecutions = new ArrayList<>(); + private boolean isAvailable = false; + + private TraceBreakPoint(String methodSignature, int lineNo, boolean isAvailable, String readableSignature) { + this.methodSignature = methodSignature; + this.lineNo = lineNo; + this.isAvailable = isAvailable; + this.readableSignature = readableSignature; + } + + public static TraceBreakPoint createNewTraceBreakPoint(String methodSignature, int lineNo, boolean isAvailable, String readableSignature) + throws IllegalArgumentException { + TraceBreakPoint newTraceBreakPoint = new TraceBreakPoint(methodSignature, lineNo, isAvailable, readableSignature); + boolean isValid = newTraceBreakPoint.initTracePoints(methodSignature, lineNo); + if (!isValid) throw new IllegalArgumentException(); + return newTraceBreakPoint; + } + + private boolean initTracePoints(String methodSignature, int lineNo) { + Trace trace = TraceDebuggerPlugin.getAnalyzer().getTrace(); + methodExecutions = trace.getMethodExecutions(methodSignature); + if (methodExecutions.isEmpty()) return false; + tracePoints.clear(); + for (MethodExecution me : methodExecutions) { + int order = 0; + for (Statement statement : me.getStatements()) { + if (statement.getLineNo() == lineNo) { + tracePoints.add(me.getTracePoint(order)); + break; + } + order++; + } + } + if (tracePoints.isEmpty()) return false; + Collections.sort(tracePoints, new Comparator() { + @Override + public int compare(TracePoint o1, TracePoint o2) { + long o1Time = getTime(o1); + long o2Time = getTime(o2); + return (o1Time < o2Time) ? -1 : 1; + } + private long getTime(TracePoint tp) { + Statement statement = tp.getStatement(); + if (statement instanceof MethodInvocation) { + return ((MethodInvocation)statement).getCalledMethodExecution().getEntryTime(); + } + return statement.getTimeStamp(); + } + }); + return true; + } + + public String getMethodSignature() { + return methodSignature; + } + + public String getReadableSignature() { + return readableSignature; + } + + public int getLineNo() { + return lineNo; + } + + public List getMethodExecutions() { + return methodExecutions; + } + + public List getTracePoints() { + return tracePoints; + } + + public boolean isAvailable() { + return isAvailable; + } + + public void setAvailable(boolean isAvailable) { + this.isAvailable = isAvailable; + } + + public void changeAvailable() { + isAvailable = !isAvailable; + } +} diff --git a/src/org/ntlab/traceDebugger/TraceBreakPoints.java b/src/org/ntlab/traceDebugger/TraceBreakPoints.java index 2fd08bf..b1e3eea 100644 --- a/src/org/ntlab/traceDebugger/TraceBreakPoints.java +++ b/src/org/ntlab/traceDebugger/TraceBreakPoints.java @@ -14,7 +14,6 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.jdt.internal.debug.core.breakpoints.JavaLineBreakpoint; -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodInvocation; import org.ntlab.traceAnalysisPlatform.tracer.trace.Statement; import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; diff --git a/src/org/ntlab/traceDebugger/TracePointsLabelProvider.java b/src/org/ntlab/traceDebugger/TracePointsLabelProvider.java index 278b1fb..3d4ae2b 100644 --- a/src/org/ntlab/traceDebugger/TracePointsLabelProvider.java +++ b/src/org/ntlab/traceDebugger/TracePointsLabelProvider.java @@ -1,63 +1,55 @@ -package org.ntlab.traceDebugger; - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; -import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; -import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; - -public class TracePointsLabelProvider extends LabelProvider implements ITableLabelProvider { - - @Override - public String getColumnText(Object element, int columnIndex) { - if (element instanceof TracePoint) { - TracePoint tp = (TracePoint)element; - switch (columnIndex) { - case 0: - return String.valueOf(tp.getStatement().getLineNo()); - case 1: - return getReadableSignature(tp.getMethodExecution()); - } - } - return "�e�X�g�p�e�L�X�g" + columnIndex; - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { -// return getImage(element); - return null; - } - -// @Override -// public Image getImage(Object element) { -// return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); -// } - - private String getReadableSignature(MethodExecution methodExecution) { - String signature = methodExecution.getSignature(); - String objectType = methodExecution.getThisClassName(); - objectType = objectType.substring(objectType.lastIndexOf(".") + 1); - boolean isConstructor = methodExecution.isConstructor(); - String declaringType = Trace.getDeclaringType(signature, isConstructor); - declaringType = declaringType.substring(declaringType.lastIndexOf(".") + 1); - String methodName = Trace.getMethodName(signature); - String args = "("; - String delimiter = ""; - String[] argArray = signature.split("\\(")[1].split(","); - for (String arg : argArray) { - args += (delimiter + arg.substring(arg.lastIndexOf(".") + 1)); - delimiter = ", "; - } - - StringBuilder sb = new StringBuilder(); - sb.append(objectType); - if (!declaringType.equals(objectType)) { - sb.append("(" + declaringType + ")"); - } - sb.append("." + methodName + args); - return sb.toString(); - } +package org.ntlab.traceDebugger; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; +import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; +import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; + +public class TracePointsLabelProvider extends LabelProvider implements ITableLabelProvider { + + @Override + public String getColumnText(Object element, int columnIndex) { + if (element instanceof TracePoint) { + TracePoint tp = (TracePoint)element; + switch (columnIndex) { + case 0: + return String.valueOf(tp.getStatement().getLineNo()); + case 1: + return getReadableSignature(tp.getMethodExecution()); + } + } + return "�e�X�g�p�e�L�X�g" + columnIndex; + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + private String getReadableSignature(MethodExecution methodExecution) { + String signature = methodExecution.getSignature(); + String objectType = methodExecution.getThisClassName(); + objectType = objectType.substring(objectType.lastIndexOf(".") + 1); + boolean isConstructor = methodExecution.isConstructor(); + String declaringType = Trace.getDeclaringType(signature, isConstructor); + declaringType = declaringType.substring(declaringType.lastIndexOf(".") + 1); + String methodName = Trace.getMethodName(signature); + String args = "("; + String delimiter = ""; + String[] argArray = signature.split("\\(")[1].split(","); + for (String arg : argArray) { + args += (delimiter + arg.substring(arg.lastIndexOf(".") + 1)); + delimiter = ", "; + } + + StringBuilder sb = new StringBuilder(); + sb.append(objectType); + if (!declaringType.equals(objectType)) { + sb.append("(" + declaringType + ")"); + } + sb.append("." + methodName + args); + return sb.toString(); + } } \ No newline at end of file diff --git a/src/org/ntlab/traceDebugger/Variable.java b/src/org/ntlab/traceDebugger/Variable.java index 125ff5f..8ea1fe1 100644 --- a/src/org/ntlab/traceDebugger/Variable.java +++ b/src/org/ntlab/traceDebugger/Variable.java @@ -29,7 +29,6 @@ private String containerId; private TracePoint lastUpdatePoint; private TracePoint before; - private boolean isReturned; private DeepHierarchy deepHierarchy; private boolean alreadyCreatedChildHierarchy = false; private boolean alreadyCreatedGrandChildHierarchy = false; @@ -60,22 +59,17 @@ } public Variable(String variableName, String containerClassName, String containerId, - String valueClassName, String valueId, TracePoint before, boolean isReturned) { - this(variableName, containerClassName, containerId, valueClassName, valueId, before, isReturned, VariableType.USE_VALUE); - } - - public Variable(String variableName, String containerClassName, String containerId, - String valueClassName, String valueId, TracePoint before, boolean isReturned, VariableType variableType) { - init(variableName, variableName, containerClassName, containerId, valueClassName, valueId, null, before, isReturned, variableType); + String valueClassName, String valueId, TracePoint before, VariableType variableType) { + init(variableName, variableName, containerClassName, containerId, valueClassName, valueId, null, before, variableType); } public Variable(String variableName, String fullyQualifiedVariableName, String containerClassName, String containerId, - String valueClassName, String valueId, TracePoint lastUpdatePoint, TracePoint before, boolean isReturned, VariableType variableType) { - init(variableName, fullyQualifiedVariableName, containerClassName, containerId, valueClassName, valueId, lastUpdatePoint, before, isReturned, variableType); - } + String valueClassName, String valueId, TracePoint lastUpdatePoint, TracePoint before, VariableType variableType) { + init(variableName, fullyQualifiedVariableName, containerClassName, containerId, valueClassName, valueId, lastUpdatePoint, before, variableType); + } private void init(String variableName, String fullyQualifiedVariableName, String containerClassName, String containerId, - String valueClassName, String valueId, TracePoint lastUpdatePoint, TracePoint before, boolean isReturned, VariableType variableType) { + String valueClassName, String valueId, TracePoint lastUpdatePoint, TracePoint before, VariableType variableType) { this.variableName = variableName; this.fullyQualifiedVariableName = fullyQualifiedVariableName; this.containerClassName = containerClassName; @@ -84,7 +78,6 @@ this.valueId = valueId; this.lastUpdatePoint = lastUpdatePoint; this.before = before; - this.isReturned = isReturned; this.variableType = variableType; this.deepHierarchy = checkDeepHierarchy(); this.alreadyCreatedChildHierarchy = false; @@ -93,8 +86,8 @@ this.additionalAttributes.clear(); } - public void update(String valueClassName, String valueId, TracePoint lastUpdatePoint, boolean isReturned) { - init(variableName, fullyQualifiedVariableName, containerClassName, containerId, valueClassName, valueId, lastUpdatePoint, lastUpdatePoint, isReturned, variableType); + public void update(String valueClassName, String valueId, TracePoint lastUpdatePoint) { + init(variableName, fullyQualifiedVariableName, containerClassName, containerId, valueClassName, valueId, lastUpdatePoint, lastUpdatePoint, variableType); } public String getVariableName() { @@ -278,10 +271,10 @@ // �t�B�[���h��ID��Type���擾(String) String nextValueId = (fieldUpdate != null) ? fieldUpdate.getValueObjId() : "---"; String nextValueClassName = (fieldUpdate != null) ? fieldUpdate.getValueClassName() : NULL_VALUE; - Variable fieldData = new Variable(fieldName, fullyQualifiedFieldName, nextClassName, nextContainerId, nextValueClassName, nextValueId, updateTracePoint, before, isReturned, VariableType.USE_VALUE); + Variable fieldData = new Variable(fieldName, fullyQualifiedFieldName, nextClassName, nextContainerId, nextValueClassName, nextValueId, updateTracePoint, before, VariableType.USE_VALUE); this.addChild(fieldData); } else { - Variable fieldData = new Variable(fieldName, fullyQualifiedFieldName, valueClassName, valueId, NULL_VALUE, "---", updateTracePoint, before, isReturned, VariableType.USE_VALUE); + Variable fieldData = new Variable(fieldName, fullyQualifiedFieldName, valueClassName, valueId, NULL_VALUE, "---", updateTracePoint, before, VariableType.USE_VALUE); this.addChild(fieldData); } } @@ -306,7 +299,7 @@ nextValueId = arrayUpdate.getValueObjectId(); nextValueClassName = arrayUpdate.getValueClassName(); } - Variable arrayIndexData = new Variable(arrayIndexName, fullyArrayIndexName, nextClassName, nextContainerId, nextValueClassName, nextValueId, updateTracePoint, before, isReturned, VariableType.USE_VALUE); + Variable arrayIndexData = new Variable(arrayIndexName, fullyArrayIndexName, nextClassName, nextContainerId, nextValueClassName, nextValueId, updateTracePoint, before, VariableType.USE_VALUE); this.addChild(arrayIndexData); } } diff --git a/src/org/ntlab/traceDebugger/VariableView.java b/src/org/ntlab/traceDebugger/VariableView.java index e47f9a7..b409e81 100644 --- a/src/org/ntlab/traceDebugger/VariableView.java +++ b/src/org/ntlab/traceDebugger/VariableView.java @@ -136,27 +136,22 @@ viewer.setInput(variables.getVariablesTreeNodesList()); viewer.refresh(); } - - public void updateVariablesByTracePoint(TracePoint tp, boolean isReturned) { - updateVariablesByTracePoint(tp, isReturned, null); - } - public void updateVariablesByTracePoint(TracePoint tp, boolean isReturned, TracePoint before) { - updateVariablesByTracePoint(null, tp, isReturned, before); + public void updateVariablesByTracePoints(TracePoint tp, TracePoint before) { + updateVariablesByTracePoints(null, tp, before); } - public void updateVariablesByTracePoint(TracePoint from, TracePoint to, boolean isReturned) { - updateVariablesByTracePoint(from, to, isReturned, null); + public void updateVariablesByTracePointsFromAToB(TracePoint from, TracePoint to) { + updateVariablesByTracePoints(from, to, null); } - public void updateVariablesByTracePoint(TracePoint from, TracePoint to, boolean isReturned, TracePoint before) { - variables.updateAllObjectDataByTracePoint(from, to, isReturned, before); + public void updateVariablesByTracePoints(TracePoint from, TracePoint to, TracePoint before) { + variables.updateAllObjectDataByTracePoint(from, to, before); viewer.setInput(variables.getVariablesTreeNodesList()); } - public void updateVariablesForDifferential(TracePoint from, TracePoint to, boolean isReturned) { - variables.updateForDifferential(from, to, isReturned); -// viewer.setInput(variables.getVariablesTreeNodes()); + public void updateVariablesForDifferential(TracePoint from, TracePoint to) { + variables.updateForDifferential(from, to); viewer.refresh(); } } diff --git a/src/org/ntlab/traceDebugger/Variables.java b/src/org/ntlab/traceDebugger/Variables.java index b0e5bbb..f30de4a 100644 --- a/src/org/ntlab/traceDebugger/Variables.java +++ b/src/org/ntlab/traceDebugger/Variables.java @@ -1,8 +1,6 @@ package org.ntlab.traceDebugger; import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -20,12 +18,12 @@ import org.ntlab.traceAnalysisPlatform.tracer.trace.Statement; import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; import org.ntlab.traceDebugger.Variable.VariableType; +import org.ntlab.traceDebugger.analyzerProvider.VariableUpdatePointFinder; public class Variables { private static final Variables theInstance = new Variables(); private List roots = new ArrayList<>(); private List rootTreeNodes = new ArrayList<>(); - private Map> containerIdToDifferentialUpdateTracePoints = new HashMap<>(); // �ϐ������X�V�ӏ����L�� public static final String VARIABLE_TYPE_KEY = "variableType"; public static Variables getInstance() { @@ -53,35 +51,35 @@ List statements = methodExecution.getStatements(); int lastOrder = statements.size() - 1; TracePoint tp = methodExecution.getTracePoint(lastOrder); - updateAllObjectData(null, tp, false, null); + updateAllObjectData(null, tp, null); } - public void updateAllObjectDataByTracePoint(TracePoint from, TracePoint to, boolean isReturned, TracePoint before) { - updateAllObjectData(from, to, isReturned, before); + public void updateAllObjectDataByTracePoint(TracePoint from, TracePoint to, TracePoint before) { + updateAllObjectData(from, to, before); } - private void updateAllObjectData(TracePoint from, TracePoint to, boolean isReturned, TracePoint before) { + private void updateAllObjectData(TracePoint from, TracePoint to, TracePoint before) { resetData(); MethodExecution me = to.getMethodExecution(); - updateRootThisState(me, to, isReturned, before); - updateArgsState(me, to, isReturned, before); + updateRootThisState(me, to, before); + updateArgsState(me, to, before); for (int i = 0; i < roots.size(); i++) { Variable rootVariableData = roots.get(i); createVariablesTreeNodeList(null, rootTreeNodes, i, rootVariableData); } - createSpecialVariables(from, to, isReturned); + createSpecialVariables(from, to); } - private void updateRootThisState(MethodExecution methodExecution, TracePoint tp, boolean isReturned, TracePoint before) { + private void updateRootThisState(MethodExecution methodExecution, TracePoint tp, TracePoint before) { String thisObjId = methodExecution.getThisObjId(); String thisClassName = methodExecution.getThisClassName(); if (before == null) before = tp; - Variable variable = new Variable("this", null, null, thisClassName, thisObjId, before, isReturned, VariableType.THIS); + Variable variable = new Variable("this", null, null, thisClassName, thisObjId, before, VariableType.THIS); roots.add(variable); variable.createNextHierarchyState(); } - private void updateArgsState(MethodExecution methodExecution, TracePoint tp, boolean isReturned, TracePoint before) { + private void updateArgsState(MethodExecution methodExecution, TracePoint tp, TracePoint before) { // methodExecution������arguments���擾(ArrayList)���A����arguments�̃T�C�Y���擾(int) List args = methodExecution.getArguments(); if (before == null) before = tp; @@ -95,7 +93,7 @@ ObjectReference arg = args.get(i); String argId = arg.getId(); String argType = arg.getActualType(); - Variable argData = new Variable(argName, null, null, argType, argId, before, isReturned, VariableType.PARAMETER); + Variable argData = new Variable(argName, null, null, argType, argId, before, VariableType.PARAMETER); argData.createNextHierarchyState(); roots.add(argData); } @@ -134,70 +132,50 @@ addAdditionalAttributes(child, idSet, additionalAttributes); } } - - public void addDifferentialUpdatePoint(TracePoint tp) { - Statement statement = tp.getStatement(); - String containerId = null; - if (statement instanceof FieldUpdate) { - FieldUpdate fu = (FieldUpdate)statement; - containerId = fu.getContainerObjId(); - } else if (statement instanceof ArrayUpdate) { - ArrayUpdate au = (ArrayUpdate)statement; - containerId = au.getArrayObjectId(); - } - if (containerId == null) return; - List tracePoints = containerIdToDifferentialUpdateTracePoints.get(containerId); - if (tracePoints == null) { - tracePoints = new ArrayList(); - containerIdToDifferentialUpdateTracePoints.put(containerId, tracePoints); - } - tracePoints.add(tp.duplicate()); - } - public void updateForDifferential(TracePoint from, TracePoint to, boolean isReturned) { + public void updateForDifferential(TracePoint from, TracePoint to) { updateForDifferential(to); resetSpecialValues(); - createSpecialVariables(from, to, isReturned); + createSpecialVariables(from, to); } private void updateForDifferential(TracePoint before) { for (Variable variable : roots) { - updateForDifferential(variable, new HashSet(), before); + updateForDifferental(variable, before); } - containerIdToDifferentialUpdateTracePoints.clear(); } - - private void updateForDifferential(Variable variable, Set hasCheckedObjectIdSet, TracePoint before) { + + private void updateForDifferental(Variable variable, TracePoint before) { variable.setBeforeTracePoint(before); - Set containerIdList = containerIdToDifferentialUpdateTracePoints.keySet(); - String containerId = variable.getContainerId(); - if (containerIdList.contains(containerId)) { - for (TracePoint tp : containerIdToDifferentialUpdateTracePoints.get(containerId)) { - Statement statement = tp.getStatement(); + String objectId = variable.getContainerId(); + String variableName = variable.getFullyQualifiedVariableName(); + if (variableName.contains("[")) { + // note: �z��̏ꍇ�̓C���f�b�N�X�݂̂����o�� + String arrayIndexName = variable.getVariableName(); + variableName = arrayIndexName.substring(arrayIndexName.indexOf("[") + 1, arrayIndexName.lastIndexOf("]")); + } + + TracePoint lastUpdatePoint = variable.getLastUpdatePoint(); + TracePoint updateTracePoint = VariableUpdatePointFinder.getInstance().getPoint(objectId, variableName, before); + if (updateTracePoint != null) { + Statement statement = updateTracePoint.getStatement(); + if (lastUpdatePoint == null || !(statement.equals(lastUpdatePoint.getStatement()))) { if (statement instanceof FieldUpdate) { FieldUpdate fu = (FieldUpdate)statement; - if (variable.getFullyQualifiedVariableName().equals(fu.getFieldName())) { - updateForDifferentialField(variable, fu.getValueClassName(), fu.getValueObjId(), tp); - } + updateForDifferentialField(variable, fu.getValueClassName(), fu.getValueObjId(), updateTracePoint); } else if (statement instanceof ArrayUpdate) { ArrayUpdate au = (ArrayUpdate)statement; - String fullyQualifiedVariableName = variable.getFullyQualifiedVariableName(); - if (fullyQualifiedVariableName.contains("[" + au.getIndex() + "]")) { - updateForDifferentialField(variable, au.getValueClassName(), au.getValueObjectId(), tp); - } + updateForDifferentialField(variable, au.getValueClassName(), au.getValueObjectId(), updateTracePoint); } } } - HashSet hasCheckedObjectIdSetOnNext = new HashSet<>(hasCheckedObjectIdSet); - hasCheckedObjectIdSetOnNext.add(variable.getContainerId()); for (Variable child : variable.getChildren()) { - if (hasCheckedObjectIdSetOnNext.contains(child.getContainerId())) continue; - updateForDifferential(child, hasCheckedObjectIdSetOnNext, before); + updateForDifferental(child, before); } } private void updateForDifferentialField(Variable variable, String valueClassName, String valueId, TracePoint lastUpdatePoint) { - variable.update(valueClassName, valueId, lastUpdatePoint, false); + variable.update(valueClassName, valueId, lastUpdatePoint); variable.createNextHierarchyState(); MyTreeNode node = getTreeNodeFor(variable, rootTreeNodes); List childList = node.getChildList(); @@ -208,8 +186,7 @@ } } - private void createSpecialVariables(TracePoint from, TracePoint to, boolean isReturned) { -// List list = new ArrayList<>(); + private void createSpecialVariables(TracePoint from, TracePoint to) { List specialVariablesOfUseSide = new ArrayList<>(); List specialVariablesDefSide = new ArrayList<>(); String parentNodeNameOfUseSide = null; @@ -223,8 +200,8 @@ String containerObjId = fa.getContainerObjId(); String valueClassName = fa.getValueClassName(); String valueObjId = fa.getValueObjId(); - Variable container = new Variable(Variable.CONTAINER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, isReturned, VariableType.USE_CONTAINER); - Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, isReturned, VariableType.USE_VALUE); + Variable container = new Variable(Variable.CONTAINER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, VariableType.USE_CONTAINER); + Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, VariableType.USE_VALUE); specialVariablesOfUseSide.add(container); specialVariablesOfUseSide.add(value); parentNodeNameOfUseSide = TraceDebuggerPlugin.isJapanese() ? "�t�B�[���h�Q�ƌ�:" : "after field get of:"; @@ -235,8 +212,8 @@ String arrayObjId = aa.getArrayObjectId(); String valueClassName = aa.getValueClassName(); String valueObjId = aa.getValueObjectId(); - Variable array = new Variable(Variable.CONTAINER_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, from, isReturned, VariableType.USE_CONTAINER); - Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, from, isReturned, VariableType.USE_VALUE); + Variable array = new Variable(Variable.CONTAINER_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, from, VariableType.USE_CONTAINER); + Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, from, VariableType.USE_VALUE); specialVariablesOfUseSide.add(array); specialVariablesOfUseSide.add(value); parentNodeNameOfUseSide = TraceDebuggerPlugin.isJapanese() ? "�z��v�f�Q�ƌ�:" : "after array get of:"; @@ -250,8 +227,8 @@ String containerObjId = calledME.getThisObjId(); String valueClassName = returnValue.getActualType(); String valueObjId = returnValue.getId(); - Variable receiver = new Variable(Variable.RECEIVER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, isReturned, VariableType.USE_RECEIVER); - Variable returned = new Variable(Variable.RETURN_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, isReturned, VariableType.USE_RETURN); + Variable receiver = new Variable(Variable.RECEIVER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, VariableType.USE_RECEIVER); + Variable returned = new Variable(Variable.RETURN_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, from, VariableType.USE_RETURN); specialVariablesOfUseSide.add(receiver); specialVariablesOfUseSide.add(returned); if (calledME.isConstructor()) { @@ -274,8 +251,8 @@ String containerObjId = fu.getContainerObjId(); String valueClassName = fu.getValueClassName(); String valueObjId = fu.getValueObjId(); - Variable container = new Variable(Variable.CONTAINER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, isReturned, VariableType.DEF_CONTAINER); - Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, isReturned, VariableType.DEF_VALUE); + Variable container = new Variable(Variable.CONTAINER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, VariableType.DEF_CONTAINER); + Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, VariableType.DEF_VALUE); specialVariablesDefSide.add(container); specialVariablesDefSide.add(value); parentNodeNameOfDefSide = TraceDebuggerPlugin.isJapanese() ? "�t�B�[���h����O:" : "before field set of:"; @@ -286,8 +263,8 @@ String arrayObjId = au.getArrayObjectId(); String valueClassName = au.getValueClassName(); String valueObjId = au.getValueObjectId(); - Variable array = new Variable(Variable.CONTAINER_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, to, isReturned, VariableType.DEF_CONTAINER); - Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, to, isReturned, VariableType.DEF_VALUE); + Variable array = new Variable(Variable.CONTAINER_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, to, VariableType.DEF_CONTAINER); + Variable value = new Variable(Variable.VALUE_VARIABLE_NAME, arrayClassName, arrayObjId, valueClassName, valueObjId, to, VariableType.DEF_VALUE); specialVariablesDefSide.add(array); specialVariablesDefSide.add(value); parentNodeNameOfDefSide = TraceDebuggerPlugin.isJapanese() ? "�z��v�f����O:" : "before array set of:"; @@ -304,12 +281,12 @@ } String containerClassName = calledME.getThisClassName(); String containerObjId = calledME.getThisObjId(); - Variable receiver = new Variable(Variable.RECEIVER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, isReturned, VariableType.DEF_RECEIVER); + Variable receiver = new Variable(Variable.RECEIVER_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, VariableType.DEF_RECEIVER); specialVariablesDefSide.add(receiver); for (ObjectReference obj : args) { valueClassName = obj.getActualType(); valueObjId = obj.getId(); - Variable arg = new Variable(Variable.ARG_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, isReturned, VariableType.DEF_ARG); + Variable arg = new Variable(Variable.ARG_VARIABLE_NAME, containerClassName, containerObjId, valueClassName, valueObjId, to, VariableType.DEF_ARG); specialVariablesDefSide.add(arg); } if (calledME.isConstructor()) { @@ -358,7 +335,6 @@ public void resetData() { roots.clear(); rootTreeNodes.clear(); - containerIdToDifferentialUpdateTracePoints.clear(); } private void resetSpecialValues() { diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java index cd2ecaf..6a28e62 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java @@ -156,15 +156,11 @@ List> relatedAliasesList = new ArrayList<>(); relatedAliasesList.add(dstSideAliases); relatedAliasesList.add(srcSideAliases); -// String[] messagesTemplates = TraceDebuggerPlugin.isJapanese() ? new String[]{"�Q�Ɛ摤%03d", "�Q�ƌ���%03d"} -// : new String[]{"ReferredSide%03d", "ReferringSide%03d"}; String[] markerIDList = {DST_SIDE_DELTA_MARKER, SRC_SIDE_DELTA_MARKER}; for (int i = 0; i < relatedAliasesList.size(); i++) { List relatedAliases = relatedAliasesList.get(i); Collections.reverse(relatedAliases); -// int cnt = 1; for (Alias alias : relatedAliases) { -// String message = String.format(messagesTemplates[i], cnt++); markAndOpenJavaFileForAlias(alias, "", markerIDList[i]); } } @@ -252,7 +248,6 @@ Map attributes = new HashMap<>(); setAttributesForAlias(attributes, alias, file, markerId); if (!(attributes.containsKey(IMarker.LINE_NUMBER))) { -// attributes.put(IMarker.LINE_NUMBER, alias.getLineNo() + " (no marker)"); attributes.put(IMarker.LINE_NUMBER, alias.getLineNo()); } attributes.put(IMarker.MESSAGE, message); @@ -318,7 +313,6 @@ markerIdToMarkers.put(markerId, markerList); } markerList.add(marker); -// orderedMarkers.add(marker); } private void setAttributesForAlias(final Map attributes, Alias alias, IFile file, String markerId) { diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaRelatedAliasCollector.java b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaRelatedAliasCollector.java index f933e4c..5542610 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaRelatedAliasCollector.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaRelatedAliasCollector.java @@ -78,11 +78,6 @@ } else { dstSideIdList.add(to); } -// if (srcSideIdList.contains(from)) { -// srcSideIdList.add(to); -// } else if (dstSideIdList.contains(from)) { -// dstSideIdList.add(to); -// } } public List getRelatedAliases() { diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/ExtractedStructure.java b/src/org/ntlab/traceDebugger/analyzerProvider/ExtractedStructure.java index 8bea6d8..922d9b6 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/ExtractedStructure.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/ExtractedStructure.java @@ -1,107 +1,67 @@ -package org.ntlab.traceDebugger.analyzerProvider; - -import java.util.ArrayList; -import java.util.List; - -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; -import org.ntlab.traceAnalysisPlatform.tracer.trace.Reference; -import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; - - -public class ExtractedStructure { - - private Delta delta = new Delta(); - private MethodExecution coordinator = null; - private MethodExecution parent = null; - private MethodExecution creationCallTree; -// private List srcSideRelatedTracePoints = new ArrayList<>(); -// private List dstSideRelatedTracePoints = new ArrayList<>(); -// private List srcSideRelatedAliases = new ArrayList<>(); -// private List dstSideRelatedAliases = new ArrayList<>(); - - public Delta getDelta() { - return delta; - } - - public MethodExecution getCoordinator() { - return coordinator; - } - - /** - * ������ ������ɍ폜���邱�� - * @param coordinator - */ - public void setCoordinator(MethodExecution coordinator) { - this.coordinator = coordinator; - } - - public void createParent(MethodExecution methodExecution) { - coordinator = methodExecution; - parent = null; - } - -// public void addParent(MethodExecution callTree) { -// if (parent == null) -// coordinator.addChild(parent = callTree); -// else -// parent.addChild(parent = callTree); -// } -// -// public void addChild(MethodExecution callTree) { -// if (parent == null) -// coordinator.addChild(callTree); -// else -// parent.addChild(callTree); -// } -// - public void addSrcSide(Reference reference) { - delta.addSrcSide(reference); - } - - public void addDstSide(Reference reference) { - delta.addDstSide(reference); - } - - public void changeParent() { - } - - public void setCreationMethodExecution(MethodExecution callTree) { - creationCallTree = callTree; - } - - public MethodExecution getCreationCallTree() { - return creationCallTree; - } - -// public List getSrcSideRelatedTracePoints() { -// return srcSideRelatedTracePoints; -// } -// -// public List getDstSideRelatedTracePoints() { -// return dstSideRelatedTracePoints; -// } -// -// public void addSrcSideRelatedTracePoint(TracePoint tp) { -// srcSideRelatedTracePoints.add(tp); -// } -// -// public void addDstSideRelatedTracePoint(TracePoint tp) { -// dstSideRelatedTracePoints.add(tp); -// } - -// public List getSrcSideRelatedAliases() { -// return srcSideRelatedAliases; -// } -// -// public List getDstSideRelatedAliases() { -// return dstSideRelatedAliases; -// } -// -// public void addSrcSideRelatedAlias(Alias alias) { -// srcSideRelatedAliases.add(alias); -// } -// -// public void addDstSideRelatedAlias(Alias alias) { -// dstSideRelatedAliases.add(alias); -// } -} +package org.ntlab.traceDebugger.analyzerProvider; + +import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; +import org.ntlab.traceAnalysisPlatform.tracer.trace.Reference; + + +public class ExtractedStructure { + + private Delta delta = new Delta(); + private MethodExecution coordinator = null; + private MethodExecution parent = null; + private MethodExecution creationCallTree; + + public Delta getDelta() { + return delta; + } + + public MethodExecution getCoordinator() { + return coordinator; + } + + /** + * ������ ������ɍ폜���邱�� + * @param coordinator + */ + public void setCoordinator(MethodExecution coordinator) { + this.coordinator = coordinator; + } + + public void createParent(MethodExecution methodExecution) { + coordinator = methodExecution; + parent = null; + } + +// public void addParent(MethodExecution callTree) { +// if (parent == null) +// coordinator.addChild(parent = callTree); +// else +// parent.addChild(parent = callTree); +// } +// +// public void addChild(MethodExecution callTree) { +// if (parent == null) +// coordinator.addChild(callTree); +// else +// parent.addChild(callTree); +// } +// + public void addSrcSide(Reference reference) { + delta.addSrcSide(reference); + } + + public void addDstSide(Reference reference) { + delta.addDstSide(reference); + } + + public void changeParent() { + } + + public void setCreationMethodExecution(MethodExecution callTree) { + creationCallTree = callTree; + } + + public MethodExecution getCreationCallTree() { + return creationCallTree; + } +}