summaryrefslogtreecommitdiff
path: root/byterun/startup.c
diff options
context:
space:
mode:
authorLuc Maranget <luc.maranget@inria.fr>2010-01-25 14:52:00 +0000
committerLuc Maranget <luc.maranget@inria.fr>2010-01-25 14:52:00 +0000
commite7ada9b93a02d39cd62f6fd7d9f629429ef51273 (patch)
tree0d5771c12e6ab43afb23e5976c1ab35686a66b30 /byterun/startup.c
parent924e832b687e914f4173bb52ec39806b1b6192a8 (diff)
downloadocaml-jo311.tar.gz
Preparing relase 3.11.2jo311
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/jo311@9590 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/startup.c')
-rw-r--r--byterun/startup.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/byterun/startup.c b/byterun/startup.c
index 34d6f315c9..419d49be60 100644
--- a/byterun/startup.c
+++ b/byterun/startup.c
@@ -439,12 +439,18 @@ CAMLexport void caml_startup_code(
char **argv)
{
value res;
+ char* cds_file;
caml_init_ieee_floats();
caml_init_custom_operations();
#ifdef DEBUG
caml_verb_gc = 63;
#endif
+ cds_file = getenv("CAML_DEBUG_FILE");
+ if (cds_file != NULL) {
+ caml_cds_file = caml_stat_alloc(strlen(cds_file) + 1);
+ strcpy(caml_cds_file, cds_file);
+ }
parse_camlrunparam();
caml_external_raise = NULL;
/* Initialize the abstract machine */
@@ -454,8 +460,17 @@ CAMLexport void caml_startup_code(
init_atoms();
/* Initialize the interpreter */
caml_interprete(NULL, 0);
+ /* Initialize the debugger, if needed */
+ caml_debugger_init();
/* Load the code */
caml_start_code = code;
+ caml_code_size = code_size;
+ if (caml_debugger_in_use) {
+ int len, i;
+ len = code_size / sizeof(opcode_t);
+ caml_saved_code = (unsigned char *) caml_stat_alloc(len);
+ for (i = 0; i < len; i++) caml_saved_code[i] = caml_start_code[i];
+ }
#ifdef THREADED_CODE
caml_thread_code(caml_start_code, code_size);
#endif
@@ -469,10 +484,19 @@ CAMLexport void caml_startup_code(
/* Record the sections (for caml_get_section_table in meta.c) */
caml_section_table = section_table;
caml_section_table_size = section_table_size;
- /* Run the code */
+ /* Initialize system libraries */
caml_init_exceptions();
caml_sys_init("", argv);
- res = caml_interprete(caml_start_code, code_size);
- if (Is_exception_result(res))
- caml_fatal_uncaught_exception(Extract_exception(res));
+ /* Execute the program */
+ caml_debugger(PROGRAM_START);
+ res = caml_interprete(caml_start_code, caml_code_size);
+ if (Is_exception_result(res)) {
+ caml_exn_bucket = Extract_exception(res);
+ if (caml_debugger_in_use) {
+ caml_extern_sp = &caml_exn_bucket; /* The debugger needs the
+ exception value.*/
+ caml_debugger(UNCAUGHT_EXC);
+ }
+ caml_fatal_uncaught_exception(caml_exn_bucket);
+ }
}