]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge branch 'master' of github.com:rocky/emacs-dbgr
authorrocky <rocky@gnu.org>
Wed, 7 Jan 2015 00:44:57 +0000 (19:44 -0500)
committerrocky <rocky@gnu.org>
Wed, 7 Jan 2015 00:46:45 +0000 (19:46 -0500)
Conflicts:
realgud/debugger/kshdb/kshdb.el

16 files changed:
.travis.yml
realgud/common/helper.el
realgud/debugger/gdb/core.el
realgud/debugger/gub/init.el
realgud/debugger/kshdb/core.el
realgud/debugger/kshdb/kshdb.el
test/Makefile.am
test/gdb/bar.sh [new file with mode: 0755]
test/gdb/baz [new file with mode: 0755]
test/gdb/baz.c [new file with mode: 0644]
test/gdb/foo [new file with mode: 0755]
test/gdb/foo.c [new file with mode: 0644]
test/gdb/test2/bar.sh [new file with mode: 0755]
test/gdb/test2/baz.c [new file with mode: 0644]
test/test-bashdb.el
test/test-gdb.el [new file with mode: 0644]

index 4d9630c7d1ad0bb725066f0483b73b89dfc69388..92dafef94d932826ae7a52084a65cd144176b182 100644 (file)
@@ -4,12 +4,6 @@ env:
   - EMACS=emacs24
 
 before_install:
-  - if [ "$EMACS" = 'emacs-snapshot' ]; then
-      sudo add-apt-repository -y ppa:cassou/emacs &&
-      sudo apt-get update -qq &&
-      sudo apt-get install -qq
-          emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot;
-    fi
   - if [ "$EMACS" = 'emacs24' ]; then
       sudo add-apt-repository -y ppa:cassou/emacs &&
       sudo apt-get update -qq &&
@@ -17,10 +11,6 @@ before_install:
           emacs24 emacs24-el emacs24-common-non-dfsg;
     fi
 
-  - sudo add-apt-repository -y ppa:cassou/emacs
-  - sudo apt-get update -qq
-  - sudo apt-get install -qq $EMACS
-
 # run the tests
 script:
   - NO_CHECK_EMACS_PACKAGES=1 /bin/bash ./autogen.sh && cd test && make check-elget
