From 78de99ecc2f1d4e1b83b85c1be922acae4d174a5 Mon Sep 17 00:00:00 2001 From: Jacques-Henri Jourdan Date: Tue, 16 Jul 2019 13:42:04 +0200 Subject: [PATCH] Xavier Clerc's remarks. --- debugger/breakpoints.ml | 4 +++- debugger/breakpoints.mli | 4 ++-- debugger/symbols.ml | 5 +---- manual/manual/cmds/debugger.etex | 2 +- runtime/caml/misc.h | 3 +-- runtime/debugger.c | 6 ++++++ runtime/misc.c | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/debugger/breakpoints.ml b/debugger/breakpoints.ml index dfbf41009..f37552821 100644 --- a/debugger/breakpoints.ml +++ b/debugger/breakpoints.ml @@ -122,7 +122,9 @@ let update_breakpoints () = let execute_without_breakpoints f = Misc.protect_refs [Misc.R (Debugger_config.break_on_load, false); Misc.R (current_version, 0); - Misc.R (positions, [])] + Misc.R (positions, []); + Misc.R (breakpoints, []); + Misc.R (breakpoint_number, 0)] f (* Add a position in the position list. *) diff --git a/debugger/breakpoints.mli b/debugger/breakpoints.mli index 623c0ef3f..d26d9b241 100644 --- a/debugger/breakpoints.mli +++ b/debugger/breakpoints.mli @@ -31,7 +31,7 @@ val breakpoints : (breakpoint_id * Events.code_event) list ref val breakpoint_at_pc : Debugcom.pc -> bool (* List of breakpoints at `pc'. *) -val breakpoints_at_pc : Debugcom.pc -> int list +val breakpoints_at_pc : Debugcom.pc -> breakpoint_id list (*** Set and remove breakpoints ***) @@ -46,7 +46,7 @@ val execute_without_breakpoints : (unit -> unit) -> unit val new_breakpoint : Events.code_event -> unit (* Remove a breakpoint from lists. *) -val remove_breakpoint : int -> unit +val remove_breakpoint : breakpoint_id -> unit val remove_all_breakpoints : unit -> unit diff --git a/debugger/symbols.ml b/debugger/symbols.ml index 6cb49c1ea..8ed9b9db7 100644 --- a/debugger/symbols.ml +++ b/debugger/symbols.ml @@ -29,8 +29,6 @@ let modules = let program_source_dirs = ref ([] : string list) -let events = - ref ([] : debug_event list) let events_by_pc = (Hashtbl.create 257 : (pc, debug_event) Hashtbl.t) let events_by_module = @@ -96,7 +94,7 @@ let read_symbols' bytecode_file = !eventlists, !dirs let clear_symbols () = - modules := []; events := []; + modules := []; program_source_dirs := []; Hashtbl.clear events_by_pc; Hashtbl.clear events_by_module; Hashtbl.clear all_events_by_module @@ -106,7 +104,6 @@ let add_symbols frag all_events = (fun evl -> List.iter (fun ev -> - events := ev :: !events; Hashtbl.add events_by_pc {frag; pos = ev.ev_pos} ev) evl) all_events; diff --git a/manual/manual/cmds/debugger.etex b/manual/manual/cmds/debugger.etex index 363911e22..e51822d20 100644 --- a/manual/manual/cmds/debugger.etex +++ b/manual/manual/cmds/debugger.etex @@ -538,7 +538,7 @@ external module is not yet loaded, it is impossible to set a breakpoint in its code. In order to facilitate setting breakpoints in dynamically loaded code, the debugger stops the program each time new modules are loaded. This behavior can be disabled using the -"break_on_load" variable: +\var{break_on_load} variable: \begin{options} \item["set break_on_load" \var{on/off}] diff --git a/runtime/caml/misc.h b/runtime/caml/misc.h index 5a0555585..2132d54a5 100644 --- a/runtime/caml/misc.h +++ b/runtime/caml/misc.h @@ -444,7 +444,6 @@ extern void caml_instr_atexit (void); #endif /* A table of all code fragments (main program and dynlinked modules) */ - struct code_fragment { char *code_start; char *code_end; @@ -454,7 +453,7 @@ struct code_fragment { extern struct ext_table caml_code_fragments_table; -int caml_find_code_fragment(char* pc, int *index, struct code_fragment **cf); +int caml_find_code_fragment(char *pc, int *index, struct code_fragment **cf); #endif /* CAML_INTERNALS */ diff --git a/runtime/debugger.c b/runtime/debugger.c index ab66a0808..271a283c1 100644 --- a/runtime/debugger.c +++ b/runtime/debugger.c @@ -386,20 +386,26 @@ void caml_debugger(enum event_kind event, value param) /* Report the event to the debugger */ switch(event) { case PROGRAM_START: /* Nothing to report */ + CAMLassert (param == Val_unit); goto command_loop; case EVENT_COUNT: + CAMLassert (param == Val_unit); caml_putch(dbg_out, REP_EVENT); break; case BREAKPOINT: + CAMLassert (param == Val_unit); caml_putch(dbg_out, REP_BREAKPOINT); break; case PROGRAM_EXIT: + CAMLassert (param == Val_unit); caml_putch(dbg_out, REP_EXITED); break; case TRAP_BARRIER: + CAMLassert (param == Val_unit); caml_putch(dbg_out, REP_TRAP); break; case UNCAUGHT_EXC: + CAMLassert (param == Val_unit); caml_putch(dbg_out, REP_UNCAUGHT_EXC); break; case DEBUG_INFO_ADDED: diff --git a/runtime/misc.c b/runtime/misc.c index 013959910..461812504 100644 --- a/runtime/misc.c +++ b/runtime/misc.c @@ -282,7 +282,7 @@ void caml_instr_atexit (void) } #endif /* CAML_INSTR */ -int caml_find_code_fragment(char* pc, int *index, struct code_fragment **cf) +int caml_find_code_fragment(char *pc, int *index, struct code_fragment **cf) { struct code_fragment *cfi; int i;