emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/realgud 0a3befb 079/140: File remap is session specific


From: Rocky Bernstein
Subject: [elpa] externals/realgud 0a3befb 079/140: File remap is session specific...
Date: Sat, 25 May 2019 19:35:37 -0400 (EDT)

branch: externals/realgud
commit 0a3befb6e26504e7274c750fe3b4cbd7823350c7
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    File remap is session specific...
    
    finish session file-map ignore re's
---
 realgud/common/buffer/command.el |  48 ++++++++++++++++--
 realgud/common/file.el           | 107 +++++++++++++++++++++++----------------
 2 files changed, 107 insertions(+), 48 deletions(-)

diff --git a/realgud/common/buffer/command.el b/realgud/common/buffer/command.el
index 9745948..eed0333 100644
--- a/realgud/common/buffer/command.el
+++ b/realgud/common/buffer/command.el
@@ -33,6 +33,11 @@
   )
 (require 'cl-lib)
 
+(when (< emacs-major-version 26)
+  (defun make-mutex(&rest name)
+    ;; Stub for Emacs that doesn't have mutex
+    ))
+
 (defface debugger-running
   '((((class color) (min-colors 16) (background light))
      (:foreground "Green4" :weight bold))
@@ -111,11 +116,24 @@
   ;; - in C ../sysdeps/x86_64/multiarch/strchr-avx2.S or or more generally 
.*/sysdeps/.*
   ;; and so on.
   ;;
-  ;; Each debug session which has a command buffer, then should have
-  ;; its own ignore list which is seeded from the kind debugger it
-  ;; services.
+  ;; A list of regular expression. When one in the list matches a source
+  ;; location, we ignore that file. Of course, the regular expression could
+  ;; be a specific file name. Various programming languages have names
+  ;; that might not be real. For example, in Python or Ruby when you compile
+  ;; a or evaluate string you provide a name in the call, and often times
+  ;; this isn't the real name of a file. It is often something like "exec" or
+  ;; "<string>", or "<eval>". Each of the debuggers has the opportunity to 
seed the
+  ;; the ignore list.
   ignore-re-file-list
 
+  ;; A property list which maps the name as seen in the location to a path 
that we
+  ;; can do a "find-file" on
+  filename-remap-alist
+
+  ;; A mutex to ensure that two threads doing things in the same debug
+  ;; session simultaneously
+  mutex
+
   loc-hist     ;; ring of locations seen in the course of execution
                ;; see realgud-lochist
   starting-directory    ;; directory where initial debug command was issued.
@@ -142,6 +160,10 @@
 (realgud-struct-field-setter "realgud-cmdbuf-info" "callback-eval-filter")
 (realgud-struct-field-setter "realgud-cmdbuf-info" "starting-directory")
 (realgud-struct-field-setter "realgud-cmdbuf-info" "ignore-re-file-list")
+;; (realgud-struct-field-setter "realgud-cmdbuf-info" "filename-remap-alist")
+
+(defun realgud-cmdbuf-filename-remap-alist= (value)
+    (setf (realgud-cmdbuf-info-filename-remap-alist realgud-cmdbuf-info) 
value))
 
 (defun realgud:cmdbuf-follow-buffer(event)
   (interactive "e")
@@ -267,6 +289,8 @@ This is based on an org-mode buffer. Hit tab to 
expand/contract sections.
                               (realgud-cmdbuf-info-in-debugger? info))
                       (format "  - Ignore file regexps ::\t%s\n"
                               (realgud-cmdbuf-info-ignore-re-file-list info))
+                      (format "  - remapped file names ::\t%s\n"
+                              (realgud-cmdbuf-info-filename-remap-alist info))
 
                       (realgud:org-mode-encode "\n*** Remap table for debugger 
commands\n"
                                                      
(realgud-cmdbuf-info-cmd-hash info))
@@ -426,6 +450,8 @@ values set in the debugger's init.el."
             :alt-line-group (realgud-sget 'loc-pat 'alt-line-group)
             :text-group (realgud-sget 'loc-pat 'text-group)
             :ignore-re-file-list (gethash "ignore-re-file-list" regexp-hash)
+            :filename-remap-alist nil
+            :mutex (make-mutex (buffer-name))
             :loc-hist (make-realgud-loc-hist)
             :starting-directory starting-directory
             ))
@@ -453,6 +479,22 @@ values set in the debugger's init.el."
       nil))
   )
 
