Re: [racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-21 Thread thomas.lynch

> 
> The calls that are missing appear to tail calls, and Racket performs
> tail-call optimization, so I imagine those missing functions are not
> really "on the stack" at the time of the error.
> 
> I don't know that there is a way around this except to deliberately
> subvert the tail-call optimization.
> 
> Otherwise, contracts would presumably help for this particular type of
> error.
> 
> Hopefully someone can correct me if I'm off the mark, or maybe provide
> more detail if I happen to be right.
> 
> David

David, you are right! See below, where I added additional calls after the tail 
calls, and routines appear in the function back trace.

So how do we turn optimization off so we can get an accurate trace?

The code-test-debug cycle is taking too long with Racket because of these 
poorly located error messages and the weak debug environment.  Making macros 
longer doesn't releieve Racket from having to provide these things.

;; bt2-ex-fun3.rkt:
;;
  #lang racket

  (define (h x y) (+ x y))

  (define (hh x y) (h x y))

  (define (f x y)
(gg x y)
(h 0 1)
)

  (define (gg x y) 
(define z 7)
(set! z (h 5 0))
(g (- x z) y)
(h (+ x z) 7)
(hh 2 0)
)

  (define zz 5)

  (define (g x y)
(hh (+ x (h zz 0)) y)
)

  (f 3 5)
  (f 3 'a)

#|

§> racket -l errortrace -t bt2-ex-fun3.rkt
1
+: contract violation
  expected: number?
  given: 'a
  argument position: 2nd
  other arguments...:
   3
  errortrace...:
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt:6:18: (+ x y)
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt:15:2: (define (gg x y) 
(define z 7) (set! z (h 5 0)) (g (- x z) y) (h (+ x ) 7) (hh 2 0))
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt:30:2: (f 3 (quote a))
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt:30:2: (f 3 (quote a))
  context...:
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt:6:2: h
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt:15:2: gg
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt:10:2: f
   /home/deep/3_doc/racket_err_mess/bt2-ex-fun3.rkt: [running body]

|#

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-21 Thread David T. Pierson
On Thu, Nov 19, 2015 at 09:04:49PM -0800, thomas.lynch wrote:
> I have a related question.  I turned on error trace using the command line 
> Robby
> suggested, but it doesn't give me a trace, but rather just the call point and 
> error function.  Here is an example, the trace should be f -> gg -> g -> hh 
> -> h then bang, the error.   But instead Racket shows me f -> + bang,  "in 
> context of h".  But which 'h' it is called many times (and in a big project 
> many many times).
> 
> How do you turn on tracing?  Is there another switch, or if I go interactive 
> is there a command which will give me the trace?

I am not an expert in this area, so take this only as a possible hint.

The calls that are missing appear to tail calls, and Racket performs
tail-call optimization, so I imagine those missing functions are not
really "on the stack" at the time of the error.

I don't know that there is a way around this except to deliberately
subvert the tail-call optimization.

Otherwise, contracts would presumably help for this particular type of
error.

Hopefully someone can correct me if I'm off the mark, or maybe provide
more detail if I happen to be right.

David

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-19 Thread thomas.lynch


I have a related question.  I turned on error trace using the command line Robby
suggested, but it doesn't give me a trace, but rather just the call point and 
error function.  Here is an example, the trace should be f -> gg -> g -> hh -> 
h then bang, the error.   But instead Racket shows me f -> + bang,  "in context 
of h".  But which 'h' it is called many times (and in a big project many many 
times).

How do you turn on tracing?  Is there another switch, or if I go interactive is 
there a command which will give me the trace?


