[Pydev-cvs] org.python.pydev.debug/src/org/python/pydev/debug/model PythonDebugTarget.java,NONE,1.1
Brought to you by:
fabioz
From: Aleksandar T. <at...@us...> - 2004-03-29 17:18:55
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32567/src/org/python/pydev/debug/model Added Files: PythonDebugTarget.java RemoteDebuggerCommand.java RemoteDebugger.java Log Message: Develpment of the debugger model --- NEW FILE: RemoteDebugger.java --- /* * Author: atotic * Created on Mar 23, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.model; import java.io.*; import java.net.*; import java.util.ArrayList; import java.util.Iterator; /** * Network interface to the remote debugger. */ public class RemoteDebugger implements Runnable { // socket communication Socket socket; PrintWriter toServer; BufferedReader fromServer; InputStream sin; ArrayList commands = new ArrayList(); // command queue public RemoteDebugger(Socket socket) throws IOException { this.socket = socket; OutputStream sout = socket.getOutputStream(); sin = socket.getInputStream(); fromServer = new BufferedReader(new InputStreamReader(sin)); toServer = new PrintWriter(new OutputStreamWriter(sout)); } public void sendCommand(RemoteDebuggerCommand command) { synchronized(commands) { commands.add(command); } } private void execute1Command(RemoteDebuggerCommand c) { String sendThis = c.getXMLMessage(); toServer.write(sendThis); // TODO process result } /** * * @param commandList - a list of RemoteDebuggerCommand's to be executed */ private void executeCommands(ArrayList commandList) { Iterator iter = commandList.iterator(); while (!iter.hasNext()) { execute1Command((RemoteDebuggerCommand)iter.next()); } } /** * Execute commands in an infinite loop. */ public void run() { try { while (!socket.isClosed()) { if (!commands.isEmpty()) { ArrayList toExecute = new ArrayList(); synchronized(commands) { while (!commands.isEmpty()) toExecute.add(commands.remove(0)); } executeCommands(toExecute); } if (fromServer.ready()) { char[] cbuf = new char[2048]; int howMany = fromServer.read(cbuf); System.out.print(new String(cbuf, 0, howMany)); } Thread.sleep(100); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO handle this e.printStackTrace(); } } } --- NEW FILE: PythonDebugTarget.java --- /* * Author: atotic * Created on Mar 23, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.model; import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IThread; import org.python.pydev.debug.core.PydevDebugPlugin; /** * * TODO Comment this class * Make sure we fire the right org.eclipse.debug.core.DebugEvents */ public class PythonDebugTarget implements IDebugTarget { ILaunch launch; IProcess process; String name; RemoteDebugger debugger; public PythonDebugTarget(ILaunch launch, IProcess process, String name, RemoteDebugger debugger) { this.launch = launch; this.process = process; this.name = name; this.debugger = debugger; launch.addDebugTarget(this); } // From IDebugElement public String getModelIdentifier() { return PydevDebugPlugin.getPluginID(); } // From IDebugElement public IDebugTarget getDebugTarget() { return this; } // From IDebugElement public ILaunch getLaunch() { return launch; } public IProcess getProcess() { return process; } public String getName() throws DebugException { return name; } public IThread[] getThreads() throws DebugException { // TODO Auto-generated method stub return null; } public boolean hasThreads() throws DebugException { // TODO Auto-generated method stub return true; } public boolean supportsBreakpoint(IBreakpoint breakpoint) { // TODO Auto-generated method stub return false; } public boolean canTerminate() { // TODO NOW Auto-generated method stub return true; } public boolean isTerminated() { // TODO NOW Auto-generated method stub return false; } public void terminate() throws DebugException { // TODO Auto-generated method stub } public boolean canResume() { // TODO NOW Auto-generated method stub return false; } public boolean canSuspend() { // TODO NOW Auto-generated method stub return true; } public boolean isSuspended() { // TODO Auto-generated method stub return false; } public void resume() throws DebugException { // TODO Auto-generated method stub } public void suspend() throws DebugException { // TODO Auto-generated method stub } public void breakpointAdded(IBreakpoint breakpoint) { // TODO Auto-generated method stub } public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) { // TODO Auto-generated method stub } public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) { // TODO Auto-generated method stub } public boolean canDisconnect() { // TODO NOW Auto-generated method stub return false; } public void disconnect() throws DebugException { // TODO Auto-generated method stub } public boolean isDisconnected() { // TODO NOW Auto-generated method stub return false; } public boolean supportsStorageRetrieval() { // TODO Auto-generated method stub return false; } public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { // TODO Auto-generated method stub return null; } public Object getAdapter(Class adapter) { // TODO Auto-generated method stub if (adapter.equals(ILaunch.class)) return launch; else System.err.println("Need adapter " + adapter.toString()); return null; } } --- NEW FILE: RemoteDebuggerCommand.java --- /* * Author: atotic * Created on Mar 23, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.model; /** * Interacts with jpydaemon.py. * * Knows how to create and interpret jpydaemon commands. * * jpydaemon commands: * * STOP: exits the debugger * CMD <command>: takes a command and executes it success: <JPY> <COMMAND cmd="CMD a=1" operation="a=1" result="OK" /></JPY> <JPY> <STDOUT content="1" /></JPY> <JPY> <STDOUT content="/EOL/" /></JPY> <JPY> <COMMAND cmd="CMD print a" operation="print a" result="OK" /></JPY> error: <JPY> <COMMAND cmd="CMD er!" operation="er!" result="Error on CMD" /></JPY> <JPY> <COMMANDDETAIL content="Traceback (most recent call last):" /></JPY> <JPY> <COMMANDDETAIL content=" File "D:\pydevspace2\org.python.pydev.debug\pysrc\jpydaemon.py", line 231, in dealWithCmd code = compile( arg ,"<string>" , cmdType)" /></JPY> <JPY> <COMMANDDETAIL content=" File "<string>", line 1" /></JPY> <JPY> <COMMANDDETAIL content=" er!" /></JPY> <JPY> <COMMANDDETAIL content=" ^" /></JPY> <JPY> <COMMANDDETAIL content="SyntaxError: unexpected EOF while parsing" /></JPY> * READSRC <filename>: reads in the whole file * SETARGS : sets arguments before we start execution <JPY> <COMMAND cmd="SETARGS -u -v" operation="-u -v" result="OK" /></JPY> * DBG: <JPY><COMMAND cmd="DBG test.py" /></JPY> <JPY> <LINE cmd="31" fn="<string>" lineno="1" name="?" line="" /></JPY> */ public class RemoteDebuggerCommand { public final static String VERSION = "JpyDbg 0.0.3" ; public final static int INACTIVE = 0 ; public final static int STARTING = 1 ; public final static int STARTED = 2 ; private final static String _ERROR_ = "ERROR:" ; private final static String _END_OF_LINE_ = "\n" ; private final static String _INACTIVE_TEXT_ = "inactive" ; private final static String _READY_TEXT_ = "ready" ; private final static String _STRING_ ="<string>" ; private final static String _EOL_ = "/EOL/" ; private final static String _OK_ = "OK" ; private final static String _COMMAND_ = "CMD " ; private final static String _BPSET_ = "BP+ " ; private final static String _BPCLEAR_ = "BP- " ; private final static String _DBG_ = "DBG " ; private final static String _SETARGS_ = "SETARGS " ; private final static String _READSRC_ = "READSRC " ; private final static String _NEXT_ = "NEXT " ; private final static String _SET_ = "set " ; private final static String _STEP_ = "STEP " ; private final static String _RUN_ = "RUN " ; private final static String _STOP_ = "STOP " ; private final static String _STACK_ = "STACK " ; private final static String _GLOBALS_ = "GLOBALS " ; private final static String _GLOBAL_ = "global" ; private final static String _EQUAL_ = "=" ; private final static String _SEMICOLON_= ";" ; private final static String _SILENT_ = "silent" ; private final static String _LOCALS_ = "LOCALS " ; private final static String _SPACE_ = " " ; String xmlMessage; public String getXMLMessage() { return xmlMessage; } } |