[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 27ab3b14de1: Better LLDB frame information (bug#66604)
From: |
Mattias Engdegård |
Subject: |
master 27ab3b14de1: Better LLDB frame information (bug#66604) |
Date: |
Tue, 24 Oct 2023 06:00:33 -0400 (EDT) |
branch: master
commit 27ab3b14de1c881cd57c4c6d96c736f48909323d
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Better LLDB frame information (bug#66604)
Instead of modifying `frame-format` to be entirely machine-readable,
keep the original human-readable format and append a second,
machine-readable line that we remove after parsing.
* lisp/progmodes/gud.el
(gud-lldb-marker-filter): Parse the new line format and filter it out.
* lisp/progmodes/gud.el
(gud-lldb-def-python-completion-function): Rename to...
(gud--lldb-python-init-string): ...this and add modification
of `frame-format`, which seems easiest done from Python.
(gud-lldb-frame-format): Remove.
(gud-lldb-initialize): Update, remove no longer needed parts.
---
lisp/progmodes/gud.el | 71 ++++++++++++++++++++++++++-------------------------
1 file changed, 36 insertions(+), 35 deletions(-)
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 1d3c2a72863..8692a6be023 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -3868,24 +3868,32 @@ so they have been disabled."))
(defun gud-lldb-marker-filter (string)
"Deduce interesting stuff from process output STRING."
- (cond
- ;; gud-info: (function-name args...)
- ((string-match (rx line-start (0+ blank) "gud-info:" (0+ blank)
- (group "(" (1+ (not ")")) ")"))
- string)
- (let* ((form (string-replace "///" "\"" (match-string 1 string)))
- (form (car (read-from-string form))))
- (when (eq (car form) 'gud-lldb-stop)
- (let ((plist (cdr form)))
- (setq gud-last-frame (list (plist-get plist :file)
- (plist-get plist :line)
- (plist-get plist :column)))))))
- ;; Process 72874 exited with status = 9 (0x00000009) killed.
- ;; Doesn't seem to be changeable as of LLDB 17.0.2.
- ((string-match (rx "Process " (1+ digit) " exited with status")
- string)
- (setq gud-last-last-frame nil)
- (setq gud-overlay-arrow-position nil)))
+
+ ;; Pick information from our own frame info line "!gud LINE:COL:FILE"
+ ;; because the file name in the standard LLDB frame-format doesn't have
+ ;; a directory.
+ (setq string
+ (replace-regexp-in-string
+ (rx bol "!gud "
+ (group (+ digit)) ":" ; 1: line
+ (group (* digit)) ":" ; 2: column
+ (group (+ (not (in "\n\r")))) ; 3: file
+ (* "\r") "\n")
+ (lambda (m)
+ (let ((line (string-to-number (match-string 1 m)))
+ (col (string-to-number (match-string 2 m)))
+ (file (match-string 3 m)))
+ (setq gud-last-frame (list file line col)))
+ ;; Remove the line so that the user won't see it.
+ "")
+ string t t))
+
+ (when (string-match (rx "Process " (1+ digit) " exited with status")
+ string)
+ ;; Process 72874 exited with status = 9 (0x00000009) killed.
+ ;; Doesn't seem to be changeable as of LLDB 17.0.2.
+ (setq gud-last-last-frame nil)
+ (setq gud-overlay-arrow-position nil))
;; LLDB sometimes emits certain ECMA-48 sequences even if TERM is "dumb":
;; CHA (Character Horizontal Absolute) and ED (Erase in Display),
@@ -3946,8 +3954,13 @@ so they have been disabled."))
:type 'integer
:version "30.1")
-(defvar gud-lldb-def-python-completion-function
- "
+(defconst gud--lldb-python-init-string
+ "\
+deb = lldb.debugger
+inst = deb.GetInstanceName()
+ff = deb.GetInternalVariableValue('frame-format', inst).GetStringAtIndex(0)
+ff = ff[:-1] + '!gud
${line.number}:${line.column}:${line.file.fullpath}\\\\n\"'
+_ = deb.SetInternalVariable('frame-format', ff, inst)
def gud_complete(s, max):
interpreter = lldb.debugger.GetCommandInterpreter()
string_list = lldb.SBStringList()
@@ -3959,7 +3972,7 @@ def gud_complete(s, max):
print(f'\"{string_list.GetStringAtIndex(i)}\" ')
print(')##')
"
- "LLDB Python function for completion.")
+ "Python code sent to LLDB for gud-specific initialisation.")
(defun gud-lldb-fetch-completions (context command)
"Return the data to complete the LLDB command before point.
@@ -4010,15 +4023,6 @@ by `gud-lldb-max-completions', which see."
(completion-table-dynamic
(apply-partially #'gud-lldb-completions context)))))
-(defvar gud-lldb-frame-format
- (concat "gud-info: (gud-lldb-stop "
- ;; Quote the filename this way to avoid quoting issues in
- ;; the interplay between Emacs and LLDB. The quotes are
- ;; corrected in the process filter.
- ":file ///${line.file.fullpath}/// "
- ":line ${line.number} "
- ":column ${line.column})\\n"))
-
(defun gud-lldb-send-python (python)
(gud-basic-call "script --language python --")
(mapc #'gud-basic-call (split-string python "\n"))
@@ -4026,12 +4030,9 @@ by `gud-lldb-max-completions', which see."
(defun gud-lldb-initialize ()
"Initialize the LLDB process as needed for this debug session."
- (gud-lldb-send-python gud-lldb-def-python-completion-function)
+ (gud-lldb-send-python gud--lldb-python-init-string)
(gud-basic-call "settings set stop-line-count-before 0")
- (gud-basic-call "settings set stop-line-count-after 0")
- (gud-basic-call (format "settings set frame-format \"%s\""
- gud-lldb-frame-format))
- (gud-basic-call "script --language python -- print('Gud initialized.')"))
+ (gud-basic-call "settings set stop-line-count-after 0"))
;;;###autoload
(defun lldb (command-line)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 27ab3b14de1: Better LLDB frame information (bug#66604),
Mattias Engdegård <=