Fix conflict between matlab-shell debugging and C++ (or other language) debugging.

Fix conflict between matlab-shell debugging and C++ (or other language) debugging.
- matlab-shell debugging previously leveraged gud.el for debugging of *.m files.
- C++ debugging also leverages gud.el for debugging.
- Only one instance of a gud.el debugger can be active. If you run two, say
  *.m debugging and C++ debugging. Then you get odd errors such as the
  ebbreak not being recognized by gdb.
To fix these issue, I copied gud.el and made a new namespace "mlgud". I also
removed a lot of unused code from mlgud.el, though there's still more that can
be removed. Now one can debug *.m files and *.cpp files in one Emacs session.
This commit is contained in:
John Ciolfi 2022-03-11 14:55:04 -05:00
parent c945bf5025
commit 45febb409c
6 changed files with 1851 additions and 487 deletions

View File

@ -1,3 +1,16 @@
2022-03-11 John Ciolfi <ciolfi@mathworks.com>
* matlab-netshell.el, matlab-shell-gud.el, matlab-shell.el, matlab.el, mlgud.el
Fix conflict between matlab-shell debugging and C++ (or other language) debugging.
- matlab-shell debugging previously leveraged gud.el for debugging of *.m files.
- C++ debugging also leverages gud.el for debugging.
- Only one instance of a gud.el debugger can be active. If you run two, say
*.m debugging and C++ debugging. Then you get odd errors such as the
ebbreak not being recognized by gdb.
To fix these issue, I copied gud.el and made a new namespace "mlgud". I also
removed a lot of unused code from mlgud.el, though there's still more that can
be removed. Now one can debug *.m files and *.cpp files in one Emacs session.
2021-11-22 Uwe Brauer <oub@mat.ucm.es>
* company-matlab-shell.el: 677 correct a silly typo

View File

