Kyle Shank wrote:
How is the debug support coming along?
Today I have checked in a basic version but I have wasted time on a try to change the threading model of ruby-debug. Therefore the integration is still very basic. Nevertheless you can run a scenario which shows the stack frames and the variable view. Threading is not correctly supported yet which means that all existing threads are shown but they do not display the correct stack frames. Only the suspended thread (e.g. the one where the breakpoint occurred) shows its stack frames along with its variables. Sometimes the connection between debug view (where the stack frames are displayed) and the editor does not work and external sources are not found. Stepping, at least "Step over" should be OK, too.

I have attached a patch which integrates the debug support into RadRails. It is just meant to be an idea of how it could work and replaces the functionality of the start action for the WEBrick server. As opposed to the current implementation it uses a launch configuration to start the server. Do you think it would make sense to switch to launch configurations also for the regular start-up? It would give further configuration options for the users.

Here is a direction if you want to give it a try (I would be interested if it works on OSX, I have tested only Linux so far):

1) Check out RDT trunk or use a nightly build not older than 0.8.0.611191859NGT (you currently have to download from http://213.239.199.113:8080/cruisecontrol/buildresults/RDT, since the upload from the build server to our official update site is out of order)
2) Install ruby-debug gem from org.rubypeople.rdt.launching
3) Apply patch to RadRails
4) Startup RDT/RadRails
5) Switch on ruby-debug in Preferences->RDT->Debugger
6) Set a breakpoint in a controller
7) Start WEBrick server
8) Call controller with URL => RDT will ask to switch to Debug perspective

cheers
Markus



Index: META-INF/MANIFEST.MF
===================================================================
--- META-INF/MANIFEST.MF        (revision 1613)
+++ META-INF/MANIFEST.MF        (working copy)
@@ -12,7 +12,8 @@
  org.eclipse.ui,
  org.eclipse.core.resources,
  org.eclipse.ui.console,
- org.eclipse.update.core
+ org.eclipse.update.core,
+ org.eclipse.debug.ui
 Eclipse-AutoStart: true
 Export-Package: org.radrails.server.core,
  org.radrails.server.core.lighttpd,
Index: src/org/radrails/server/core/webrick/WEBrickServer.java
===================================================================
--- src/org/radrails/server/core/webrick/WEBrickServer.java     (revision 1613)
+++ src/org/radrails/server/core/webrick/WEBrickServer.java     (working copy)
@@ -23,6 +23,9 @@
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.debug.core.IStreamListener;
 import org.eclipse.debug.core.Launch;
@@ -28,6 +31,8 @@
 import org.eclipse.debug.core.Launch;
 import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.IStreamMonitor;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.DebugUITools;
 import org.eclipse.swt.SWT;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.console.ConsolePlugin;
@@ -34,6 +39,7 @@
 import org.eclipse.ui.console.IConsole;
 import org.eclipse.ui.console.MessageConsoleStream;
 import org.radrails.db.core.IDatabaseConstants;
+import org.radrails.rails.core.IRailsConstants;
 import org.radrails.rails.internal.core.RailsRuntime;
 import org.radrails.server.core.IServerConstants;
 import org.radrails.server.core.Server;
@@ -58,7 +64,7 @@
        private MessageConsoleStream stdErrStream;
 
        private int pid = -1;
-       
+
        private boolean keepStarting;
 
        /**
@@ -131,7 +137,8 @@
        public void start() {
                Job j = new Job("Starting server") {
                        protected IStatus run(IProgressMonitor monitor) {
-                               startServer();
+                               //startServer();
+                               debug() ;
                                return Status.OK_STATUS;
                        }
                };
@@ -138,6 +145,39 @@
                j.schedule();
        }
 
+       public void debug() {
+               // TODO: Create a dependendy to rdt.launching and use
+               // 
RubyLaunchConfigurationAttribute.RUBY_LAUNCH_CONFIGURATION_TYPE ?
+
+               ILaunchConfigurationType launchConfigurationType = DebugPlugin
+                               .getDefault()
+                               .getLaunchManager()
+                               .getLaunchConfigurationType(
+                                               
"org.rubypeople.rdt.launching.LaunchConfigurationTypeRubyApplication");
+               try {
+                       ILaunchConfigurationWorkingCopy launchConfigWC = 
launchConfigurationType
+                                       .newInstance(null, "webrickserver");
+                       launchConfigWC.setAttribute(
+                                       
"org.rubypeople.rdt.launching.PROJECT_NAME", getProject().getName());
+                       launchConfigWC.setAttribute(
+                                       
"org.rubypeople.rdt.launching.FILE_NAME", "script/server");
+                       String args = "-e puts('RAILSPID='+Process.pid.to_s) "
+                                       + IRailsConstants.OUTPUT_SYNC + " 
webrick --port=" + port
+                                       + " --environment=" + environment;
+                       launchConfigWC.setAttribute(
+                                       
"org.rubypeople.rdt.launching.PROGRAM_ARGUMENTS", args);
+                       ILaunchConfiguration configuration = 
launchConfigWC.doSave() ;
+                       // 
attributeName.equals(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY
+                       // 
RubyLaunchConfigurationAttribute.INTERPRETER_ARGUMENTS
+               
+
+                       DebugUITools.launch(configuration, "debug") ;
+               } catch (CoreException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+       }
+
        /**
         * Internal implementation of starting the WEBrick server. Runs the 
server
         * command, opens a console window, and attaches the output streams to 
the
@@ -225,7 +265,8 @@
                        // Wait for the server to start
                        boolean available = true;
                        keepStarting = true;
-                       while (available = ServerPlugin.isPortAvailable(port) 
&& keepStarting) {
+                       while (available = ServerPlugin.isPortAvailable(port)
+                                       && keepStarting) {
                                try {
                                        Thread.sleep(10);
                                } catch (InterruptedException e) {
@@ -251,7 +292,7 @@
                        // Make sure to stop the start job, just in case the 
user is
                        // stopping the server while it's still starting
                        keepStarting = false;
-                       
+
                        Job j = new Job("Stopping server") {
                                protected IStatus run(IProgressMonitor monitor) 
{
                                        stopServer();
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rubyeclipse-development mailing list
Rubyeclipse-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rubyeclipse-development

Reply via email to