Example #1
0
        private void StopDebuggingSession()
        {
            _fileLoader = null;

            if (_CurrentLocation.line != -1)
            {
                xdc.Forms.SourceFileForm form = _fileMgr.getFormByRemoteFilename(_CurrentLocation.filename);

                if (form != null)
                {
                    form.RemoveActiveMark();
                }
            }

            _client.Disconnect();

            foreach (OpenFileStruct file in _fileMgr.Forms.Values)
            {
                file.form.ToggleMenuItems(false);
            }

            this.ToggleMenuItems(false);

            // TODO cleanup forms
            List <Property> emp = new List <Property>();

            _globalContextFrm.LoadPropertyList(emp);
            _localContextFrm.LoadPropertyList(emp);

            _statusFrm.WriteStatusLine("(!) Debugging session terminated.");
        }
Example #2
0
        private bool LoadFile(string filename)
        {
            /**
             * Loading a file:
             *  1. Local file which can be used 1-on-1
             *  2. "Local" file which needs rewriting (FTP Location Service)
             *  3. Remote file, not accessible via Samba.
             *  4. Remote file, accessible via Samba.
             *
             * Situations 1, 2 and 4 can be resolved using a simple filename rewriter. In case (1)
             * no rewriting has to be done, in case (2) complete rewriting has be done and in case (3)
             * partial rewriting has to be done.
             *
             * Situation 3 can be resolved by using the Source DBGP command, but that leaves us in the dark
             * as to what other files are available which makes debugging rather annoying when dealing
             * with large systems. It can also take a very long time with loading large files, at least
             * with the current implementation.
             */

            string baseFile = System.IO.Path.GetFileName(filename);

            string remoteFilename = filename;
            string localFilename  = filename;

            xdc.Forms.SourceFileForm sff = _fileMgr.getFormByRemoteFilename(filename);

            if (sff != null)
            {
                sff.Focus();
                return(true);
            }

            xdc.Forms.SourceFileForm f = new xdc.Forms.SourceFileForm(_client, filename);


            f.FormClosed += new FormClosedEventHandler(SourceFileForm_FileClosed);
            f.Text        = baseFile;
            f.TabText     = localFilename;

            /* When we can't find the file specified, offer a way to rewrite the path */
            if (!System.IO.File.Exists(filename))
            {
                if (_fileLoader == null)
                {
                    xdc.Forms.FileHandlingForm filehandlingForm = new xdc.Forms.FileHandlingForm(filename);
                    DialogResult handlerResult = filehandlingForm.ShowDialog();

                    if (handlerResult != DialogResult.OK)
                    {
                        MessageBox.Show("Can't debug without a source file. Terminating debug session.", "No file loaded.");
                        this.StopDebuggingSession();
                        return(false);
                    }

                    _fileLoader = FileLoaderFactory.Create(filehandlingForm.SelectedFileLoader);
                    _fileLoader.setClient(_client);
                }

                bool fileLoaded = false;

                if (_fileLoader.DetermineLocalFilename(filename, ref localFilename))
                {
                    if (_fileLoader.OpenFile(f, localFilename))
                    {
                        fileLoaded = true;
                    }
                }

                if (!fileLoaded)
                {
                    MessageBox.Show("Can't debug without a source file. Terminating debug session.", "No file loaded");
                    this.StopDebuggingSession();
                    return(false);
                }
            }
            else
            {
                /* The user might've opened a file that appears to be local (opened via network, for instance)
                 * that should be mapped to a remote path. If we have a fileLoader instance, see if it
                 * can rewrite the file for us. */

                if (_fileLoader != null)
                {
                    string tmpRemoteFilename = "";
                    if (_fileLoader.DetermineRemoteFilename(localFilename, ref tmpRemoteFilename))
                    {
                        f.TabText = tmpRemoteFilename;

                        /* The filename in the SourceFileForm is always considered
                         * to be the filename expected by xdebug, so update it to
                         * the remote version */
                        f.setFilename(tmpRemoteFilename);
                        filename = tmpRemoteFilename;
                    }
                }

                f.LoadFile(localFilename);
            }

            _fileMgr.Add(filename, localFilename, f);
            f.Show(this.dockPanel, DockState.Document);

            closeToolStripMenuItem.Enabled = true;

            // We have to collect all the bookmarks added and removed. This way
            // XdebugClient is able to restore bookmarks whenever a script is rerun.
            f.getBookmarkManager().Added   += new BookmarkEventHandler(BreakpointAdded);
            f.getBookmarkManager().Removed += new BookmarkEventHandler(BreakpointRemoved);

            return(true);
        }
