diff options
Diffstat (limited to 'debugger')
-rw-r--r-- | debugger/.depend | 6 | ||||
-rw-r--r-- | debugger/Makefile.shared | 9 | ||||
-rw-r--r-- | debugger/debugcom.ml | 6 | ||||
-rw-r--r-- | debugger/input_handling.mli | 2 | ||||
-rw-r--r-- | debugger/main.ml | 2 | ||||
-rw-r--r-- | debugger/program_loading.ml | 27 | ||||
-rw-r--r-- | debugger/program_management.ml | 4 | ||||
-rw-r--r-- | debugger/source.ml | 2 | ||||
-rw-r--r-- | debugger/symbols.ml | 15 | ||||
-rw-r--r-- | debugger/symbols.mli | 4 |
10 files changed, 61 insertions, 16 deletions
diff --git a/debugger/.depend b/debugger/.depend index 13de8ede1..b62541619 100644 --- a/debugger/.depend +++ b/debugger/.depend @@ -164,11 +164,13 @@ program_loading.cmx : unix_tools.cmx $(UNIXDIR)/unix.cmx \ program_management.cmo : unix_tools.cmi $(UNIXDIR)/unix.cmi \ time_travel.cmi symbols.cmi question.cmi program_loading.cmi \ primitives.cmi parameters.cmi int64ops.cmi input_handling.cmi history.cmi \ - debugger_config.cmi breakpoints.cmi program_management.cmi + ../typing/envaux.cmi debugger_config.cmi ../utils/config.cmi \ + breakpoints.cmi program_management.cmi program_management.cmx : unix_tools.cmx $(UNIXDIR)/unix.cmx \ time_travel.cmx symbols.cmx question.cmx program_loading.cmx \ primitives.cmx parameters.cmx int64ops.cmx input_handling.cmx history.cmx \ - debugger_config.cmx breakpoints.cmx program_management.cmi + ../typing/envaux.cmx debugger_config.cmx ../utils/config.cmx \ + breakpoints.cmx program_management.cmi question.cmo : primitives.cmi lexer.cmi input_handling.cmi question.cmi question.cmx : primitives.cmx lexer.cmx input_handling.cmx question.cmi show_information.cmo : symbols.cmi source.cmi show_source.cmi printval.cmi \ diff --git a/debugger/Makefile.shared b/debugger/Makefile.shared index d85419eb0..fed1d26da 100644 --- a/debugger/Makefile.shared +++ b/debugger/Makefile.shared @@ -12,8 +12,9 @@ include ../config/Makefile -CAMLC=../ocamlcomp.sh -COMPFLAGS=-warn-error A $(INCLUDES) +ROOTDIR=.. +CAMLC=$(ROOTDIR)/boot/ocamlrun $(ROOTDIR)/ocamlc -nostdlib -I $(ROOTDIR)/stdlib +COMPFLAGS=-warn-error A -safe-string $(INCLUDES) LINKFLAGS=-linkall -I $(UNIXDIR) CAMLYACC=../boot/ocamlyacc YACCFLAGS= @@ -21,6 +22,8 @@ CAMLLEX=../boot/ocamlrun ../boot/ocamllex CAMLDEP=../boot/ocamlrun ../tools/ocamldep DEPFLAGS=$(INCLUDES) +INSTALL_BINDIR=$(DESTDIR)$(BINDIR) + INCLUDES=\ -I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../toplevel \ -I $(UNIXDIR) @@ -83,7 +86,7 @@ ocamldebug$(EXE): $(OBJS) $(OTHEROBJS) $(CAMLC) $(LINKFLAGS) -o ocamldebug$(EXE) -linkall $(OTHEROBJS) $(OBJS) install: - cp ocamldebug$(EXE) $(BINDIR)/ocamldebug$(EXE) + cp ocamldebug$(EXE) $(INSTALL_BINDIR)/ocamldebug$(EXE) clean:: rm -f ocamldebug$(EXE) diff --git a/debugger/debugcom.ml b/debugger/debugcom.ml index 72702da16..ac91df799 100644 --- a/debugger/debugcom.ml +++ b/debugger/debugcom.ml @@ -187,10 +187,10 @@ let set_trap_barrier pos = let value_size = if 1 lsl 31 = 0 then 4 else 8 let input_remote_value ic = - Misc.input_bytes ic value_size + really_input_string ic value_size let output_remote_value ic v = - output ic v 0 value_size + output_substring ic v 0 value_size exception Marshalling_error @@ -244,7 +244,7 @@ module Remote_value = if input_byte !conn.io_in = 0 then Remote(input_remote_value !conn.io_in) else begin - let buf = Misc.input_bytes !conn.io_in 8 in + let buf = really_input_string !conn.io_in 8 in let floatbuf = float n (* force allocation of a new float *) in String.unsafe_blit buf 0 (Obj.magic floatbuf) 0 8; Local(Obj.repr floatbuf) diff --git a/debugger/input_handling.mli b/debugger/input_handling.mli index 749687ce3..66db47f15 100644 --- a/debugger/input_handling.mli +++ b/debugger/input_handling.mli @@ -49,7 +49,7 @@ val current_prompt : string ref (* Where the user input come from. *) val user_channel : io_channel ref -val read_user_input : string -> int -> int +val read_user_input : bytes -> int -> int (* Stop reading user input. *) val stop_user_input : unit -> unit diff --git a/debugger/main.ml b/debugger/main.ml index 52c1ed995..60cd96a89 100644 --- a/debugger/main.ml +++ b/debugger/main.ml @@ -193,7 +193,7 @@ let main () = (Unix.string_of_inet_addr Unix.inet_addr_loopback)^ ":"^ (string_of_int (10000 + ((Unix.getpid ()) mod 10000))) - | _ -> Filename.concat Filename.temp_dir_name + | _ -> Filename.concat (Filename.get_temp_dir_name ()) ("camldebug" ^ (string_of_int (Unix.getpid ()))) ); begin try diff --git a/debugger/program_loading.ml b/debugger/program_loading.ml index b2d472a7d..1ebbd1e82 100644 --- a/debugger/program_loading.ml +++ b/debugger/program_loading.ml @@ -41,10 +41,35 @@ let get_unix_environment () = String.concat "" (List.map f !Debugger_config.environment) ;; +(* Notes: + 1. This quoting is not the same as [Filename.quote] because the "set" + command is a shell built-in and its quoting rules are different + from regular commands. + 2. Microsoft's documentation omits the double-quote from the list + of characters that need quoting, but that is a mistake (unquoted + quotes are included in the value, but they alter the quoting of + characters between them). + Reference: http://msdn.microsoft.com/en-us/library/bb490954.aspx + *) +let quote_for_windows_shell s = + let b = Buffer.create (20 + String.length s) in + for i = 0 to String.length s - 1 do + begin match s.[i] with + | '<' | '>' | '|' | '&' | '^' | '\"' -> + Buffer.add_char b '^'; + | _ -> () + end; + Buffer.add_char b s.[i]; + done; + Buffer.contents b +;; + (* Returns a command line prefix to set environment for the debuggee *) let get_win32_environment () = (* Note: no space before the & or Windows will add it to the value *) - let f (vname, vvalue) = Printf.sprintf "set %s=%s&" vname vvalue in + let f (vname, vvalue) = + Printf.sprintf "set %s=%s&" vname (quote_for_windows_shell vvalue) + in String.concat "" (List.map f !Debugger_config.environment) (* A generic function for launching the program *) diff --git a/debugger/program_management.ml b/debugger/program_management.ml index c7438b398..48118573e 100644 --- a/debugger/program_management.ml +++ b/debugger/program_management.ml @@ -30,7 +30,7 @@ open Time_travel let file_name = ref (None : string option) (* Default connection handler. *) -let buffer = String.create 1024 +let buffer = Bytes.create 1024 let control_connection pid fd = if (read fd.io_fd buffer 0 1024) = 0 then forget_process fd pid @@ -124,6 +124,8 @@ let initialize_loading () = raise Toplevel; end; Symbols.read_symbols !program_name; + Config.load_path := !Config.load_path @ !Symbols.program_source_dirs; + Envaux.reset_cache (); if !debug_loading then prerr_endline "Opening a socket..."; open_connection !socket_name diff --git a/debugger/source.ml b/debugger/source.ml index c68df3373..af69fbc7b 100644 --- a/debugger/source.ml +++ b/debugger/source.ml @@ -74,7 +74,7 @@ let get_buffer pos mdle = try List.assoc mdle !buffer_list with Not_found -> let inchan = open_in_bin (source_of_module pos mdle) in - let content = Misc.input_bytes inchan (in_channel_length inchan) in + let content = really_input_string inchan (in_channel_length inchan) in let buffer = (content, ref []) in buffer_list := (list_truncate !buffer_max_count ((mdle, buffer)::!buffer_list)); diff --git a/debugger/symbols.ml b/debugger/symbols.ml index 331d5bbdb..1be725332 100644 --- a/debugger/symbols.ml +++ b/debugger/symbols.ml @@ -17,9 +17,14 @@ open Instruct open Debugger_config (* Toplevel *) open Program_loading +module StringSet = Set.Make(String) + let modules = ref ([] : string list) +let program_source_dirs = + ref ([] : string list) + let events = ref ([] : debug_event list) let events_by_pc = @@ -52,13 +57,16 @@ let read_symbols' bytecode_file = raise Toplevel end; let num_eventlists = input_binary_int ic in + let dirs = ref StringSet.empty in let eventlists = ref [] in for i = 1 to num_eventlists do let orig = input_binary_int ic in let evl = (input_value ic : debug_event list) in (* Relocate events in event list *) List.iter (relocate_event orig) evl; - eventlists := evl :: !eventlists + eventlists := evl :: !eventlists; + dirs := + List.fold_left (fun s e -> StringSet.add e s) !dirs (input_value ic) done; begin try ignore (Bytesections.seek_section ic "CODE") @@ -68,12 +76,13 @@ let read_symbols' bytecode_file = set_launching_function (List.assoc "manual" loading_modes) end; close_in_noerr ic; - !eventlists + !eventlists, !dirs let read_symbols bytecode_file = - let all_events = read_symbols' bytecode_file in + let all_events, all_dirs = read_symbols' bytecode_file in modules := []; events := []; + program_source_dirs := StringSet.elements all_dirs; Hashtbl.clear events_by_pc; Hashtbl.clear events_by_module; Hashtbl.clear all_events_by_module; diff --git a/debugger/symbols.mli b/debugger/symbols.mli index 980892e04..883b81aa3 100644 --- a/debugger/symbols.mli +++ b/debugger/symbols.mli @@ -14,6 +14,10 @@ (* Modules used by the program. *) val modules : string list ref +(* Absolute directories containing source code on machine where source was + * compiled *) +val program_source_dirs : string list ref + (* Read debugging info from executable file *) val read_symbols : string -> unit |