@ -122,7 +122,7 @@ response from some Emacs based request."
;; Interpret the command.
(cond ((string= "init" cmd)
;; Make sure GUD bindings are available, but do so in
;; the netshell buffer so when gud bundings run, they
;; the netshell buffer so when mlgud bundings run, they
;; don't stomp on C-c matlab-mode bindings.
(with-current-buffer (process-buffer proc)
(matlab-shell-mode-gud-enable-bindings))

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
(require 'server)
(eval-and-compile
(require 'gud)
(require 'mlgud)
(require 'shell)
)
@ -563,7 +563,7 @@ Try C-h f matlab-shell RET"))
;;; PROCESS FILTERS & SENTINEL
;;
;; These are wrappers around the GUD filters so we can pre and post process
;; decisions by comint and gud.
;; decisions by comint and mlgud.
(defvar matlab-shell-capturetext-start-text "<EMACSCAP>"
"Text used as simple signal for text that should be captured.")
(defvar matlab-shell-capturetext-end-text "</EMACSCAP>"
@ -635,7 +635,7 @@ STRING is the recent output from PROC to be filtered."
matlab-shell-flush-accumulation-buffer nil))
(with-current-buffer buff
(gud-filter proc string))
(mlgud-filter proc string))
;; In case things get switched around on us
(with-current-buffer buff
@ -656,7 +656,7 @@ PROC is the function which experienced a change in state.
STRING is a description of what happened."
(let ((buff (process-buffer proc)))
(with-current-buffer buff
(gud-sentinel proc string))))
(mlgud-sentinel proc string))))
;;; COMINT support fcns
;;
@ -1933,8 +1933,8 @@ If DEBUG is non-nil, then setup GUD debugging features."
(goto-char (point-min))
(forward-line (1- (string-to-number el)))
(when debug
(setq gud-last-frame (cons (buffer-file-name) (string-to-number el)))
(gud-display-frame))
(setq mlgud-last-frame (cons (buffer-file-name) (string-to-number el)))
(mlgud-display-frame))
(setq ec (string-to-number ec))
(if (> ec 0) (forward-char (1- ec)))))
@ -1953,7 +1953,7 @@ If DEBUG is non-nil, then setup GUD debugging features."
(matlab-find-other-window-file-line-column ef el ec debug)))
((string-match "^matlab:*\\(.*\\)$" url)
(process-send-string
(get-buffer-process gud-comint-buffer)
(get-buffer-process mlgud-comint-buffer)
(concat (substring url (match-beginning 1) (match-end 1)) "\n")))))
(defun matlab-shell-last-error ()
@ -2413,12 +2413,13 @@ Return the name of the temporary file."
(goto-char (point-min))
(dolist (F functions)
(save-excursion
;; Copy all local functions to script.
(let ((ft (matlab-semantic-tag-text F orig)))
(goto-char (point-max))
(insert "% Copy of " (semantic-tag-name F) "\n\n")
(insert ft)
(insert "\n%%\n")))
(when (re-search-forward (semantic-tag-name F) nil t)
;; Found, copy it in.
(let ((ft (matlab-semantic-tag-text F orig)))
(goto-char (point-max))
(insert "% Copy of " (semantic-tag-name F) "\n\n")
(insert ft)
(insert "\n%%\n"))))
)
;; Save buffer, and setup ability to run this new script.
@ -2460,31 +2461,31 @@ Argument FNAME specifies if we should echo the region to the command line."
;;; matlab-shell.el ends here
;; LocalWords: el Ludlam zappo compat comint gud Slience defcustom el cb
;; LocalWords: el Ludlam zappo compat comint mlgud Slience defcustom el cb
;; LocalWords: nodesktop defface autostart netshell emacsclient errorscanning
;; LocalWords: cco defun setq Keymaps keymap kbd featurep fboundp subprocess
;; LocalWords: online EDU postoutput progn subjob eol mlfile emacsinit msbn pc
;; LocalWords: Thx Chappaz windowid dirtrackp dbhot erroexamples Ludlam zappo
;; LocalWords: compat comint gud Slience defcustom nodesktop defface emacscd
;; LocalWords: compat comint mlgud Slience defcustom nodesktop defface emacscd
;; LocalWords: autostart netshell emacsclient errorscanning cco defun setq el
;; LocalWords: Keymaps keymap kbd featurep fboundp subprocess online EDU
;; LocalWords: postoutput progn subjob eol mlfile emacsinit msbn pc Thx Ludlam
;; LocalWords: Chappaz windowid dirtrackp dbhot erroexamples cdr ENDPT dolist
;; LocalWords: overlaystack mref deref errortext ERRORTXT Missmatched zappo
;; LocalWords: shellerror dbhotlink realfname aset buf noselect tcp auth ef
;; LocalWords: dbhotlinks compat comint gud Slience defcustom capturetext
;; LocalWords: shellerror dbhotlink realfname aset buf noselect auth ef
;; LocalWords: dbhotlinks compat comint mlgud Slience defcustom capturetext
;; LocalWords: nodesktop defface autostart netshell emacsclient errorscanning
;; LocalWords: cco defun setq Keymaps keymap kbd featurep fboundp subprocess
;; LocalWords: online EDU postoutput progn subjob eol mlfile emacsinit msbn pc
;; LocalWords: Thx Chappaz windowid dirtrackp dbhot erroexamples cdr ENDPT
;; LocalWords: dolist overlaystack mref deref errortext ERRORTXT Missmatched
;; LocalWords: shellerror dbhotlink realfname aset buf noselect tcp auth ef
;; LocalWords: shellerror dbhotlink realfname aset buf noselect auth ef
;; LocalWords: dbhotlinks dbhlcmd endprompt mello pmark memq promptend
;; LocalWords: numchars integerp emacsdocomplete mycmd ba nreverse EMACSCAP
;; LocalWords: emacsdocompletion subfield fil byteswap stringp cbuff mapcar bw
;; LocalWords: FCN's alist BUILTINFLAG dired bol bobp numberp lattr princ
;; LocalWords: minibuffer fn matlabregex stackexchange doesnt lastcmd Emacsen
;; LocalWords: notimeout stacktop eltest testme localfcn LF mlx meth fileref
;; LocalWords: notimeout stacktop eltest testme localfcn LF meth fileref
;; LocalWords: funcall ec basec sk ignoredups boundp nondirectory edir sexp iq
;; LocalWords: Fixup mapc ltype noshow emacsrunregion cnt commandline elipsis
;; LocalWords: newf bss fname nt initcmd nsa ecc ecca clientcmd buffname

View File

