From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Camm Maguire <camm@debian.org>
Date: Nov, 25 2026 17:10:36 +0000
Subject: [PATCH] <short summary of the patch>

TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.

---
The information above should follow the Patch Tagging Guidelines,
see https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-<Vendor>: <vendor-bugtracker-url>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>

--- gcl27-2.7.1.orig/Makefile.am
+++ gcl27-2.7.1/Makefile.am
@@ -327,7 +327,12 @@ unixport/lib%.a: | xbin/ar_merge
 
 %/recompile: | unixport/%
 	$| -batch \
-	   -eval "(let ((si::*do-recomp-output-dir* \"$(@D)\")) (si::do-recomp t))" \
+	   -eval "(si::do-recomp \
+			(lambda (x) \
+                           (list :system-p t :c-file t :h-file t :data-file t \
+				 :output-file (merge-pathnames \
+					        (make-pathname :type \"o\" :name (pathname-name x)) \
+						\"$(@D)/\"))))" \
 	   -eval "(mapc (quote delete-file) (directory \"$(@D)/*.hsh\"))" \
 	   -eval "(compiler::dump-inl-hash \"$(@D)/all.hsh\" t)"
 	touch $@
--- gcl27-2.7.1.orig/Makefile.in
+++ gcl27-2.7.1/Makefile.in
@@ -4660,7 +4660,12 @@ unixport/lib%.a: | xbin/ar_merge
 
 %/recompile: | unixport/%
 	$| -batch \
-	   -eval "(let ((si::*do-recomp-output-dir* \"$(@D)\")) (si::do-recomp t))" \
+	   -eval "(si::do-recomp \
+			(lambda (x) \
+                           (list :system-p t :c-file t :h-file t :data-file t \
+				 :output-file (merge-pathnames \
+					        (make-pathname :type \"o\" :name (pathname-name x)) \
+						\"$(@D)/\"))))" \
 	   -eval "(mapc (quote delete-file) (directory \"$(@D)/*.hsh\"))" \
 	   -eval "(compiler::dump-inl-hash \"$(@D)/all.hsh\" t)"
 	touch $@
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpeval.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpeval.lsp
@@ -880,16 +880,17 @@
 		`(merge-inls
 		  ',x
 		  (list
-		   ,@(mapcar (lambda (z)
-			       `(list (mapcar 'uniq-tp ',(mapcar 'export-type (pop z)))
-				      ',(pop z) ',(pop z) ',(pop z)
-				      (cons ',(caar z) (uniq-tp ',(cdar z)))
-				      (list ,@(mapcan
-					       (lambda (x)
-						 `((list ',(pop x) ',(pop x) ',(mapcar 'export-type (car x)))))
-					       (sort (cadr z) '< :key (lambda (x) (hash-equal x -5)))))
-				      ,(caddr z)))
-			     (sort (car y) '< :key (lambda (x) (hash-equal x -5))))))
+		   ,@(flet ((srt (x) (sort (copy-list x) '< :key (lambda (x) (hash-equal x -5)))))
+		       (mapcar (lambda (z)
+				 `(list (mapcar 'uniq-tp ',(mapcar 'export-type (pop z)))
+					',(pop z) ',(pop z) ',(pop z)
+					(cons ',(caar z) (uniq-tp ',(export-type (cdar z))))
+					(list ,@(mapcan
+						 (lambda (x)
+						   `((list ',(pop x) ',(pop x) ',(mapcar 'export-type (car x)))))
+						 (srt (cadr z))))
+					,(caddr z)))
+			       (srt (car y))))))
 		s)
 	       (terpri s))
 	  (let (r)
@@ -1692,10 +1693,10 @@
 
 
 (defun mod-env (e l)
-  (setq *lexical-env-mask* (nconc (remove-if (lambda (x) (or (symbolp x) (is-fun-var x))) (ldiff l e)) *lexical-env-mask*));FIXME
-  l)
-
-
+  (labels ((ft (e) (if (tailp e l) e (ft (cdr e)))))
+    (let ((te (ft e)))
+      (setq *lexical-env-mask* (nconc (remove-if (lambda (x) (or (symbolp x) (is-fun-var x))) (ldiff l te)) *lexical-env-mask*));FIXME
+      (nconc (ldiff e te) l))))
 
 (defvar *lexical-env-mask* nil)
 
--- gcl27-2.7.1.orig/cmpnew/gcl_cmplet.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmplet.lsp
@@ -148,7 +148,7 @@
     (unless star (mapc (lambda (x) (push-var (car x) (cdr x))) vs))
 
     (when (member-if-not 'identity forms :key (lambda (x) (info-type (cadr x))))
-      (eliminate-src body)
+      (eliminate-src (cons 'progn body))
       (setq body nil))
 
     (c1add-globals (set-difference ss vnames))
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpmain.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpmain.lsp
@@ -398,10 +398,10 @@ Cannot compile ~a.~%" (namestring (merge
 (defun fun-env (name)
   (let ((fun (when (fboundp name) (or (macro-function name) (symbol-function name)))))
     (multiple-value-bind
-	    (src clo blk)
-	    (function-lambda-expression fun)
-	    (declare (ignore src blk))
-	    (mapcar 'cadr clo))))
+	  (src clo blk)
+	(function-lambda-expression fun)
+      (declare (ignore src blk))
+      (mapcar 'cadr (car clo)))))
 
     ;; (cond ((si::interpreted-function-p fun) 
     ;; 	   (multiple-value-bind
@@ -424,7 +424,7 @@ Cannot compile ~a.~%" (namestring (merge
        (let ((form `(,(if mac 'defmacro 'defun) ,(if mac (cons 'macro na) na) ,(cadr lam) ,@(cddr lam))))
 	 (values
 	  (if clo
-	      `(let* ((e (fun-env ',name)) ,@(mapcar (lambda (x) `(,(car x) (pop e))) clo))
+	      `(let* ((e (fun-env ',name)) ,@(mapcar (lambda (x) `(,(car x) (pop e))) (car clo)))
 		 ,form)
 	    form)
 	  na))))))
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpmulti.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpmulti.lsp
@@ -259,7 +259,7 @@
 
   (unless (let ((x (info-type (cadr init-form))))
 	    (if (cmpt x) (not (member nil x)) x))
-    (eliminate-src body)
+    (eliminate-src (cons 'progn body))
     (return-from c1multiple-value-bind init-form))
 
   (when (single-type-p (info-type (cadr init-form)))
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpspecial.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpspecial.lsp
@@ -142,7 +142,7 @@
 	 (args  (pop l))
 	 (w   (make-string-output-stream))
 	 (out (pd fname args l))
-	 (out (if y `(lambda-closure ,y nil nil ,@(cdr out)) out)))
+	 (out (if (member-if 'identity y) `(lambda-closure ,(pop y) ,(pop y) ,(pop y) ,@(cdr out)) out)))
     (if *compiler-compile* out
 	(let ((ss  (si::open-fasd w :output nil nil)))
 	  (si::find-sharing-top out (aref ss 1))
@@ -209,11 +209,19 @@
 	       (setf (info-flags info) (logior (info-flags info) (iflags provisional))))
 	     `(function ,info ,fd))))))
 
-(defun update-closure-indices (cl)
-  (mapc (lambda (x &aux (y (var-ref-ccb (car x))))
+(defun update-closure-indices (cl &aux (env (second (third cl))))
+  (mapc (lambda (x &aux (c (car x)) (y (var-ref-ccb c)))
 	  (setf (cadr x) (if (integerp y) (- y *initial-ccb-vs*) (baboon))
-		(car x) (var-name (car x))))
-	(second (third cl)))
+		(car x) (var-name c)))
+	(car env))
+  (mapc (lambda (x &aux (c (car x)) (y (fun-ref-ccb c)))
+	  (setf (caddr x) (if (integerp y) (- y *initial-ccb-vs*) (baboon))
+		(car x) (fun-name c)))
+	(cadr env))
+  (mapc (lambda (x &aux (c (car x)) (y (if (blk-p c) (blk-ref-ccb c) (tag-ref-ccb c))))
+	  (setf (caddr x) (if (integerp y) (- y *initial-ccb-vs*) (baboon))
+		(car x) (if (blk-p c) (blk-name c) (tag-name c))))
+	(caddr env))
   cl)
 
 
--- gcl27-2.7.1.orig/cmpnew/gcl_cmptop.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmptop.lsp
@@ -903,10 +903,11 @@
 	  (l))))
 
 
-(defun get-clv (l &aux (i (cadr l)))
-  (mapcan
-   (lambda (v) (when (var-p v) (list (list v nil))))
-   (append (info-ref-ccb i) (info-ref-clb i))))
+(defun get-clv (l &aux (i (cadr l))(obs (append (info-ref-ccb i) (info-ref-clb i))))
+  (list
+   (mapcan (lambda (v) (when (var-p v) `((,v nil)))) obs)
+   (mapcan (lambda (v) (when (fun-p v) `((,v function nil)))) obs)
+   (mapcan (lambda (v) (when (or (blk-p v) (tag-p v)) `((,v ,(if (blk-p v) 'block 'tag) nil)))) obs)))
 
 (defvar *top-tag* nil)
 
--- gcl27-2.7.1.orig/elisp/gcl.el
+++ gcl27-2.7.1/elisp/gcl.el
@@ -15,31 +15,108 @@
 ;;        using this prompt and this beginning.   Useful in shell, in lisp, in gdb,...
 
 
