diff options
Diffstat (limited to 'debug')
-rw-r--r-- | debug/Debug.ml | 2 | ||||
-rw-r--r-- | debug/Debug.mli | 2 | ||||
-rw-r--r-- | debug/DebugInformation.ml | 8 | ||||
-rw-r--r-- | debug/Dwarfgen.ml | 16 |
4 files changed, 20 insertions, 8 deletions
diff --git a/debug/Debug.ml b/debug/Debug.ml index eb616dab..c2b48618 100644 --- a/debug/Debug.ml +++ b/debug/Debug.ml @@ -33,7 +33,7 @@ type implem = mutable insert_local_declaration: storage -> ident -> typ -> location -> unit; mutable atom_local_variable: ident -> atom -> unit; mutable enter_scope: int -> int -> int -> unit; - mutable enter_function_scope: ident -> int -> unit; + mutable enter_function_scope: int -> int -> unit; mutable add_lvar_scope: int -> ident -> int -> unit; } diff --git a/debug/Debug.mli b/debug/Debug.mli index a7d40382..1fabb943 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -29,5 +29,5 @@ val all_files_iter: (string -> unit) -> unit val insert_local_declaration: storage -> ident -> typ -> location -> unit val atom_local_variable: ident -> atom -> unit val enter_scope: int -> int -> int -> unit -val enter_function_scope: ident -> int -> unit +val enter_function_scope: int -> int -> unit val add_lvar_scope: int -> ident -> int -> unit diff --git a/debug/DebugInformation.ml b/debug/DebugInformation.ml index d8d608af..ef8993ea 100644 --- a/debug/DebugInformation.ml +++ b/debug/DebugInformation.ml @@ -439,6 +439,7 @@ let atom_to_local: (atom, int) Hashtbl.t = Hashtbl.create 7 let scope_to_local: (int * int,int) Hashtbl.t = Hashtbl.create 7 (* Map from scope id + function atom to debug id *) +let atom_to_scope: (atom, int) Hashtbl.t = Hashtbl.create 7 let find_lvar_stamp id = let id = (Hashtbl.find stamp_to_local id) in @@ -477,6 +478,7 @@ let insert_global_declaration env dec= in match dec.gdesc with | Gdecl (sto,id,ty,init) -> + Printf.printf "Entering information for %s\n" id.name; if not (is_function_type env ty) then begin if not (Hashtbl.mem stamp_to_definition id.stamp) then begin let at_decl,ext = (match sto with @@ -644,9 +646,9 @@ let new_scope f_id sc_id = let enter_function_scope fun_id sc_id = try - let id = new_scope fun_id.stamp sc_id in - let fun_id,f = find_fun_stamp fun_id.stamp in - replace_fun id ({f with fun_scope = Some id}) + let id = new_scope fun_id sc_id in + let fun_id,f = find_fun_stamp fun_id in + replace_fun fun_id ({f with fun_scope = Some id}) with Not_found -> () let enter_scope f_id p_id id = diff --git a/debug/Dwarfgen.ml b/debug/Dwarfgen.ml index 8e29fcaf..15c63b66 100644 --- a/debug/Dwarfgen.ml +++ b/debug/Dwarfgen.ml @@ -305,7 +305,17 @@ and local_to_entry acc id = | LocalVariable v -> local_variable_to_entry acc v id | Scope v -> scope_to_entry acc v id +let fun_scope_to_entries acc id = + match id with + | None -> [],acc + | Some id -> + let sc = Hashtbl.find local_variables id in + (match sc with + | Scope sc ->mmap local_to_entry acc sc.scope_variables + | _ -> assert false) + let function_to_entry acc id f = + Printf.printf "Generating information for %s with id %d\n" f.fun_name id; let f_tag = { subprogram_file_loc = f.fun_file_loc; subprogram_external = Some f.fun_external; @@ -318,8 +328,8 @@ let function_to_entry acc id f = let acc = match f.fun_return_type with Some s -> IntSet.add s acc | None -> acc in let f_entry = new_entry id (DW_TAG_subprogram f_tag) in let params,acc = mmap function_parameter_to_entry acc f.fun_parameter in -(* let vars = List.map local_variable_to_entry f.fun_locals in*) - add_children f_entry params,acc + let vars,acc = fun_scope_to_entries acc f.fun_scope in + add_children f_entry (params@vars),acc let definition_to_entry acc id t = match t with @@ -327,7 +337,7 @@ let definition_to_entry acc id t = | Function f -> function_to_entry acc id f let gen_defs () = - let defs,typ = Hashtbl.fold (fun id t (acc,bcc) -> let t,bcc = definition_to_entry bcc id t in + let defs,typ = Hashtbl.fold (fun id t (acc,bcc) -> let t,bcc = definition_to_entry bcc id t in t::acc,bcc) definitions ([],IntSet.empty) in List.rev defs,typ |