I should know this.
I want to configure and build gambit with maximum,maximum,maximum debugging info.
For example, when I add
-track-scheme -debug -debug-location -debug-source -debug-environments
to the gsc-boot line for converting .scm to .c files in lib/makefile, and I hit an error called on the routine at the bottom, I see
1> ,y 0 naive-div "lib/_num.scm"@9184.3 (apply error 'crap2 (map unveil-bignum (list normalizing-bit... 1> ,e n == 2 normalizing-bit-shift == 5 u2 == 2097152 v2 == 3200000000
but there are also other variables---u, v, iota, etc.---that are in the routine and don't show up in the environment.
Is it possible to get these?
I'm trying to debug a problem where ... well, you might not believe me, but it seems to be nasty.
Brad
#<procedure #2 naive-div> = (##lambda (u v) (define (iota n) (if (##fx= n 0) '() (cons (fx- n 1) (iota (fx- n 1))))) (or (and (##bignum? u) (##bignum? v)) (error 'crap u v)) '(pp 'naive-div-orig) '(pp (cons '##bignum.mdigit-length (map ##bignum.mdigit-length (list u v)))) '(pp (cons '##bignum.adigit-length (map ##bignum.adigit-length (list u v)))) '(pp (map unveil-bignum (list u v))) (let ((n (let loop1 ((i (##fixnum.- (##bignum.mdigit-length v) 1))) (if (##fixnum.< 0 (##bignum.mdigit-ref v i)) (##fixnum.+ i 1) (loop1 (##fixnum.- i 1)))))) (let ((normalizing-bit-shift (##fixnum.- ##bignum.mdigit-width (##integer-length (##bignum.mdigit-ref v (##fixnum.- n 1)))))) (let ((u2 (##bignum.arithmetic-shift u normalizing-bit-shift)) (v2 (##bignum.arithmetic-shift v normalizing-bit-shift))) (or (and (##bignum? u2) (##bignum? v2)) (let () '(pp '(list normalizing-bit-shift u v u2 v2)) (apply error 'crap2 (map unveil-bignum (list normalizing-bit-shift u v u2 v2))))) (let* ((u u2) (v v2) (q (##bignum.make (##fixnum.+ (##fixnum.- (##bignum.adigit-length u) (##bignum.adigit-length v)) 2) #f #f)) (v_n-1 (##bignum.mdigit-ref v (##fixnum.- n 1))) (v_n-2 (##bignum.mdigit-ref v (##fixnum.- n 2)))) (let ((m (let loop2 ((i (##fixnum.- (##bignum.mdigit-length u) 1))) (let ((u_i (##bignum.mdigit-ref u i))) (if (##fixnum.< 0 u_i) (if (##not (##fixnum.< u_i v_n-1)) (##fixnum.- (##fixnum.+ i 1) n) (##fixnum.- i n)) (loop2 (##fixnum.- i 1))))))) (let loop3 ((j m)) (if (##not (##fixnum.< j 0)) (let ((q-hat (let ((q-hat (##bignum.mdigit-quotient u (##fixnum.+ j n) v_n-1)) (u_n+j-2 (##bignum.mdigit-ref u (##fixnum.+ (##fixnum.- j 2) n)))) (let ((r-hat (##bignum.mdigit-remainder u (##fixnum.+ j n) v_n-1 q-hat))) (if (or (##fixnum.= q-hat ##bignum.mdigit-base) (##bignum.mdigit-test? q-hat v_n-2 r-hat u_n+j-2)) (let ((q-hat (##fixnum.- q-hat 1)) (r-hat (##fixnum.+ r-hat v_n-1))) (if (and (##fixnum.< r-hat ##bignum.mdigit-base) (or (##fixnum.= q-hat ##bignum.mdigit-base) (##bignum.mdigit-test? q-hat v_n-2 r-hat u_n+j-2))) (##fixnum.- q-hat 1) q-hat)) q-hat))))) (##declare (not interrupts-enabled)) (let loop4 ((i j) (k 0) (borrow 0)) (if (##fixnum.< k n) (loop4 (##fixnum.+ i 2) (##fixnum.+ k 2) (##bignum.mdigit-div! u (##fixnum.+ i 1) v (##fixnum.+ k 1) q-hat (##bignum.mdigit-div! u i v k q-hat borrow))) (let ((borrow (if (##fixnum.< n k) borrow (##bignum.mdigit-div! u i v k q-hat borrow)))) (if (##fixnum.< borrow 0) (let loop5 ((i j) (l 0) (carry 0)) (if (##fixnum.< n l) (begin (##bignum.mdigit-set! q j (##fixnum.- q-hat 1)) (loop3 (##fixnum.- j 1))) (loop5 (##fixnum.+ i 1) (##fixnum.+ l 1) (##bignum.mdigit-mul! u i v l 1 carry)))) (begin (##bignum.mdigit-set! q j q-hat) (loop3 (##fixnum.- j 1)))))))) (##cons (##bignum.normalize! q) (##arithmetic-shift (##bignum.normalize! u) (##fixnum.- normalizing-bit-shift)))))))))))
Afficher les réponses par date
Try:
(declare (not optimize-dead-local-variables))
This will ruin the "safety for space", but will greatly improve debugging. It won't get rid of variables that are no longer necessary by the program logic.
Marc
On 2013-09-28, at 9:33 PM, Bradley Lucier lucier@math.purdue.edu wrote:
I should know this.
I want to configure and build gambit with maximum,maximum,maximum debugging info.
For example, when I add
-track-scheme -debug -debug-location -debug-source -debug-environments
to the gsc-boot line for converting .scm to .c files in lib/makefile, and I hit an error called on the routine at the bottom, I see
1> ,y 0 naive-div "lib/_num.scm"@9184.3 (apply error 'crap2 (map unveil-bignum (list normalizing-bit... 1> ,e n == 2 normalizing-bit-shift == 5 u2 == 2097152 v2 == 3200000000
but there are also other variables---u, v, iota, etc.---that are in the routine and don't show up in the environment.
Is it possible to get these?
I'm trying to debug a problem where ... well, you might not believe me, but it seems to be nasty.
Brad
#<procedure #2 naive-div> = (##lambda (u v) (define (iota n) (if (##fx= n 0) '() (cons (fx- n 1) (iota (fx- n 1))))) (or (and (##bignum? u) (##bignum? v)) (error 'crap u v)) '(pp 'naive-div-orig) '(pp (cons '##bignum.mdigit-length (map ##bignum.mdigit-length (list u v)))) '(pp (cons '##bignum.adigit-length (map ##bignum.adigit-length (list u v)))) '(pp (map unveil-bignum (list u v))) (let ((n (let loop1 ((i (##fixnum.- (##bignum.mdigit-length v) 1))) (if (##fixnum.< 0 (##bignum.mdigit-ref v i)) (##fixnum.+ i 1) (loop1 (##fixnum.- i 1)))))) (let ((normalizing-bit-shift (##fixnum.- ##bignum.mdigit-width (##integer-length (##bignum.mdigit-ref v (##fixnum.- n 1)))))) (let ((u2 (##bignum.arithmetic-shift u normalizing-bit-shift)) (v2 (##bignum.arithmetic-shift v normalizing-bit-shift))) (or (and (##bignum? u2) (##bignum? v2)) (let () '(pp '(list normalizing-bit-shift u v u2 v2)) (apply error 'crap2 (map unveil-bignum (list normalizing-bit-shift u v u2 v2))))) (let* ((u u2) (v v2) (q (##bignum.make (##fixnum.+ (##fixnum.- (##bignum.adigit-length u) (##bignum.adigit-length v)) 2) #f #f)) (v_n-1 (##bignum.mdigit-ref v (##fixnum.- n 1))) (v_n-2 (##bignum.mdigit-ref v (##fixnum.- n 2)))) (let ((m (let loop2 ((i (##fixnum.- (##bignum.mdigit-length u) 1))) (let ((u_i (##bignum.mdigit-ref u i))) (if (##fixnum.< 0 u_i) (if (##not (##fixnum.< u_i v_n-1)) (##fixnum.- (##fixnum.+ i 1) n) (##fixnum.- i n)) (loop2 (##fixnum.- i 1))))))) (let loop3 ((j m)) (if (##not (##fixnum.< j 0)) (let ((q-hat (let ((q-hat (##bignum.mdigit-quotient u (##fixnum.+ j n) v_n-1)) (u_n+j-2 (##bignum.mdigit-ref u (##fixnum.+ (##fixnum.- j 2) n)))) (let ((r-hat (##bignum.mdigit-remainder u (##fixnum.+ j n) v_n-1 q-hat))) (if (or (##fixnum.= q-hat ##bignum.mdigit-base) (##bignum.mdigit-test? q-hat v_n-2 r-hat u_n+j-2)) (let ((q-hat (##fixnum.- q-hat 1)) (r-hat (##fixnum.+ r-hat v_n-1))) (if (and (##fixnum.< r-hat ##bignum.mdigit-base) (or (##fixnum.= q-hat ##bignum.mdigit-base) (##bignum.mdigit-test? q-hat v_n-2 r-hat u_n+j-2))) (##fixnum.- q-hat 1) q-hat)) q-hat))))) (##declare (not interrupts-enabled)) (let loop4 ((i j) (k 0) (borrow 0)) (if (##fixnum.< k n) (loop4 (##fixnum.+ i 2) (##fixnum.+ k 2) (##bignum.mdigit-div! u (##fixnum.+ i 1) v (##fixnum.+ k 1) q-hat (##bignum.mdigit-div! u i v k q-hat borrow))) (let ((borrow (if (##fixnum.< n k) borrow (##bignum.mdigit-div! u i v k q-hat borrow)))) (if (##fixnum.< borrow 0) (let loop5 ((i j) (l 0) (carry 0)) (if (##fixnum.< n l) (begin (##bignum.mdigit-set! q j (##fixnum.- q-hat 1)) (loop3 (##fixnum.- j 1))) (loop5 (##fixnum.+ i 1) (##fixnum.+ l 1) (##bignum.mdigit-mul! u i v l 1 carry)))) (begin (##bignum.mdigit-set! q j q-hat) (loop3 (##fixnum.- j 1)))))))) (##cons (##bignum.normalize! q) (##arithmetic-shift (##bignum.normalize! u) (##fixnum.- normalizing-bit-shift)))))))))))
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list