|Anonymous | Login | Signup for a new account||2015-03-30 16:16 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0004880||OCaml||OCaml general||public||2009-10-01 12:20||2012-09-25 20:07|
|Platform||Windows||OS||Windows XP + VC8||OS Version||CXP, SP3|
|Target Version||Fixed in Version||3.13.0+dev|
|Summary||0004880: caml_print_exception_backtrace do not print backtrace when main program is C|
|Description||This is a regression with 3.10.0.|
When program is in CAML, call of "Printexc.record_backtrace true" triggers the printing of stack when exception are uncaught.
When main program is C or C++, backtrace are not printed anymore.
|Tags||No tags attached.|
|Attached Files|| caml_from_c.zip [^] (3,251 bytes) 2009-10-01 12:20|
caml_from_c2.zip [^] (4,089 bytes) 2009-10-01 16:56
After deeper analysis, it appears that :
1) for bytecode compiler, it is not a regression : printing backtrace from c never worked. (unzip attach file caml_from_c2.zip and type make byte_dll.exe)
2) for native compiler, I was able to print backtrace with the toy example. Within the whole application, I found a hack to print the back trace : just after caml_startup, I'v added the folowwing line "caml_backtrace_active = 1;", which replace the call to "//caml_init_backtrace();" in ocaml3.10
Is it the good hack?
In OCaml 3.11, you can either
- call "Printexc.record_backtrace true" from your Caml code, e.g. in the initialization of one of your Caml modules,
- or call "caml_record_backtrace(Val_int(1));" from your C code.
In native code, this will produce backtraces even if your Caml code is embedded in C.
Seeting "caml_backtrace_active = 1;" is a little bit less safe than calling "caml_record_backtrace". The stakes are low (a re-raise of an exception can be confused for an initial raise), but better go through the function.
In bytecode, this is not supported: the C object file produced by ocamlc -output-obj does not contain the debugging information associated to the corresponding bytecode.
Finally, your example shows that the exception raising in an "assert" construct lacks debugging information when compiled with the native-code compiler, which results in a less precise backtrace than for a regular "raise". In other terms, your example works better if "assert false" is replaced by "raise (Failure "foo")". I'll investigate this further.
Sorry for the long long delay to answer. That works.
Is it possible to include these advice in the official doc ?
Mentioned the backtrace trick in the manual (commit 11892).
Fixed the compiler so that "assert" constructs carry the debugging info needed for them to appear properly in stack backtraces (commit 11891 in SVN trunk).
|2009-10-01 12:20||daweil||New Issue|
|2009-10-01 12:20||daweil||File Added: caml_from_c.zip|
|2009-10-01 16:56||daweil||Note Added: 0005126|
|2009-10-01 16:56||daweil||File Added: caml_from_c2.zip|
|2010-04-18 15:05||xleroy||Status||new => assigned|
|2010-04-18 15:05||xleroy||Assigned To||=> xleroy|
|2010-04-28 15:06||xleroy||Note Added: 0005404|
|2010-08-31 16:16||daweil||Note Added: 0005647|
|2011-12-20 11:46||xleroy||Note Added: 0006406|
|2011-12-20 11:46||xleroy||Status||assigned => resolved|
|2011-12-20 11:46||xleroy||Resolution||open => fixed|
|2011-12-20 11:46||xleroy||Fixed in Version||=> 3.13.0+dev|
|2012-09-25 20:07||xleroy||Status||resolved => closed|
|Copyright © 2000 - 2011 MantisBT Group|