index df96b77c87fedbdda9458417f488fdb2f8653ad7..26054a0ddce033f78dd5c3f2d02c95a1b130d7af 100644 (file)
@@ -1,6 +1,7 @@
 ;;; Copyright (C) 2010, 2014 Rocky Bernstein <rocky@gnu.org>
 ;;; Miscellaneous utility functions
 (require 'load-relative)
+
 (defun fn-p-to-fn?-alias (fn-sym)
   "FN-SYM is assumed to be a symbol which is a function.  If it
 ends in a 'p' or '-p', that suffix is stripped; in either case, a
@@ -23,14 +24,16 @@ function FN-SYM."
 (defun realgud:debugger-name-transform (debugger-name)
   "In some cases we need to prefix a short debugger name, like
 'gdb' with 'realgud:'. This does that."
-  (cond
-   ((equal debugger-name "gdb") "realgud:gdb")
-   ((equal debugger-name "jdb") "realgud:jdb")
-   ((equal debugger-name "tortoise") "gub")
-   ((or (equal debugger-name "trepan.pl")
-       (equal debugger-name "trepanpl"))
-    "realgud:trepanpl")
-   ('t debugger-name)))
+  (let ((debugger-name-short
+        (file-name-sans-extension (file-name-nondirectory debugger-name))))
+    (cond
+     ((equal debugger-name-short "gdb") "realgud:gdb")
+     ((equal debugger-name-short "jdb") "realgud:jdb")
+     ((equal debugger-name-short "tortoise") "gub")
+     ((or (equal debugger-name "trepan.pl")
+         (equal debugger-name-short "trepanpl"))
+      "realgud:trepanpl")
+     ('t debugger-name-short))))
 
 (defun buffer-killed? (buffer)
   "Return t if BUFFER is killed."
index b6b34766f94d8c76eefdaf41403fcf39d5ac621e..98f80ac2e6c719df91dc6763c277c17bd5e097f7 100644 (file)
@@ -123,40 +123,57 @@ Note that path elements have been expanded via `expand-file-name'.
 
 (defvar realgud:gdb-command-name)
 
+(defun realgud:gdb-executable (file-name)
+"Return a priority for wehther file-name is likely we can run gdb on"
+  (let ((output (shell-command-to-string (format "file %s" file-name))))
+    (cond
+     ((string-match "ASCII" output) 2)
+     ((string-match "ELF" output) 7)
+     ((string-match "executable" output) 6)
+     ('t 5))))
+
+
 (defun realgud:gdb-suggest-invocation (&optional debugger-name)
-  "Suggest a gdb command invocation. If the current buffer is a C
-source file and there is an executable with the extension
-stripped, then use the executable name.  Next try to find an
-executable in the default-directory that doesn't have an
-extension Next, try to use the first value of MINIBUFFER-HISTORY
-if that exists. When all else fails return the empty string."
-  (let* ((lang-ext-regexp "\\.\\([ch]\\)\\(pp\\)?")
-        (file-list (directory-files default-directory))
+  "Suggest a gdb command invocation. Here is the priority we use:
+* an executable file with the name of the current buffer stripped of its extension
+* any executable file in the current directory with no extension
+* the last invocation in gdb:minibuffer-history
+* any executable in the current directory
+When all else fails return the empty string."
+  (let* ((file-list (directory-files default-directory))
         (priority 2)
+        (best-filename nil)
         (try-filename (file-name-base (or (buffer-file-name) "gdb"))))
-    (if (member try-filename (directory-files default-directory))
-       (concat "gdb " try-filename)
+    (when (member try-filename (directory-files default-directory))
+       (setq best-filename try-filename)
+       (setq priority (+ (realgud:gdb-executable try-filename) 2)))
+
+    ;; FIXME: I think a better test would be to look for
+    ;; c-mode in the buffer that have a corresponding executable
+    (while (and (setq try-filename (car-safe file-list)) (< priority 8))
+      (setq file-list (cdr file-list))
+      (if (and (file-executable-p try-filename)
+              (not (file-directory-p try-filename)))
+         (if (equal try-filename (file-name-sans-extension try-filename))
+             (progn
+               (setq best-filename try-filename)
+               (setq priority (1+ (realgud:gdb-executable best-filename))))
+           ;; else
+           (progn
+             (setq best-filename try-filename)
+             (setq priority (realgud:gdb-executable best-filename))
+             ))
+       ))
+    (if (< priority 8)
+       (cond
+        (realgud:gdb-minibuffer-history
+         (car realgud:gdb-minibuffer-history))
+        ((equal priority 7)
+         (concat "gdb " best-filename))
+        (t "gdb "))
       ;; else
-      (progn
-       ;; FIXME: I think a better test would be to look for
-       ;; c-mode in the buffer that have a corresponding executable
-       (while (and (setq try-filename (car-safe file-list)) (< priority 8))
-         (setq file-list (cdr file-list))
-         (if (and (file-executable-p try-filename)
-                  (not (file-directory-p try-filename)))
-             (if (equal try-filename (file-name-sans-extension try-filename))
-                 (setq priority 8)
-               (setq priority 7))))
-       )
-      (if (< priority 6)
-         (cond
-          (realgud:gdb-minibuffer-history
-           (car realgud:gdb-minibuffer-history))
-          (t "gdb "))
-       (concat "gdb " try-filename)
-       )
-    )))
-
+      (concat "gdb " best-filename))
+    ))
 
 (defun realgud:gdb-reset ()
   "Gdb cleanup - remove debugger's internal buffers (frame,
index 80345aa0991eb6817c1497e379de78e541b2255b..615b278890e7fe9248f5063b1b55a923c5e8ecda 100644 (file)
@@ -28,6 +28,20 @@ realgud-loc-pat struct")
        :file-group 1
        :line-group 2))
 
+;; Regular expression that describes a Go backtrace line.
+;; For example:
+;; ssa-interp/interp/interp.go:202 (0x506c84)
+;;     visitInstr: *fr.get(instr.Addr).(*Value) = copyVal(fr.get(instr.Val))
+;; sa-interp/interp/interp.go:604 (0x50b5b1)
+;;     runFrame: switch visitInstr(fr, instr) {
+(setf (gethash "lang-backtrace" realgud:gub-pat-hash)
+  (make-realgud-loc-pat
+   :regexp
+   "\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\]*\\.go\\):\\([0-9]+\\)"
+   :file-group 1
+   :line-group 2))
+
+
 ;; Regular expression that describes a gub location generally shown
 ;; before a command prompt.
 ;; For example:
index a374de4a53bddfb64e2376d00e93ec24d1882318..3856b07608b5259082771168d30fdde31ed86d43 100644 (file)
@@ -43,33 +43,34 @@ We return the a list containing
 
 For example for the following input
   (map 'list 'symbol-name
-   '(zsh -W -C /tmp kshdb --emacs ./gcd.rb a b))
+   '(ksh -W -C /tmp kshdb --emacs ./gcd.rb a b))
 
 we might return:
-   ((zsh -W -C) (kshdb --emacs) (./gcd.rb a b) 't)
+   ((ksh -W -C) (kshdb --emacs) (./gcd.rb a b) 't)
 
 NOTE: the above should have each item listed in quotes.
 "
 
   ;; Parse the following kind of pattern:
-  ;;  [zsh zsh-options] kshdb kshdb-options script-name script-options
+  ;;  [ksh ksh-options] kshdb kshdb-options script-name script-options
   (let (
        (args orig-args)
        (pair)          ;; temp return from
-       ;; zsh doesn't have any optional two-arg options
-       (zsh-opt-two-args '())
-       (zsh-two-args '("o" "c"))
+       ;; ksh doesn't have any optional two-arg options
+       (ksh-opt-two-args '())
+       (ksh-two-args '("o" "c"))
 
        ;; One dash is added automatically to the below, so
        ;; h is really -h and -host is really --host.
        (kshdb-two-args '("A" "-annotate" "l" "-library"
+                         "-highlight" "-no-highlight"
                           "c" "-command" "-t" "-tty"
                           "x" "-eval-command"))
        (kshdb-opt-two-args '())
        (interp-regexp
         (if (member system-type (list 'windows-nt 'cygwin 'msdos))
-            "^zsh*\\(.exe\\)?$"
-          "^zsh*$"))
+            "^ksh*\\(.exe\\)?$"
+          "^ksh*$"))
 
        ;; Things returned
        (script-name nil)
@@ -93,7 +94,7 @@ NOTE: the above should have each item listed in quotes.
        (while (and args
                    (string-match "^-" (car args)))
          (setq pair (realgud-parse-command-arg
-                     args zsh-two-args zsh-opt-two-args))
+                     args ksh-two-args ksh-opt-two-args))
          (nconc interpreter-args (car pair))
          (setq args (cadr pair))))
 
index bb35f474cda76ed80e91c540dc670bf1d0c6ae21..9c5763780039a08c4f0ffcb27da24f5b907355f2 100644 (file)
@@ -34,7 +34,7 @@ This should be an executable on your path, or an absolute file name."
 
 ;;;###autoload
 (defun realgud:kshdb (&optional opt-command-line no-reset)
-  "Invoke the kshdb Z-shell debugger and start the Emacs user interface.
+  "Invoke the Korn shell debugger, kshdb, and start the Emacs user interface.
 
 String COMMAND-LINE specifies how to run kshdb.
 
index 94d9d2161661dfe6730c10b0ea3ff992156a88ed..c0e7ededec3eec650d314377a16679b632117b2c 100644 (file)
@@ -1,7 +1,7 @@
 include $(top_srcdir)/common.mk
 
 PHONY=check test all check-elget test-elget help
-EXTRA_DIST += gcd.py gcd.rb
+EXTRA_DIST += gcd.py gcd.rb gdb
 
 #: overall help on running the make targets
 help:
diff --git a/test/gdb/bar.sh b/test/gdb/bar.sh
new file mode 100755 (executable)
index 0000000..6c961d1
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo This Should get selected 3rd
diff --git a/test/gdb/baz b/test/gdb/baz
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/test/gdb/baz.c b/test/gdb/baz.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/gdb/foo b/test/gdb/foo
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/test/gdb/foo.c b/test/gdb/foo.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/gdb/test2/bar.sh b/test/gdb/test2/bar.sh
new file mode 100755 (executable)
index 0000000..6c961d1
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo This Should get selected 3rd
diff --git a/test/gdb/test2/baz.c b/test/gdb/test2/baz.c
new file mode 100644 (file)
index 0000000..e69de29
index fcd6f44d70b6f520d0fb7b11c5253bb8865eb7a1..ba6d11d8046b0c527d4dc1093ed2eedcc10d2ba9 100644 (file)
@@ -1,4 +1,5 @@
 (require 'test-simple)
+(require 'load-relative)
 (load-file "../realgud/debugger/bashdb/bashdb.el")
 (load-file "../realgud/common/core.el")
 
diff --git a/test/test-gdb.el b/test/test-gdb.el
new file mode 100644 (file)
index 0000000..4ee6796
--- /dev/null
@@ -0,0 +1,64 @@
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/gdb/core.el")
+(load-file "./regexp-helper.el")
+
+(eval-when-compile
+  (defvar realgud:gdb-minibuffer-history)
+  (defvar test:realgud-gdb-executable-save)
+  (defvar test:realgud-minibuffer-history-save)
+)
+
+(declare-function realgud:gdb-suggest-invocation 'realgud:bashdb)
+(declare-function __FILE__              'require-relative)
+
+(test-simple-start)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:realgud-gdb-executable-save (symbol-function 'realgud:gdb-executable))
+(setq test:realgud-minibuffer-history-save realgud:gdb-minibuffer-history)
+
+(defun realgud:gdb-executable (filename)
+  "Mock function for testing"
+  (cond ((equal filename "bar.sh") 7)
+       ((equal filename "foo") 8)
+       ((equal filename "baz") 8)
+       (t 3)))
+
+(setq realgud:gdb-minibuffer-history nil)
+
+(note "realgud:gdb-suggest-invocation")
+(let ((my-directory (file-name-directory (__FILE__))))
+  (save-excursion
+    (note "Test preference to buffer editing")
+    (setq default-directory
+         (concat my-directory "gdb"))
+    (find-file-literally "foo.c")
+    (assert-equal "gdb foo" (realgud:gdb-suggest-invocation)
+                 "Should find file sans extension - foo")
+    (find-file-literally "baz.c")
+    (assert-equal "gdb baz" (realgud:gdb-suggest-invocation)
+                 "Should find file sans extension - baz")
+    )
+  (save-excursion
+    (note "Pick up non-sans executable")
+    (setq default-directory
+       (concat my-directory  "gdb/test2"))
+    (assert-equal "gdb bar.sh" (realgud:gdb-suggest-invocation))
+    (setq realgud:gdb-minibuffer-history '("gdb testing"))
+    (setq default-directory
+       (concat my-directory  "gdb/test2"))
+    (assert-equal "gdb testing" (realgud:gdb-suggest-invocation)
+                 "After setting minibuffer history - takes precidence")
+    )
+  (setq default-directory my-directory)
+)
+
+(end-tests)
+
+;; Restore the old values.
+;; You might have to run the below if you run this interactively.
+(fset 'realgud:gdb-executable test:realgud-gdb-executable-save)
+(setq realgud:gdb-minibuffer-history test:realgud-minibuffer-history-save)
+(setq default-directory (file-name-directory (__FILE__)))