diff --git a/org.ntlab.debuggingControl/.classpath b/org.ntlab.debuggingControl/.classpath new file mode 100644 index 0000000..b1dabee --- /dev/null +++ b/org.ntlab.debuggingControl/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.ntlab.debuggingControl/.project b/org.ntlab.debuggingControl/.project new file mode 100644 index 0000000..2cad714 --- /dev/null +++ b/org.ntlab.debuggingControl/.project @@ -0,0 +1,28 @@ + + + org.ntlab.debuggingControl + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.ntlab.debuggingControl/.settings/CVS/Entries b/org.ntlab.debuggingControl/.settings/CVS/Entries new file mode 100644 index 0000000..3f96714 --- /dev/null +++ b/org.ntlab.debuggingControl/.settings/CVS/Entries @@ -0,0 +1 @@ +/org.eclipse.jdt.core.prefs/1.2/Wed Dec 9 07:18:21 2015// diff --git a/org.ntlab.debuggingControl/.settings/CVS/Repository b/org.ntlab.debuggingControl/.settings/CVS/Repository new file mode 100644 index 0000000..f9ae7d0 --- /dev/null +++ b/org.ntlab.debuggingControl/.settings/CVS/Repository @@ -0,0 +1 @@ +org.ntlab.debuggingControl/.settings diff --git a/org.ntlab.debuggingControl/.settings/CVS/Root b/org.ntlab.debuggingControl/.settings/CVS/Root new file mode 100644 index 0000000..6041112 --- /dev/null +++ b/org.ntlab.debuggingControl/.settings/CVS/Root @@ -0,0 +1 @@ +:pserver:n-nitta@nitta-lab-www.is.konan-u.ac.jp:\CVSProject diff --git a/org.ntlab.debuggingControl/.settings/org.eclipse.jdt.core.prefs b/org.ntlab.debuggingControl/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..11f6e46 --- /dev/null +++ b/org.ntlab.debuggingControl/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/org.ntlab.debuggingControl/META-INF/CVS/Entries b/org.ntlab.debuggingControl/META-INF/CVS/Entries new file mode 100644 index 0000000..8b3db2a --- /dev/null +++ b/org.ntlab.debuggingControl/META-INF/CVS/Entries @@ -0,0 +1 @@ +/MANIFEST.MF/1.1/Wed Dec 9 07:11:31 2015// diff --git a/org.ntlab.debuggingControl/META-INF/CVS/Repository b/org.ntlab.debuggingControl/META-INF/CVS/Repository new file mode 100644 index 0000000..0ad0de2 --- /dev/null +++ b/org.ntlab.debuggingControl/META-INF/CVS/Repository @@ -0,0 +1 @@ +org.ntlab.debuggingControl/META-INF diff --git a/org.ntlab.debuggingControl/META-INF/CVS/Root b/org.ntlab.debuggingControl/META-INF/CVS/Root new file mode 100644 index 0000000..6041112 --- /dev/null +++ b/org.ntlab.debuggingControl/META-INF/CVS/Root @@ -0,0 +1 @@ +:pserver:n-nitta@nitta-lab-www.is.konan-u.ac.jp:\CVSProject diff --git a/org.ntlab.debuggingControl/META-INF/MANIFEST.MF b/org.ntlab.debuggingControl/META-INF/MANIFEST.MF new file mode 100644 index 0000000..dd256e7 --- /dev/null +++ b/org.ntlab.debuggingControl/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: DebuggingControl +Bundle-SymbolicName: org.ntlab.debuggingControl;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.ntlab.debuggingControl.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.debug.core, + org.eclipse.jdt.debug +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy diff --git a/org.ntlab.debuggingControl/bin/.gitignore b/org.ntlab.debuggingControl/bin/.gitignore new file mode 100644 index 0000000..cf1db2e --- /dev/null +++ b/org.ntlab.debuggingControl/bin/.gitignore @@ -0,0 +1 @@ +/org/ diff --git a/org.ntlab.debuggingControl/build.properties b/org.ntlab.debuggingControl/build.properties new file mode 100644 index 0000000..6f20375 --- /dev/null +++ b/org.ntlab.debuggingControl/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/org.ntlab.debuggingControl/plugin.xml b/org.ntlab.debuggingControl/plugin.xml new file mode 100644 index 0000000..c7729d6 --- /dev/null +++ b/org.ntlab.debuggingControl/plugin.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/org.ntlab.debuggingControl/src/org/ntlab/debuggingControl/Activator.java b/org.ntlab.debuggingControl/src/org/ntlab/debuggingControl/Activator.java new file mode 100644 index 0000000..e6910b9 --- /dev/null +++ b/org.ntlab.debuggingControl/src/org/ntlab/debuggingControl/Activator.java @@ -0,0 +1,50 @@ +package org.ntlab.debuggingControl; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.ntlab.helloWorld"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/org.ntlab.debuggingControl/src/org/ntlab/debuggingControl/DebuggingControlAction.java b/org.ntlab.debuggingControl/src/org/ntlab/debuggingControl/DebuggingControlAction.java new file mode 100644 index 0000000..7d0fd7c --- /dev/null +++ b/org.ntlab.debuggingControl/src/org/ntlab/debuggingControl/DebuggingControlAction.java @@ -0,0 +1,111 @@ +package org.ntlab.debuggingControl; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.internal.core.LaunchManager; +import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.ClassType; +import com.sun.jdi.IncompatibleThreadStateException; +import com.sun.jdi.InvalidTypeException; +import com.sun.jdi.InvocationException; +import com.sun.jdi.Location; +import com.sun.jdi.Method; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.StackFrame; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; + +public class DebuggingControlAction implements IWorkbenchWindowActionDelegate { + + @Override + public void run(IAction arg0) { + // TODO Auto-generated method stub + LaunchManager lm = (LaunchManager)DebugPlugin.getDefault().getLaunchManager(); + + ILaunch[] launches = lm.getLaunches(); + if (launches.length == 0) { + MessageDialog.openInformation(null, null, "��xJava�v���O���������s���Ă�������"); + } else { + ILaunch debugLaunch = null; + for (int i = 0; i < launches.length; i++) { + System.out.print(launches[i].getLaunchConfiguration().getName() + ":"); + System.out.print(launches[i].getDebugTarget()); + if (launches[i].getDebugTarget() != null) { + debugLaunch = launches[i]; + break; + } + } + if (debugLaunch != null) { + JDIDebugTarget debugTarget = ((JDIDebugTarget)debugLaunch.getDebugTarget()); + VirtualMachine vm = debugTarget.getVM(); + if (vm != null) { + // �f�o�b�O���s���̏ꍇ + List allThreads = vm.allThreads(); + for (int i = 0; i < allThreads.size(); i++) { + ThreadReference thread = allThreads.get(i); + if (thread.isSuspended()) { + try { + // ��~���Ă���X���b�h���ǂ̃N���X�i�ǂ̃��\�b�h�j�̉��s�ڂŒ�~���Ă���̂���\������ + List frames = thread.frames(); // ��~�X���b�h���̑S�X�^�b�N�t���[�� + StackFrame topFrame = frames.get(0); + Location location = topFrame.location(); // �X�^�b�N�g�b�v�ɂ���t���[��(�u���[�N�|�C���g�Œ�~��) + MessageDialog.openInformation(null, null, "Thread [" + thread.name() + "] \n" + + location.method().declaringType().name() + "." + location.method().name() + location.method().signature() + " line: " + + location.lineNumber()); + + // �f�o�b�O���̃v���O�������̃N���X���\�b�h Test.test(Thread, Object) ���Ăяo��(�����������͒�~�X���b�h�Ƃ��̃X���b�h��Ō��ݎ��s���̃C���X�^���X) + List testClasses = vm.classesByName("Test"); // �N���X�� + ClassType testType = (ClassType)testClasses.get(0); + List methodsByName = testType.methodsByName("test"); // ���\�b�h�� + ArrayList args = new ArrayList(); // ���\�b�h�ɓn������ + args.add(topFrame.thread()); // �����ɂ̓X���b�h�iThreadReference�^�j��n���� + args.add(topFrame.thisObject()); // this �Ȃǂ� ObjectReference �^�̃I�u�W�F�N�g���n���� + Value v = testType.invokeMethod(thread, methodsByName.get(0), args, thread.INVOKE_SINGLE_THREADED); // �f�o�b�O���̃v���O�������̃��\�b�h���Ăяo�� + } catch (InvalidTypeException + | ClassNotLoadedException + | InvocationException e) { + e.printStackTrace(); + } catch (IncompatibleThreadStateException e) { + e.printStackTrace(); + } + } + } + } else { + MessageDialog.openInformation(null, null, "Java�v���O�������f�o�b�O���s���̒�~��Ԃɂ��Ă�������"); + } + } else { + MessageDialog.openInformation(null, null, "Java�v���O�������f�o�b�O���s���Ă�������"); + } + } + } + + @Override + public void selectionChanged(IAction arg0, ISelection arg1) { + // TODO Auto-generated method stub + + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } + + @Override + public void init(IWorkbenchWindow arg0) { + // TODO Auto-generated method stub + + } + +}