Example #1
0
        public void refreshCurrentBuildValues()
        {
            this.BuilderState = ResponseBuilder.Instance;
            this.localsListView.BeginUpdate();
            TreeListViewItem itemParent = null;
            if (this.localsListView.SelectedItems.Count > 0)
            {
                itemParent = this.localsListView.SelectedItems[0];
            }

            //Copy all var
            if (this.BuilderState.Locals != null)
            {
                for (int i = 0; i < this.BuilderState.Locals.Count; i++)
                {
                    Local local = this.BuilderState.Locals[i];
                    TreeListViewItem localItem = new TreeListViewItem();
                    if (itemParent == null)
                    {
                        this.localsListView.Items.Add(localItem);
                    }
                    else
                    {
                        itemParent.Items.Add(localItem);
                    }

                    localItem.Text = local.Name;
                    if (local.Type == null) continue;
                    if (local.Type.Equals("TABLE"))
                        localItem.ImageIndex = 0;
                    else if (local.Type.Equals("FIELD"))
                        localItem.ImageIndex = 3;
                    else if (local.Type.Equals("FUNCTION"))
                        localItem.ImageIndex = 2;
                    else if (local.Type.Equals("USERDATA"))
                        localItem.ImageIndex = 1;

                    localItem.SubItems.Add(local.Type);
                    localItem.SubItems.Add(local.Value);
                    localItem.SetIndentation();
                    localItem.Tag = local;
                }

            }

            this.localsListView.EndUpdate();

            //The Watches
            this.watchesListView.Items.Clear();

            if (this.BuilderState.Watchs != null)
            {
                for (int i = 0; i < this.BuilderState.Watchs.Count; i++)
                {
                    Watch watch = this.BuilderState.Watchs[i];
                    if (watch == null) continue;
                    TreeListViewItem localItem = new TreeListViewItem();
                    localItem.Text = watch.Number;
                    localItem.SubItems.Add(watch.Expression);
                    this.watchesListView.Items.Add(localItem);

                }
            }

            if (this.BuilderState.Backtraces != null)
            {
                for (int i = 0; i < this.BuilderState.Backtraces.Count; i++)
                {
                    Backtrace trace = this.BuilderState.Backtraces[i];
                    if (trace == null) continue;
                    TreeListViewItem localItem = new TreeListViewItem();
                    localItem.Text = trace.Number.ToString();
                    localItem.SubItems.Add(trace.Kind);

                    int indexFileStart = 0;
                    if (trace.File.Contains("\\"))
                        indexFileStart = trace.File.LastIndexOf("\\") + 1;

                    localItem.SubItems.Add(trace.File.Substring(indexFileStart, trace.File.Length - indexFileStart));
                    localItem.SubItems.Add(trace.Line.ToString());
                    this.backtraceListView.Items.Add(localItem);
                    localItem.ImageIndex = 2;

                }
            }
        }
