Function: gdb-send

gdb-send is a byte-compiled function defined in gdb-mi.el.gz.

Signature

(gdb-send PROC STRING)

Documentation

A comint send filter for gdb.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/gdb-mi.el.gz
(defun gdb-send (proc string)
  "A comint send filter for gdb."
  (with-current-buffer gud-comint-buffer
    (let ((inhibit-read-only t))
      (remove-text-properties (point-min) (point-max) '(face nil))))
  ;; mimic <RET> key to repeat previous command in GDB
  (when (= gdb-control-level 0)
    (if (not (string= "" string))
        (if gdb-continuation
            (setq gdb-last-command (concat gdb-continuation
                                           (gdb-strip-string-backslash string)
                                           " "))
          (setq gdb-last-command (gdb-strip-string-backslash string)))
      (if gdb-last-command (setq string gdb-last-command))
      (setq gdb-continuation nil)))
  (if (and (not gdb-continuation)
           (or (string-match "^-" string)
               (> gdb-control-level 0)))
      ;; Either MI command or we are feeding GDB's recursive reading loop.
      (progn
	(setq gdb-first-done-or-error t)
	(process-send-string proc (concat string "\n"))
	(if (and (string-match
                  (concat "^\\("
                          (if (eq system-type 'windows-nt) "\026" "\004")
                          "\\|,q\\|,quit\\|end\\)$")
                  string)
		 (> gdb-control-level 0))
	    (setq gdb-control-level (1- gdb-control-level))))
    ;; CLI command
    (if (string-match "\\\\$" string)
	(setq gdb-continuation
	      (concat gdb-continuation (gdb-strip-string-backslash
					string)
		      " "))
      (setq gdb-first-done-or-error t)
      (let ((to-send (concat "-interpreter-exec console "
                             (gdb-mi-quote (concat gdb-continuation string))
                             "\n")))
        (if gdb-enable-debug
            (push (cons 'mi-send to-send) gdb-debug-log))
        (process-send-string proc to-send))
      (if (and (string-match
                  (concat "^\\("
                          (if (eq system-type 'windows-nt) "\026" "\004")
                          "\\|,q\\|,quit\\|end\\)$")
                  string)
	       (> gdb-control-level 0))
	  (setq gdb-control-level (1- gdb-control-level)))
      (setq gdb-continuation nil)))
  ;; Python and Guile commands that have an argument don't enter the
  ;; recursive reading loop.
  (when (string-match gdb-control-commands-regexp string)
    (let ((python-or-guile-p (match-beginning 1))
          (command-arg (match-string 2 string)))
      (when (or (not python-or-guile-p)
                (null command-arg)
                (zerop (length command-arg)))
        (setq gdb-control-level (1+ gdb-control-level))))))