@ -594,25 +594,25 @@ point, but it will be restored for them."
["Edit File (toggle read-only)" matlab-shell-gud-mode-edit
:help "Exit MATLAB debug minor mode to edit without exiting MATLAB's K>> prompt."
:visible gud-matlab-debug-active ]
["Add Breakpoint (ebstop in FILE at point)" gud-break
["Add Breakpoint (ebstop in FILE at point)" mlgud-break
:active (matlab-shell-active-p)
:help "When MATLAB debugger is active, set break point at current M-file point"]
["Remove Breakpoint (ebclear in FILE at point)" gud-remove
["Remove Breakpoint (ebclear in FILE at point)" mlgud-remove
:active (matlab-shell-active-p)
:help "Show all active breakpoints in a separate buffer." ]
["List Breakpoints (ebstatus)" gud-list-breakpoints
:help "When MATLAB debugger is active, remove break point in FILE at point." ]
["List Breakpoints (ebstatus)" mlgud-list-breakpoints
:active (matlab-shell-active-p)
:help "List active breakpoints."]
["Step (dbstep in)" gud-step
["Step (dbstep in)" mlgud-step
:active gud-matlab-debug-active
:help "When MATLAB debugger is active, step into line"]
["Next (dbstep)" gud-next
["Next (dbstep)" mlgud-next
:active gud-matlab-debug-active
:help "When MATLAB debugger is active, step one line"]
["Finish function (dbstep out)" gud-finish
["Finish function (dbstep out)" mlgud-finish
:active gud-matlab-debug-active
:help "When MATLAB debugger is active, run to end of function"]
["Continue (dbcont)" gud-cont
["Continue (dbcont)" mlgud-cont
:active gud-matlab-debug-active
:help "When MATLAB debugger is active, run to next break point or finish"]
["Evaluate Expression" matlab-shell-gud-show-symbol-value
@ -621,14 +621,14 @@ point, but it will be restored for them."
["Show Stack" mlg-show-stack
:active gud-matlab-debug-active
:help "When MATLAB debugger is active, show the stack in a buffer."]
;;; Advertise these more if we can get them working w/ gud's frame show.
;;; ["Up Call Stack (dbup)" gud-up
;;; Advertise these more if we can get them working w/ mlgud's frame show.
;;; ["Up Call Stack (dbup)" mlgud-up
;;; :active gud-matlab-debug-active
;;; :help "When MATLAB debugger is active and at break point, go up a frame"]
;;; ["Down Call Stack (dbdown)" gud-down
;;; ["Down Call Stack (dbdown)" mlgud-down
;;; :active gud-matlab-debug-active
;;; :help "When MATLAB debugger is active and at break point, go down a frame"]
["Quit debugging (dbquit)" gud-stop-subjob
["Quit debugging (dbquit)" mlgud-stop-subjob
:active gud-matlab-debug-active
:help "When MATLAB debugger is active, stop debugging"]
)
@ -3243,10 +3243,10 @@ desired. Optional argument FAST is not used."
;;; matlab.el ends here
;; LocalWords: el Wette mwette caltech edu Ludlam eludlam defconst online mfiles ebstop ebclear
;; LocalWords: compat easymenu defcustom CASEINDENT COMMANDINDENT sexp defun ebstatus mlg gud's
;; LocalWords: compat easymenu defcustom CASEINDENT COMMANDINDENT sexp defun ebstatus mlg mlgud's
;; LocalWords: mmode setq progn sg Fns Alist elipsis vf functionname vers subjob flb fle elisp
;; LocalWords: minibuffer featurep fboundp facep zmacs defface cellbreak bcend lastcompute noblock
;; LocalWords: cellbreaks overline keymap torkel ispell gud allstring strchar decl lcbounds setcar
;; LocalWords: cellbreaks overline keymap torkel ispell mlgud allstring strchar decl lcbounds setcar
;; LocalWords: bs eu bc ec searchlim eol charvec Matchers ltype cdr if'd setcdr bcwrapped
;; LocalWords: uicontext setcolor mld keywordlist mapconcat pragmas Classdefs
;; LocalWords: dem Za Imenu imenu alist prog reindent unindent boundp fn

1298
mlgud.el Normal file

File diff suppressed because it is too large Load Diff