aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cparser/Unblock.ml1
-rw-r--r--debug/Debug.ml2
-rw-r--r--debug/Debug.mli2
-rw-r--r--debug/DebugInformation.ml8
-rw-r--r--debug/Dwarfgen.ml16
-rw-r--r--powerpc/TargetPrinter.ml9
6 files changed, 27 insertions, 11 deletions
diff --git a/cparser/Unblock.ml b/cparser/Unblock.ml
index ad4b5497..c6646b5c 100644
--- a/cparser/Unblock.ml
+++ b/cparser/Unblock.ml
@@ -255,6 +255,7 @@ let new_scope_id () =
let process_decl loc env ctx (sto, id, ty, optinit) k =
let ty' = remove_const env ty in
local_variables := (sto, id, ty', None) :: !local_variables;
+ debug_var_decl ctx id;
(* TODO: register the fact that id is declared in scope ctx *)
match optinit with
| None ->
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
diff --git a/powerpc/TargetPrinter.ml b/powerpc/TargetPrinter.ml
index 2faaf2e3..21181215 100644
--- a/powerpc/TargetPrinter.ml
+++ b/powerpc/TargetPrinter.ml
@@ -269,8 +269,11 @@ module Diab_System : SYSTEM =
fprintf oc ".L%d: .d2filenum \"%s\"\n" label file);
fprintf oc " .d2_line_end\n";
StringSet.iter (fun s ->
- fprintf oc " %s\n" s;
- fprintf oc " .d2_line_end\n") !additional_debug_sections
+ if s <> (name_of_section Section_text) then
+ begin
+ fprintf oc " %s\n" s;
+ fprintf oc " .d2_line_end\n"
+ end) !additional_debug_sections
end
let print_file_loc oc (file,col) =
@@ -282,7 +285,7 @@ module Diab_System : SYSTEM =
match sec with
| Section_user (name,_,_) ->
let sec_name = name_of_section sec in
- if not (StringSet.mem sec_name !additional_debug_sections) then
+ if not (StringSet.mem sec_name !additional_debug_sections) && name <> ".text" then
begin
let name = ".debug_line"^name in
additional_debug_sections := StringSet.add sec_name !additional_debug_sections;