Example #3
0
        private void StopDebuggingSession()
        {
            _fileLoader = null;

            if (_CurrentLocation.line != -1)
            {
                xdc.Forms.SourceFileForm form = _fileMgr.getFormByRemoteFilename(_CurrentLocation.filename);

                if (form != null)
                    form.RemoveActiveMark();
            }

            _client.Disconnect();

            foreach (OpenFileStruct file in _fileMgr.Forms.Values)
            {
                file.form.ToggleMenuItems(false);
            }

            this.ToggleMenuItems(false);

            // TODO cleanup forms
            List<Property> emp = new List<Property>();
            _globalContextFrm.LoadPropertyList(emp);
            _localContextFrm.LoadPropertyList(emp);

            _statusFrm.WriteStatusLine("(!) Debugging session terminated.");
        }
Example #4
0
        private bool LoadFile(string filename)
        {
            /**
             * Loading a file:
             *  1. Local file which can be used 1-on-1
             *  2. "Local" file which needs rewriting (FTP Location Service)
             *  3. Remote file, not accessible via Samba.
             *  4. Remote file, accessible via Samba.
             *
             * Situations 1, 2 and 4 can be resolved using a simple filename rewriter. In case (1)
             * no rewriting has to be done, in case (2) complete rewriting has be done and in case (3)
             * partial rewriting has to be done.
             *
             * Situation 3 can be resolved by using the Source DBGP command, but that leaves us in the dark
             * as to what other files are available which makes debugging rather annoying when dealing
             * with large systems. It can also take a very long time with loading large files, at least
             * with the current implementation.
             */

            string baseFile = System.IO.Path.GetFileName(filename);

            string remoteFilename = filename;
            string localFilename = filename;

            xdc.Forms.SourceFileForm sff = _fileMgr.getFormByRemoteFilename(filename);

            if (sff != null)
            {
                sff.Focus();
                return true;
            }

            xdc.Forms.SourceFileForm f = new xdc.Forms.SourceFileForm(_client, filename);

            f.FormClosed += new FormClosedEventHandler(SourceFileForm_FileClosed);
            f.Text = baseFile;
            f.TabText = localFilename;

            /* When we can't find the file specified, offer a way to rewrite the path */
            if (!System.IO.File.Exists(filename))
            {

                if (_fileLoader == null)
                {
                    xdc.Forms.FileHandlingForm filehandlingForm = new xdc.Forms.FileHandlingForm(filename);
                    DialogResult handlerResult = filehandlingForm.ShowDialog();

                    if (handlerResult != DialogResult.OK)
                    {
                        MessageBox.Show("Can't debug without a source file. Terminating debug session.", "No file loaded.");
                        this.StopDebuggingSession();
                        return false;
                    }

                    _fileLoader = FileLoaderFactory.Create(filehandlingForm.SelectedFileLoader);
                    _fileLoader.setClient(_client);

                }

                bool fileLoaded = false;

                if (_fileLoader.DetermineLocalFilename(filename, ref localFilename))
                {
                    if (_fileLoader.OpenFile(f, localFilename))
                    {
                        fileLoaded = true;
                    }
                }

                if (!fileLoaded)
                {
                    MessageBox.Show("Can't debug without a source file. Terminating debug session.", "No file loaded");
                    this.StopDebuggingSession();
                    return false;
                }
            }
            else
            {
                /* The user might've opened a file that appears to be local (opened via network, for instance)
                 * that should be mapped to a remote path. If we have a fileLoader instance, see if it
                 * can rewrite the file for us. */

                if (_fileLoader != null)
                {
                    string tmpRemoteFilename = "";
                    if (_fileLoader.DetermineRemoteFilename(localFilename, ref tmpRemoteFilename))
                    {
                        f.TabText = tmpRemoteFilename;

                        /* The filename in the SourceFileForm is always considered
                         * to be the filename expected by xdebug, so update it to
                         * the remote version */
                        f.setFilename(tmpRemoteFilename);
                        filename = tmpRemoteFilename;
                    }
                }

                f.LoadFile(localFilename);
            }

            _fileMgr.Add(filename, localFilename, f);
            f.Show(this.dockPanel, DockState.Document);

            closeToolStripMenuItem.Enabled = true;

            // We have to collect all the bookmarks added and removed. This way
            // XdebugClient is able to restore bookmarks whenever a script is rerun.
            f.getBookmarkManager().Added   += new BookmarkEventHandler(BreakpointAdded);
            f.getBookmarkManager().Removed += new BookmarkEventHandler(BreakpointRemoved);

            return true;
        }