- 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 &&
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
;;; 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
(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."
(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,
: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:
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)
(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))))
;;;###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.
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:
--- /dev/null
+#!/bin/sh
+echo This Should get selected 3rd
--- /dev/null
+#!/bin/sh
+echo This Should get selected 3rd
(require 'test-simple)
+(require 'load-relative)
(load-file "../realgud/debugger/bashdb/bashdb.el")
(load-file "../realgud/common/core.el")
--- /dev/null
+(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__)))