From 55eb2d92376f592258855cfa5c0cfbbf39e8e833 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 6 Oct 2015 11:08:58 +0200 Subject: Fast fix for functions in different sections in one compilation unit for gcc. --- debug/DwarfPrinter.ml | 15 ++++++++++++++- debug/DwarfTypes.mli | 2 +- debug/Dwarfgen.ml | 12 ++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'debug') diff --git a/debug/DwarfPrinter.ml b/debug/DwarfPrinter.ml index 980c49db..2a54fa6a 100644 --- a/debug/DwarfPrinter.ml +++ b/debug/DwarfPrinter.ml @@ -590,8 +590,21 @@ module DwarfPrinter(Target: DWARF_TARGET): fprintf oc " .4byte 0\n"; fprintf oc " .4byte 0\n" + let print_location_entry_abs oc l = + print_label oc (loc_to_label l.loc_id); + List.iter (fun (b,e,loc) -> + fprintf oc " .4byte %a\n" label b; + fprintf oc " .4byte %a\n" label e; + print_list_loc oc loc) l.loc; + fprintf oc " .4byte 0\n"; + fprintf oc " .4byte 0\n" + + let print_location_list oc (c_low,l) = - List.iter (print_location_entry oc c_low) l + let f = match c_low with + | Some s -> print_location_entry oc s + | None -> print_location_entry_abs oc in + List.iter f l let print_diab_entries oc entries = let abbrev_start = new_label () in diff --git a/debug/DwarfTypes.mli b/debug/DwarfTypes.mli index ed75b3d7..8f03eb8d 100644 --- a/debug/DwarfTypes.mli +++ b/debug/DwarfTypes.mli @@ -247,7 +247,7 @@ type location_entry = loc: (int * int * location_value) list; loc_id: reference; } -type dw_locations = int * location_entry list +type dw_locations = int option * location_entry list type diab_entries = (string * int * int * dw_entry * dw_locations) list diff --git a/debug/Dwarfgen.ml b/debug/Dwarfgen.ml index 2258f948..eff80110 100644 --- a/debug/Dwarfgen.ml +++ b/debug/Dwarfgen.ml @@ -463,7 +463,7 @@ let gen_diab_debug_info sec_name var_section : debug_entries = } in let cp = new_entry (next_id ()) (DW_TAG_compile_unit cp) in let cp = add_children cp ((gen_types (diab_file_loc s) ty) @ defs) in - (s,debug_start,line_start,cp,(low_pc,locs))::acc) defs [] in + (s,debug_start,line_start,cp,(Some low_pc,locs))::acc) defs [] in Diab entries let gnu_file_loc (f,l) = @@ -472,9 +472,12 @@ let gnu_file_loc (f,l) = let gen_gnu_debug_info sec_name var_section : debug_entries = let low_pc = Hashtbl.find compilation_section_start ".text" and high_pc = Hashtbl.find compilation_section_end ".text" in - let defs,(ty,locs) = Hashtbl.fold (fun id t (acc,bcc) -> + let defs,(ty,locs),sec = Hashtbl.fold (fun id t (acc,bcc,sec) -> + let s = match t with + | GlobalVariable _ -> var_section + | Function f -> sec_name (get_opt_val f.fun_atom) in let t,bcc = definition_to_entry gnu_file_loc bcc id t in - t::acc,bcc) definitions ([],(IntSet.empty,[])) in + t::acc,bcc,StringSet.add s sec) definitions ([],(IntSet.empty,[]),StringSet.empty) in let types = gen_types gnu_file_loc ty in let cp = { compile_unit_name = !file_name; @@ -483,4 +486,5 @@ let gen_gnu_debug_info sec_name var_section : debug_entries = } in let cp = new_entry (next_id ()) (DW_TAG_compile_unit cp) in let cp = add_children cp (types@defs) in - Gnu (cp,(low_pc,locs)) + let loc_pc = if StringSet.cardinal sec > 1 then None else Some low_pc in + Gnu (cp,(loc_pc,locs)) -- cgit