Example #2
0
        public void AnalyzeStatus(String debug_response)
        {
            if (debug_response.Equals("")) return;
            String[] breakpoint = debug_response.Split('\n');

            if (Regex.IsMatch(breakpoint[0], "^200 OK$"))
            {
                this.BuilderState = ResponseBuilder.Instance;
                this.BuilderState.Init(breakpoint[0]);
                this.BuilderState.Analyse();

            }
            else if (Regex.IsMatch(breakpoint[0], "^200 OK(\\s?\\d+)$"))
            {
                  string[] responseTab = Regex.Split(breakpoint[0], " ");

                  if (LastCommand != null)
                  {
                      if (Regex.IsMatch(LastCommand, "^setb(\\s+\\s+\\d+)$"))
                      {
                          string[] lastResponseTab = Regex.Split(LastCommand, "\\s");
                          if (Convert.ToInt32(lastResponseTab[2]) > 0)
                          {
                              string message = debug_response.Substring(0, Convert.ToInt32(lastResponseTab[2]));
                              this.BuilderState = ResponseBuilder.Instance;
                              this.BuilderState.Init(message);
                              this.BuilderState.Analyse();

                              MessageBox.Show(BuilderState.ToString());
                          }
                      }
                  }

            }
            else if (Regex.IsMatch(breakpoint[0], "^202 Paused\\s+([\\w\\W]+)\\s+(\\d+)$"))
            {
                string[] response = Regex.Split(breakpoint[0], "\\s");
                if (!response[2].Equals("=?"))
                {
                    this.BuilderState.CurrentBreakPointFile = response[2];
                    this.BuilderState.CurrentBreakPointLine = Convert.ToInt32(response[3]);
                    //    String FilePath = cProject.BuildFolderPath + "\\" + response[2];
                    //    cgEeditor1.OpenFileInEditor(FilePath);
                    //    cgEeditor1.SetDebuggerAtLine(Convert.ToInt32(response[3]) - 1);
                    MessageBox.Show(BuilderState.ToString());
                }
                else
                {
                    this.BuilderState.CurrentBreakPointFile = "?";
                    this.BuilderState.CurrentBreakPointLine = 0;

                    MessageBox.Show(BuilderState.ToString());
                }
            }
            else if (Regex.IsMatch(breakpoint[0], "^203 Paused\\s+([\\w\\W]+)\\s+(\\d+)\\s+(\\d+)$"))
            {
                string[] response = Regex.Split(breakpoint[0], "\\s");
                this.BuilderState.CurrentBreakPointFile = response[2];
                this.BuilderState.CurrentBreakPointLine = Convert.ToInt32(response[3]);
             //   String FilePath = cProject.BuildFolderPath + "\\" + response[2];
              //  cgEeditor1.OpenFileInEditor(FilePath);
              //  cgEeditor1.SetDebuggerAtLine(Convert.ToInt32(response[3]) - 1);
                MessageBox.Show(BuilderState.ToString());
            }
            else if (Regex.IsMatch(breakpoint[0], "^401 Error in Expression (\\d+)$"))
            {
                this.BuilderState.ErrorFound = true;
                this.BuilderState.ErrorDescription = "401 Error In Expression";
            }
            else if (Regex.IsMatch(breakpoint[0], "^401 Error in Execution (\\d+)$"))
            {
                this.BuilderState.ErrorFound = true;
                this.BuilderState.ErrorDescription = "401 Error In Expression";
            }
            else if (Regex.IsMatch(breakpoint[0], "^(%s*)$"))
            {
                if (this.BuilderState.ErrorFound == true) {
                    string[] response = Regex.Split(breakpoint[0], "\\s");
                    this.BuilderState.ErrorDescription = breakpoint[0];
                    MessageBox.Show(BuilderState.ToString());
                }

            }
            if (LastCommand != null)
            {
                if (Regex.IsMatch(LastCommand, "^200 OK(\\s?\\d+)$"))
                {
                    string[] lastResponseTab = Regex.Split(LastCommand, "\\s");
                    if (Convert.ToInt32(lastResponseTab[2]) > 0)
                    {
                        string message = debug_response.Substring(0, Convert.ToInt32(lastResponseTab[2]));
                        this.BuilderState = ResponseBuilder.Instance;
                        this.BuilderState.Init(message);
                        this.BuilderState.Analyse();
                        MessageBox.Show(BuilderState.ToString());
                    }
                }
                if (Regex.IsMatch(LastCommand, "^401 Error in Expression (\\d+)$"))
                {
                    string[] lastResponseTab = Regex.Split(LastCommand, "\\s");
                    if (Convert.ToInt32(lastResponseTab[4]) > 0)
                    {
                        string message = debug_response.Substring(0, Convert.ToInt32(lastResponseTab[4]));
                        this.BuilderState = ResponseBuilder.Instance;
                        this.BuilderState.Init(message);
                        this.BuilderState.Analyse();
                        MessageBox.Show(BuilderState.ToString());
                    }
                }
                if (Regex.IsMatch(LastCommand, "^401 Error in Execution (\\d+)$"))
                {
                    string[] lastResponseTab = Regex.Split(LastCommand, "\\s");
                    if (Convert.ToInt32(lastResponseTab[4]) > 0)
                    {
                        string message = debug_response.Substring(0, Convert.ToInt32(lastResponseTab[4]));
                        this.BuilderState = ResponseBuilder.Instance;
                        this.BuilderState.Init(message);
                        this.BuilderState.Analyse();
                        MessageBox.Show(BuilderState.ToString());
                    }
                }
            }
            LastCommand = breakpoint[0];
        }
