Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
5.9 KiB

  1. ;;; Copyright (C) 2011, 2014-2016, 2019 Free Software Foundation, Inc
  2. ;; Author: Rocky Bernstein <rocky@gnu.org>
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;;; Regular expressions for nodejs Javascript debugger.
  14. ;;; Stock Perl debugger perldb
  15. (eval-when-compile (require 'cl-lib)) ;For setf.
  16. (require 'load-relative)
  17. (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
  18. (require-relative-list '("../../lang/perl") "realgud-lang-")
  19. (defvar realgud-pat-hash)
  20. (declare-function make-realgud-loc-pat 'realgud-regexp)
  21. (defvar realgud:perldb-pat-hash (make-hash-table :test 'equal)
  22. "Hash key is the what kind of pattern we want to match:
  23. lang-backtrace, prompt, etc. The values of a hash entry is a
  24. realgud-loc-pat struct")
  25. (declare-function make-realgud-loc "realgud-loc" (a b c d e f))
  26. ;; Program-location lines look like these:
  27. ;; File::Basename::dirname(/usr/share/perl/5.16.0/File/Basename.pm:284):
  28. ;; File::Basename::dirname(/usr/share/perl/5.16.0/File/Basename.pm:284): my $path;
  29. ;; main::(/usr/bin/latex2html:102):
  30. ;; main::(/usr/bin/latex2html:102): @ARGV=2;
  31. ;; main::CODE(0x9407ac8)(l2hconf.pm:6):;;
  32. ;; main::((eval 8)[/tmp/eval.pl:2]:1):
  33. ;;
  34. ;; And what are complications MS Windows adds?
  35. ;; Hnadle eval form first, e.g.:
  36. ;; main::((eval 8)[/tmp/eval.pl:2]:1):
  37. (defconst realgud:perldb-loc-eval-regexp
  38. (format "(eval [0-9]+)\\[\\(.+\\):%s\\]"
  39. realgud:regexp-captured-num))
  40. ;; Hnadle non eval form
  41. ;; main::CODE(0x9407ac8)(l2hconf.pm:6):;;
  42. (defconst realgud:perldb-loc-noeval-regexp
  43. (format "\\(?:CODE(0x[0-9a-h]+)\\)?(\\(.+\\):%s):\\(?:\t\\(.*\\)\\)?\n"
  44. realgud:regexp-captured-num))
  45. ;; Note that eval form has to come before non-eval form as the non-eval
  46. ;; form encompases the eval form. The two clauses makes it hard
  47. ;; to match file and line positions, so we ned to result to the
  48. ;; "alt" forms of file and lines as well as the non-alt formes
  49. (defconst realgud:perldb-loc-regexp
  50. (format "\\(?:%s\\)\\|\\(?:%s\\)"
  51. realgud:perldb-loc-eval-regexp realgud:perldb-loc-noeval-regexp))
  52. ;; Regular expression that describes a perldb location generally shown
  53. ;; before a command prompt. We include matching the source text so we
  54. ;; can save that.
  55. (setf (gethash "loc" realgud:perldb-pat-hash)
  56. (make-realgud-loc-pat
  57. :regexp realgud:perldb-loc-regexp
  58. :alt-file-group 1
  59. :alt-line-group 2
  60. :file-group 3
  61. :line-group 4
  62. :text-group 5))
  63. ;; perldb debugger prompt.
  64. ;; Examples:
  65. ;; DB<4>
  66. ;; [pid=6489->6502] DB<1>
  67. ;;
  68. (setf (gethash "prompt" realgud:perldb-pat-hash)
  69. (make-realgud-loc-pat
  70. :regexp "\\(?:\\[pid=[0-9]+->[0-9]+\\]\\)? DB<\\([0-9]+\\)> "
  71. :num 1
  72. ))
  73. ;; Regular expression that describes a Perl debugger backtrace line.
  74. ;; $ = main::top_navigation_panel called from file `./latex2html' line 7400
  75. ;; $ = main::BEGIN() called from file `(eval 19)[/usr/bin/latex2html:126]' line 2
  76. (setf (gethash "debugger-backtrace" realgud:perldb-pat-hash)
  77. (make-realgud-loc-pat
  78. :regexp "\s+called from file `\\(.+\\)' line \\([0-9]+\\)"
  79. :file-group 1
  80. :line-group 2))
  81. ;; Regular expression that describes location in a Perl errmsg
  82. (setf (gethash "perl-errmsg" realgud:perldb-pat-hash)
  83. realgud-perl-errmsg-loc-pat)
  84. ;; Regular expression that describes a Perl Carp backtrace line.
  85. ;; at /tmp/foo.pl line 7
  86. ;; main::__ANON__('Illegal division by zero at /tmp/foo.pl line 4.\x{a}') called at /tmp/foo.pl line 4
  87. ;; main::foo(3) called at /tmp/foo.pl line 8
  88. (setf (gethash "lang-backtrace" realgud:perldb-pat-hash)
  89. realgud-perl-carp-loc-pat)
  90. (defvar realgud:perldb-command-hash (make-hash-table :test 'equal)
  91. "Hash key is command name like 'quit' and the value is
  92. the perldb command to use, like 'q'")
  93. (setf (gethash "font-lock-keywords" realgud:perldb-pat-hash)
  94. '(
  95. ("\s+called from file `\\(.+\\)' line \\([0-9]+\\)"
  96. (1 realgud-file-name-face)
  97. (2 realgud-line-number-face))
  98. ))
  99. (setf (gethash "perldb" realgud-pat-hash) realgud:perldb-pat-hash)
  100. (setf (gethash "backtrace" realgud:perldb-command-hash) "T")
  101. (setf (gethash "break" realgud:perldb-command-hash) "b %l")
  102. (setf (gethash "clear" realgud:perldb-command-hash) "B %l")
  103. (setf (gethash "continue" realgud:perldb-command-hash) "c")
  104. (setf (gethash "eval" realgud:perldb-command-hash) "x %s")
  105. (setf (gethash "info-breakpoints" realgud:perldb-command-hash) "L")
  106. (setf (gethash "quit" realgud:perldb-command-hash) "q")
  107. (setf (gethash "restart" realgud:perldb-command-hash) "R")
  108. (setf (gethash "run" realgud:perldb-command-hash) "R")
  109. (setf (gethash "step" realgud:perldb-command-hash) "s")
  110. (setf (gethash "next" realgud:perldb-command-hash) "n")
  111. (setf (gethash "until" realgud:perldb-command-hash) "c %l")
  112. (setf (gethash "perldb" realgud-command-hash) realgud:perldb-command-hash)
  113. ;; Unsupported features:
  114. (setf (gethash "frame" realgud:perldb-command-hash) "*not-implemented*")
  115. (setf (gethash "shell" realgud:perldb-command-hash) "*not-implemented*")
  116. (setf (gethash "up" realgud:perldb-command-hash) "*not-implemented*")
  117. (setf (gethash "down" realgud:perldb-command-hash) "*not-implemented*")
  118. (setf (gethash "jump" realgud:perldb-command-hash) "*not-implemented*")
  119. (setf (gethash "kill" realgud:perldb-command-hash) "*not-implemented*")
  120. (provide-me "realgud:perldb-")