Revu l'initialisation de verb_gc. Ajout de messages de trace pour attempt_open

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3419 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2001-02-19 10:01:41 +00:00
parent b594c39052
commit d130e50285
5 changed files with 31 additions and 23 deletions

View File

@ -380,7 +380,7 @@ value gc_compaction(value v) /* ML */
void init_gc (unsigned long minor_size, unsigned long major_size,
unsigned long major_incr, unsigned long percent_fr,
unsigned long percent_m, unsigned long verb)
unsigned long percent_m)
{
unsigned long major_heap_size = Bsize_wsize (norm_heapincr (major_size));
@ -392,7 +392,6 @@ void init_gc (unsigned long minor_size, unsigned long major_size,
"###\n", 0);
#endif
verb_gc = verb;
set_minor_heap_size (Bsize_wsize (norm_minsize (minor_size)));
major_heap_increment = Bsize_wsize (norm_heapincr (major_incr));
percent_free = norm_pfree (percent_fr);

View File

@ -29,7 +29,7 @@ extern long
stat_compactions;
void init_gc (unsigned long, unsigned long, unsigned long,
unsigned long, unsigned long, unsigned long);
unsigned long, unsigned long);
#ifdef DEBUG

View File

@ -31,7 +31,7 @@ void caml_failed_assert (char * expr, char * file, int line)
#endif
int verb_gc;
unsigned long verb_gc = 0;
void gc_message (int level, char *msg, unsigned long arg)
{

View File

@ -56,7 +56,7 @@ void fatal_error_arg (char *, char *) Noreturn;
/* GC flags and messages */
extern int verb_gc;
extern unsigned long verb_gc;
void gc_message (int, char *, unsigned long);
/* Memory routines */

View File

@ -67,8 +67,7 @@ static void init_atoms(void)
/* Read the trailer of a bytecode file */
#define FILE_NOT_FOUND (-1)
#define TRUNCATED_FILE (-2)
#define BAD_MAGIC_NUM (-3)
#define BAD_BYTECODE (-2)
static void fixup_endianness_trailer(uint32 * p)
{
@ -81,12 +80,12 @@ static int read_trailer(int fd, struct exec_trailer *trail)
{
lseek(fd, (long) -TRAILER_SIZE, SEEK_END);
if (read(fd, (char *) trail, TRAILER_SIZE) < TRAILER_SIZE)
return TRUNCATED_FILE;
return BAD_BYTECODE;
fixup_endianness_trailer(&trail->num_sections);
if (strncmp(trail->magic, EXEC_MAGIC, 12) == 0)
return 0;
else
return BAD_MAGIC_NUM;
return BAD_BYTECODE;
}
static int attempt_open(char **name, struct exec_trailer *trail,
@ -99,15 +98,27 @@ static int attempt_open(char **name, struct exec_trailer *trail,
truename = searchpath(*name);
if (truename == 0) truename = *name; else *name = truename;
gc_message(0x100, "Opening bytecode executable %s\n",
(unsigned long) truename);
fd = open(truename, O_RDONLY | O_BINARY);
if (fd == -1) return FILE_NOT_FOUND;
if (!do_open_script){
if (fd == -1) {
gc_message(0x100, "Cannot open file\n", 0);
return FILE_NOT_FOUND;
}
if (!do_open_script) {
err = read (fd, buf, 2);
if (err < 2) { close(fd); return TRUNCATED_FILE; }
if (buf [0] == '#' && buf [1] == '!') { close(fd); return BAD_MAGIC_NUM; }
if (err < 2 || (buf [0] == '#' && buf [1] == '!')) {
close(fd);
gc_message(0x100, "Rejected #! script\n", 0);
return BAD_BYTECODE;
}
}
err = read_trailer(fd, trail);
if (err != 0) { close(fd); return err; }
if (err != 0) {
close(fd);
gc_message(0x100, "Not a bytecode executable\n", 0);
return err;
}
return fd;
}
@ -198,7 +209,6 @@ Algorithm:
/* Configuration parameters and flags */
static unsigned long verbose_init = 0;
static unsigned long percent_free_init = Percent_free_def;
static unsigned long max_percent_free_init = Max_percent_free_def;
static unsigned long minor_heap_init = Minor_heap_def;
@ -225,7 +235,7 @@ static int parse_command_line(char **argv)
break; }
#endif
case 'v':
verbose_init = 1+4+8+16+32;
verb_gc = 1+4+8+16+32;
break;
case 'p':
for (j = 0; names_of_cprim[j] != NULL; j++)
@ -269,7 +279,7 @@ static void parse_camlrunparam(void)
case 'l': scanmult (opt, &max_stack_init); break;
case 'o': scanmult (opt, &percent_free_init); break;
case 'O': scanmult (opt, &max_percent_free_init); break;
case 'v': scanmult (opt, &verbose_init); break;
case 'v': scanmult (opt, &verb_gc); break;
}
}
}
@ -298,7 +308,7 @@ void caml_main(char **argv)
external_raise = NULL;
/* Determine options and position of bytecode file */
#ifdef DEBUG
verbose_init = 63;
verb_gc = 63;
#endif
parse_camlrunparam();
pos = 0;
@ -312,8 +322,7 @@ void caml_main(char **argv)
case FILE_NOT_FOUND:
fatal_error_arg("Fatal error: cannot find file %s\n", argv[pos]);
break;
case TRUNCATED_FILE:
case BAD_MAGIC_NUM:
case BAD_BYTECODE:
fatal_error_arg(
"Fatal error: the file %s is not a bytecode executable file\n",
argv[pos]);
@ -324,7 +333,7 @@ void caml_main(char **argv)
read_section_descriptors(fd, &trail);
/* Initialize the abstract machine */
init_gc (minor_heap_init, heap_size_init, heap_chunk_init,
percent_free_init, max_percent_free_init, verbose_init);
percent_free_init, max_percent_free_init);
init_stack (max_stack_init);
init_atoms();
/* Initialize the interpreter */
@ -373,13 +382,13 @@ void caml_startup_code(code_t code, asize_t code_size, char *data, char **argv)
init_ieee_floats();
#ifdef DEBUG
verbose_init = 63;
verb_gc = 63;
#endif
parse_camlrunparam();
external_raise = NULL;
/* Initialize the abstract machine */
init_gc (minor_heap_init, heap_size_init, heap_chunk_init,
percent_free_init, max_percent_free_init, verbose_init);
percent_free_init, max_percent_free_init);
init_stack (max_stack_init);
init_atoms();
/* Initialize the interpreter */