Example #3
0
        public void AnalyzeStatus(String debug_response)
        {
            if (debug_response.Equals("")) return;
            String[] breakpoint = debug_response.Split('\n');
            breakpoint = CleanDuplicate(breakpoint);
            if (Regex.IsMatch(breakpoint[0], "^200 OK$"))
            {
                this.BuilderState = ResponseBuilder.Instance;
                this.BuilderState.Init(breakpoint[0]);
                this.BuilderState.Analyse();

            }
            else if (Regex.IsMatch(breakpoint[0], "^200 OK(\\s?\\d+)$"))
            {
                string[] responseTab = Regex.Split(breakpoint[0], " ");

                if (LastCommandReceive != null)
                {
                    if (Regex.IsMatch(LastCommandReceive, "^setb(\\s+\\s+\\d+)$"))
                    {
                        string[] lastResponseTab = Regex.Split(LastCommandReceive, "\\s");
                        if (Convert.ToInt32(lastResponseTab[2]) > 0)
                        {
                            string message = debug_response.Substring(0, Convert.ToInt32(lastResponseTab[2]));
                            this.BuilderState = ResponseBuilder.Instance;
                            this.BuilderState.Init(message);
                            this.BuilderState.Analyse();
                            // MessageBox.Show(BuilderState.ToString());
                        }
                    }
                    else if (breakpoint.Length > 1)
                    {
                        this.BuilderState = ResponseBuilder.Instance;
                        this.BuilderState.Init(debug_response);
                        this.BuilderState.Analyse();
                    }
                }

            }
            else if (Regex.IsMatch(breakpoint[0], "^202 Paused\\s+([\\w\\W]+)\\s+(\\d+)$"))
            {

                string[] response = Regex.Split(breakpoint[0], "\\s");
                DocumentForm activeDoc = this.mainForm.cgEeditor1.ActiveDocument;
                if (activeDoc != null)
                    activeDoc.Scintilla.FindReplace.ClearAllHighlights();

                if (!response[2].Equals("=?"))
                {
                    this.BuilderState.CurrentBreakPointFile = response[2];
                    this.BuilderState.CurrentBreakPointLine = Convert.ToInt32(response[3]);

                    bool isOpen = false;
                    foreach (DocumentForm documentForm in this.mainForm.cgEeditor1.dockPanel.Documents)
                    {
                        if (response[2].Equals(documentForm.Text.Replace(" *", ""), StringComparison.OrdinalIgnoreCase))
                        {
                            documentForm.Select();
                            documentForm.Show(this.mainForm.cgEeditor1.dockPanel);
                            isOpen = true;
                            break;
                        }
                    }

                    // Open the files
                    if (!isOpen)
                    {
                        DirectoryInfo dir = new DirectoryInfo(this.project.BuildFolderPath);
                        String FilePath = dir.Parent.FullName + "\\DebugTemp\\" + response[2];
                        if (File.Exists(FilePath))
                            this.mainForm.cgEeditor1.OpenFileInEditor(FilePath);
                    }

                    //-----SELECT LINE IN EDITOR
                    try
                    {

                        if (this.mainForm.cgEeditor1.ActiveDocument != null)
                        {
                            if (!this.mainForm.cgEeditor1.ActiveDocument.Scintilla.Text.Equals(""))
                            {

                                int lineNumber = -1;
                                int.TryParse(response[3], out lineNumber);
                                if (lineNumber > -1)
                                {
                                    if (this.mainForm.cgEeditor1.ActiveDocument.Scintilla.Lines.Count > lineNumber - 1)
                                    {
                                        this.mainForm.cgEeditor1.SetDebuggerAtLine(lineNumber - 1);
                                    }
                                }
                            }

                        }
                    }
                    catch (Exception ex)
                    {

                    }
                    // this.outPutTxtBx.AppendText(BuilderState.ToString());

                    if (CurrentCommandSend != null && this.listCommands.Count == 0)
                    {
                        if (CurrentCommandSend.Contains("STEP"))
                        {
                            this.listCommands.Add("LOCALS");
                            this.listCommands.Add("BACKTRACE");
                        }
                        this.listCommands = new List<String>(this.listCommands.Distinct().ToArray());
                    }
                }
                else
                {
                    this.BuilderState.CurrentBreakPointFile = "?";
                    this.BuilderState.CurrentBreakPointLine = 0;
                    if (activeDoc != null)
                    {
                        activeDoc.Scintilla.Markers.DeleteAll(2);
                    }

                    // this.outPutTxtBx.AppendText(BuilderState.ToString());
                }

            }
            else if (Regex.IsMatch(breakpoint[0], "^203 Paused\\s+([\\w\\W]+)\\s+(\\d+)\\s+(\\d+)$"))
            {
                string[] response = Regex.Split(breakpoint[0], "\\s");
                this.BuilderState.CurrentBreakPointFile = response[2];
                this.BuilderState.CurrentBreakPointLine = Convert.ToInt32(response[3]);
                //   String FilePath = cProject.BuildFolderPath + "\\" + response[2];
                //  cgEeditor1.OpenFileInEditor(FilePath);
                //  cgEeditor1.SetDebuggerAtLine(Convert.ToInt32(response[3]) - 1);

                if (CurrentCommandSend != null)
                {
                    if (!CurrentCommandSend.Equals("LOCALS\n"))
                    {
                        this.listCommands.Add("LOCALS");
                    }
                    if (!CurrentCommandSend.Equals("BACKTRACE\n"))
                    {
                        this.listCommands.Add("BACKTRACE");
                    }
                    this.listCommands = new List<String>(this.listCommands.Distinct().ToArray());
                }
            }
            else if (Regex.IsMatch(breakpoint[0], "^401 Error in Expression (\\d+)$"))
            {
                this.BuilderState.ErrorFound = true;
                this.BuilderState.ErrorDescription = "401 Error In Expression";
            }
            else if (Regex.IsMatch(breakpoint[0], "^401 Error in Execution (\\d+)$"))
            {
                this.BuilderState.ErrorFound = true;
                this.BuilderState.ErrorDescription = "401 Error In Expression";
            }
            else if (Regex.IsMatch(breakpoint[0], "^(%s*)$"))
            {
                if (this.BuilderState.ErrorFound == true)
                {
                    string[] response = Regex.Split(breakpoint[0], "\\s");
                    this.BuilderState.ErrorDescription = breakpoint[0];
                    // MessageBox.Show(BuilderState.ToString());
                }

            }
            if (LastCommandReceive != null)
            {
                if (Regex.IsMatch(LastCommandReceive, "^200 OK(\\s?\\d+)$"))
                {
                    string[] lastResponseTab = Regex.Split(LastCommandReceive, "\\s");
                    int bytesNumber = -1;
                    int.TryParse(lastResponseTab[2], out bytesNumber);
                    if (bytesNumber > debug_response.Length) bytesNumber = debug_response.Length - 1;
                    if (bytesNumber > 0)
                    {
                        string message = debug_response.Substring(0, bytesNumber);
                        this.BuilderState = ResponseBuilder.Instance;
                        this.BuilderState.Init(message);
                        this.BuilderState.Analyse();

                    }
                }

                if (Regex.IsMatch(LastCommandReceive, "^401 Error in Expression (\\d+)$"))
                {
                    string[] lastResponseTab = Regex.Split(LastCommandReceive, "\\s");
                    int bytesNumber = -1;
                    int.TryParse(lastResponseTab[4], out bytesNumber);
                    if (bytesNumber > debug_response.Length) bytesNumber = debug_response.Length - 1;
                    if (bytesNumber > 0)
                    {
                        string message = debug_response.Substring(0, bytesNumber);
                        this.BuilderState = ResponseBuilder.Instance;
                        this.BuilderState.Init(message);
                        this.BuilderState.Analyse();

                        //  MessageBox.Show(BuilderState.ToString());
                    }
                }
                if (Regex.IsMatch(LastCommandReceive, "^401 Error in Execution (\\d+)$"))
                {
                    string[] lastResponseTab = Regex.Split(LastCommandReceive, "\\s");
                    int bytesNumber = -1;
                    int.TryParse(lastResponseTab[4], out bytesNumber);
                    if (bytesNumber > debug_response.Length) bytesNumber = debug_response.Length - 1;
                    if (bytesNumber > 0)
                    {
                        string message = debug_response.Substring(0, bytesNumber);
                        this.BuilderState = ResponseBuilder.Instance;
                        this.BuilderState.Init(message);
                        this.BuilderState.Analyse();

                        //  MessageBox.Show(BuilderState.ToString());
                    }
                }
            }
            LastCommandReceive = breakpoint[0];

            refreshCurrentBuildValues();
        }