]> code.delx.au - gnu-emacs-elpa/blob - realgud/debugger/gdb/gdb.el
DRY/fix debugger invocation code. This time, mostly for remake and gdb
[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 'load-relative)
4 (require-relative-list '("../../common/helper") "realgud-")
5 (require-relative-list '("core" "track-mode") "realgud:gdb-")
6
7 ;; This is needed, or at least the docstring part of it is needed to
8 ;; get the customization menu to work in Emacs 23.
9 (defgroup realgud:gdb nil
10 "The dbgr interface to gdb"
11 :group 'processes
12 :group 'realgud
13 :group 'gdb
14 :version "23.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 (require 'list-utils)
39 ;;;###autoload
40 (defun realgud:gdb (&optional opt-cmd-line no-reset)
41 "Invoke the gdb debugger and start the Emacs user interface.
42
43 OPT-CMD-LINE is treated like a shell string; arguments are
44 tokenized by `split-string-and-unquote'.
45
46 Normally, command buffers are reused when the same debugger is
47 reinvoked inside a command buffer with a similar command. If we
48 discover that the buffer has prior command-buffer information and
49 NO-RESET is nil, then that information which may point into other
50 buffers and source buffers which may contain marks and fringe or
51 marginal icons is reset. See `loc-changes-clear-buffer' to clear
52 fringe and marginal icons.
53 "
54
55 (interactive)
56 (let* ((cmd-str (or opt-cmd-line (realgud:gdb-query-cmdline "gdb")))
57 (cmd-args (split-string-and-unquote cmd-str))
58 (parsed-args (realgud:gdb-parse-cmd-args cmd-args))
59 (script-args (caddr parsed-args))
60 (script-name (car script-args))
61 (parsed-cmd-args
62 (remove-if 'nil (list-utils-flatten parsed-args)))
63 (cmd-buf (realgud:run-process realgud:gdb-command-name
64 script-name parsed-cmd-args
65 'realgud:gdb-track-mode-hook nil))
66 )
67 (if cmd-buf
68 (with-current-buffer cmd-buf
69 (realgud-command "set annotate 1" nil nil nil)
70 )
71 )
72 )
73 )
74
75 (provide-me "realgud-")
76
77 ;; Local Variables:
78 ;; byte-compile-warnings: (not cl-functions)
79 ;; End: