Permalink
Browse files

initial commit of debugging framework code

  • Loading branch information...
1 parent 9daee1b commit a361143473bc4e3086f3b483c793376407f90f7c @JPMoresmau committed Dec 30, 2009
Showing with 1,128 additions and 6 deletions.
  1. +60 −0 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/util/GHCiSyntaxTest.java
  2. +1 −0 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/GHCSyntax.java
  3. +35 −0 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/GHCiSyntax.java
  4. +2 −0 ...l.debug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/HaskellDebugCore.java
  5. +48 −0 ....core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellBreakpoint.java
  6. +321 −0 ...core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellDebugTarget.java
  7. +172 −0 ...core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellStrackFrame.java
  8. +150 −0 ...ebug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellThread.java
  9. +62 −0 ...debug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellValue.java
  10. +105 −0 ...ug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellVariable.java
  11. +10 −1 .../INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/launch/HaskellLaunchDelegate.java
  12. +2 −0 ...ell.debug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/util/CoreTexts.java
  13. +3 −1 ...bug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/util/coretexts.properties
  14. +3 −1 net.sf.eclipsefp.haskell.debug.core/META-INF/MANIFEST.MF
  15. +19 −1 net.sf.eclipsefp.haskell.debug.core/plugin.xml
  16. +31 −0 ...AL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/debug/HaskellBreakpointAdapterFactory.java
  17. +91 −0 ...ERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/debug/HaskellLineBreakpointAdapter.java
  18. +4 −1 net.sf.eclipsefp.haskell.debug.ui/META-INF/MANIFEST.MF
  19. +8 −0 net.sf.eclipsefp.haskell.debug.ui/plugin.xml
  20. +1 −1 net.sf.eclipsefp.haskell.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,60 @@
