From eaf4bab84af4b3db1ca9c6785ed803bbbd61b9a7 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 1 Oct 2015 12:19:16 +0200 Subject: Only print locations for symbols that are present in the assembler. --- backend/PrintAsm.ml | 3 ++- debug/Debug.ml | 3 +++ debug/Debug.mli | 2 ++ debug/DebugInformation.ml | 8 +++++++- debug/DebugInit.ml | 6 ++++-- debug/Dwarfgen.ml | 6 +++++- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml index a152e3c2..45b1e878 100644 --- a/backend/PrintAsm.ml +++ b/backend/PrintAsm.ml @@ -79,10 +79,11 @@ module Printer(Target:TARGET) = match v.gvar_init with | [] -> () | _ -> + Debug.variable_printed (extern_atom name); let sec = match C2C.atom_sections name with | [s] -> s - | _ -> Section_data true + | _ -> Section_data true and align = match C2C.atom_alignof name with | Some a -> a diff --git a/debug/Debug.ml b/debug/Debug.ml index 79da3695..30ff288f 100644 --- a/debug/Debug.ml +++ b/debug/Debug.ml @@ -49,6 +49,7 @@ type implem = mutable compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit; mutable exists_section: string -> bool; mutable remove_unused: ident -> unit; + mutable variable_printed: string -> unit; } let implem = @@ -80,6 +81,7 @@ let implem = compute_file_enum = (fun _ _ _ -> ()); exists_section = (fun _ -> true); remove_unused = (fun _ -> ()); + variable_printed = (fun _ -> ()); } let init_compile_unit name = implem.init name @@ -109,3 +111,4 @@ let add_compilation_section_start sec addr = implem.add_compilation_section_star let exists_section sec = implem.exists_section sec let compute_file_enum end_l entry_l line_e = implem.compute_file_enum end_l entry_l line_e let remove_unused ident = implem.remove_unused ident +let variable_printed ident = implem.variable_printed ident diff --git a/debug/Debug.mli b/debug/Debug.mli index 4677fdf8..a1b4408d 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -47,6 +47,7 @@ type implem = mutable compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit; mutable exists_section: string -> bool; mutable remove_unused: ident -> unit; + mutable variable_printed: string -> unit; } val implem: implem @@ -78,3 +79,4 @@ val add_compilation_section_start: string -> (int * int * int * string) -> unit val compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit val exists_section: string -> bool val remove_unused: ident -> unit +val variable_printed: string -> unit diff --git a/debug/DebugInformation.ml b/debug/DebugInformation.ml index b14548e7..654c983c 100644 --- a/debug/DebugInformation.ml +++ b/debug/DebugInformation.ml @@ -810,6 +810,11 @@ let compute_file_enum end_label entry_label line_end = Hashtbl.add filenum (sec,file) lbl) !all_files; line_end ()) compilation_section_start +let printed_vars: StringSet.t ref = ref StringSet.empty + +let variable_printed id = + printed_vars := StringSet.add id !printed_vars + let init name = id := 0; file_name := name; @@ -826,4 +831,5 @@ let init name = Hashtbl.reset compilation_section_start; Hashtbl.reset compilation_section_end; Hashtbl.reset filenum; - all_files := StringSet.empty + all_files := StringSet.empty; + printed_vars := StringSet.empty; diff --git a/debug/DebugInit.ml b/debug/DebugInit.ml index 8c74e38e..d3ce8d18 100644 --- a/debug/DebugInit.ml +++ b/debug/DebugInit.ml @@ -45,7 +45,8 @@ let init_debug () = implem.add_compilation_section_start <- DebugInformation.add_compilation_section_start; implem.compute_file_enum <- DebugInformation.compute_file_enum; implem.exists_section <- DebugInformation.exists_section; - implem.remove_unused <- DebugInformation.remove_unused + implem.remove_unused <- DebugInformation.remove_unused; + implem.variable_printed <- DebugInformation.variable_printed let init_none () = implem.init <- (fun _ -> ()); @@ -73,7 +74,8 @@ let init_none () = implem.atom_parameter <- (fun _ _ _ -> ()); implem.add_compilation_section_start <- (fun _ _ -> ()); implem.exists_section <- (fun _ -> true); - implem.remove_unused <- (fun _ -> ()) + implem.remove_unused <- (fun _ -> ()); + implem.variable_printed <- (fun _ -> ()) let init () = if !Clflags.option_g && Configuration.advanced_debug then diff --git a/debug/Dwarfgen.ml b/debug/Dwarfgen.ml index aaf2d53f..8f71d487 100644 --- a/debug/Dwarfgen.ml +++ b/debug/Dwarfgen.ml @@ -284,13 +284,17 @@ let gen_types sec needed = acc) types []) let global_variable_to_entry sec acc id v = + let loc = match v.gvar_atom with + | Some a when StringSet.mem (extern_atom a) !printed_vars -> + Some (LocSymbol a) + | _ -> None in let var = { variable_file_loc = translate_file_loc sec v.gvar_file_loc; variable_declaration = Some v.gvar_declaration; variable_external = Some v.gvar_external; variable_name = v.gvar_name; variable_type = v.gvar_type; - variable_location = match v.gvar_atom with Some a -> Some (LocSymbol a) | None -> None; + variable_location = loc; } in new_entry id (DW_TAG_variable var),IntSet.add v.gvar_type acc -- cgit