From: Stephan R. <ste...@us...> - 2005-01-04 15:41:08
|
Update of /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8082/src/org/epic/debug/util Modified Files: PathMapping.java PathMapper.java OutputStreamMonitor.java DebuggerProxy.java Log Message: Remote Debugging: - path mapping fixed - inc path mapping included - problems with console fixed - non Perl project files added to Remote Package Index: DebuggerProxy.java =================================================================== RCS file: /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/util/DebuggerProxy.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- DebuggerProxy.java 31 Dec 2004 12:46:54 -0000 1.5 +++ DebuggerProxy.java 4 Jan 2005 15:40:56 -0000 1.6 @@ -49,12 +49,14 @@ mLabel = fLabel; mLaunch = fLaunch; mShutDown = false; + create(); } public DebuggerProxy(PerlDB fDebugger, String fLabel) throws InstantiationException { mLabel = fLabel; mShutDown = false; + create(); init(fDebugger); } @@ -83,8 +85,8 @@ "Could not Create Connection to Debugger Console"); mMonitorIn = new InputStreamMonitor(mIOStream.getOutStream()); - mMonitorOut = new OutputStreamMonitor(mIOStream.getInStream()); - mMonitorError = new OutputStreamMonitor(mErrorStream.getInStream()); + mMonitorOut.setStream(mIOStream.getInStream()); + mMonitorError.setStream(mErrorStream.getInStream()); mMonitorIn.startMonitoring(); mMonitorOut.startMonitoring(); mMonitorError.startMonitoring(); @@ -232,7 +234,8 @@ * @see org.eclipse.debug.core.model.IStreamsProxy#write(java.lang.String) */ public void write(String input) throws IOException { - mOut.print(input); + if( mOut != null) + mOut.print(input); } /** @@ -275,4 +278,12 @@ mErrorStream.shutdown(); fireTerminateEvent(); } + + private void create() + { + mMonitorOut = new OutputStreamMonitor(); + mMonitorError = new OutputStreamMonitor(); + } + + } \ No newline at end of file Index: OutputStreamMonitor.java =================================================================== RCS file: /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/util/OutputStreamMonitor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- OutputStreamMonitor.java 20 Dec 2004 08:59:42 -0000 1.4 +++ OutputStreamMonitor.java 4 Jan 2005 15:40:56 -0000 1.5 @@ -17,8 +17,6 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ - - import java.io.IOException; import java.io.InputStream; @@ -32,11 +30,10 @@ import org.eclipse.debug.internal.core.ListenerList; /** - * Monitors the output stream of a system process and notifies - * listeners of additions to the stream. - * - * The output stream monitor reads system out (or err) via - * and input stream. + * Monitors the output stream of a system process and notifies listeners of + * additions to the stream. + * + * The output stream monitor reads system out (or err) via and input stream. */ public class OutputStreamMonitor implements IFlushableStreamMonitor { /** @@ -47,7 +44,7 @@ /** * A collection of listeners */ - private ListenerList fListeners= new ListenerList(1); + private ListenerList fListeners = new ListenerList(1); /** * Whether content is being buffered @@ -67,24 +64,29 @@ /** * The size of the read buffer */ - private static final int BUFFER_SIZE= 8192; + private static final int BUFFER_SIZE = 8192; /** - * Whether or not this monitor has been killed. - * When the monitor is killed, it stops reading - * from the stream immediately. + * Whether or not this monitor has been killed. When the monitor is killed, + * it stops reading from the stream immediately. */ - private boolean fKilled= false; + private boolean fKilled = false; /** - * Creates an output stream monitor on the - * given stream (connected to system out or err). + * Creates an output stream monitor on the given stream (connected to system + * out or err). */ public OutputStreamMonitor(InputStream stream) { - fStream= stream; - fContents= new StringBuffer(); + fStream = stream; + fContents = new StringBuffer(); + } + public OutputStreamMonitor() { + fContents = new StringBuffer(); } + public void setStream(InputStream stream) { + fStream = stream; + } /** * @see IStreamMonitor#addListener(IStreamListener) */ @@ -93,14 +95,13 @@ } /** - * Causes the monitor to close all - * communications between it and the + * Causes the monitor to close all communications between it and the * underlying stream by waiting for the thread to terminate. */ protected void close() { if (fThread != null) { - Thread thread= fThread; - fThread= null; + Thread thread = fThread; + fThread = null; try { thread.join(); } catch (InterruptedException ie) { @@ -110,8 +111,7 @@ } /** - * Notifies the listeners that text has - * been appended to the stream. + * Notifies the listeners that text has been appended to the stream. */ private void fireStreamAppended(String text) { getNotifier().notifyAppend(text); @@ -127,22 +127,22 @@ /** * Continually reads from the stream. * <p> - * This method, along with the <code>startReading</code> - * method is used to allow <code>OutputStreamMonitor</code> - * to implement <code>Runnable</code> without publicly - * exposing a <code>run</code> method. + * This method, along with the <code>startReading</code> method is used to + * allow <code>OutputStreamMonitor</code> to implement + * <code>Runnable</code> without publicly exposing a <code>run</code> + * method. */ private void read() { - byte[] bytes= new byte[BUFFER_SIZE]; + byte[] bytes = new byte[BUFFER_SIZE]; int read = 0; while (read >= 0) { try { if (fKilled) { break; } - read= fStream.read(bytes); + read = fStream.read(bytes); if (read > 0) { - String text= new String(bytes, 0, read); + String text = new String(bytes, 0, read); if (isBuffered()) { fContents.append(text); } @@ -154,9 +154,9 @@ } catch (Exception e) { // killing the stream monitor while reading can cause an NPE // when reading from the stream -// if (!fKilled || fThread != null) { -// DebugPlugin.log(e); -// } + // if (!fKilled || fThread != null) { + // DebugPlugin.log(e); + // } return; } } @@ -168,7 +168,7 @@ } protected void kill() { - fKilled= true; + fKilled = true; } /** @@ -183,7 +183,7 @@ */ protected void startMonitoring() { if (fThread == null) { - fThread= new Thread(new Runnable() { + fThread = new Thread(new Runnable() { public void run() { read(); } @@ -239,8 +239,8 @@ if (text == null) return; fText = text; - Object[] copiedListeners= fListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { + Object[] copiedListeners = fListeners.getListeners(); + for (int i = 0; i < copiedListeners.length; i++) { fListener = (IStreamListener) copiedListeners[i]; Platform.run(this); } Index: PathMapping.java =================================================================== RCS file: /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/util/PathMapping.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PathMapping.java 24 Dec 2004 15:12:29 -0000 1.1 +++ PathMapping.java 4 Jan 2005 15:40:56 -0000 1.2 @@ -11,7 +11,7 @@ public PathMapping(String fOrg, String fMapped) { - mOrg=fOrg; + mOrg= new Path(fOrg).toString(); mMapped=fMapped; } Index: PathMapper.java =================================================================== RCS file: /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/util/PathMapper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- PathMapper.java 24 Dec 2004 15:12:29 -0000 1.3 +++ PathMapper.java 4 Jan 2005 15:40:56 -0000 1.4 @@ -1,10 +1,14 @@ package org.epic.debug.util; +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.epic.debug.PerlDB; +import org.epic.debug.PerlDebugPlugin; +import org.epic.debug.RemoteTarget; /* * Created on 19.03.2004 @@ -15,51 +19,114 @@ /** * @author ST - * + * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ -public class PathMapper -{ +public class PathMapper { ArrayList mMapping; - - public PathMapper() - { + ArrayList mIncLocal; + ArrayList mIncRemote; + + public PathMapper() { mMapping = new ArrayList(); + mIncLocal = new ArrayList(); + mIncRemote = new ArrayList(); } - - public void add(PathMapping fMap) - { - mMapping.add(fMap); - Collections.sort(mMapping,(Comparator)mMapping.get(0)); + + public void add(PathMapping fMap) { + mMapping.add(fMap); + Collections.sort(mMapping, (Comparator) mMapping.get(0)); } - - public IPath mapPath( IPath fPath ) - { + + public IPath mapPath(IPath fPath) { String erg = mapPath(fPath.toString()); - if( erg != null) - return( new Path(erg)); - - return( null ); + if (erg != null) + return (new Path(erg)); + + return (null); } - public String mapPath(String fOrg) - { + private String mapPath(String fOrg) { PathMapping map; - - for( int i =0; i< mMapping.size(); ++i) - { + String erg; + + for (int i = 0; i < mMapping.size(); ++i) { + map = ((PathMapping) mMapping.get(i)); - if( fOrg.indexOf(map.getOrg())== 0) - { - String erg = map.getMapped() + fOrg.substring(map.getOrg().length()); - return(erg); + if (fOrg.indexOf(map.getOrg()) == 0) { + erg = map.getMapped() + fOrg.substring(map.getOrg().length()); + return (erg); } - + erg = mapInc(fOrg); + if (erg != null) + return erg; } - return fOrg; - + erg = mapInc(fOrg); + if( erg != null ) + return erg; + return fOrg; + } -} + public void addLocalInc(String fPath) { + mIncLocal.add(fPath); + } + + public void addRemoteInc(String fPath) { + mIncRemote.add(fPath); + } + + public String mapInc(String fOrg) { + String incRem; + String cut = null; + String mapped; + File file; + + for (int i = 0; (i < mIncRemote.size()) && (cut == null); ++i) { + incRem = (String) mIncRemote.get(i); + + if (fOrg.startsWith(incRem)) { + cut = fOrg.substring(incRem.length()); + } + } + + if (cut != null) { + for (int i = 0; i < mIncLocal.size(); ++i) { + mapped = ((String) mIncLocal.get(i)) + cut; + file = new File(mapped); + if(file.exists()) + return mapped; + } + } + + return(null); + } + public void initInc(PerlDB fDB) + { + PerlDebugPlugin.createDefaultIncPath(mIncLocal); + fDB.getRemoteInc(mIncRemote); + + } + + public void print() + { + String t = "\n*****PathMapper*****\n"; + for( int i=0; i < mMapping.size(); ++i) + { + t+= "\n"+((PathMapping)mMapping.get(i)).mOrg+"-->"+((PathMapping)mMapping.get(i)).mMapped+"\n"; + } + t += "\n++++incMappingRemote++++\n"; + for( int i=0; i < mIncRemote.size(); ++i) + { + t+= "\n"+((String)mIncRemote.get(i))+"\n"; + } + t += "\n++++incMappingLocal++++\n"; + for( int i=0; i < mIncLocal.size(); ++i) + { + t+= "\n"+((String)mIncLocal.get(i))+"\n"; + } + System.err.println(t); + } +} |