+package net.sf.eclipsefp.haskell.core.util;
+
+import java.util.regex.Matcher;
+import junit.framework.TestCase;
+
+
+public class GHCiSyntaxTest extends TestCase {
+
+ public GHCiSyntaxTest( final String name ) {
+ super( name );
+ }
+
+ public void testBreakpointPattern(){
+ String s="Breakpoint 0 activated at D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\Haskell0\\src\\Main.hs:9:4-14"+ResourceUtil.NL+"*Main> ";
+ Matcher m=GHCiSyntax.BREAKPOINT_SET_PATTERN.matcher( s );
+ assertTrue(m.find());
+ assertEquals("0",m.group( 1 ));
+ assertEquals("D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\Haskell0\\src\\Main.hs:9:4-14",m.group( 2 ));
+ }
+
+ public void testBreakpointLocationPattern(){
+ String s="D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\Haskell0\\src\\Main.hs:9:4-14";
+ //Pattern p=Pattern.compile( "([^\\:]+)");
+ Matcher m=GHCiSyntax.BREAKPOINT_LOCATION_PATTERN.matcher( s );
+ assertTrue(m.matches());
+ assertEquals("D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\Haskell0\\src\\Main.hs",m.group( 1 ));
+ assertEquals("9",m.group( 2 ));
+ assertEquals("4",m.group( 3 ));
+ assertEquals("14",m.group( 4 ));
+ }
+
+ public void testBreakpointLocationMultilinePattern(){
+ String s="D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\Haskell0\\src\\Test.hs:(29,0)-(35,13)";
+ //Pattern p=Pattern.compile( "([^\\:]+)");
+ Matcher m=GHCiSyntax.BREAKPOINT_LOCATIONMULTILINE_PATTERN.matcher( s );
+ assertTrue(m.matches());
+ assertEquals("D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\Haskell0\\src\\Test.hs",m.group( 1 ));
+ assertEquals("29",m.group( 2 ));
+ assertEquals("0",m.group( 3 ));
+ assertEquals("35",m.group( 4 ));
+ assertEquals("13",m.group( 5 ));
+ }
+
+ public void testBindingPattern(){
+ String s="_result :: IO String = _";
+ Matcher m=GHCiSyntax.BINDING_PATTERN.matcher( s );
+ assertTrue(m.matches());
+ assertEquals("_result",m.group(1));
+ assertEquals("IO String",m.group(2));
+ assertEquals("_",m.group(4));
+
+ s="_result :: IO String";
+ m=GHCiSyntax.BINDING_PATTERN.matcher( s );
+ assertTrue(m.matches());
+ assertEquals("_result",m.group(1));
+ assertEquals("IO String",m.group(2));
+ assertNull( m.group(3));
+ assertNull( m.group(4));
+ }
+}
@@ -66,4 +66,5 @@ private static String makeExe( final String command ) {
boolean windows = Platform.OS_WIN32.equals( Platform.getOS() );
return windows ? command + ".exe" : command; //$NON-NLS-1$
}
+
}
@@ -0,0 +1,35 @@
+package net.sf.eclipsefp.haskell.core.util;
+
+import java.util.regex.Pattern;
+
+/**
+ * GHCi syntax strings, for parsing answers
+ * @author jean-philippem
+ *
+ */
+public class GHCiSyntax {
+
+ public static final Pattern BREAKPOINT_SET_PATTERN=Pattern.compile( "Breakpoint (\\d+) activated at (.+)$",Pattern.MULTILINE); //$NON-NLS-1$
+ public static final Pattern BREAKPOINT_STOP_PATTERN=Pattern.compile( "^Stopped at (.+)$",Pattern.MULTILINE); //$NON-NLS-1$
+ public static final Pattern BREAKPOINT_LOCATION_PATTERN=Pattern.compile( "(.+)\\:(\\d+)\\:(\\d+)\\-(\\d+)"); //$NON-NLS-1$
+ public static final Pattern BREAKPOINT_LOCATIONMULTILINE_PATTERN=Pattern.compile( "(.+)\\:\\((\\d+),(\\d+)\\)\\-\\((\\d+),(\\d+)\\)");//$NON-NLS-1$
+ public static final Pattern BINDING_PATTERN=Pattern.compile("(.+) \\:\\: ([^\\=]+)( \\= (.+))?"); //$NON-NLS-1$
+
+ public static final String UNRESOLVED="_"; //$NON-NLS-1$
+
+ public static final String CONTINUE_COMMAND=":continue"; //$NON-NLS-1$
+ public static final String QUIT_COMMAND=":q"; //$NON-NLS-1$
+ public static final String DELETE_ALL_BREAKPOINTS_COMMAND=":delete *"; //$NON-NLS-1$
+ public static final String SHOW_BINDINGS_COMMAND=":show bindings"; //$NON-NLS-1$
+ public static final String STEP_COMMAND=":step"; //$NON-NLS-1$
+
+ public static final String PROMPT_END="> "; //$NON-NLS-1$
+
+ public static String setBreakpointCommand(final String module, final int lineNumber){
+ return ":break " +module+" "+ lineNumber; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ public static String deleteBreakpointCommand(final int breakpointNumber){
+ return ":delete " + breakpointNumber; //$NON-NLS-1$
+ }
+}
@@ -14,6 +14,8 @@
*/
public class HaskellDebugCore extends Plugin {
+ public static final String ID_HASKELL_DEBUG_MODEL = "net.sf.eclipsefp.haskell.debug"; //$NON-NLS-1$
+
// The shared instance
private static HaskellDebugCore plugin;
@@ -0,0 +1,48 @@
+package net.sf.eclipsefp.haskell.debug.core.internal.debug;
+
+import net.sf.eclipsefp.haskell.debug.core.internal.HaskellDebugCore;
+import net.sf.eclipsefp.haskell.debug.core.internal.util.CoreTexts;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.LineBreakpoint;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * breakpoint on haskell source file
+ * @author jean-philippem
+ *
+ */
+public class HaskellBreakpoint extends LineBreakpoint {
+
+ /**
+ *
+ * @param resource file on which to set the breakpoint
+ * @param lineNumber 1-based line number of the breakpoint
+ * @throws CoreException if unable to create the breakpoint
+ */
+ public HaskellBreakpoint(final IResource resource, final int lineNumber)
+ throws CoreException {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(final IProgressMonitor monitor) throws CoreException {
+ IMarker marker = resource
+ .createMarker("net.sf.eclipsefp.haskell.debug.core.breakpoint"); //$NON-NLS-1$
+ setMarker(marker);
+ marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE);
+ marker.setAttribute(IBreakpoint.PERSISTED, Boolean.TRUE);
+ marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
+ marker.setAttribute(IBreakpoint.ID, getModelIdentifier());
+ marker.setAttribute(IMarker.MESSAGE, NLS.bind( CoreTexts.breakpoint_message, resource.getName(),String.valueOf(lineNumber) ));
+ }
+ };
+ run(getMarkerRule(resource), runnable);
+ }
+
+ public String getModelIdentifier() {
+ return HaskellDebugCore.ID_HASKELL_DEBUG_MODEL;
+ }
+
+}
Oops, something went wrong.

0 comments on commit a361143

Please sign in to comment.