| Anonymous | Login | Signup for a new account | 2010-02-10 00:36 CET |
| Main | My View | View Issues | Change Log | Roadmap | Docs |
| Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||
| ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
| 0003885 | [OCaml] OCaml general | feature | N/A | 2005-11-22 17:11 | 2008-12-12 09:56 | ||||
| Reporter | mottl | View Status | public | ||||||
| Assigned To | xleroy | ||||||||
| Priority | normal | Resolution | fixed | ||||||
| Status | closed | Product Version | 3.09.0 | ||||||
| Summary | 0003885: Compiler patch for native code function backtraces | ||||||||
| Description |
One missing feature of OCaml that makes it less useful in production code for long-running, mission-critical systems is that it is difficult to find out the reasons for crashes due to uncaught exceptions. We have now created a patch for the most recent CVS-snapshot of the OCaml-compiler that allow users to get a backtrace at runtime about the last functions called. This is not the same as a stack backtrace. Sometimes it is more useful, sometimes less. But it is usually sufficient to find out what was going on shortly before an unexpected exception escaped a part of code or the whole program. This feature is thread-safe: each thread maintains its own backtrace buffer. There is always a (though very small) performance overhead for calling functions that were compiled with backtracing. Inlined functions are not traced (and hence have no call-overhead). If the program neither uses threads nor backtracing, there is never any kind of performance penalty. If threads are used, there is always a tiny penalty for thread creation/termination (due to (de)allocation of backtrace buffers), and for context switches (blitting of backtrace buffers). If backtracing is turned off, this penalty is reduced to only one instruction (for checking the backtracing flag). The large overhead that naturally comes with these thread operations renders the tiny additional overhead practically unmeasurable. This patch does the following: * add a code generation module asmcomp/cmmgen_bt.ml which generates code for functions that should be traced. This module is thoroughly documented. * small patch to asmcomp/cmmgen.ml to call code generation for backtraces if demanded by the command line flags. * adds runtime argument "b" to "startup.c" to turn on backtracing. * adds functions to "printexc.{c,h,ml,mli}" to print backtraces to stderr, or to get an array of strings denoting the last functions called. * adds command-line argument "-gb" to "optmain.ml" and "clflags.{ml,mli}" to compile a module with code for backtracing. * larger patch to "otherlibs/systhreads/posix.c" such that each thread maintains its own backtrace ring buffer. * some small patches to Makefiles We would be very grateful if this patch could be incorporated into the next OCaml-release, because it would make debugging long-running production code considerably easier. Of course, feel free to make any changes to it that you see fit for making it even more useful. Best regards, Markus |
||||||||
| Additional Information | |||||||||
| Tags | No tags attached. | ||||||||
| Attached Files |
|
||||||||
|
|
|||||||||
| Copyright © 2000 - 2008 Mantis Group |