Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“如何修复”;“regexp matcher”中的堆栈溢出;在emacs中_Regex_Debugging_Emacs_Gdb_Gud - Fatal编程技术网

“如何修复”;“regexp matcher”中的堆栈溢出;在emacs中

“如何修复”;“regexp matcher”中的堆栈溢出;在emacs中,regex,debugging,emacs,gdb,gud,Regex,Debugging,Emacs,Gdb,Gud,我非常喜欢Emacs,并且经常使用它,特别是在编程和调试(使用gud)(C/C++)时 最近我不得不调试一个程序(相当简单,但需要大量数据(图论)进行计算),但我遇到了一个相当恼人的问题。 在程序的逐步执行过程中,我得到以下错误: error in process filter: Stack overflow in regexp matcher 我做了一些研究来找出它是什么,我发现了这个帖子: 据我所知,regexp matcher有一个问题,我的程序中有些东西太长了?(我确实有非常长的函数名

我非常喜欢Emacs,并且经常使用它,特别是在编程和调试(使用gud)(C/C++)时

最近我不得不调试一个程序(相当简单,但需要大量数据(图论)进行计算),但我遇到了一个相当恼人的问题。 在程序的逐步执行过程中,我得到以下错误:

error in process filter: Stack overflow in regexp matcher
我做了一些研究来找出它是什么,我发现了这个帖子:

据我所知,regexp matcher有一个问题,我的程序中有些东西太长了?(我确实有非常长的函数名和很多参数,而且我还使用非常大的容器。)

我真的很想解决这个问题,但我对调试Emacs Lisp一无所知,有人能帮我吗

以下是我从Emacs internal debbuger获得的输出:


我还应该指出,我使用的是Emacs Prelude的个性化版本。

根本的问题是正则表达式(regexp)包含太多的替代项,当应用于(通常较长)文本时,它无法匹配它试图匹配的任何内容

在您的情况下,它是regexp:

"\\([[:alnum:]-_]+\\)=\\({\\|\\[\\|\"\"\\|\"\\(?:[^\\\"]\\|\\\\.\\)*\"\\)"
它由函数
gdbjsonify buffer
使用

看起来这个regexp试图匹配赋值。基本上,它匹配
=
左侧的变量和右侧的表达式(部分)。regexp似乎匹配的内容之一是字符串,其中包含转义引号——这始终是一个警告标志,因为Emacs提供了更好的字符串解析方法

这个问题可能源于以下事实:这个regexp是错误的(因此它匹配的字符串比您的字符串多得多),您的字符串格式不正确,或者您的程序只是包含一个非常大的字符串

我建议您向该软件包的维护人员提交一份bug报告。确保包含导致触发错误的文本


或者,您可以尝试自己修复此问题。我建议您将复杂的regexp替换为查找字符串开头的更简单的regexp。例如,您可以使用
(forward sexp)
来查找字符串的结尾。

我也遇到了这个问题,所以我使用了Lindydancer的建议,将字符串文本上的regexp转换为use(forward sexp),这对我来说很好

我已经发布了补丁:

所以希望它能在某个时候被合并。同时,您可以将其用于gdb jsonify缓冲区:


(defun gdb-jsonify-buffer (&optional fix-key fix-list)
  "Prepare GDB/MI output in current buffer for parsing with `json-read'.

Field names are wrapped in double quotes and equal signs are
replaced with semicolons.

If FIX-KEY is non-nil, strip all \"FIX-KEY=\" occurrences from
partial output.  This is used to get rid of useless keys in lists
in MI messages, e.g.: [key=.., key=..].  -stack-list-frames and
-break-info are examples of MI commands which issue such
responses.

If FIX-LIST is non-nil, \"FIX-LIST={..}\" is replaced with
\"FIX-LIST=[..]\" prior to parsing. This is used to fix broken
-break-info output when it contains breakpoint script field
incompatible with GDB/MI output syntax.

If `default-directory' is remote, full file names are adapted accordingly."
  (save-excursion
    (let ((remote (file-remote-p default-directory)))
      (when remote
        (goto-char (point-min))
        (while (re-search-forward "[\\[,]fullname=\"\\(.+\\)\"" nil t)
          (replace-match (concat remote "\\1") nil nil nil 1))))
    (goto-char (point-min))
    (when fix-key
      (save-excursion
        (while (re-search-forward (concat "[\\[,]\\(" fix-key "=\\)") nil t)
          (replace-match "" nil nil nil 1))))
    (when fix-list
      (save-excursion
        ;; Find positions of braces which enclose broken list
        (while (re-search-forward (concat fix-list "={\"") nil t)
          (let ((p1 (goto-char (- (point) 2)))
                (p2 (progn (forward-sexp)
                           (1- (point)))))
            ;; Replace braces with brackets
            (save-excursion
              (goto-char p1)
              (delete-char 1)
              (insert "[")
              (goto-char p2)
              (delete-char 1)
              (insert "]"))))))
    (goto-char (point-min))
    (insert "{")
    (let ((re (concat "\\([[:alnum:]-_]+\\)=")))
      (while (re-search-forward re nil t)
        (replace-match "\"\\1\":" nil nil)
        (if (eq (char-after) ?\") (forward-sexp) (forward-char))))
    (goto-char (point-max))
    (insert "}")))

您的问题似乎与您链接的问题没有什么不同,或者我遗漏了什么?我应用了基于emacs 26.3的此修补程序,但仍然得到相同的错误(输出太长,无法粘贴到此处),我们是否有方法自定义只输出gdb输出而不做任何更改?如果是这样,我们还需要调用这个函数吗?