Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » Dbgp Howto needed
Dbgp Howto needed [message #502040] Fri, 04 December 2009 16:15 Go to next message
John Updike is currently offline John Updike
Messages: 3
Registered: December 2009
Junior Member
Dear Dltk users and developers,

I would like to find out how to use the Dbgp classes of Dltk in a minimal project. Unfortunately I am not able to understand the overall interaction of all Dltk classes (no documentation exists, does it?)

I try to do nothing more than starting a simple Dbgp server on port 9000 and then to connect with Activestate's pydbgp client (or any other client, if you have a better suggestion).

The following code continues until dbgp.waitTerminated(), and then waits forever. If I start the pydbgp script, some additional println statements in DbgpServer.workingCycle() show, that the connection is accepted and that DbgpServer.createSession() is called. But pydbgp just hangs and shows no initialization string.

I know, this is a stupid question. But how do I do something very simple, like sending the "feature_get" or "run" command to the pydbgp client???

Please help
John


Here comes my test class:
import org.eclipse.dltk.dbgp.DbgpServer;
import org.eclipse.dltk.dbgp.IDbgpServerListener;
import org.eclipse.dltk.dbgp.IDbgpSession;
import org.eclipse.dltk.dbgp.internal.DbgpDebugingEngine;
import org.eclipse.dltk.dbgp.internal.DbgpSession;


public class Main implements IDbgpServerListener {

public static void main(String[] args) throws InterruptedException {
new Main().runme(args);
}

private void runme(String[] args) throws InterruptedException {
DbgpServer dbgp=new DbgpServer(9000, 600000);

dbgp.setListener(this);
System.err.println("start");
dbgp.start();
System.err.println("started");
dbgp.waitTerminated();
System.err.println("terminated");
}

public void clientConnected(IDbgpSession session) {
System.err.println("client connected");
}

}
Re: Dbgp Howto needed [message #502126 is a reply to message #502040] Sun, 06 December 2009 03:33 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex Panchenko
Messages: 342
Registered: July 2009
Senior Member
Hi John,

The following code works for me.

But probably it should be done a bit differently. DbgpServer uses
ServerSocket to accept (multiple) connections, so if you don't want to
wait for another dbgp connection, you can close DbgpServer after 1st one
is connected.

Regards,
Alex

private DbgpServer dbgp = null;

private void runme() throws InterruptedException {
dbgp = new DbgpServer(9000, 600000);
dbgp.setListener(this);
System.err.println("start");
dbgp.start();
System.err.println("started");
dbgp.waitTerminated();
System.err.println("terminated");
}

public void clientConnected(IDbgpSession session) {
System.err.println("client connected");
try {
handleStatus(session.getCoreCommands().run(), session);
} catch (DbgpException e) {
e.printStackTrace();
}
}

private void handleStatus(final IDbgpStatus status,
final IDbgpSession session) {
if (status.isStopping()) {
new Job("Stop") {
@Override
protected IStatus run(IProgressMonitor monitor)
try {
handleStatus(session.getCoreCommands().stop(), session);
} catch (DbgpException e) {
e.printStackTrace();
}
return Status.OK_STATUS;
}
}.schedule();
} else if (status.isStopped() && dbgp != null) {
dbgp.requestTermination();
}
}
Re: Dbgp Howto needed [message #502134 is a reply to message #502126] Sun, 06 December 2009 07:48 Go to previous messageGo to next message
John Updike is currently offline John Updike
Messages: 3
Registered: December 2009
Junior Member
Alex, thank you very much for posting the code.

You have basically added the call to handleStatus() inside clientConnected(), right?

My problem is that the clientConnected() method is never reached, not with my code and not with yours.

My steps are:
1) Start your or my example code.

output:
>start
>started
>accept (from modified DbgpServer.workingCycle(), code not shown here)

2) Run pydbgp -d localhost:9000 test.py

output:
>accepted (from modified DbgpServer.workingCycle())
>create session (from modified DbgpServer.workingCycle())
>created session (from modified DbgpServer.workingCycle())
>accept (from modified DbgpServer.workingCycle())


Does your output show the "client connected" message? What are the exact steps that you did?
At the end of your line "protected IStatus run(IProgressMonitor monitor)" a "{" is missing (inside handleStatus()), could it be possible, that other code got lost during copy & paste?

Thanks
John
Re: Dbgp Howto needed [message #502150 is a reply to message #502134] Sun, 06 December 2009 11:08 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex Panchenko
Messages: 342
Registered: July 2009
Senior Member
Hi John,

Please make sure you launch your code as Eclipse Application.
Plugins expect lifecycle calls from the environment, so if you launch it
as java application some fields won't be initialized, and it wouldn't work.

The "public static void main(String[] args)" line in your original code
make me think you launch it as java application.

You should create plugin, and use org.eclipse.core.runtime.applications
extension point to declare your application entry point and specify your
application in the launch configuration.

Regards,
Alex
Re: Dbgp Howto needed [message #502152 is a reply to message #502150] Sun, 06 December 2009 11:31 Go to previous message
John Updike is currently offline John Updike
Messages: 3
Registered: December 2009
Junior Member
Good point. You are right. I tested this with a Java application.

I'll try to change it into an eclipse application within the next days.

Can you recommend any documentation on this topic, how the remote debugging functions are implemented in Dltk, and how they are supposed to be used? The Dltk Wiki is not helpful.

Thanks
John
Previous Topic:Javascript
Next Topic:Parameters in method completion proposals (as in templates proposals)
Goto Forum:
  


Current Time: Wed Apr 16 03:21:48 EDT 2014

Powered by FUDForum. Page generated in 0.01732 seconds