-(setq lisp-mode-hook  'remote-lisp)
+(require 'shell)
+(require 'gud)
+(require 'gdb-mi)
+(require 'cl-lib)
+(require 'inf-lisp)
+
+(defgroup gcl nil
+  "Customization group for GNU Common Lisp (GCL) development environment."
+  :group 'lisp
+  :prefix "gcl-")
+
+(defcustom gcl-dirs nil
+  "List of directories searched to locate the GCL executable files.
+Each directory string should include the trailing slash."
+  :type '(repeat directory)
+  :group 'gcl)
+
+;;;###autoload
+(define-derived-mode gcl-mode lisp-mode "GCL Source"
+  "Major mode for editing GNU Common Lisp source files."
+  (setq-local lisp-package nil)
+  (setq-local lisp-mode-hook nil)
+
+  (local-set-key (kbd "C-M-x")   'gcl-eval-defun)
+  (local-set-key (kbd "C-c C-r") 'gcl-eval-region)
+  (local-set-key (kbd "C-c C-l") 'gcl-load-file)
+  (local-set-key (kbd "C-c C-b") 'gcl-break))
+
+(defun gcl-make-overlay-mode-map nil
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "SPC") 'gcl-step)  ; Space bar steps into forms
+    (define-key map (kbd "n")   'gcl-next)  ; 'n' skips functions
+    (define-key map (kbd "e")   'lisp-eval-last-sexp)
+    (define-key map (kbd "v")   'gcl-env)
+    (define-key map (kbd "m")   'gcl-form)
+    (define-key map (kbd "f")   'gcl-finish)
+    (define-key map (kbd "c")   'gcl-r)
+    (define-key map (kbd "t")   'gcl-bt)
+    (define-key map (kbd "l")   'gcl-bl)
+    (define-key map (kbd "u")   'gcl-up)
+    (define-key map (kbd "d")   'gcl-down)
+    (define-key map (kbd "r")   'gcl-refresh-layout)
+    (define-key map (kbd "q")   'gcl-source-overlay-mode-quit) ; Turn off overlays
+    map))
+
+(defvar gcl-source-overlay-mode-map
+  (gcl-make-overlay-mode-map)
+  "Keymap active when the GCL debugger has focus inside a source buffer file.")
+
+(define-minor-mode gcl-source-overlay-mode
+  "Minor mode overlaying single-stroke GCL debugging keys in source buffers."
+  :init-value nil
+  :lighter " GCL-Debug"
+  :keymap gcl-source-overlay-mode-map
+  (read-only-mode (if gcl-source-overlay-mode 1 -1)))
+
+;; Local functions
+
+(defun gcl-substitute-% (command n)
+  (let* (result	(file-line (gcl-find-line)))
+    (while (and command (string-match "\\([^%]*\\)%\\([adeflp]\\)" command))
+      (setq result (concat result
+			   (substring command (match-beginning 1) (match-end 1))
+			   (cl-case (string-to-char (substring command (match-beginning 2)))
+				 (?p (if n (int-to-string n) ""))
+				 (?f (or (car file-line) "unknown-file"))
+				 (?l (if (cadr file-line) (int-to-string (cadr file-line)) "unknown-line")))))
+      (setq command (substring command (match-end 2))))
+    (concat result command)))
 
-(autoload 'lisp-complete "lisp-complete" nil t)
-(autoload 'smart-complete "smart-complete" nil t)
-
-;(global-set-key "p" 'lisp-complete)
-(global-set-key "p" 'smart-complete)
-
-(defun remote-lisp (&rest l)
-  (and (boundp 'lisp-mode-map)
-       lisp-mode-map
-       (progn
-  (define-key lisp-mode-map "\e\C-d" 'lisp-send-disassemble)
-  (define-key lisp-mode-map "\e\C-x" 'lisp-send-defun-compile)
-  (make-local-variable 'lisp-package)
-  (setq lisp-package nil)
-  (and (boundp 'remote-lisp-hook) (funcall remote-lisp-hook))
-  )))
-
-
-(defvar search-back-for-lisp-package-p nil)
-
-;; look at the beginning of buffer to try to find an in package statement
-(defun get-buffer-package ()
+(defun gcl-call (command &optional numeric)
+  "Invoke gcl COMMAND displaying source in inferior-lisp-buffer."
+  (interactive)
+  (save-excursion
+    (goto-char (point-max))
+    (process-send-string (get-buffer-process inferior-lisp-buffer)
+			 (concat (gcl-substitute-% command numeric) "\n"))))
+
+(defmacro def-gcl (name &optional doc def)
+  (let ((fun (intern (format "gcl-%s" (cadr (split-string (car (split-string name " ")) ":")))))
+	(argp (string-match-p "%" name)))
+    `(defun ,fun (,@(when argp `(&optional arg)))
+       ,(or doc "")
+       (interactive ,@(when argp `("P")))
+       (apply 'gcl-call ,name
+	      ,(when argp
+		  `(when (or arg ,def)
+		      (list (if arg (prefix-numeric-value arg) ,def))))))))
+
+(def-gcl ":finish %p" "Finish current function")
+(def-gcl ":next %p"   "Step one source line (skip functions)")
+(def-gcl ":step %p"   "Step one source line with display")
+(def-gcl ":up %p"     "Step one source line with display")
+(def-gcl ":down %p"   "Step one source line with display")
+(def-gcl ":bt %p"     "Stack trace")
+(def-gcl ":bl"        "Locals")
+(def-gcl ":r"         "Continue")
+(def-gcl ":env"       "Environment")
+(def-gcl ":form %p"   "Invoking form for frame")
+(def-gcl ":q"         "Quit")
 
+(defun gcl-get-buffer-package ()
   "Returns what it thinks is the lisp package for the current buffer.
 It caches this information in the local variable `lisp-package'.  It
 obtains the information from searching for the first in-package from
@@ -51,133 +128,14 @@ in the tmp-lisp-file, used for sending f
 lisp-process."
 
   (cond ((eq lisp-package t) nil)
-	(search-back-for-lisp-package-p
-	 (save-excursion
+	((save-excursion
 	   (cond ((re-search-backward "^[ \t]*(in-package "  nil t)
 		  (goto-char (match-end 0))
-		  (read (current-buffer))))))
-	(lisp-package lisp-package)
-	(t
-	 (setq
-	  lisp-package
-	  (let (found success)
-	    (save-excursion
-	      (goto-char (point-min))
-	      (while (not found)
-		(if (and (setq success (search-forward "(in-package " 1000 t))
-			 (not (save-excursion
-				(beginning-of-line)
-				(looking-at "[ \t]*;"))))
-		    (setq found  (read (current-buffer))))
-		(if (>= (point) 980) (setq found t))
-		(or success (setq found t))
-		))
-	    found)))))
-
-
-(defun run (arg)
-  "Run an inferior Lisp process, input and output via buffer *lisp*."
-  (interactive "sEnter name of file to run: ")
-  (require 'sshell)
-  ;; in emacs 19 uncomment:
-  ;;(require 'inf-lisp)
-  (setq lisp-mode-hook 'remote-lisp)
-  (switch-to-buffer  (make-sshell (concat arg "-lisp") arg nil "-i"))
-  (make-local-variable 'shell-prompt-pattern)
-    (setq sshell-prompt-pattern "^[^#%)>]*[#%)>]+ *")
-    (cond ((or (string-match "maxima" arg) (string-match "affine" arg)
-	   (save-excursion     (sleep-for 2)
-			       (re-search-backward "maxima"
-						   (max 1 (- (point) 300))
-						   t)))
-	   (require 'maxima-mode)
-	   (inferior-maxima-mode)
-	   (goto-char (point-max))
-	   )
-	  (t
-	   (if (boundp 'inferior-lisp-mode)
-	       (inferior-lisp-mode)
-	     (funcall lisp-mode-hook))
-	      )))
-
-(defun lisp-send-disassemble (arg)
-  (interactive "P")
-   (if  arg 
-       ( lisp-send-defun-compile "disassemble-h")
-            ( lisp-send-defun-compile "disassemble"))
-     )
-
-(defvar time-to-throw-away nil)
-(defvar telnet-new-line "")
-
-(defun lisp-send-defun-compile (arg)
-
-  "Send the current defun (or other form) to the lisp-process.  If there
-is a numeric arg, the form (compile function-name) is also sent.  The
-value of lisp-process will be the process of the other exposed window (if
-there is one) or else the global value of lisp-process.  If the
-...received message is not received, probably either the reading of
-the form caused an error.   If the process does not have telnet in
-its name, then we write a tmp file and load it.
-If :sdebug is in *features*, then si::nload is used instead of
-ordinary load, in order to record line information for debugging.
-
-The value of `lisp-package' if non nil, will be used in putting an
-in-package statement at the front of the tmp file to be loaded.
-`lisp-package' is determined automatically on a per file basis,
-by get-buffer-package.
-"
-
-  (interactive "P")
-  (other-window 1)
-  (let* ((proc (or (get-buffer-process (current-buffer)) lisp-process))
-	 def beg
-	 (this-lisp-process proc)
-	 (lisp-buffer (process-buffer this-lisp-process))
-	 fun)
-    (other-window 1)
-    (save-excursion
-      (end-of-defun)
-      (let ((end (dot)) (buffer (current-buffer))
-	    (proc (get-process this-lisp-process)))
-	(setq lisp-process proc)
-	(beginning-of-defun)
-	(save-excursion
-	  (cond ((and arg (looking-at "(def")) (setq def t))
-		(t (setq arg nil)))
-	  (cond (def (forward-char 2)(forward-sexp 1)
-		     (setq fun (read buffer))
-		     (setq fun (prin1-to-string fun))
-		     (message (format
-			       "For the lisp-process %s: %s"
-			       (prin1-to-string this-lisp-process) fun)))))
-	(cond ((equal (char-after (1- end)) ?\n)
-	       (setq end (1- end)) ))
-	(setq beg (dot))
-	(my-send-region this-lisp-process beg end)
-	))
-    
-
-    (send-string this-lisp-process
-		 (concat ";;end of form" "\n" telnet-new-line))
-    (cond (arg
-	   (if (numberp arg) (setq arg "compile"))
-	   (send-string this-lisp-process (concat "(" arg "'" fun ")"
-						  telnet-new-line))))
-    (and time-to-throw-away
-	 (string-match "telnet"(buffer-name (process-buffer proc)))
-	 (dump-output proc time-to-throw-away))
-    (cond (nil  ;(get-buffer-window lisp-buffer)
-		  (select-window (get-buffer-window lisp-buffer))
-		  (goto-char (point-max)))
-	  (t nil))))
-
-(fset 'lisp-eval-defun (symbol-function 'lisp-send-defun-compile))
+		  (setq lisp-package (read (current-buffer)))))))
+	(lisp-package lisp-package)))
 
-(defvar telnet-new-line "")
-(defvar tmp-lisp-file (concat "/tmp/" (user-login-name) ".lsp"))
 
-(defun get-buffer-clear (name)
+(defun gcl-get-buffer-clear (name)
   (let ((cb (current-buffer))
 	(buf (get-buffer-create name)))
     (set-buffer buf)
@@ -185,191 +143,309 @@ by get-buffer-package.
     (set-buffer cb)
     buf))
 
-(defmacro my-with-output-to-temp-buffer  (name &rest body)
-  (append (list
-	   'let
-	   (list (list 'standard-output (list 'get-buffer-clear name))))
-	   body))
-	      
-
-(defun my-send-region (proc beg end)
-  (cond ((or (string-match "telnet" (process-name proc)))
-	 (send-region proc beg end))
-	(t
-	 (let ((package (get-buffer-package)))
-	   (save-excursion
-	       (my-with-output-to-temp-buffer  "*tmp-gcl*"
-		 (if (and package (not (eq package t)))
-		     (prin1 (list 'in-package  package)))
-		 (princ ";!(:line ")
-		 (prin1
-		   (let ((na (buffer-file-name (current-buffer))))
-		     (if na (expand-file-name na)
-		       (buffer-name (current-buffer))))
-		   )
-		 (princ (- (count-lines (point-min) (+ beg 5)) 1))
-		 (princ ")\n")
-		 (set-buffer "*tmp-gcl*")
-		 (write-region (point-min) (point-max) tmp-lisp-file nil nil)))
-	   (write-region beg end tmp-lisp-file t nil)
-	   (message "sending ..")
-	   (send-string
-	    proc
-	    (concat "(lisp::let ((*load-verbose* nil)) (#+sdebug si::nload #-sdebug load \""
-		    tmp-lisp-file
-		    "\")#+gcl(setq si::*no-prompt* t)(values))\n  ")
-			)
-	   (message (format "PACKAGE: %s ..done"
-			    (if (or (not package) (eq package t))
-				"none"
-			      package)))
-
-
-	   ))))
-
-(defun dump-output (proc seconds)
-  "dump output for PROCESS for SECONDS or to \";;end of form\""
- (let ((prev-filter (process-filter proc)) (already-waited 0))
-       (unwind-protect (progn (set-process-filter proc 'dump-filter)
-			      (while (< already-waited seconds)
-			      (sleep-for 1)(setq already-waited
-						 (1+ already-waited))))
-	 (set-process-filter proc prev-filter))))
-
-
-
-(defun dump-filter (proc string)
-;  (setq she (cons string she))
-  (let ((ind (string-match ";;end of form" string)))
-    (cond (ind (setq string (substring
-			     string
-			     (+ ind (length
-				     ";;end of form"))))
-
-	       (message "... received.")
-	       (setq already-waited 1000)
-	       (set-process-filter proc prev-filter)
-	       (cond (prev-filter (funcall prev-filter proc string))
-		     (t string)))
-	  (t ""))))
-
-
-;;(process-filter (get-process "lisp"))
-(defun macroexpand-next ()
-  "macroexpand current form"
-  (interactive)
-  (save-excursion
-    (let ((beg (point)))
-      (forward-sexp )
-      (message "sending macro")
-
-      (let* ((current-lisp-process
-	      (or (get-buffer-process (current-buffer))
-		       (prog2 (other-window 1)
-			      (get-buffer-process (current-buffer))
-			      (other-window 1)))))
-	(send-string current-lisp-process "(macroexpand '")
-	(send-region current-lisp-process  beg (point) )
-	(send-string current-lisp-process ")\n")))))
-
-(defun delete-comment-char (arg) 
-  (while (and (> arg 0) (looking-at comment-start)) (delete-char 1) 
-	 (setq arg (1- arg))))
+(defun gcl-my-send-region (proc beg end &optional arg)
+  (if (string-match "telnet" (process-name proc))
+      (send-region proc beg end)
+    (let* ((package (gcl-get-buffer-package))
+	   (src-buf (current-buffer))
+	   (src-name (let ((na (buffer-file-name src-buf)))
+                       (if na (expand-file-name na) (buffer-name src-buf))))
+	   (src-line (- (count-lines (point-min) (+ beg 5)) 1))
+	   (tmp-file (make-temp-file "gcl-" nil ".lsp")))
+      (with-current-buffer (gcl-get-buffer-clear "*tmp-gcl*")
+	(when package
+	  (unless (eq package t)
+	    (prin1 (list 'in-package package) (current-buffer))))
+	(insert (format ";!(:line %S %d)\n" src-name src-line))
+	(insert-buffer-substring src-buf beg end)
+	(insert "\n")
+	(write-region (point-min) (point-max) tmp-file nil 'nomsg))
+      (message "sending ..")
+      (let ((str (concat "(lisp::let ((*load-verbose* nil)) ("
+			 (if arg "#+sdebug si::nload #-sdebug " "")
+			 "load \""
+			 tmp-file
+			 "\")(values))\n  ")))
+	(process-send-string proc str))
+      (message (format "PACKAGE: %s ..done" (if (unless (eq package t) package) package "none"))))))
+
+(defun gcl-eval-defun (&optional arg &aux proc)
+  "Evaluate the current top-level form.
+Plain execution evaluates the form natively.
+Passing a universal prefix argument (C-u) routes execution through
+`si::nload' to arm the line-tracking debugger."
+  (interactive "P")
+  (if (when (and (boundp 'inferior-lisp-buffer) inferior-lisp-buffer)
+	  (setq proc (get-buffer-process inferior-lisp-buffer))
+	  (and proc (eq (process-status proc) 'run)))
+      (let ((beg (save-excursion (beginning-of-defun) (point)))
+            (end (save-excursion (end-of-defun) (point))))
+        (gcl-my-send-region proc beg end arg))
+    (message "No active GCL process available for evaluation.")))
+
+(defun gcl-eval-region (start end &optional arg &aux proc)
+  "Evaluate the current region.
+Plain execution evaluates the form natively.
+Passing a universal prefix argument (C-u) routes execution through
+`si::nload' to arm the line-tracking debugger."
+ (interactive "r\nP")
+  (if (when (and (boundp 'inferior-lisp-buffer) inferior-lisp-buffer)
+	  (setq proc (get-buffer-process inferior-lisp-buffer))
+	  (and proc (eq (process-status proc) 'run)))
+      (gcl-my-send-region proc start end arg)
+    (message "No active GCL process available for evaluation.")))
+
+(defun gcl-load-file (file &optional instrument)
+  "Load Lisp FILE into the active inferior Lisp process.
+Plain execution (C-c C-l) loads the file normally.
+Passing a universal prefix argument (C-u C-c C-l) overrides the load string
+dynamically to channel the entire file through `si::nload' for line-tracking."
+  (interactive
+   (list (let ((def (buffer-file-name)))
+	   (read-file-name (format "Load Lisp file (%s): " def) nil def t))
+         current-prefix-arg))
+
+  (let ((inferior-lisp-load-command
+         (if instrument
+             "(let ((*load-verbose* nil)) (#+sdebug si::nload #-sdebug load \"%s\")(values))\n"
+           "(load \"%s\")\n")))
+
+    (message (if instrument
+                 "GCL: Loading file with line-tracking enabled..."
+               "GCL: Loading file normally..."))
+    (save-window-excursion
+      (lisp-load-file file))))
 
-(defun mark-long-comment ()
+(defun gcl-refresh-layout ()
+  "Restore the modern GDB multi-window layout frame layout if distorted."
   (interactive)
-  (let ((at (point)))
-    (beginning-of-line)
-    (while(and (not (eobp))
-	       (or  (looking-at comment-start)
-		    ;(looking-at "[ 	]*\n")
-		    ))
-      (forward-line 1))
-    (set-mark (point))
-    (goto-char at)
-    (while(and (not (bobp))
-	       (or  (looking-at comment-start)
-		    ;(looking-at "[ 	]*\n")
-		    ))
-      (forward-line -1))
-    (or (bobp )(forward-line 1))))
-    
+  (let ((buffer (current-buffer)))
+    (with-current-buffer inferior-lisp-buffer
+      (when gcl-gdb-p
+	  (gdb-restore-windows)
+	  (let ((sw (cl-find-if (lambda (x)
+				  (string-match-p "main\\.c" (buffer-name (window-buffer x))))
+				(window-list))))
+	    (when sw
+	      (with-selected-window sw
+		(switch-to-buffer (buffer-name buffer) nil t))))
+	  (setq gcl-last-frame-displayed-p nil))
+      (gcl-display-frame))))
 
-(defun fill-long-comment ()
+(defun gcl-break nil
+  "Set GCL breakpoint at this source line."
   (interactive)
-  (mark-long-comment)
-  (let ((beg (min (dot) (mark)))
-	(end (max (dot) (mark))) (n 0)m)
-    (narrow-to-region beg end)
-    (goto-char (point-min))    
-    (while (looking-at ";")
-      (forward-char 1))
-    (setq n (- (point) beg))
-    (goto-char (point-min))    
-    (while (not (eobp))
-      (setq m n)
-      (while (> m  0)
-	(cond ((looking-at ";")
-	       (delete-char 1)
-	       (cond ((looking-at " ")(delete-char 1)(setq m 0)))
-	       (setq m (- m 1)))
-	      (t (setq m 0))))
-      (forward-line 1))
-    (fill-region (dot-min) (dot-max))
-    (goto-char (point-min))
-    (while (not (eobp))
-      (cond ((looking-at "\n")
-	     nil)
-	    (t(insert ";; ")))
-      (forward-line 1))
-   (goto-char (point-min))
-   (set-mark (point-max))
-   (widen)))
-
-(defun comment-region (arg) 
-  "Comments the region, with a numeric arg deletes up to arg comment 
-characters from the beginning of each line in the region.  The region stays, 
-so a second comment-region adds another comment character" 
- (interactive "P") 
- (save-excursion 
-   (let ((beg (dot)) 
-	 (ok t)(end (mark)))
-          (comment-region1 beg end arg))))
-
-(defun comment-region1 (beg end arg)
-  (let ((ok t))
-    (cond((> beg end) 
-	  (let ((oth end)) 
-	    (setq end beg beg oth)))) 
-    (narrow-to-region beg end) 
-    (goto-char beg) 
-       (unwind-protect 
-	   (while ok 
-	     (cond (arg 
-		    (delete-comment-char arg)) 
-		   (t   (insert-string comment-start)))
-	     (if (< end (dot)) (setq ok nil)
-	       (if  (search-forward "\n" end t) nil (setq ok nil))) )
-	 (widen))))
+  (save-excursion
+    (end-of-line)
+    (let (name at (where (point)))
+      (beginning-of-defun)
+      (search-forward "(def")
+      (forward-sexp 2)
+      (setq at (point))
+      (forward-sexp -1)
+      (setq name (buffer-substring (point) at))
+      (beginning-of-line)
+      (let ((name (format "(si::break-function '%s %s t)"  name (count-lines 1 where))))
+	(message "%s" name)
+	(process-send-string (get-buffer-process inferior-lisp-buffer) (concat name "\n"))))))
 
-(defun trace-expression ()
+(defun gcl-source-overlay-mode-quit ()
+  "Safely drop out of the read-only debugger map back to active editing."
+  (interactive)
+  (gcl-source-overlay-mode -1)
+  (when (markerp overlay-arrow-position)
+    (set-marker overlay-arrow-position nil))
+  (gcl-q)
+  (message "Debugger keys detached. Editing restored."))
+
+;; Inferior lisp buffer
+
+(defun gcl-find-line ()
+  "If the current buffer has a process, then look first for a file-line
+property, and if none, then search for a regexp.
+If a non process buffer, just return current file and line number.
+"
   (interactive)
   (save-excursion
-     (forward-sexp )
-    (let ((end (point)))
-           (forward-sexp -1)
-      (other-window 1)
-      (let* ((proc (get-buffer-process (current-buffer)))
-	     (current-lisp-process (or  proc lisp-process)))
-	(other-window 1)
-	(message "Tracing: %s" (buffer-substring (point) end))
-	(send-string current-lisp-process "(trace ")
-	(send-region current-lisp-process (point) end)
-	(send-string current-lisp-process ")\n")))))
+    (end-of-line)
+    (cond ((get-buffer-process (current-buffer))
+	   (cond
+	    ((progn
+	       (beginning-of-line)
+	       (get-text-property (point) 'file-line)))
+	    ((progn (end-of-line) (re-search-backward "\(\\([^ ]+\\) +line +\\([0-9]+\\)\)" 300 nil))
+	     (let* ((file (buffer-substring (match-beginning 1) (match-end 1)))
+		    (line (buffer-substring (match-beginning 2) (match-end 2)))
+		    (line (read line)))
+	     (and (integerp line) file (list file line))))))
+	  (t (list (buffer-file-name)
+		   (+ 1 (if (featurep 'xemacs) (line-number) (line-number-at-pos))))))))
 
-(defun gcl-mode ()
+(defun gcl-find-and-display-line nil
+  (interactive)
+  (let ((res (gcl-find-line)))
+    (when res
+      (apply 'gcl-display-line res))))
+
+(defun gcl-find-file (file)
+  (cond ((file-exists-p file)
+	 (find-file-noselect file))
+	((get-buffer file))
+	(t (find-file-noselect file))))
+
+(defvar gcl-last-frame nil)
+(defvar gcl-last-frame-displayed-p t)
+(defvar gcl-iob-init nil)
+(defvar gcl-gdb-p nil)
+
+(defun gcl-setup-iob nil
+
+  (let* ((buf (current-buffer))
+	 (gdb-com (when (boundp 'gud-comint-buffer) gud-comint-buffer))
+	 (gdb-io (when gdb-com (gdb-get-buffer 'gdb-inferior-io)))
+	 (buf (if (eq buf gdb-com) gdb-io buf))
+	 (gdb-p (eq buf gdb-io)))
+    (with-current-buffer buf
+
+      (setq inferior-lisp-buffer (current-buffer))
+      (setq-local gcl-last-frame nil)
+      (setq-local gcl-last-frame-displayed-p t)
+      (setq-local gcl-iob-init t)
+      (setq-local gcl-gdb-p gdb-p)
+
+      (local-set-key (kbd "C-c l") 'gcl-find-and-display-line)
+      (message "GCL environment bound cleanly to %s" (buffer-name)))))
+
+;; Filter
+
+(defun gcl-display-line (true-file line)
+  (let* ((buffer (gcl-find-file true-file))
+	 (window (progn
+		   (pop-to-buffer buffer '(display-buffer-reuse-window display-buffer-pop-up-window))
+		   (get-buffer-window buffer)))
+ 	 pos)
+    (save-excursion
+      (set-buffer buffer)
+      (save-restriction
+	(widen)
+	(goto-line line)
+	(setq pos (point))
+	(setq overlay-arrow-string "=>")
+	(unless overlay-arrow-position
+	  (setq overlay-arrow-position (make-marker)))
+	(set-marker overlay-arrow-position (point) (current-buffer)))
+      (unless (<= (point-min) pos (point-max))
+	(widen)
+	(goto-char pos))
+      (gcl-source-overlay-mode 1))
+    (set-window-point window overlay-arrow-position)))
+
+(defun gcl-display-frame (&optional nodisplay noauto)
+  "Find, obey and delete the last filename-and-line marker from GCL.
+The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n.
+Obeying it means displaying in another window the specified file and line."
   (interactive)
-  (lisp-mode)
-  )
+  (with-current-buffer inferior-lisp-buffer
+    (when gcl-last-frame
+      (unless nodisplay
+	(unless (and gcl-last-frame-displayed-p noauto)
+	  (gcl-display-line (car gcl-last-frame) (cdr gcl-last-frame))
+	  (setq gcl-last-frame-displayed-p t))))))
+
+(defun gcl-filter (string)
+  (let ((filtered-string string))
+    (unless gcl-iob-init
+      (when (string-match-p "^GCL (GNU Common Lisp)" string)
+	(gcl-setup-iob)))
+    (when gcl-iob-init
+      (when (string-match "^[^:]*:?\032\032\\([A-Za-z]?:?[^:]*\\):\\([0-9]*\\):[^\n]+\n" string)
+	(let ((file (match-string 1 string))
+              (line (string-to-number (match-string 2 string))))
+	  (setq filtered-string (replace-match "" t t string))
+          (unless (equal line 0)
+            (setq gcl-last-frame (cons file line))
+            (setq gcl-last-frame-displayed-p nil)
+            (gcl-display-frame)))))
+    filtered-string))
+
+
+;; COMINT mode
+
+(defun gcl-comint-filter (proc string)
+  (let ((inhibit-quit t))
+    (with-current-buffer (process-buffer proc)
+      (comint-output-filter proc (gcl-filter string)))))
+
+(defun gcl-process-sentinel (proc msg)
+  "Manage process state changes for GCL/GDB, cleaning up debugging hooks on exit."
+  (let* ((p-buf (process-buffer proc))
+	 (killed (or (null p-buf) (null (buffer-name p-buf)))))
+
+    (when (or killed (memq (process-status proc) '(signal exit)))
+
+      (message "GCL: Process stream terminated (%s). Cleaning up environment..." (string-trim msg))
+
+      (when (markerp overlay-arrow-position)
+        (set-marker overlay-arrow-position nil))
+
+      (dolist (buf (buffer-list))
+        (with-current-buffer buf
+          (when (bound-and-true-p gcl-source-overlay-mode)
+            (gcl-source-overlay-mode -1)
+            (message "Restored editing configuration to %s" (buffer-name buf)))))
+
+      (unless killed
+	(let ((obuf (current-buffer)))
+          (unwind-protect
+              (with-current-buffer p-buf
+		(setq mode-line-process (format ": %s" (symbol-name (process-status proc))))
+		(set-buffer-modified-p (buffer-modified-p))
+		(save-excursion
+                  (goto-char (point-max))
+                  (insert (format "\nProcess %s %s" (process-name proc) msg)))
+		(unless gcl-gdb-p
+		  (delete-process proc)))
+            (when (buffer-live-p obuf)
+              (set-buffer obuf))))))))
+
+;;GDB mode
+
+(defun gcl-gdb-inferior-io-filter-advice (orig-filter proc string)
+  "Intercept GCL source-tracking traces in the GDB I/O channel before rendering."
+  (with-current-buffer (process-buffer proc)
+    (funcall orig-filter proc (gcl-filter string))))
+(advice-add 'gdb-inferior-filter :around 'gcl-gdb-inferior-io-filter-advice)
+
+(defun gcl-gdb-cleanup-advice (&rest _args)
+  "Hook into gdb-mi's native reset routine to tear down custom Lisp overlays safely."
+
+  (message "GCL: GDB session ended. Cleaning up environment overlays...")
+
+  (when (markerp overlay-arrow-position)
+    (set-marker overlay-arrow-position nil))
+
+  (dolist (buf (buffer-list))
+    (with-current-buffer buf
+      (when (bound-and-true-p gcl-source-overlay-mode)
+        (gcl-source-overlay-mode -1)
+        (message "Restored editing configuration to %s" (buffer-name buf))))))
+(advice-add 'gdb-reset :after 'gcl-gdb-cleanup-advice)
+
+;;;###autoload
+(defun gcl (&optional debug)
+  (interactive "P")
+  (let* ((fn (or (locate-file "saved_ansi_gcl" gcl-dirs nil 'executable)
+		 (shell-command-to-string "gcl27 -batch -eval '(print (si::kcl-self))'")))
+	 (dir (file-name-directory
+	       (directory-file-name
+		(file-name-directory fn)))))
+    (cond
+     (debug
+      (setq gdb-many-windows t)
+      (gdb (format "gdb -i=mi -cd=%s -d=%s --args %s -nocinit" dir dir fn)))
+     (t (let ((buf (make-comint "gcl" fn nil "-nocinit")))
+	  (set-process-filter (get-buffer-process buf) 'gcl-comint-filter)
+	  (set-process-sentinel (get-buffer-process buf) 'gcl-process-sentinel)
+	  (pop-to-buffer buf '(display-buffer-pop-up-window)))))))
 
-(provide 'gcl)
\ No newline at end of file
+(provide 'gcl)
--- gcl27-2.7.1.orig/git.tag
+++ gcl27-2.7.1/git.tag
@@ -1 +1 @@
-"Version_2_7_2pre44"
+"Version_2_7_2pre45"
--- gcl27-2.7.1.orig/h/frame.h
+++ gcl27-2.7.1/h/frame.h
@@ -33,6 +33,7 @@ Foundation, 675 Mass Ave, Cambridge, MA
 typedef struct invocation_history {
   object ihs_function;
   object *ihs_base;
+  object *ihs_top;
 } *ihs_ptr;
 
 EXTER ihs_ptr ihs_org,ihs_limit,ihs_top;
@@ -42,11 +43,8 @@ EXTER ihs_ptr ihs_org,ihs_limit,ihs_top;
 #define ihs_push(function)  do {\
         if (++ihs_top>=ihs_limit) ihs_overflow();\
 	ihs_top->ihs_function = (function);  \
-	ihs_top->ihs_base = vs_base;} while (0)
-#define ihs_push_base(function,base)  do {\
-        if (++ihs_top>=ihs_limit) ihs_overflow();\
-	ihs_top->ihs_function = (function);  \
-	ihs_top->ihs_base = base;} while (0)
+	ihs_top->ihs_base = vs_base; \
+ 	ihs_top->ihs_top = vs_top;} while (0)
 
 #define ihs_pop() ihs_top--
 
--- gcl27-2.7.1.orig/h/lex.h
+++ gcl27-2.7.1/h/lex.h
@@ -47,16 +47,16 @@ where 'FUN' is the LISP object with pnam
 
 */
 
-#define lex_copy()	if (ihs_top>=ihs_org) ihs_top->ihs_base = vs_top;  \
-			vs_push(lex_env[0]);  \
-                  	vs_push(lex_env[1]);  \
-                  	vs_push(lex_env[2]);  \
-			lex_env = vs_top - 3
+#define lex_copy()							\
+  vs_push(lex_env[0]);							\
+  vs_push(lex_env[1]);							\
+  vs_push(lex_env[2]);							\
+  lex_env = vs_top - 3
 
-#define lex_new()	if (ihs_top>=ihs_org) ihs_top->ihs_base = vs_top; \
-			lex_env = vs_top;  \
-			vs_top[0] = vs_top[1] = vs_top[2] = Cnil;  \
-			vs_top += 3
+#define lex_new()							\
+  lex_env = vs_top;							\
+  vs_top[0] = vs_top[1] = vs_top[2] = Cnil;				\
+  vs_top += 3
 
 #define lex_var_sch(name)	assoc_eq((name),lex_env[0])
 
--- gcl27-2.7.1.orig/lsp/gcl_callhash.lsp
+++ gcl27-2.7.1/lsp/gcl_callhash.lsp
@@ -294,21 +294,16 @@
 	(push (list s sig) r))))
   (write-sys-proclaims1 sp r))
 
-(defvar *do-recomp-output-dir* nil)
 ;;FIXME not always idempotent
-(defun do-recomp (&optional cdebug &rest excl &aux *sig-discovery-props* *compile-verbose*)
+(defun do-recomp (&optional opts-fn &rest excl &aux *sig-discovery-props* *compile-verbose*)
   (gen-discovery-props)
   (let* ((fl (mapcar 'car *sig-discovery-props*))
 	 (fl (remove-duplicates (mapcar (lambda (x &aux (f (file x))) (when f (namestring f))) fl) :test 'string=))
 	 (fl (set-difference fl excl :test (lambda (x y) (search y x)))))
-    (when cdebug (compiler::cdebug))
     (format t "~%Recompiling original source files ...~%")
-    (mapc (lambda (x)
-	    (format t "~s~%" x)
-	    (compile-file x :output-file
-			  (merge-pathnames
-			   (make-pathname :type "o" :name (pathname-name x))
-			   (if *do-recomp-output-dir* (truename *do-recomp-output-dir*) x))))
+    (mapc (lambda (x &aux (opts (when opts-fn (funcall opts-fn x))))
+	    (format t "~s -> ~s~%" x (compile-file-pathname x :output-file (getf opts :output-file)))
+	    (apply 'compile-file x opts))
 	  (remove nil fl))))
 
 (defun gen-all-ftype-symbols (&aux r)
--- gcl27-2.7.1.orig/lsp/gcl_debug.lsp
+++ gcl27-2.7.1/lsp/gcl_debug.lsp
@@ -46,11 +46,9 @@
    (break-previous)
    ))
 
-(defun show-environment (ihs)
-  (let ((lis  (vs (ihs-vs ihs))))
-    (if (listp lis)
-	(dolist (v (reverse (vs (ihs-vs ihs))))
-	  (format *debug-io* "~%~9a: ~s" (car v) (second v))))))
+(defun show-environment nil
+  (dolist (v (reverse (car (current-env))))
+    (format *debug-io* "~%~9a: ~s" (car v) (second v))))
 
 (putprop :a 'show-break-variables 'break-command)
 
@@ -61,15 +59,10 @@
   (setq string (cond((symbolp sym)(symbol-name sym))
 		    (t sym)))
   (sloop
-     for ihs downfrom (ihs-top) above 2
+     for ihs downfrom (ihs-top) above 1
      for fun = (ihs-fun ihs) with name
-     do 
-     (cond ((functionp fun) (setq name (fun-name fun)))
-	   ((symbolp fun ) (setq name fun))
-	   ((and (listp fun)
-		 (member (car fun) '(lambda lambda-block)))
-	    (setq name (second fun)))
-	   (t (setq name '||)))
+     do
+     (setq name (ihs-fname ihs))
      when (search string (symbol-name name) :test 'equal)
      do (return (progn (break-go ihs)(terpri) (break-locals)))
      finally (format *debug-io* "~%Search for ~a failed" string)
@@ -79,41 +72,17 @@
 
 (defun break-locals (&optional (n 1) ;FIXME
 			       &aux (ihs *current-ihs*)
-			       (base  (ihs-vs ihs))
 			       (*print-level* *debug-print-level*)
 			       (*print-circle* t)
 			       (*print-length* *debug-print-level*)
-			       (current-ihs *current-ihs*)
-			       (fun (ihs-fun ihs)) name args)
+			       (current-ihs *current-ihs*))
   (cond ((fb > n 1)
 	 (sloop for i below n
 	    for ihs downfrom current-ihs above 2
-	    do (let ((*current-ihs* ihs))
-		 (break-locals) (terpri)(terpri)
-		 )))
-	(t
-	 (cond ((functionp fun) (setq name (fun-name fun)))
-	       (t (setq name fun)))
-         (if (symbolp name)(setq args (get name 'debugger)))
-	 (let ((next (ihs-vs (f + 1 *current-ihs*))))
-	   (cond (next
-		  (format *debug-io* ">> ~a():" name)
-		  (cond ((symbolp name)     
-			 (sloop for i from base below next for j from 0
-			    for u = nil
-			    do 
-			    (cond ((member 0 args);;old debug info.
-				   (setf u (getf  args j)))
-				  (t (setf u (nth j args))))
-			    (cond (u
-				   (format t
-					   "~%Local~a(~a): ~a" j u  (vs i)))
-				  (t
-				   (format *debug-io* "~%Local(~d): ~a"
-					   j (vs i))))))
-			((listp name)
-			 (show-environment  ihs))
-			(t (format *debug-io* "~%Which case is this??")))))))))
+	    do (let ((*current-ihs* ihs)) (break-locals) (terpri)(terpri))))
+	((ihs-vs (f + 1 *current-ihs*))
+	 (format *debug-io* ">> ~a():" (ihs-fname ihs))
+	 (show-environment))))
 
 (defun loc (&optional (n 0))
   (let ((base (ihs-vs *current-ihs*)))
@@ -247,18 +216,44 @@
   
   )
 
-(defun nload (file &rest args )
+;;FIXME bring back clear-props in fSet
+(defun record-line-info (sym fun &aux (body (fle fun))(ar *fun-array*)(old-info (get sym 'line-info)))
+  (remprop sym 'line-info)
+  (when (when (eq *readtable* *line-info-readtable*) (consp body))
+    (setf (fill-pointer ar) 0)
+    (walk-through body)
+    (if (zerop (length ar))
+	(iterate-over-bkpts (get sym 'break-points) :delete)
+	(let* ((min (reduce 'min ar :key 'cdar :initial-value most-positive-fixnum))
+	       (max (reduce 'max ar :key 'cdar :initial-value 0))
+	       (new (make-array (- max min -2) :initial-element :blank-line)))
+	  (setf (aref new 0) (cons (caar (aref ar 0)) min))
+	  (decf min)
+	  (map nil (lambda (x) (setf (aref new (- (cdar x) min)) (cdr x))) ar)
+	  (setf (get sym 'line-info) new)
+	  (when old-info
+	    (let* ((old-begin (cdr (aref old-info 0))))
+	      (mapc (lambda (x &aux (bpt (aref *break-points* x)))
+		      (setf (aref *break-points* x)
+			    (make-break-point (fourth bpt) new (- (third bpt) old-begin))))
+		    (get sym 'break-points))))))))
+
+(defun nload (file &rest args)
   (clrhash *record-line-info*)
   (cleanup)
   (setq file (truename file))
   (setup-lineinfo)
-  (let ((*readtable* *line-info-readtable*))
-    (apply 'load file args)))
+  (let ((*readtable* *line-info-readtable*)
+	(ofsf (symbol-function 'fset)))
+    (unwind-protect
+	 (progn
+	   (setf (symbol-function 'fset) (lambda (x y) (record-line-info x y) (funcall ofsf x y)))
+	   (apply 'load file args))
+      (setf (symbol-function 'fset) ofsf))))
 
 (eval-when (compile eval)
 
-(defmacro break-data (name line) `(cons ,name ,line))
-  )
+(defmacro break-data (name line) `(cons ,name ,line)))
 
 (defun left-parenthesis-reader (str ch &aux line(flag *at-newline*))
   (if (eq *at-newline* t) (setq *at-newline* nil))
@@ -275,23 +270,33 @@
 
 (defvar *fun-array* (make-array 50 :fill-pointer 0 :adjustable t))
 
-(defun walk-through (body &aux tem)
-  (tagbody
-   top
-   (cond ((consp body)
-	  (when (setq tem (gethash body *record-line-info*))
-	    ;; lines beginning with ((< u v)..)
-	    ;; aren't eval'd but are part of a special form
-	    (cond ((and (consp (car body))
-			(not (eq (caar body) 'lambda)))
-		   (remhash body *record-line-info*)
-		   (setf (gethash (car body) *record-line-info*)
-			 tem))
-		  (t (vector-push-extend (cons tem body) *fun-array*))))
-	  (walk-through (car body))
-	  (setq body (cdr body))
-	  (go top))
-	 (t nil))))
+(defun walk-through (body &aux (tem (gethash body *record-line-info*)))
+  (when (consp body)
+    (when tem
+      (vector-push-extend (cons tem body) *fun-array*))
+    (flet ((repl (body key &aux (tem (gethash body *record-line-info*)))
+	     (when (consp body)
+	       (when tem
+		 (remhash body *record-line-info*)
+		 (setf (gethash (funcall key body) *record-line-info*) tem))))
+	   (l (x) (when (listp x) x)))
+      (case (car body)
+	(cond (mapc (lambda (x) (when (consp x) (repl x 'car))) (cdr body)))
+	((do do*)
+	 (mapc (lambda (x) (when (consp x) (repl x 'car))) (l (cadr body)))
+	 (mapc (lambda (x) (when (consp x) (repl x 'car))) (l (caddr body))))
+	((case ecase ccase typecase etypecase ctypecase)
+	 (mapc (lambda (x) (when (consp x) (repl x 'cadr))) (cdr body)))
+	((let let*)
+	 (repl (cadr body) 'car)
+	 (mapc (lambda (x) (when (consp x) (repl x 'cadr))) (l (cadr body))))
+	((flet labels macrolet)
+	 (repl (cadr body) 'car)
+	 (mapc (lambda (x) (when (consp x) (repl x 'caddr))) (l (cadr body))))
+	((multiple-value-bind multiple-value-setq)
+	 (repl (cadr body) (lambda (x) (declare (ignore x)) (l (caddr body)))))))
+    (walk-through (car body))
+    (walk-through (cdr body))))
 
 ;; (defun compiler::compiler-def-hook (name body &aux (ar *fun-array*)
 ;; 					 (min most-positive-fixnum)
@@ -366,7 +371,7 @@
   (do ((i (1- ihs) (f - i 1)))
       ((fb <=  i 0))
     (let ((na (ihs-fname i)))
-      (if (get na 'line-info) (return na)))))
+      (if (get na 'line-info) (return (list na i))))))
 
 (defun init-break-points ()
   (setf (fill-pointer *break-point-vector*) 0)
@@ -387,33 +392,71 @@
     (setq *break-step* 'break-step-next)
     :resume))
 
-(defun maybe-break (form line-info fun env &aux pos)
-  (cond ((setq pos (position form line-info))
-	 (setq *break-step* nil)
-	 (or (> (length *break-points*) 0)
-	     (setf *break-points* nil))
-	 (break-level (make-break-point fun line-info pos) env)
-	 t)))
+(defvar *step-finish* nil)
+
+(defun step-finish (&optional (n 1))
+  (let ((fun (current-step-fun)))
+    (setq *step-finish* (cons n fun))
+    (or *break-points* (init-break-points))
+    (setq *break-step* 'break-step-finish)
+    :resume))
+
+
+(defun maybe-break (form line-info fun env &aux (pos (position form line-info)))
+  (when pos
+    (setq *break-step* nil)
+    (unless (plusp (length *break-points*))
+      (setf *break-points* nil))
+    (break-level (make-break-point fun line-info pos) env)
+    t))
 
 ;; These following functions, when they are the value of *break-step*
 ;; are invoked by an inner hook in eval.   They may choose to stop
 ;; things.
 
+(defvar *break-instep* nil)
+
 (defun break-step-into (form env)
-  (let ((fun (current-step-fun)))
-    (let ((line-info (get fun 'line-info)))
-      (maybe-break form line-info fun env))))
+  (unless *break-instep*
+    (let* ((*break-instep* t)
+	   (fun (car (current-step-fun))))
+      (if fun
+	  (maybe-break form (get fun 'line-info) fun env)
+	  (setq *break-step* nil)))))
 
 (defun break-step-next (form env)
-  (let ((fun (current-step-fun)))
-    (cond ((eql (cdr *step-next*) fun)
-	   (let ((line-info (get fun 'line-info)))
-	     (maybe-break form line-info fun env))))))
+  (unless *break-instep*
+    (let* ((*break-instep* t)
+	   (fun (current-step-fun)))
+      (if fun
+	  (when (eql (caddr *step-next*) (cadr fun))
+	    (maybe-break form (get (car fun) 'line-info) (car fun) env))
+	  (setq *break-step* nil)))))
+
+ (defun break-step-finish (form env)
+  (unless *break-instep*
+    (let* ((*break-instep* t)
+	   (fun (current-step-fun)))
+      (if fun
+	  (when (< (cadr fun) (caddr *step-finish*))
+	    (maybe-break form (get (car fun) 'line-info) (car fun) env))
+	  (setq *break-step* nil)))))
 
 (setf (get :next 'break-command) 'step-next)
 (setf (get :step 'break-command) 'step-into)
 (setf (get :loc 'break-command) 'loc)
+(setf (get :fin 'break-command) 'step-finish)
+(setf (get :finish 'break-command) 'step-finish)
 
+(defun break-display (&rest r)
+  (setq *step-display* (append r *step-display*)))
+(setf (get :dis 'break-command) 'break-display)
+(setf (get :display 'break-command) 'break-display)
+
+(defun break-undisplay (&rest r)
+  (setq *step-display* (set-difference *step-display* r :test 'equal)))
+(setf (get :undis 'break-command) 'break-undisplay)
+(setf (get :undisplay 'break-command) 'break-undisplay)
 
 (defun *break-points* (form  env) 
   (let ((pos(position form *break-points* :key 'car)))
@@ -510,11 +553,9 @@
 
 (setf (get :info 'break-command)
       '(lambda (type)
-	 (case type
+	 (ecase type
 	   (:bkpt  (iterate-over-bkpts nil :show))
-	   (otherwise
-	    (format t "usage: :info :bkpt -- show breakpoints")
-	    ))))
+	   ((:dis :display) (format t "Displaying ~s~%" *step-display*)))))
 
 (defun complete-prop (sym package prop &optional return-list)
   (cond ((and (symbolp sym)(get sym prop)(equal (symbol-package sym)
@@ -634,44 +675,27 @@
 	   (or (fb >= n 0) (setq n 0))
 	   (dbl-up n *ihs-top*))))
 	
-(dolist (v '( break-level universal-error-handler terminal-interrupt
-			  break-level   evalhook find-line-in-fun))
+(dolist (v '(break-level universal-error-handler terminal-interrupt
+	     break-level evalhook find-line-in-fun maybe-break
+	     break-step-next break-step-into))
   (setf (get v 'dbl-invisible) t))
 
-(defun next-stack-frame (ihs &aux line-info li i k na)
+(defun get-lower-line-info (n i &aux (f (get n 'line-info)))
+  (do* ((j (+ i 2) (1- j))
+	(k nil (get-line-of-form (ihs-fun j) f)))
+       ((or k (<= j i)) (when k (list f k j)))))
+
+(defun next-stack-frame (ihs &aux line-info li n i k na)
+  (mv-setq (n i) (get-next-visible-fun ihs))
   (cond
-   ((fb < ihs *ihs-base*) (mv-values nil nil nil nil nil))
-   (t (let (fun)
-	;; next lower visible ihs
-	(mv-setq (fun i) (get-next-visible-fun  ihs))
-	(setq na fun)
-	(cond
-	 ((and
-	   (setq line-info (get fun 'line-info))
-	   (do ((j (f + ihs 1) (f - j 1)))
-;		(form ))
-	       ((<= j i) nil)
-;	     (setq form (ihs-fun j))
-	     (cond ((setq li (get-line-of-form (ihs-fun j) line-info))
-		    (return-from next-stack-frame 
-				 (mv-values
-				  i fun li
-				  ;; filename
-				  (car (aref line-info 0))
-				  ;;environment
-				  (list (vs (setq k (ihs-vs j)))
-					(vs (1+ k))
-					(vs (+ k 2)))
-				  )))))))
-	 ((special-operator-p na) nil)
-	 ((get na 'dbl-invisible))
-	 ((fboundp na)
-	  (mv-values i na nil nil
-		     (if (ihs-not-interpreted-env i)
-			 nil
-		       (let ((i (ihs-vs i)))
-			 (list (vs i) (vs (1+ i)) (vs (f + i 2)))))))
-	 ((mv-values nil nil nil nil nil)))))))
+    ((not n) (mv-values nil nil nil nil nil))
+    ((special-operator-p n))
+    (t (let* ((llf (get-lower-line-info n i))
+	      (line-info (pop llf)))
+	 (mv-values
+	  i n (pop llf)
+	  (when line-info (car (aref line-info 0)))
+	  (ihs-env (or (car llf) i)))))))
 
 (defun nth-stack-frame (n &optional (ihs *ihs-top*)
 			  &aux  name line file env next)
@@ -698,29 +722,29 @@
    )
   (values))
 
-(defun display-compiled-env ( plength ihs &aux
-				      (base (ihs-vs ihs))
-				      (end (min (ihs-vs (1+ ihs)) (vs-top))))
-  (format *display-string* "")
-  (do ((i base)
-       (v (get (ihs-fname ihs) 'debugger) (cdr v)))
-      ((or (fb >= i end)(fb > (fill-pointer *display-string*) plength)(= 0 (address (vs i)))));FIXME
-    (format *display-string* "~a~@[~d~]=~s~@[,~]"
-	    (or (car v)  'loc) (if (not (car v)) (f - i base)) (vs i)
-	    (fb < (setq i (f + i 1)) end))))
+(defconstant +lsym-cdr-alist+ '((lambda . 0)(lambda-closure . 3)(lambda-block-closure . 4)(lambda-block . 1)))
+
+(deftype lambda-syms nil '(and gsym #.`(member ,@(mapcar 'car +lsym-cdr-alist+))))
+
+(defun ihs-fname (ihs-index &aux (fun (ihs-fun ihs-index)));FIXME
+  (typecase fun
+    (symbol fun)
+    (compiled-function (fun-name fun))
+    ((cons lambda-syms t)
+     (get-blocked-body-name (nthcdr (cdr (assoc (car fun) +lsym-cdr-alist+)) fun)))
+    ((cons (and symbol (or (satisfies special-operator-p) (satisfies fboundp))) t)
+     (car fun))
+    (t :zombi)))
 
-(defun computing-args-p (ihs)
   ;; When running interpreted we want a line like
   ;; (list joe jane) to get recorded in the invocation
   ;; history while joe and jane are being evaluated,
   ;; even though list has not yet been invoked.   We put
   ;; it in the history, but with the previous lexical environment.
-  (and (consp (ihs-fun ihs))
-       (> ihs 3)
-       (not (member (car (ihs-fun ihs)) '(lambda-block lambda)))
-       ;(<= (ihs-vs ihs) (ihs-vs (- ihs 1)))
-       )
-  )
+(defun computing-args-p (ihs)
+  (when (> ihs 3)
+    (typecase (ihs-fun ihs)
+      ((cons (not lambda-syms) t) t))))
 
 
 (defun print-stack-frame (i auto-display ihs fun &optional line file env)
@@ -731,13 +755,9 @@
     (format *debug-io* "~&#~d  ~@[~a~] ~a ~@[~a~] " i
 	    (and computing-args "Computing args for ")
 	    fun
-	    (if (not (ihs-not-interpreted-env ihs))
-		(apply-display-fun 'display-env  80
-				   (car (vs (ihs-vs ihs))))
-	      (apply-display-fun 'display-compiled-env 80 ihs)))
+	    (apply-display-fun 'display-env 80 (car (ihs-env ihs))))
     (if file (format *debug-io* "(~a line ~a)" file line))
-    (format *debug-io* "[ihs=~a]"  ihs)
-    ))
+    (format *debug-io* "[ihs=~a]"  ihs)))
 
 (defun make-break-point (fun ar i)
   (list					;make-bkpt	;:form
@@ -776,7 +796,32 @@
 
 (defvar *no-prompt* nil)
 
-(defun set-back (at env &aux (i *current-ihs*))
+(defun break-form (&rest l &aux ihs)
+  (mv-setq (ihs) (if l (nth-stack-frame (car l) *ihs-top*) *current-ihs*))
+  (cons (ihs-fname ihs) (ihs-args ihs)))
+(putprop :form 'break-form 'break-command)
+
+(defun ihs-args (ihs)
+  (if (ihs-not-interpreted-env ihs)
+      (labels ((aa (i)
+		 (when (< i (ihs-vstop ihs))
+		   (cons (vs i) (aa (1+ i))))))
+	(aa (ihs-vs ihs)))
+      (let* ((fun (ihs-fun ihs))
+	     (env (when (eq (car fun) 'lambda-closure) (cadr fun))))
+	(mapcar 'cadr
+		(remove-if (lambda (x) (member (car x) env :key 'car))
+			   (reverse (vs (ihs-vs ihs))))))))
+
+(defun ihs-current-step-fun nil
+  (let ((nm (car (current-step-fun))))
+    (labels ((s (i) (when (plusp i)
+		      (if (eq nm (ihs-fname i)) i
+			  (s (1- i))))))
+      (s *current-ihs*))))
+
+
+(defun set-back (at env &aux (i (ihs-current-step-fun)))
   (setq *no-prompt* nil)
   (setq *current-ihs* i)
   (cond (env   (setq *break-env* env))
--- gcl27-2.7.1.orig/lsp/gcl_fle.lsp
+++ gcl27-2.7.1/lsp/gcl_fle.lsp
@@ -71,12 +71,15 @@
 	 (fas (unless (fixnump fas) fas))
 	 (ss  (if (stringp fas) (open-fasd (make-string-input-stream fas) :input 'eof nil) fas))
 	 (out (if (vectorp ss) (read-fasd-top ss) ss))
-	 (es  (when (eq (car out) 'lambda-closure) (cadr out)))
-	 (env (when es (function-env fun 0))))
+	 (es  (when (eq (car out) 'lambda-closure) (list (cadr out) (caddr out) (cadddr out))))
+	 (n (apply '+ (mapcar 'length es)))
+	 (env (when (member-if 'identity es) (function-env fun 0))))
     (when env
       (setq out (list* (car out)
-		       (mapcar (lambda (x) (list (pop x) (nth (- (length es) (car x)) env))) es)
-		       (cddr out))))
+		       (mapcar (lambda (x) (list (pop x) (nth (- n (car x)) env))) (pop es))
+		       (mapcar (lambda (x) (list (pop x) (pop x) (nth (- n (car x)) env))) (pop es))
+		       (mapcar (lambda (x) (list (pop x) (pop x) (nth (- n (car x)) env))) (pop es))
+		       (nthcdr 4 out))))
     (when (vectorp ss)
       (close-fasd ss))
     out))
@@ -93,14 +96,15 @@
   (declare (optimize (safety 1)))
   (check-type y function)
   (let ((x (uncompress-src y)))
-    (case (car x)
-	  (lambda (values x nil (get-blocked-body-name x)))
-	  (lambda-block (values (block-lambda (caddr x) (cadr x) (cdddr x)) nil (cadr x)))
-	  (lambda-closure (values (setq z (cons 'lambda (cddr (cddr x))))  (cadr x) (get-blocked-body-name z)))
-	  (lambda-block-closure (values
-				 (block-lambda (caddr (cdddr x)) (cadr (cdddr x)) (cddr (cddr (cddr x)))) 
-				 (cadr x) (fifth x)))
-	  (otherwise (values nil t nil)))))
+    (flet ((mclo (x &aux (x (ldiff (cdr x) (nthcdr 4 x)))) (when (member-if 'identity x) x)))
+      (case (car x)
+	(lambda (values x nil (get-blocked-body-name x)))
+	(lambda-block (values (block-lambda (caddr x) (cadr x) (cdddr x)) nil (cadr x)))
+	(lambda-closure (values (setq z (cons 'lambda (cddr (cddr x)))) (mclo x) (get-blocked-body-name z)))
+	(lambda-block-closure (values
+			       (block-lambda (caddr (cdddr x)) (cadr (cdddr x)) (cddr (cddr (cddr x))))
+			       (mclo x) (fifth x)))
+	(otherwise (values nil t nil))))))
 
 (defun function-src (sym)
   (let ((fun (if (symbolp sym) (symbol-to-function sym) sym)));FIXME
--- gcl27-2.7.1.orig/lsp/gcl_serror.lsp
+++ gcl27-2.7.1/lsp/gcl_serror.lsp
@@ -108,7 +108,9 @@
 	 (invoke-restart-interactively (nth (1- n) *debug-restarts*)))
 	((format t "~&no such restart."))))
 
-(defun fun-name (fun) (sixth (c-function-plist fun)))
+(defun fun-name (fun)
+  (typecase fun
+    (function (sixth (c-function-plist fun)))))
 
 (defun find-ihs (s i &optional (j i))
   (cond ((eq (ihs-fname i) s) i)
@@ -181,8 +183,11 @@
 
 (defvar *sig-fn-name* nil)
 
-(defun get-sig-fn-name (&aux (p (ihs-top))(p (next-stack-frame p)))
-  (when p (ihs-fname p)))
+(defun get-sig-fn-name nil
+  (labels ((l (ihs)
+	     (multiple-value-bind (n ihs) (get-next-visible-fun ihs)
+	       (if (special-operator-p n) (l ihs) n))))
+    (l (ihs-top))))
 
 (defun process-error (datum args &optional (default-type 'simple-error))
   (let ((internal (cond ((simple-condition-class-p datum)
@@ -304,7 +309,7 @@
 	 (debug-level *debug-level*)
 	 (*quit-tags* (cons (cons *break-level* *quit-tag*) *quit-tags*))
 	 *quit-tag*
-	 (*break-level* (if p-e-p (cons t *break-level*) *break-level*))
+	 (*break-level* (cons t *break-level*))
 	 (*ihs-base* (1+ *ihs-top*))
 	 (*ihs-top* (ihs-top))
 	 (*frs-base* (or (sch-frs-base *frs-top* *ihs-base*) (1+ (frs-top))))
--- gcl27-2.7.1.orig/lsp/gcl_top.lsp
+++ gcl27-2.7.1/lsp/gcl_top.lsp
@@ -444,39 +444,52 @@
 (defun ihs-visible (i &aux (tem (ihs-fname i)))
   (and tem (not (member tem *break-hidden-packages*))))
 
+(defun ihs-not-interpreted-env (i)
+  (typecase (ihs-fun i) (function t)))
 
-(defun ihs-fname (ihs-index)
-  (let ((fun (ihs-fun ihs-index)))
-    (cond ((symbolp fun) fun)
-	  ((functionp fun) (fun-name fun));(name fun)
-          ((consp fun)
-           (case (car fun)
-             (lambda 'lambda)
-             ((lambda-block lambda-block-expanded) (cadr fun))
-             (lambda-block-closure (cadr (cdddr fun)))
-             (lambda-closure 'lambda-closure)
-             (t (if (and (symbolp (car fun))
-			 (or (special-operator-p (car fun))
-			     (fboundp (car fun))))
-		    (car fun) :zombi)
-		    )))
-          (:zombi))))
-
-(defun ihs-not-interpreted-env (ihs-index)
-  (let ((fun (ihs-fun ihs-index)))
-    (cond ((and (consp fun)
-		(> ihs-index 3)
-		;(<= (ihs-vs ihs-index) (ihs-vs (- ihs-index 1)))
-		)
-	   nil)
-	  (t t))))
-
-(defun set-env ()
-  (setq *break-env*
-        (if (ihs-not-interpreted-env *current-ihs*)
-            nil
-            (let ((i (ihs-vs *current-ihs*)))
-              (list (vs i) (vs (1+ i)) (vs (+ i 2)))))))
+(defun vnms (ll &optional (k '(&whole &optional &rest &key &allow-other-keys &aux &environment) kp) &aux x)
+  (flet ((addp (x y &aux (p (when (consp x) (caddr x)))) (if p (cons p y) y))
+	 (nm (x &optional k) (if (consp x) (if k (funcall k (car x)) (car x)) x)))
+    (when ll
+      (cond
+	((setq x (member (car ll) k)) (vnms (cdr ll) x))
+	((not kp) (cons (car ll) (vnms (cdr ll))))
+	((case (car k)
+	   (&optional (cons (nm (car ll)) (addp (car ll) (vnms (cdr ll) k))))
+	   (&rest (cons (car ll) (vnms (cdr ll) k)))
+	   (&key (cons (nm (car ll) (lambda (x) (if (consp x) (cadr x) x)))
+		       (addp (car ll) (vnms (cdr ll) k))))
+	   (&aux (cons (nm (car ll) (vnms (cdr ll) k))))))))))
+
+(defun eval-clean-or-nil (form)
+  (multiple-value-bind (er val)
+      (error-set `(evalhook ',form nil nil nil))
+    (unless er
+      val)))
+
+(defun compiled-fn-env (ihs)
+  (multiple-value-bind (src clo) (function-lambda-expression (ihs-fun ihs))
+    (when src
+      (let* ((ll (cadr src))
+	     (clo (or clo '(nil nil nil))))
+	(cons
+	 (nconc
+	  (eval-clean-or-nil
+	   (blla ll nil
+		 (cons 'list (mapcar (lambda (x) `',x) (ihs-args ihs)))
+		 `((list ,@(mapcar (lambda (x) `(list ',x ,x)) (nreverse (vnms ll)))))))
+	   (pop clo))
+	 clo)))))
+
+(defun ihs-env (ihs)
+  (if (ihs-not-interpreted-env ihs)
+      (compiled-fn-env ihs)
+      (let ((i (ihs-vs ihs)))
+        (list (vs i) (vs (1+ i)) (vs (+ i 2))))))
+
+(defun current-env nil (ihs-env *current-ihs*))
+
+(defun set-env nil (setq *break-env* (current-env)))
 
 (defun list-delq (x l)
   (cond ((null l) nil)
--- gcl27-2.7.1.orig/lsp/gcl_typecase.lsp
+++ gcl27-2.7.1/lsp/gcl_typecase.lsp
@@ -108,7 +108,7 @@
 		      (if (eq ctp 'proper-cons)
 			  (or (tp>= #tproper-list (cmp-norm-tp (cadr tp))) `(not (improper-consp ,o)))
 			(or (tp>= #t(not proper-list) (cmp-norm-tp (cadr tp))) `(improper-consp ,o))))))
-	   (progn (break) (simple-type-case o otp))))));;undecidable aggregation support
+	   (simple-type-case o otp)))));;FIXME (progn (break) (simple-type-case o otp)) undecidable aggregation support
 
 
 (defun branch (tpsff x f y &aux (q (cdr x))(x (car x))(z (cddr (assoc x tpsff))))
--- gcl27-2.7.1.orig/o/error.c
+++ gcl27-2.7.1/o/error.c
@@ -32,7 +32,7 @@ object siSuniversal_error_handler;
 
 object sSterminal_interrupt;
 
-#if defined(__APPLE__)
+#if defined(__APPLE__) || (defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 32)))
 const char *
 strerrordesc_np(int errnum) {
   return (errnum >= 0 && errnum < sys_nerr) ? sys_errlist[errnum] : "Unknown error";
@@ -220,6 +220,11 @@ DEFUN("IHS-VS",object,fSihs_vs,SI,1,1,NO
   RETURN1(x0);
 }
 
+DEFUN("IHS-VSTOP",object,fSihs_vstop,SI,1,1,NONE,OO,OO,OO,OO,(object x0),"") {
+  x0 = make_fixnum(get_ihs_ptr(x0)->ihs_top - vs_org);
+  RETURN1(x0);
+}
+
 static frame_ptr get_frame_ptr(object x) {
 
   frame_ptr p;
--- gcl27-2.7.1.orig/o/eval.c
+++ gcl27-2.7.1/o/eval.c
@@ -292,7 +292,7 @@ funcall(object fun) {
      if we pushed by vs_base being the same.
   */
   { VOL int not_pushed = 0;
-    if (vs_base != ihs_top->ihs_base){
+    if (vs_base != ihs_top->ihs_base || fun!=ihs_top->ihs_function){
       ihs_check;
       ihs_push(fun);
     }
@@ -300,6 +300,7 @@ funcall(object fun) {
       not_pushed = 1;
     
     ihs_top->ihs_base = lex_env;
+    ihs_top->ihs_top = lex_env+3;
     x = MMcar(fun);
     top = vs_top;
     lex = lex_env;
@@ -359,6 +360,7 @@ funcall(object fun) {
     vs_push(fun);
     lambda_bind(top);
     ihs_top->ihs_base = lex_env;
+    ihs_top->ihs_top = lex_env+3;
     if (b) {
       fun = temporary = alloc_frame_id();
       /*  lex_block_bind(x, temporary);  */
@@ -700,6 +702,7 @@ APPLICATION:
 		ihs_check;
 		ihs_push(form);
 		ihs_top->ihs_base = lex_env;
+		ihs_top->ihs_top = lex_env+3;
 		((void (*)(object))fun->s.s_sfdef)(MMcdr(form));
 		CHECK_AVMA;
 		ihs_pop();
@@ -736,6 +739,7 @@ EVAL_ARGS:
 	ihs_check;
 	ihs_push(form);
 	ihs_top->ihs_base = lex_env;
+	ihs_top->ihs_top = lex_env+3;
 	form = form->c.c_cdr;
 	base = vs_top;
 	top = vs_top;
@@ -752,6 +756,7 @@ EVAL_ARGS:
 	}
 	ihs_top->ihs_function = x;
 	ihs_top->ihs_base = vs_base;
+	ihs_top->ihs_top = vs_top;
 	/* if (type_of(x) == t_cfun)  */
 	/*   (*(x)->cf.cf_self)(); */
 	/* else */
--- gcl27-2.7.1.orig/o/gprof.c
+++ gcl27-2.7.1/o/gprof.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE 1
+
 #include <dlfcn.h>
 
 #include "include.h"
--- gcl27-2.7.1.orig/o/reference.c
+++ gcl27-2.7.1/o/reference.c
@@ -165,52 +165,57 @@ FFN(Fquote)(object form)
 }
 
 static void
-FFN(Ffunction)(object form)
-{
+FFN(Ffunction)(object form) {
+
+  object fun;
+  object fd;
+
+  if (endp(form))
+    FEtoo_few_argumentsF(form);
+  if (!endp(MMcdr(form)))
+    FEtoo_many_argumentsF(form);
+
+  fun = MMcar(form);
 
-	object fun;
-	object fd;
-	if (endp(form))
-		FEtoo_few_argumentsF(form);
-	if (!endp(MMcdr(form)))
-		FEtoo_many_argumentsF(form);
-	fun = MMcar(form);
  AGAIN:
-	if (type_of(fun) == t_symbol) {
-		fd = lex_fd_sch(fun);
-		if (MMnull(fd) || MMcadr(fd) != sLfunction)
-			if (fun->s.s_gfdef == OBJNULL || fun->s.s_mflag)
-				FEundefined_function(fun);
-			else {
-				vs_base = vs_top;
-				vs_push(fun->s.s_gfdef);
-			}
-		else {
-			vs_base = vs_top;
-			vs_push(MMcaddr(fd));
-		}
-	} else if (consp(fun) && MMcar(fun) == sLlambda) {
-		vs_base = vs_top;
-		vs_push(MMcdr(fun));
-		vs_base[0] = MMcons(lex_env[2], vs_base[0]);
-		vs_base[0] = MMcons(lex_env[1], vs_base[0]);
-		vs_base[0] = MMcons(lex_env[0], vs_base[0]);
-		vs_base[0] = MMcons(sSlambda_closure, vs_base[0]);
-		{
-		  vs_base[0]=fSfset_in(Cnil,vs_base[0],Cnil);
-		}
-		/* { */
-		/*   object x=alloc_object(t_ifun); */
-		/*   x->ifn.ifn_self=vs_base[0]; */
-		/*   x->ifn.ifn_name=x->ifn.ifn_call=Cnil; */
-		/*   vs_base[0]=x; */
-		/* } */
-	} else {
-	        fun=ifuncall1(sSfunid_to_sym,fun);
-/* 		if (fun==Cnil) */
-/* 		  FEundefined_function(sff); */
-		goto AGAIN;
-	}
+
+  if (type_of(fun)==t_symbol) {
+
+    fd = lex_fd_sch(fun);
+    if (MMnull(fd) || MMcadr(fd) != sLfunction)
+      if (fun->s.s_gfdef == OBJNULL || fun->s.s_mflag)
+	FEundefined_function(fun);
+      else {
+	vs_base = vs_top;
+	vs_push(fun->s.s_gfdef);
+      }
+    else {
+      vs_base = vs_top;
+      vs_push(MMcaddr(fd));
+    }
+
+  } else if (consp(fun)&&MMcar(fun)==sLlambda) {
+
+    vs_base = vs_top;
+    if (lex_env[0]==Cnil && lex_env[1]==Cnil && lex_env[2]==Cnil)
+      vs_push(fun);
+    else {
+      vs_push(MMcdr(fun));
+      vs_base[0] = MMcons(lex_env[2], vs_base[0]);
+      vs_base[0] = MMcons(lex_env[1], vs_base[0]);
+      vs_base[0] = MMcons(lex_env[0], vs_base[0]);
+      vs_base[0] = MMcons(sSlambda_closure, vs_base[0]);
+    }
+
+    vs_base[0]=fSfset_in(Cnil,vs_base[0],Cnil);
+
+  } else {
+
+    fun=ifuncall1(sSfunid_to_sym,fun);
+    goto AGAIN;
+
+  }
+
 }
 
 DEFUN("SYMBOL-VALUE",object,fLsymbol_value,LISP,1,1,NONE,OO,OO,OO,OO,(object sym),"") {
--- gcl27-2.7.1.orig/pcl/gcl_pcl_defs.lisp
+++ gcl27-2.7.1/pcl/gcl_pcl_defs.lisp
@@ -30,10 +30,11 @@
 
 (eval-when (compile load eval)
   
-(defvar *defclass-times*   '(load eval))	;Probably have to change this
-						;if you use defconstructor.
-(defvar *defmethod-times*  '(load eval))
-(defvar *defgeneric-times* '(load eval))
+  (defvar *defclass-times*   '(compile load eval)) ;FIXME with eval-when overhaul
+					;Probably have to change this
+					;if you use defconstructor.
+  (defvar *defmethod-times*  '(load eval))
+  (defvar *defgeneric-times* '(load eval))
 
 ; defvar is now actually in macros
 ;(defvar *boot-state* ())			;NIL
--- gcl27-2.7.1.orig/unixport/init_raw.lsp.in
+++ gcl27-2.7.1/unixport/init_raw.lsp.in
@@ -55,7 +55,7 @@
        (lsp (append x (list "lsp")))
        (cmpnew (append x (list "cmpnew")))
        (h (append x (list "h")))
-       (u (append x (list "unixport")))
+       (u (append (pathname-directory *lib-directory*) (list :back "unixport")))
        (xgcl-2 (append x (list "xgcl-2")))
        (pcl (append x (list "pcl")))
        (clcs (append x (list "clcs")))
