diff options
| author | Xavier Leroy <xavier.leroy@inria.fr> | 1997-06-13 15:50:32 +0000 |
|---|---|---|
| committer | Xavier Leroy <xavier.leroy@inria.fr> | 1997-06-13 15:50:32 +0000 |
| commit | 967558958ca72cb75f308593f4c839b40f2a824d (patch) | |
| tree | 7c9cb0f5b4a7cf61166599764c87acf0ec028f99 /debugger/main.ml | |
| parent | c99916fdb9585905e9545584167b8f680e15ff96 (diff) | |
| download | ocaml-967558958ca72cb75f308593f4c839b40f2a824d.tar.gz | |
symbols: nouveau format d'executable.
main: parsing des arguments sur la ligne de commande revu.
command_line: meilleur message d'aide pour "break".
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1595 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'debugger/main.ml')
| -rw-r--r-- | debugger/main.ml | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/debugger/main.ml b/debugger/main.ml index 1c8750219f..ce6ca3d5d9 100644 --- a/debugger/main.ml +++ b/debugger/main.ml @@ -75,10 +75,12 @@ let rec protect cont = let toplevel_loop () = protect loop +(* Parsing of command-line arguments *) + +exception Found_program_name + let anonymous s = - if !program_name = "" - then program_name := s - else arguments := Printf.sprintf "%s '%s'" !arguments s + program_name := s; raise Found_program_name let add_include d = default_load_path := d :: !default_load_path let set_socket s = @@ -90,22 +92,35 @@ let set_directory dir = let set_emacs () = emacs := true +let speclist = + ["-I", Arg.String add_include, + "<dir> Add <dir> to the list of include directories"; + "-s", Arg.String set_socket, + "<filename> Set the name of the communication socket"; + "-c", Arg.Int set_checkpoints, + "<count> Set max number of checkpoints kept"; + "-cd", Arg.String set_directory, + "<dir> Change working directory"; + "-emacs", Arg.Unit set_emacs, + "For running the debugger under emacs"] + let main () = try socket_name := "/tmp/camldebug" ^ (string_of_int (Unix.getpid ())); - Arg.parse - ["-I", Arg.String add_include, - "<dir> Add <dir> to the list of include directories"; - "-s", Arg.String set_socket, - "<filename> Set the name of the communication socket"; - "-c", Arg.Int set_checkpoints, - "<count> Set max number of checkpoints kept"; - "-cd", Arg.String set_directory, - "<dir> Change working directory"; - "-emacs", Arg.Unit set_emacs, - "For running the debugger under emacs"] - anonymous - ""; + begin try + Arg.parse speclist anonymous ""; + Arg.usage speclist + "No program name specified\n\ + Usage: ocamldebug [options] <program> [arguments]\n\ + Options are:"; + exit 2 + with Found_program_name -> + let i = ref 1 in + while Sys.argv.(!i) != !program_name do incr i done; + for j = !i + 1 to Array.length Sys.argv - 1 do + arguments := Printf.sprintf "%s '%s'" !arguments Sys.argv.(j) + done + end; current_prompt := debugger_prompt; print_string "\tObjective Caml Debugger version "; print_string Config.version; |
