From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta037.useast.a.cloudfilter.net (omta037.useast.a.cloudfilter.net [44.202.169.36]) by sourceware.org (Postfix) with ESMTPS id CD9A53858C36 for ; Sat, 19 Aug 2023 20:20:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD9A53858C36 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from eig-obgw-5003a.ext.cloudfilter.net ([10.0.29.159]) by cmsmtp with ESMTP id XN2rqloqjWU1cXSQiq7a7L; Sat, 19 Aug 2023 20:20:16 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id XSQhqxDDA9I7XXSQhq2CJz; Sat, 19 Aug 2023 20:20:15 +0000 X-Authority-Analysis: v=2.4 cv=RfaDtnhv c=1 sm=1 tr=0 ts=64e123ff a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=UttIx32zK-AA:10 a=Qbun_eYptAEA:10 a=9mQ_jhQ3xX9O9Ej4-WwA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=xrH4g41NjGa7X73uaN2bGew7WFCBwfhk3LkOjmqXPXg=; b=MdJTEFcwxHRwaUzusRG9iIc1oW cfeZP7qBDo3V52zg7gqnYwU2KQ5rHLIvDIC9nzMprnwaik7Mjv6xqqY5kgesvbgTNb9xSYLI5tlWl yfh7B1bKOBR3IQ6LJ0OrNRo+X; Received: from 75-166-142-177.hlrn.qwest.net ([75.166.142.177]:36668 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qXQ4X-003yKO-2V; Sat, 19 Aug 2023 11:49:13 -0600 From: Tom Tromey To: cgen@sourceware.org Cc: Tom Tromey Subject: [RFC 12/14] Nuke cgen-call-with-debugging and cgen-debugging-stack-start Date: Sat, 19 Aug 2023 11:42:11 -0600 Message-ID: <20230819174900.866436-13-tom@tromey.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230819174900.866436-1-tom@tromey.com> References: <20230819174900.866436-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.142.177 X-Source-L: No X-Exim-ID: 1qXQ4X-003yKO-2V X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-142-177.hlrn.qwest.net (localhost.localdomain) [75.166.142.177]:36668 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJqMsFt4+pW0K4usH0PZT82HHihNrJ4ffdfIaET7Ftve/WHOVECl3yT4eNFgo6Fk6sAFCtm9KqUrDYTWZjvYZHJXk0NYXoasS8GSazWEUMLM3LXbpN7V JPzRxfnXcPa/N+ugn4PmfTL/QZ/5v5ZzyC7wVenaL8TantYmJYyXqSaXtMSoi7FCQmPZyZaHVzq92w== X-Spam-Status: No, score=-3025.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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