[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patched `gud-common-init' for "libtool gdb ./program"
From: |
Kalle Olavi Niemitalo |
Subject: |
patched `gud-common-init' for "libtool gdb ./program" |
Date: |
14 Mar 2001 11:25:24 +0200 |
;;; kon-gud-cus.el --- my Grand Unified Debugger customizations
;; Copyright (C) 1992, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.
;; Copyright (C) 2001 by Kalle Olavi Niemitalo
;; Author: Eric S. Raymond <address@hidden>
;; Maintainer: Kalle Olavi Niemitalo <address@hidden>
;; Keywords: local, unix, tools
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; GUD was originally written by Eric S. Raymond. This file contains
;; a modified version of `gud-common-init', made by Kalle Olavi
;; Niemitalo on 2001-03-10.
;; When libtool links a program in a build directory, it stores the
;; actual binary in a subdirectory and generates a script which sets
;; up environment variables and executes the binary. Such programs
;; cannot be debugged directly with gdb; one must instead run "libtool
;; gdb program". That clashes with GUD, which expects the name of the
;; debuggee to be the second non-option word on the command line. The
;; purpose of this file then, is to adapt GUD to the reality.
;;; Code:
;; Load the original version of `gud-common-init', then redefine it.
;; The correction cannot easily be done with defadvice.
(require 'gud)
(eval-when-compile (require 'cl))
(defun gud-common-init (command-line massage-args marker-filter find-file)
(let* ((words (gud-chop-words command-line))
;; If the debugger must be run via libtool, move the libtool
;; command and options to this list and add them back later.
(libtool-and-options
(if (string-match "libtool" (car words))
(loop collect (pop words)
while (and words (= ?- (aref (car words) 0))))))
(debugger (car words))
;; Extract the file name from WORDS
;; and put t in its place.
;; Later on we will put the modified file name arg back there.
(file-word (let ((w (cdr words)))
(while (and w (= ?- (aref (car w) 0)))
(setq w (cdr w)))
(and w
(prog1 (car w)
(setcar w t)))))
(file-subst
(and file-word (substitute-in-file-name file-word)))
(args (cdr words))
;; If a directory was specified, expand the file name.
;; Otherwise, don't expand it, so GDB can use the PATH.
;; A file name without directory is literally valid
;; only if the file exists in ., and in that case,
;; omitting the expansion here has no visible effect.
(file (and file-word
(if (file-name-directory file-subst)
(expand-file-name file-subst)
file-subst)))
(filepart (and file-word (concat "-" (file-name-nondirectory file)))))
(pop-to-buffer (concat "*gud" filepart "*"))
;; Set default-directory to the file's directory.
(and file-word
;; Don't set default-directory if no directory was specified.
;; In that case, either the file is found in the current directory,
;; in which case this setq is a no-op,
;; or it is found by searching PATH,
;; in which case we don't know what directory it was found in.
(file-name-directory file)
(setq default-directory (file-name-directory file)))
(or (bolp) (newline))
(insert "Current directory is " default-directory "\n")
;; Put the substituted and expanded file name back in its place.
(let ((w args))
(while (and w (not (eq (car w) t)))
(setq w (cdr w)))
(if w
(setcar w file)))
(let ((debugger-and-args (nconc libtool-and-options (list debugger)
(funcall massage-args file args))))
(apply 'make-comint (concat "gud" filepart) (car debugger-and-args) nil
(cdr debugger-and-args))))
;; Since comint clobbered the mode, we don't set it until now.
(gud-mode)
(make-local-variable 'gud-marker-filter)
(setq gud-marker-filter marker-filter)
(make-local-variable 'gud-find-file)
(setq gud-find-file find-file)
(set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
(set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel)
(gud-set-buffer)
)
(provide 'kon-gud-cus)
;;; kon-gud-cus.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- patched `gud-common-init' for "libtool gdb ./program",
Kalle Olavi Niemitalo <=