;; bt2-ex-fun2.rkt:
;;
  #lang racket

  (define (h x y) (+ x y))

  (define (hh x y) (h x y))

  (define (f x y)
(gg x y)
)

  (define (gg x y) 
(define z 7)
(set! z (h 5 0))
(g (- x z) y)
)

  (define zz 5)

  (define (g x y)
(hh (+ x (h zz 0)) y)
)

  (f 3 5)
  (f 3 'a)

  #| result:

  §> racket -l errortrace -t bt2-ex-fun2.rkt 
  8
  +: contract violation
expected: number?
given: 'a
argument position: 2nd
other arguments...:
 3
errortrace...:
 /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt:3:16: (+ x y)
 /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt:24:0: (f 3 (quote a))
context...:
 /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt:3:0: h
 /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt: [running body]

  §> 

  |#














On Thursday, November 12, 2015 at 5:19:20 PM UTC, Matthew Flatt wrote:
> At Sun, 8 Nov 2015 21:56:04 -0500, Ben Lerner wrote:
> > 
> > On 11/8/2015 9:18 PM, Nota Poin wrote:
> > >> Or if you insist on command line usage, use error trace.
> > > What's wrong with command line usage? Anyway, I was going to say this:
> > >
> > > http://docs.racket-lang.org/errortrace/using-errortrace.html
> > >
> > > That seems to enable stack traces that work.
> > >
> > Relatedly, is there a way to use this stacktrace mechanism with 
> > scribble?  That is, can I write `scribble -l errortrace  > files>` or `racket -l errortrace  
> > `, or would that not work out for some reason?
> 
> For errors while a document is constructed, just running
> 
>  racket -l errortrace -t 
> 
> would work, since a Scribble document is a Racket program.
> 
> 
> For an error that happens only during rendering, you could use
> 
>  racket -l errortrace -l scribble/run 
> 
> since the `scribble` program just runs the `scribble/run` module.
> 
> I'm not sure why it's `scribble/run` instead of just `scribble`, and
> maybe it's worth adding a `scribble` module as an alias. I'll think
> about that more, in case there was a reason that I've forgotten.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-12 Thread Matthew Flatt
At Sun, 8 Nov 2015 21:56:04 -0500, Ben Lerner wrote:
> 
> On 11/8/2015 9:18 PM, Nota Poin wrote:
> >> Or if you insist on command line usage, use error trace.
> > What's wrong with command line usage? Anyway, I was going to say this:
> >
> > http://docs.racket-lang.org/errortrace/using-errortrace.html
> >
> > That seems to enable stack traces that work.
> >
> Relatedly, is there a way to use this stacktrace mechanism with 
> scribble?  That is, can I write `scribble -l errortrace  files>` or `racket -l errortrace  
> `, or would that not work out for some reason?

For errors while a document is constructed, just running

 racket -l errortrace -t 

would work, since a Scribble document is a Racket program.


For an error that happens only during rendering, you could use

 racket -l errortrace -l scribble/run 

since the `scribble` program just runs the `scribble/run` module.

I'm not sure why it's `scribble/run` instead of just `scribble`, and
maybe it's worth adding a `scribble` module as an alias. I'll think
about that more, in case there was a reason that I've forgotten.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-08 Thread Nota Poin
I'll have code like this:

#lang racket/base

(define (baz foo)
  (error 'whoops))

(define (bar ber)
  (baz ber))

(define (foo ber)
  (let ((a 3))
(if (and
 (= a 3)
 (= (* a 9) 27)
 (bar ber)
 (list? (list 1 2 3 4)))
ber
(not ber

(foo 42)

And I get an error message like this:

error: whoops
  context...:
   /extra/user/code/racket-stack.rkt: [running body]

That doesn't show the line number on which the error occurred, or even the 
location of the expression being evaluated. For a custom error, I could just 
grep through the code for "whoops", but for say an error like "string-append: 
contract violation" I may have many uses of string-append, and I might not be 
able to debug them if I can't tell what context they're being being evaluated 
in.

How do I enable uh, "working" stack traces? --no-jit just removes stack traces 
entirely. -W debug says the functions are being inlined, but doesn't debug info 
for the inlining specify what function was inlined? racket has no debug flag 
that I can find. Setting --disable-inline in raco and running the bytecode 
produces no information in the stack trace either.

Sometimes (unpredictably AFAIK) I do get /some/ line information, but it's at 
most the function that the error happened in, not the error itself which could 
be anywhere inside it or any inlined function.

$ racket -V 
Welcome to Racket v6.2.1.

Please tell me I'm not gonna have to say Guido was right...

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-08 Thread Nota Poin
On Monday, November 9, 2015 at 1:38:56 AM UTC, Matthias Felleisen wrote:
> Use drracket. 
Yeah, I would, but it takes about 30 seconds to start up if I disable all the 
extensions, add another 10 or 20 for the debugger, and then when I type it lags 
behind at about 0.25s per character. Also it consumes huge amounts of memory, 
and that seems to increase without bounds if you leave it open.

> Or if you insist on command line usage, use error trace. 
What's wrong with command line usage? Anyway, I was going to say this:

http://docs.racket-lang.org/errortrace/using-errortrace.html

That seems to enable stack traces that work.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-08 Thread Ben Lerner


On 11/8/2015 9:18 PM, Nota Poin wrote:

Or if you insist on command line usage, use error trace.

What's wrong with command line usage? Anyway, I was going to say this:

http://docs.racket-lang.org/errortrace/using-errortrace.html

That seems to enable stack traces that work.

Relatedly, is there a way to use this stacktrace mechanism with 
scribble?  That is, can I write `scribble -l errortrace files>` or `racket -l errortrace  
`, or would that not work out for some reason?


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to get information about where an error occurs, in a stack trace context?

2015-11-08 Thread Robby Findler
How much memory do you have on your machine? 0.25 seconds per
keystroke sounds worse than expected.

Robby

On Sun, Nov 8, 2015 at 8:18 PM, Nota Poin  wrote:
> On Monday, November 9, 2015 at 1:38:56 AM UTC, Matthias Felleisen wrote:
>> Use drracket.
> Yeah, I would, but it takes about 30 seconds to start up if I disable all the 
> extensions, add another 10 or 20 for the debugger, and then when I type it 
> lags behind at about 0.25s per character. Also it consumes huge amounts of 
> memory, and that seems to increase without bounds if you leave it open.
>
>> Or if you insist on command line usage, use error trace.
> What's wrong with command line usage? Anyway, I was going to say this:
>
> http://docs.racket-lang.org/errortrace/using-errortrace.html
>
> That seems to enable stack traces that work.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.