Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a stack trace in OCaml?

The Objective Caml language will only produce stack traces if you ask for them just right - what are the requirements for both bytecode and native code?

like image 892
Thelema Avatar asked Sep 28 '08 13:09

Thelema


People also ask

How do I get a stack trace?

You can obtain a stack trace from a thread – by calling the getStackTrace method on that Thread instance. This invocation returns an array of StackTraceElement, from which details about stack frames of the thread can be extracted.

How do I print current stack trace?

Just use new Throwable(). printStackTrace() method and it will print complete stack trace from where a method is called, into the console.

How can I check my browser stack trace?

You can easily see the stack trace in JavaScript by adding the following into your code: console. trace(); And you'll get an outputted stack trace.


2 Answers

Compile with -g and set environment variable OCAMLRUNPARAM=b

like image 102
Thelema Avatar answered Sep 16 '22 13:09

Thelema


Some Printexc functions let you do this programmatically.

like image 31
Tobu Avatar answered Sep 20 '22 13:09

Tobu