🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99201

Strange behavior using gdb.el

#99201
From: Thomas A Peterson
Date: Wed, 17 Oct 1990 22:03
69 lines
3414 bytes
When using the gdb mode within Emacs there is some strange behavior
with respect to the starting buffer. When I start gdb I am normally in
a shell buffer. I do M-x gdb and provide the filename which is usually
not in the current directory. The gdb buffer comes up fine and it
thinks that its default-directory is where the file is. Everything is
fine and dandy except that the shell buffer from where I was
previously residing now also thinks that its default-directory is
where the file is.

I did some modification to the gdb defun so that it would do what I
expected. Since I am not even an Elisp novice there may be problems
with it, but so far it has been working fine for me.

Enjoy, Tom


From gdb.el from Emacs 18.55
----------------------------
;; Run gdb under Emacs
;; Author: W. Schelter, University of Texas
;;     wfs@rascal.ics.utexas.edu
;; Rewritten by rms.

;; Some ideas are due to  Masanobu. 

;; This file is part of GNU Emacs.
;; Copyright (C) 1988 Free Software Foundation, Inc.

(defun gdb (path)
  "Run gdb on program FILE in buffer *gdb-FILE*.
The directory containing FILE becomes the initial working directory
and source-file directory for GDB.  If you wish to change this, use
the GDB commands `cd DIR' and `directory'."
  (interactive "FRun gdb on file: ")
  (setq path (expand-file-name path))
  (let ((file (file-name-nondirectory path)))
    (switch-to-buffer (concat "*gdb-" file "*"))
    (setq default-directory (file-name-directory path))
    (or (bolp) (newline))
    (insert "Current directory is " default-directory "\n")
    (make-shell (concat "gdb-" file) gdb-command-name nil "-fullname"
		"-cd" default-directory file)
    (gdb-mode)
    (set-process-filter (get-buffer-process (current-buffer)) 'gdb-filter)
    (set-process-sentinel (get-buffer-process (current-buffer)) 'gdb-sentinel)
    (gdb-set-buffer)))



My Version
----------
(defun gdb (path)
  "Run gdb on program FILE in buffer *gdb-FILE*.
The directory containing FILE becomes the initial working directory
and source-file directory for GDB.  If you wish to change this, use
the GDB commands `cd DIR' and `directory'."
  (interactive "FRun gdb on file: ")
  (setq path (expand-file-name path))
  (let ((file (file-name-nondirectory path))
	(directory (file-name-directory path)))
    (make-shell (concat "gdb-" file) gdb-command-name nil "-fullname"
		"-cd" directory file)
    (switch-to-buffer (concat "*gdb-" file "*"))
    (setq default-directory directory)
    (message "Current directory is %s" directory)
    (gdb-mode)
    (set-process-filter (get-buffer-process (current-buffer)) 'gdb-filter)
    (set-process-sentinel (get-buffer-process (current-buffer)) 'gdb-sentinel)
    (gdb-set-buffer)))
Technical Details
Message-ID: <9010172203.AA08013@beethoven.src.honeywell.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!SRC.HONEYWELL.COM!tap

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,d4819ba50c70d9a,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-10-17 15:03:18 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!SRC.HONEYWELL.COM!tap
From: tap@SRC.HONEYWELL.COM (Thomas A Peterson)
Newsgroups: gnu.emacs.bug
Subject: Strange behavior using gdb.el
Message-ID: <9010172203.AA08013@beethoven.src.honeywell.com>
Date: 17 Oct 90 22:03:18 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: Gnus Not Usenet
Lines: 69
Approved: bug-gnu-emacs@prep.ai.mit.edu
Posted: Wed Oct 17 23:03:18 1990