Changeset View
Changeset View
Standalone View
Standalone View
editors/emacs/files/extrapatch-lldb-gud.el
This diff is retrieved from http://lists.gnu.org/archive/html/emacs-devel/2015-02/msg00274.html | --- lisp/progmodes/gud.el.orig 2018-01-08 20:23:57 UTC | ||||
And traces its origin back to https://gitorious.org/lldb/lldb/commit/40e4dbf | |||||
It's also present on Apple's OS site: | |||||
http://www.opensource.apple.com/source/lldb/lldb-76/utils/emacs/ | |||||
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el | |||||
index 42c5b20..7f2e9c0 100644 | |||||
--- lisp/progmodes/gud.el | |||||
+++ lisp/progmodes/gud.el | +++ lisp/progmodes/gud.el | ||||
@@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||||
;; kluge with the gud-xdb-directories hack producing gud-dbx-directories. | ;; kluge with the gud-xdb-directories hack producing gud-dbx-directories. | ||||
;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java | ;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java | ||||
;; debugger.) Jan Nieuwenhuizen added support for the Guile REPL (Guile | ;; debugger.) Jan Nieuwenhuizen added support for the Guile REPL (Guile | ||||
-;; debugger). | -;; debugger). | ||||
+;; debugger). llvm.org added support for lldb. | +;; debugger). llvm.org added support for lldb. | ||||
;;; Code: | ;;; Code: | ||||
@@ -56,7 +56,7 @@ | @@ -56,7 +56,7 @@ | ||||
(defgroup gud nil | (defgroup gud nil | ||||
"The \"Grand Unified Debugger\" interface. | "The \"Grand Unified Debugger\" interface. | ||||
-Supported debuggers include gdb, sdb, dbx, xdb, perldb, | -Supported debuggers include gdb, sdb, dbx, xdb, perldb, | ||||
+Supported debuggers include lldb, gdb, sdb, dbx, xdb, perldb, | +Supported debuggers include lldb, gdb, sdb, dbx, xdb, perldb, | ||||
pdb (Python), and jdb." | pdb (Python), and jdb." | ||||
:group 'processes | :group 'processes | ||||
:group 'tools) | :group 'tools) | ||||
@@ -141,12 +141,12 @@ Used to gray out relevant toolbar icons.") | @@ -141,12 +141,12 @@ Used to gray out relevant toolbar icons. | ||||
(display-graphic-p) | (display-graphic-p) | ||||
(fboundp 'x-show-tip)) | (fboundp 'x-show-tip)) | ||||
:visible (memq gud-minor-mode | :visible (memq gud-minor-mode | ||||
- '(gdbmi guiler dbx sdb xdb pdb)) | - '(gdbmi guiler dbx sdb xdb pdb)) | ||||
+ '(lldb gdbmi guiler dbx sdb xdb pdb)) | + '(lldb gdbmi guiler dbx sdb xdb pdb)) | ||||
:button (:toggle . gud-tooltip-mode)) | :button (:toggle . gud-tooltip-mode)) | ||||
([refresh] "Refresh" . gud-refresh) | ([refresh] "Refresh" . gud-refresh) | ||||
([run] menu-item "Run" gud-run | ([run] menu-item "Run" gud-run | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
- :visible (memq gud-minor-mode '(gdbmi gdb dbx jdb))) | - :visible (or (memq gud-minor-mode '(gdb dbx jdb)) | ||||
+ :visible (memq gud-minor-mode '(lldb gdbmi gdb dbx jdb))) | + :visible (or (memq gud-minor-mode '(lldb gdb dbx jdb)) | ||||
([go] menu-item (if (bound-and-true-p gdb-active-process) | (and (eq gud-minor-mode 'gdbmi) | ||||
"Continue" "Run") gud-go | (or (not (gdb-show-run-p)) | ||||
:visible (and (eq gud-minor-mode 'gdbmi) | (bound-and-true-p | ||||
@@ -164,18 +164,18 @@ Used to gray out relevant toolbar icons.") | @@ -169,18 +169,18 @@ Used to gray out relevant toolbar icons. | ||||
([tbreak] menu-item "Temporary Breakpoint" gud-tbreak | ([tbreak] menu-item "Temporary Breakpoint" gud-tbreak | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
:visible (memq gud-minor-mode | :visible (memq gud-minor-mode | ||||
- '(gdbmi gdb sdb xdb))) | - '(gdbmi gdb sdb xdb))) | ||||
+ '(lldb gdbmi gdb sdb xdb))) | + '(lldb gdbmi gdb sdb xdb))) | ||||
([break] menu-item "Set Breakpoint" gud-break | ([break] menu-item "Set Breakpoint" gud-break | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
:visible (gud-tool-bar-item-visible-no-fringe)) | :visible (gud-tool-bar-item-visible-no-fringe)) | ||||
([up] menu-item "Up Stack" gud-up | ([up] menu-item "Up Stack" gud-up | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
:visible (memq gud-minor-mode | :visible (memq gud-minor-mode | ||||
- '(gdbmi gdb guiler dbx xdb jdb pdb))) | - '(gdbmi gdb guiler dbx xdb jdb pdb))) | ||||
+ '(lldb gdbmi gdb guiler dbx xdb jdb pdb))) | + '(lldb gdbmi gdb guiler dbx xdb jdb pdb))) | ||||
([down] menu-item "Down Stack" gud-down | ([down] menu-item "Down Stack" gud-down | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
:visible (memq gud-minor-mode | :visible (memq gud-minor-mode | ||||
- '(gdbmi gdb guiler dbx xdb jdb pdb))) | - '(gdbmi gdb guiler dbx xdb jdb pdb))) | ||||
+ '(lldb gdbmi gdb guiler dbx xdb jdb pdb))) | + '(lldb gdbmi gdb guiler dbx xdb jdb pdb))) | ||||
([pp] menu-item "Print S-expression" gud-pp | ([pp] menu-item "Print S-expression" gud-pp | ||||
:enable (and (not gud-running) | :enable (and (not gud-running) | ||||
(bound-and-true-p gdb-active-process)) | (bound-and-true-p gdb-active-process)) | ||||
@@ -187,7 +187,7 @@ Used to gray out relevant toolbar icons.") | @@ -192,7 +192,7 @@ Used to gray out relevant toolbar icons. | ||||
"Dump object" | "Dump object" | ||||
"Print Dereference") gud-pstar | "Print Dereference") gud-pstar | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
- :visible (memq gud-minor-mode '(gdbmi gdb jdb))) | - :visible (memq gud-minor-mode '(gdbmi gdb jdb))) | ||||
+ :visible (memq gud-minor-mode '(lldb gdbmi gdb jdb))) | + :visible (memq gud-minor-mode '(lldb gdbmi gdb jdb))) | ||||
([print] menu-item "Print Expression" gud-print | ([print] menu-item "Print Expression" gud-print | ||||
:enable (not gud-running)) | :enable (not gud-running)) | ||||
([watch] menu-item "Watch Expression" gud-watch | ([watch] menu-item "Watch Expression" gud-watch | ||||
@@ -196,13 +196,13 @@ Used to gray out relevant toolbar icons.") | @@ -201,13 +201,13 @@ Used to gray out relevant toolbar icons. | ||||
([finish] menu-item "Finish Function" gud-finish | ([finish] menu-item "Finish Function" gud-finish | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
:visible (memq gud-minor-mode | :visible (memq gud-minor-mode | ||||
- '(gdbmi gdb guiler xdb jdb pdb))) | - '(gdbmi gdb guiler xdb jdb pdb))) | ||||
+ '(lldb gdbmi gdb guiler xdb jdb pdb))) | + '(lldb gdbmi gdb guiler xdb jdb pdb))) | ||||
([stepi] menu-item "Step Instruction" gud-stepi | ([stepi] menu-item "Step Instruction" gud-stepi | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
- :visible (memq gud-minor-mode '(gdbmi gdb dbx))) | - :visible (memq gud-minor-mode '(gdbmi gdb dbx))) | ||||
+ :visible (memq gud-minor-mode '(lldb gdbmi gdb dbx))) | + :visible (memq gud-minor-mode '(lldb gdbmi gdb dbx))) | ||||
([nexti] menu-item "Next Instruction" gud-nexti | ([nexti] menu-item "Next Instruction" gud-nexti | ||||
:enable (not gud-running) | :enable (not gud-running) | ||||
- :visible (memq gud-minor-mode '(gdbmi gdb dbx))) | - :visible (memq gud-minor-mode '(gdbmi gdb dbx))) | ||||
+ :visible (memq gud-minor-mode '(lldb gdbmi gdb dbx))) | + :visible (memq gud-minor-mode '(lldb gdbmi gdb dbx))) | ||||
([step] menu-item "Step Line" gud-step | ([step] menu-item "Step Line" gud-step | ||||
:enable (not gud-running)) | :enable (not gud-running)) | ||||
([next] menu-item "Next Line" gud-next | ([next] menu-item "Next Line" gud-next | ||||
@@ -237,7 +237,7 @@ Used to gray out relevant toolbar icons.") | @@ -242,7 +242,7 @@ Used to gray out relevant toolbar icons. | ||||
:visible (not (eq gud-minor-mode 'gdbmi))) | :visible (not (eq gud-minor-mode 'gdbmi))) | ||||
([menu-bar run] menu-item | ([menu-bar run] menu-item | ||||
,(propertize "run" 'face 'font-lock-doc-face) gud-run | ,(propertize "run" 'face 'font-lock-doc-face) gud-run | ||||
- :visible (memq gud-minor-mode '(gdbmi gdb dbx jdb))) | - :visible (memq gud-minor-mode '(gdbmi gdb dbx jdb))) | ||||
+ :visible (memq gud-minor-mode '(lldb gdbmi gdb dbx jdb))) | + :visible (memq gud-minor-mode '(lldb gdbmi gdb dbx jdb))) | ||||
([menu-bar go] menu-item | ([menu-bar go] menu-item | ||||
,(propertize " go " 'face 'font-lock-doc-face) gud-go | ,(propertize " go " 'face 'font-lock-doc-face) gud-go | ||||
:visible (and (eq gud-minor-mode 'gdbmi) | :visible (and (eq gud-minor-mode 'gdbmi) | ||||
@@ -356,6 +356,7 @@ are interpreted specially if present. These are: | @@ -361,6 +361,7 @@ are interpreted specially if present. T | ||||
%l -- Number of current source line. | %l -- Number of current source line. | ||||
%e -- Text of the C lvalue or function-call expression surrounding point. | %e -- Text of the C lvalue or function-call expression surrounding point. | ||||
%a -- Text of the hexadecimal address surrounding point. | %a -- Text of the hexadecimal address surrounding point. | ||||
+ %b -- Text of the most recently created breakpoint id. | + %b -- Text of the most recently created breakpoint id. | ||||
%p -- Prefix argument to the command (if any) as a number. | %p -- Prefix argument to the command (if any) as a number. | ||||
%c -- Fully qualified class name derived from the expression | %c -- Fully qualified class name derived from the expression | ||||
surrounding point (jdb only). | surrounding point (jdb only). | ||||
@@ -964,6 +965,131 @@ SKIP is the number of chars to skip on each line, it defaults to 0." | @@ -975,6 +976,131 @@ SKIP is the number of chars to skip on e | ||||
␌ | ␌ | ||||
;; ====================================================================== | ;; ====================================================================== | ||||
+;; lldb functions | +;; lldb functions | ||||
+ | + | ||||
+;; History of argument lists passed to lldb. | +;; History of argument lists passed to lldb. | ||||
+(defvar gud-lldb-history nil) | +(defvar gud-lldb-history nil) | ||||
+ | + | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | |||||
+ (run-hooks 'lldb-mode-hook) | + (run-hooks 'lldb-mode-hook) | ||||
+ ) | + ) | ||||
+ | + | ||||
+␌ | +␌ | ||||
+;; ====================================================================== | +;; ====================================================================== | ||||
;; sdb functions | ;; sdb functions | ||||
;; History of argument lists passed to sdb. | ;; History of argument lists passed to sdb. | ||||
@@ -2499,9 +2625,10 @@ gud, see `gud-mode'." | @@ -2505,9 +2631,10 @@ gud, see `gud-mode'." | ||||
"Major mode for interacting with an inferior debugger process. | "Major mode for interacting with an inferior debugger process. | ||||
You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx, | You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx, | ||||
-M-x perldb, M-x xdb, or M-x jdb. Each entry point finishes by executing a | -M-x perldb, M-x xdb, or M-x jdb. Each entry point finishes by executing a | ||||
-hook; `gdb-mode-hook', `sdb-mode-hook', `dbx-mode-hook', | -hook; `gdb-mode-hook', `sdb-mode-hook', `dbx-mode-hook', | ||||
-`perldb-mode-hook', `xdb-mode-hook', or `jdb-mode-hook' respectively. | -`perldb-mode-hook', `xdb-mode-hook', or `jdb-mode-hook' respectively. | ||||
+M-x perldb, M-x xdb, M-x jdb, or M-x lldb. Each entry point finishes by | +M-x perldb, M-x xdb, M-x jdb, or M-x lldb. Each entry point finishes by | ||||
+executing a hook; `gdb-mode-hook', `sdb-mode-hook', `dbx-mode-hook', | +executing a hook; `gdb-mode-hook', `sdb-mode-hook', `dbx-mode-hook', | ||||
+`perldb-mode-hook', `xdb-mode-hook', `jdb-mode-hook', or `lldb-mode-hook' | +`perldb-mode-hook', `xdb-mode-hook', `jdb-mode-hook', or `lldb-mode-hook' | ||||
+respectively. | +respectively. | ||||
After startup, the following commands are available in both the GUD | After startup, the following commands are available in both the GUD | ||||
interaction buffer and any source buffer GUD visits due to a breakpoint stop | interaction buffer and any source buffer GUD visits due to a breakpoint stop | ||||
@@ -2531,7 +2658,7 @@ Under gdb, sdb and xdb, \\[gud-tbreak] behaves exactly like \\[gud-break], | @@ -2537,7 +2664,7 @@ Under gdb, sdb and xdb, \\[gud-tbreak] b | ||||
except that the breakpoint is temporary; that is, it is removed when | except that the breakpoint is temporary; that is, it is removed when | ||||
execution stops on it. | execution stops on it. | ||||
-Under gdb, dbx, and xdb, \\[gud-up] pops up through an enclosing stack | -Under gdb, dbx, and xdb, \\[gud-up] pops up through an enclosing stack | ||||
+Under gdb, dbx, xdb, and lldb, \\[gud-up] pops up through an enclosing stack | +Under gdb, dbx, xdb, and lldb, \\[gud-up] pops up through an enclosing stack | ||||
frame. \\[gud-down] drops back down through one. | frame. \\[gud-down] drops back down through one. | ||||
If you are using gdb or xdb, \\[gud-finish] runs execution to the return from | If you are using gdb or xdb, \\[gud-finish] runs execution to the return from | ||||
@@ -2858,7 +2985,7 @@ Obeying it means displaying in another window the specified file and line." | @@ -2859,7 +2986,7 @@ Obeying it means displaying in another w | ||||
result) | result) | ||||
(while (and str | (while (and str | ||||
(let ((case-fold-search nil)) | (let ((case-fold-search nil)) | ||||
- (string-match "\\([^%]*\\)%\\([adefFlpc]\\)" str))) | - (string-match "\\([^%]*\\)%\\([adefFlpc]\\)" str))) | ||||
+ (string-match "\\([^%]*\\)%\\([abdefFlpc]\\)" str))) | + (string-match "\\([^%]*\\)%\\([abdefFlpc]\\)" str))) | ||||
(let ((key (string-to-char (match-string 2 str))) | (let ((key (string-to-char (match-string 2 str))) | ||||
subst) | subst) | ||||
(cond | (cond | ||||
@@ -2886,6 +3013,8 @@ Obeying it means displaying in another window the specified file and line." | @@ -2887,6 +3014,8 @@ Obeying it means displaying in another w | ||||
(setq subst (gud-find-expr))) | (setq subst (gud-find-expr))) | ||||
((eq key ?a) | ((eq key ?a) | ||||
(setq subst (gud-read-address))) | (setq subst (gud-read-address))) | ||||
+ ((eq key ?b) | + ((eq key ?b) | ||||
+ (setq subst gud-breakpoint-id)) | + (setq subst gud-breakpoint-id)) | ||||
((eq key ?c) | ((eq key ?c) | ||||
(setq subst | (setq subst | ||||
(gud-find-class | (gud-find-class | ||||
@@ -3520,6 +3649,7 @@ With arg, dereference expr if ARG is positive, otherwise do not dereference." | @@ -3522,6 +3651,7 @@ With arg, dereference expr if ARG is pos | ||||
(defun gud-tooltip-print-command (expr) | (defun gud-tooltip-print-command (expr) | ||||
"Return a suitable command to print the expression EXPR." | "Return a suitable command to print the expression EXPR." | ||||
(pcase gud-minor-mode | (pcase gud-minor-mode | ||||
+ (`lldb (concat "expression -o -- \"" expr "\"")) | + (`lldb (concat "expression -o -- \"" expr "\"")) | ||||
(`gdbmi (concat "-data-evaluate-expression \"" expr "\"")) | (`gdbmi (concat "-data-evaluate-expression \"" expr "\"")) | ||||
(`guiler expr) | (`guiler expr) | ||||
(`dbx (concat "print " expr)) | (`dbx (concat "print " expr)) |