]> code.delx.au - gnu-emacs-elpa/blob - realgud/debugger/gdb/gdb.el
Merge branch 'master' of github.com:rocky/emacs-dbgr
[gnu-emacs-elpa] / realgud / debugger / gdb / gdb.el
1 ;;; Copyright (C) 2010-2011, 2014 Rocky Bernstein <rocky@gnu.org>
2 ;; `realgud:gdb' Main interface to gdb via Emacs
3 (require 'cl)
4 (require 'list-utils)
5 (require 'load-relative)
6 (require-relative-list '("../../common/helper") "realgud-")
7 (require-relative-list '("core" "track-mode") "realgud:gdb-")
8
9 ;; This is needed, or at least the docstring part of it is needed to
10 ;; get the customization menu to work in Emacs 24.
11 (defgroup realgud:gdb nil
12 "The realgud interface to gdb"
13 :group 'realgud
14 :version "24.1")
15
16 ;; -------------------------------------------------------------------
17 ;; User definable variables
18 ;;
19
20 (defcustom realgud:gdb-command-name
21 ;;"gdb --emacs 3"
22 "gdb"
23 "File name for executing the Ruby debugger and command options.
24 This should be an executable on your path, or an absolute file name."
25 :type 'string
26 :group 'realgud:gdb)
27
28 (declare-function realgud:gdb-track-mode 'realgud:gdb-track-mode)
29 (declare-function realgud-command 'realgud:gdb-core)
30 (declare-function realgud:gdb-parse-cmd-args 'realgud:gdb-core)
31 (declare-function realgud:gdb-query-cmdline 'realgud:gdb-core)
32 (declare-function realgud:run-process 'realgud-core)
33
34 ;; -------------------------------------------------------------------
35 ;; The end.
36 ;;
37
38 ;;;###autoload
39 (defun realgud:gdb (&optional opt-cmd-line no-reset)
40 "Invoke the gdb debugger and start the Emacs user interface.
41
42 OPT-CMD-LINE is treated like a shell string; arguments are
43 tokenized by `split-string-and-unquote'.
44
45 Normally, command buffers are reused when the same debugger is
46 reinvoked inside a command buffer with a similar command. If we
47 discover that the buffer has prior command-buffer information and
48 NO-RESET is nil, then that information which may point into other
49 buffers and source buffers which may contain marks and fringe or
50 marginal icons is reset. See `loc-changes-clear-buffer' to clear
51 fringe and marginal icons.
52 "
53
54 (interactive)
55 (let* ((cmd-str (or opt-cmd-line (realgud:gdb-query-cmdline "gdb")))
56 (cmd-args (split-string-and-unquote cmd-str))
57 (parsed-args (realgud:gdb-parse-cmd-args cmd-args))
58 (script-args (caddr parsed-args))
59 (script-name (car script-args))
60 (parsed-cmd-args
61 (cl-remove-if 'nil (list-utils-flatten parsed-args)))
62 (cmd-buf (realgud:run-process realgud:gdb-command-name
63 script-name parsed-cmd-args
64 'realgud:gdb-track-mode-hook
65 'realgud:gdb-minibuffer-history
66 nil))
67 )
68 (if cmd-buf
69 (with-current-buffer cmd-buf
70 (realgud-command "set annotate 1" nil nil nil)
71 )
72 )
73 )
74 )
75
76 (provide-me "realgud-")
77
78 ;; Local Variables:
79 ;; byte-compile-warnings: (not cl-functions)
80 ;; End: