public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: cgen@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFC 12/14] Nuke cgen-call-with-debugging and cgen-debugging-stack-start
Date: Sat, 19 Aug 2023 11:42:11 -0600	[thread overview]
Message-ID: <20230819174900.866436-13-tom@tromey.com> (raw)
In-Reply-To: <20230819174900.866436-1-tom@tromey.com>

cgen-call-with-debugging and cgen-debugging-stack-start are ostensibly
just for Guile, but I don't think they provide much value with more
recent versions of Guile.  This patch removes them.
---
 guile.scm | 63 -----------------------------------------
 read.scm  | 85 ++++++++++++++++++++++++-------------------------------
 2 files changed, 37 insertions(+), 111 deletions(-)

diff --git a/guile.scm b/guile.scm
index 9d7c64c..5899f15 100644
--- a/guile.scm
+++ b/guile.scm
@@ -24,66 +24,3 @@
 ;;; Enabling and disabling debugging features of the host Scheme.
 
 (read-enable 'positions)
-
-;;; Call THUNK, with debugging enabled if FLAG is true, or disabled if
-;;; FLAG is false.
-;;;
-;;; (On systems other than Guile, this needn't actually do anything at
-;;; all, beyond calling THUNK, so long as your backtraces are still
-;;; helpful.  In Guile, the debugging evaluator is slower, so we don't
-;;; want to use it unless the user asked for it.)
-(define (cgen-call-with-debugging flag thunk)
-  (if (memq 'debug-extensions *features*)
-      ((if flag debug-enable debug-disable) 'debug))
-
-  ;; Now, make that debugging / no-debugging setting actually take
-  ;; effect.
-  ;;
-  ;; Guile has two separate evaluators, one that does the extra
-  ;; bookkeeping for backtraces, and one which doesn't, but runs
-  ;; faster.  However, the evaluation process (in either evaluator)
-  ;; ordinarily never consults the variable that says which evaluator
-  ;; to use: whatever evaluator was running just keeps rolling along.
-  ;; There are certain primitives, like some of the eval variants,
-  ;; that do actually check.  start-stack is one such primitive, but
-  ;; we don't want to shadow whatever other stack id is there, so we
-  ;; do all the real work in the ID argument, and do nothing in the
-  ;; EXP argument.  What a kludge.
-  (start-stack (begin (thunk) #t) #f))
-
-
-;;; Apply PROC to ARGS, marking that application as the bottom of the
-;;; stack for error backtraces.
-;;;
-;;; (On systems other than Guile, this doesn't really need to do
-;;; anything other than apply PROC to ARGS, as long as something
-;;; ensures that backtraces will work right.)
-(define (cgen-debugging-stack-start proc args)
-
-  ;; Naming this procedure, rather than using an anonymous lambda,
-  ;; allows us to pass less fragile cut info to save-stack.
-  (define (handler . args)
-		;;(display args (current-error-port))
-		;;(newline (current-error-port))
-		;; display-error takes 6 arguments.
-		;; If `quit' is called from elsewhere, it may not have 6
-		;; arguments.  Not sure how best to handle this.
-		(if (= (length args) 5)
-		    (begin
-		      (apply display-error #f (current-error-port) (cdr args))
-		      ;; Grab a copy of the current stack,
-		      (save-stack handler 0)
-		      (backtrace)))
-		(quit 1))
-
-  ;; Apply proc to args, and if any uncaught exception is thrown, call
-  ;; handler WITHOUT UNWINDING THE STACK (that's the 'lazy' part).  We
-  ;; need the stack left alone so we can produce a backtrace.
-  (lazy-catch #t
-	      (lambda ()
-		;; I have no idea why the 'load-stack' stack mark is
-		;; not still present on the stack; we're still loading
-		;; cgen-APP.scm, aren't we?  But stack-id returns #f
-		;; in handler if we don't do a start-stack here.
-		(start-stack proc (apply proc args)))
-	      handler))
diff --git a/read.scm b/read.scm
index ee3f488..8856da0 100644
--- a/read.scm
+++ b/read.scm
@@ -1252,7 +1252,7 @@ Define a preprocessor-style macro.
 ;; OPTION-HANDLER is either (lambda () ...) or (lambda (arg) ...) and
 ;; processes the option.
 
-(define /cgen
+(define cgen
   (lambda args
     (let ((app-name "unknown")
 	  (opt-spec nil)
@@ -1380,54 +1380,43 @@ Define a preprocessor-style macro.
 
 	;; All arguments have been parsed.
 
-	(cgen-call-with-debugging
-	 debugging
-	 (lambda ()
-
-	   (if (not arch-file)
-	       (error "-a option missing, no architecture specified"))
-
-	   (if repl?
-	       (debug-repl nil))
-
-	   (cpu-load arch-file
-		     keep-mach keep-isa flags
-		     trace-options diagnostic-options
-		     app-init! app-finish! app-analyze!)
-
-	   ;; Start another repl loop if -d.
-	   ;; Awkward.  Both places are useful, though this is more useful.
-	   (if repl?
-	       (debug-repl nil))
-
-	   ;; Done with processing the arguments.  Application arguments
-	   ;; are processed in two passes.  This is because the app may
-	   ;; have arguments that specify things that affect file
-	   ;; generation (e.g. to specify another input file) and we
-	   ;; don't want to require an ordering of the options.
-	   (for-each (lambda (opt-arg)
-		       (let ((opt (car opt-arg))
-			     (arg (cdr opt-arg)))
-			 (if (cadr opt)
-			     ((opt-get-first-pass opt) arg)
-			     ((opt-get-first-pass opt)))))
-		     (reverse app-args))
-
-	   (for-each (lambda (opt-arg)
-		       (let ((opt (car opt-arg))
-			     (arg (cdr opt-arg)))
-			 (if (cadr opt)
-			     ((opt-get-second-pass opt) arg)
-			     ((opt-get-second-pass opt)))))
-		     (reverse app-args))))
+	(if (not arch-file)
+	    (error "-a option missing, no architecture specified"))
+
+	(if repl?
+	    (debug-repl nil))
+
+	(cpu-load arch-file
+		  keep-mach keep-isa flags
+		  trace-options diagnostic-options
+		  app-init! app-finish! app-analyze!)
+
+	;; Start another repl loop if -d.
+	;; Awkward.  Both places are useful, though this is more useful.
+	(if repl?
+	    (debug-repl nil))
+
+	;; Done with processing the arguments.  Application arguments
+	;; are processed in two passes.  This is because the app may
+	;; have arguments that specify things that affect file
+	;; generation (e.g. to specify another input file) and we
+	;; don't want to require an ordering of the options.
+	(for-each (lambda (opt-arg)
+		    (let ((opt (car opt-arg))
+			  (arg (cdr opt-arg)))
+		      (if (cadr opt)
+			  ((opt-get-first-pass opt) arg)
+			  ((opt-get-first-pass opt)))))
+		  (reverse app-args))
+
+	(for-each (lambda (opt-arg)
+		    (let ((opt (car opt-arg))
+			  (arg (cdr opt-arg)))
+		      (if (cadr opt)
+			  ((opt-get-second-pass opt) arg)
+			  ((opt-get-second-pass opt)))))
+		  (reverse app-args))
 	)
       )
     #f) ;; end of lambda
 )
-
-;; Main entry point called by application file generators.
-
-(define cgen
-  (lambda args
-    (cgen-debugging-stack-start /cgen args))
-)
-- 
2.41.0


  parent reply	other threads:[~2023-08-19 20:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-19 17:41 [RFC 00/14] Port to Guile 3.0 Tom Tromey
2023-08-19 17:42 ` [RFC 01/14] Add a .gitignore Tom Tromey
2023-08-20  8:04   ` Jose E. Marchesi
2023-08-19 17:42 ` [RFC 02/14] Remove some 'fastcall' code Tom Tromey
2023-08-20  8:13   ` Jose E. Marchesi
2023-08-22 16:52     ` Tom Tromey
2023-08-19 17:42 ` [RFC 03/14] Remove bound-symbol? Tom Tromey
2023-08-20  8:14   ` Jose E. Marchesi
2023-08-19 17:42 ` [RFC 04/14] Remove =? and >=? aliases Tom Tromey
2023-08-20  8:15   ` Jose E. Marchesi
2023-08-19 17:42 ` [RFC 05/14] Fix bug in insn.scm Tom Tromey
2023-08-20  8:15   ` Jose E. Marchesi
2023-08-19 17:42 ` [RFC 06/14] Remove support for old versions of Guile Tom Tromey
2023-08-19 17:42 ` [RFC 07/14] Use define-macro in rtl.scm Tom Tromey
2023-08-19 17:42 ` [RFC 08/14] Remove let bindings of macros Tom Tromey
2023-08-20  8:33   ` Jose E. Marchesi
2023-08-19 17:42 ` [RFC 09/14] Remove define-in-define Tom Tromey
2023-08-19 17:42 ` [RFC 10/14] Hack cos.scm to work with new Guile Tom Tromey
2023-08-19 17:42 ` [RFC 11/14] Invalid code in rtx-traverse.scm Tom Tromey
2023-08-20  8:42   ` Jose E. Marchesi
2023-08-19 17:42 ` Tom Tromey [this message]
2023-08-19 17:42 ` [RFC 13/14] Load macros before uses Tom Tromey
2023-08-19 17:42 ` [RFC 14/14] Remove pprint.scm and cos-pprint.scm Tom Tromey
2023-08-20  8:03 ` [RFC 00/14] Port to Guile 3.0 Jose E. Marchesi
2023-08-20 17:26   ` Frank Ch. Eigler
2023-08-20 19:52     ` Tom Tromey
2023-08-21  1:38       ` Frank Ch. Eigler
2023-08-21 13:06 ` Julian Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230819174900.866436-13-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=cgen@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).