+(defun realgud-cmdbuf-mutex (&optional cmd-buf)
+  "Return the mutex for the current command buffer"
+  (with-current-buffer-safe (or cmd-buf (current-buffer))
+    (if (realgud-cmdbuf?)
+       (realgud-sget 'cmdbuf-info 'mutex)
+      nil))
+  )
+
+(defun realgud-cmdbuf-filename-remap-alist (&optional cmd-buf)
+  "Return the file-remap alist the current command buffer"
+  (with-current-buffer-safe (or cmd-buf (current-buffer))
+    (if (realgud-cmdbuf?)
+       (realgud-sget 'cmdbuf-info 'filename-remap-alist)
+      nil))
+  )
+
 (defun realgud-cmdbuf-pat(key)
   "Extract regexp stored under KEY in a realgud-cmdbuf via realgud-cmdbuf-info"
   (if (realgud-cmdbuf?)
diff --git a/realgud/common/file.el b/realgud/common/file.el
index c50395a..1758188 100644
--- a/realgud/common/file.el
+++ b/realgud/common/file.el
@@ -19,13 +19,6 @@
 (require-relative-list '("helper" "loc") "realgud-")
 (require-relative-list '("buffer/command") "realgud-buffer-")
 
-(defvar realgud-file-remap (make-hash-table :test 'equal)
-  "How to remap files we otherwise can't find in the
-  filesystem. The hash key is the file string we saw, and the
-  value is associated filesystem string presumably in the
-  filesystem")
-
-
 (declare-function realgud:strip         'realgud)
 (declare-function realgud-loc-goto      'realgud-loc)
 (declare-function realgud-get-cmdbuf    'realgud-buffer-helper)
@@ -33,11 +26,17 @@
 (declare-function compilation-find-file 'compile)
 (declare-function realgud-cmdbuf-info-ignore-re-file-list= 
'realgud-buffer-command)
 
+;; (defcustom realgud-file-find-function 'realgud:find-file
 (defcustom realgud-file-find-function 'compilation-find-file
   "Function to call when we can't easily find file"
   :type 'function
   :group 'realgud)
 
+;; (defun realgud:find-file (marker filename directory &rest formats)
+;;   "A wrapper around compilation find-file."
+;;   (let ((compilation-error "source-code file"))
+;;     (compilation-find-file marker filename directory formats)))
+
 (defun realgud:file-line-count(filename)
   "Return the number of lines in file FILENAME, or nil FILENAME can't be
 found"
@@ -85,44 +84,62 @@ blanks, or deliberately ignoring 'pseudo-file patterns like 
(eval
 If we're unable find the source code we return a string describing the
 problem as best as we can determine."
 
-  (unless (and filename (file-readable-p filename))
-    (let* ((cmdbuf (realgud-get-cmdbuf))
-          (ignore-re-file-list (realgud-sget 'cmdbuf-info 
'ignore-re-file-list))
-          (remapped-filename (gethash filename realgud-file-remap))
-          )
-      (cond
-       ;; Is file already listed for ignore?
-       ((realgud:file-ignore filename ignore-re-file-list)
-       (message "tracking ignored for %s" filename))
-
-       ;; Do we want to black-list this?
-       ((y-or-n-p (format "Black-list file %s for location tracking?" 
filename))
-       ;; FIXME: there has to be a simpler way to set ignore-file-list
-       (with-current-buffer cmdbuf
-         (push filename ignore-re-file-list)
-         (realgud-cmdbuf-info-ignore-re-file-list= ignore-re-file-list))
-       (setq filename nil))
-
-       ;; Do we have a custom find-file function?
-       (find-file-fn
-       (setq filename (funcall find-file-fn cmd-marker filename directory)))
-
-       (t (setq filename nil)
-         (if remapped-filename
-             (if (file-exists-p remapped-filename)
-                 (setq filename remapped-filename)
-               ;; else remove from map since no find
-               (remhash filename realgud-file-remap)))
-           ;; else - try find-file-function
-           (let ((found-file (funcall realgud-file-find-function 
(point-marker) filename directory)))
-             (when found-file
-               (setq remapped-filename (buffer-file-name found-file))
-               (when (and remapped-filename (file-exists-p remapped-filename))
-                 (puthash filename remapped-filename realgud-file-remap)
-                 (setq filename remapped-filename)
-                 ))
-             )))
-       ))
+  (let* ((cmdbuf (realgud-get-cmdbuf))
+        (ignore-re-file-list (realgud-cmdbuf-ignore-re-file-list cmdbuf))
+        (filename-remap-alist (realgud-cmdbuf-filename-remap-alist cmdbuf))
+        (remapped-filename
+         (assoc filename filename-remap-alist))
+        (mutex (realgud-cmdbuf-mutex cmdbuf))
+        )
+
+    ;;(with-mutex
+    ;; mutex
+     (when remapped-filename
+       (if (file-readable-p (cdr remapped-filename))
+          (setq filename (cdr remapped-filename))
+        ;; else remove from map since no find
+        (realgud-cmdbuf-filename-remap-alist=
+         (delq (assoc remapped-filename filename-remap-alist)
+                                         filename-remap-alist))))
+
+     (unless (and filename (file-readable-p filename))
+
+       (cond
+       ;; Is file already listed for ignore?
+       ((realgud:file-ignore filename ignore-re-file-list)
+        (message "tracking ignored for %s" filename))
+
+       ;; Do we want to black-list this?
+       ((y-or-n-p (format "Black-list file %s for location tracking?" 
filename))
+        ;; FIXME: there has to be a simpler way to set ignore-file-list
+        (with-current-buffer cmdbuf
+          (push filename ignore-re-file-list)
+          (realgud-cmdbuf-info-ignore-re-file-list= ignore-re-file-list))
+        (setq filename nil)
+        )
+
+       ;; Do we have a custom find-file function?
+       (find-file-fn
+        (setq filename (funcall find-file-fn cmd-marker filename directory)))
+
+       (t
+        (let ((found-file (funcall realgud-file-find-function (point-marker) 
filename directory)))
+          (if found-file
+              (progn
+                (setq remapped-filename (buffer-file-name found-file))
+                (when (and remapped-filename (file-exists-p remapped-filename))
+                  (realgud-cmdbuf-filename-remap-alist=
+                   (cons
+                    (cons filename remapped-filename)
+                    filename-remap-alist))
+                  (setq filename remapped-filename)
+                  ))
+            ;; else
+            (setq filename nil)
+            )))
+       )))
+  ;;)
+
   (if filename
       (if (file-readable-p filename)
          (if (integerp line-number)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]