List Info

Thread: "ocaml_beginners"::[] stack backtrace




"ocaml_beginners"::[] stack backtrace
country flaguser name
United States
2007-08-26 20:18:28

From the description of the Ocaml 3.10 release:

"Printing of stack backtraces on uncaught exceptions, previously
available only for bytecode-compiled programs, "

I have inferred that my own version 3.09.3 release should print out a
backtrace for an out of bounds index into an array. Is this the case?
If so how do I turn on this feature?

For example, here is a trivial program:

<BEGIN>
open Printf;;

printf "starting testn";;;

let array = Array.create 10 0;;

printf "first number: %dn" array.(0);;
printf "this should produce an error %dn" array.(11);;

printf "end of testn";;;
<END>

which I compile with the -g option (because I thought maybe -g would
turn this feature on.

&lt;BEGIN>;
make[1]: Entering directory `/home/ais/workspace/ocode'
ocamldep test.ml > ._d/test.d
make[1]: Leaving directory `/home/ais/workspace/ocode'
make[1]: Entering directory `/home/ais/workspace/ocode'
ocamlc -g -c test.ml
ocamlc -g

-o foo
test.cmo
make[1]: Leaving directory `/home/ais/workspace/ocode'
aisubuntu:~/workspace/ocode$
<END>

Then I run the program:

aisubuntu:~/workspace/ocode$ ./foo
starting test
first number: 0
Fatal error: exception Invalid_argument(&quot;index out of bounds&quot;)
aisubuntu:~/workspace/ocode$

No stack backtrace. Am I missing something?

Thanks in advance for any suggestions,

Andrew

__._,_.___
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

New business?

Get new customers.

List your web site

in Yahoo! Search.

Find Enlightenment

Yoga groups and

resources on

Yahoo! Groups.

"ocaml_beginners"::[] Re: stack backtrace
country flaguser name
United States
2007-08-26 20:58:54

You do have to compile with -g. Then run your program through ocamlrun
with the -b option. Like this:
$ ocamlrun -b foo

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )