aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-10-04 22:15:20 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-10-04 22:15:20 +0200
commit34cc6a603f34a430fc3b9a7071dcc1e19b2b7250 (patch)
tree2bc811f0893b7925164f70e0b284ea6061aca36c
parent57fceab9ba11cb98635236f31c85ca976ca7f48c (diff)
downloadcompcert-kvx-34cc6a603f34a430fc3b9a7071dcc1e19b2b7250.tar.gz
compcert-kvx-34cc6a603f34a430fc3b9a7071dcc1e19b2b7250.zip
Ensure that there are file directives for all files used in the debug
information.
-rw-r--r--backend/Fileinfo.ml15
-rw-r--r--debug/Debug.ml9
-rw-r--r--debug/Debug.mli6
-rw-r--r--debug/DebugInformation.ml5
-rw-r--r--debug/DebugInit.ml5
-rw-r--r--powerpc/TargetPrinter.ml3
6 files changed, 28 insertions, 15 deletions
diff --git a/backend/Fileinfo.ml b/backend/Fileinfo.ml
index afdea382..0490def0 100644
--- a/backend/Fileinfo.ml
+++ b/backend/Fileinfo.ml
@@ -42,16 +42,17 @@ let enter_filename f =
(* Add file and line debug location, using GNU assembler-style DWARF2
directives *)
+let print_file oc file =
+ try
+ Hashtbl.find filename_info file
+ with Not_found ->
+ let (filenum, filebuf as res) = enter_filename file in
+ fprintf oc " .file %d %S\n" filenum file;
+ res
let print_file_line oc pref file line =
if !Clflags.option_g && file <> "" then begin
- let (filenum, filebuf) =
- try
- Hashtbl.find filename_info file
- with Not_found ->
- let (filenum, filebuf as res) = enter_filename file in
- fprintf oc " .file %d %S\n" filenum file;
- res in
+ let (filenum, filebuf) = print_file oc file in
fprintf oc " .loc %d %d\n" filenum line;
match filebuf with
| None -> ()
diff --git a/debug/Debug.ml b/debug/Debug.ml
index 348310f6..161ee3ed 100644
--- a/debug/Debug.ml
+++ b/debug/Debug.ml
@@ -47,7 +47,8 @@ type implem =
mutable atom_parameter: ident -> ident -> atom -> unit;
mutable add_compilation_section_start: string -> int -> unit;
mutable add_compilation_section_end: string -> int -> unit;
- mutable compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit;
+ mutable compute_diab_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit;
+ mutable compute_gnu_file_enum: (string -> unit) -> unit;
mutable exists_section: string -> bool;
mutable remove_unused: ident -> unit;
mutable variable_printed: string -> unit;
@@ -81,7 +82,8 @@ let implem =
atom_parameter = (fun _ _ _ -> ());
add_compilation_section_start = (fun _ _ -> ());
add_compilation_section_end = (fun _ _ -> ());
- compute_file_enum = (fun _ _ _ -> ());
+ compute_diab_file_enum = (fun _ _ _ -> ());
+ compute_gnu_file_enum = (fun _ -> ());
exists_section = (fun _ -> true);
remove_unused = (fun _ -> ());
variable_printed = (fun _ -> ());
@@ -114,7 +116,8 @@ let atom_parameter fid pid atom = implem.atom_parameter fid pid atom
let add_compilation_section_start sec addr = implem.add_compilation_section_start sec addr
let add_compilation_section_end sec addr = implem.add_compilation_section_end sec addr
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 compute_diab_file_enum end_l entry_l line_e = implem.compute_diab_file_enum end_l entry_l line_e
+let compute_gnu_file_enum f = implem.compute_gnu_file_enum f
let remove_unused ident = implem.remove_unused ident
let variable_printed ident = implem.variable_printed ident
let add_diab_info sec addr = implem.add_diab_info sec addr
diff --git a/debug/Debug.mli b/debug/Debug.mli
index 98a13b30..577b0ef8 100644
--- a/debug/Debug.mli
+++ b/debug/Debug.mli
@@ -45,7 +45,8 @@ type implem =
mutable atom_parameter: ident -> ident -> atom -> unit;
mutable add_compilation_section_start: string -> int -> unit;
mutable add_compilation_section_end: string -> int -> unit;
- mutable compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit;
+ mutable compute_diab_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit;
+ mutable compute_gnu_file_enum: (string -> unit) -> unit;
mutable exists_section: string -> bool;
mutable remove_unused: ident -> unit;
mutable variable_printed: string -> unit;
@@ -79,7 +80,8 @@ val generate_debug_info: (atom -> string) -> string -> debug_entries option
val atom_parameter: ident -> ident -> atom -> unit
val add_compilation_section_start: string -> int -> unit
val add_compilation_section_end: string -> int -> unit
-val compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit
+val compute_diab_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit
+val compute_gnu_file_enum: (string -> 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 36138882..874dfb77 100644
--- a/debug/DebugInformation.ml
+++ b/debug/DebugInformation.ml
@@ -663,7 +663,7 @@ let exists_section sec =
let filenum: (string * string,int) Hashtbl.t = Hashtbl.create 7
-let compute_file_enum end_label entry_label line_end =
+let compute_diab_file_enum end_label entry_label line_end =
Hashtbl.iter (fun sec (_,_,secname) ->
Hashtbl.add compilation_section_end sec (end_label secname);
StringSet.iter (fun file ->
@@ -671,6 +671,9 @@ let compute_file_enum end_label entry_label line_end =
Hashtbl.add filenum (sec,file) lbl) !all_files;
line_end ()) diab_additional
+let compute_gnu_file_enum f =
+ StringSet.iter f !all_files
+
let printed_vars: StringSet.t ref = ref StringSet.empty
let variable_printed id =
diff --git a/debug/DebugInit.ml b/debug/DebugInit.ml
index 5aac6566..7ee56ff1 100644
--- a/debug/DebugInit.ml
+++ b/debug/DebugInit.ml
@@ -48,7 +48,8 @@ let init_debug () =
implem.atom_parameter <- DebugInformation.atom_parameter;
implem.add_compilation_section_start <- DebugInformation.add_compilation_section_start;
implem.add_compilation_section_end <- DebugInformation.add_compilation_section_end;
- implem.compute_file_enum <- DebugInformation.compute_file_enum;
+ implem.compute_diab_file_enum <- DebugInformation.compute_diab_file_enum;
+ implem.compute_gnu_file_enum <- DebugInformation.compute_gnu_file_enum;
implem.exists_section <- DebugInformation.exists_section;
implem.remove_unused <- DebugInformation.remove_unused;
implem.variable_printed <- DebugInformation.variable_printed;
@@ -80,6 +81,8 @@ let init_none () =
implem.atom_parameter <- (fun _ _ _ -> ());
implem.add_compilation_section_start <- (fun _ _ -> ());
implem.add_compilation_section_end <- (fun _ _ -> ());
+ implem.compute_diab_file_enum <- (fun _ _ _ -> ());
+ implem.compute_gnu_file_enum <- (fun _ -> ());
implem.exists_section <- (fun _ -> true);
implem.remove_unused <- (fun _ -> ());
implem.variable_printed <- (fun _ -> ());
diff --git a/powerpc/TargetPrinter.ml b/powerpc/TargetPrinter.ml
index 579573b9..530e269d 100644
--- a/powerpc/TargetPrinter.ml
+++ b/powerpc/TargetPrinter.ml
@@ -161,6 +161,7 @@ module Linux_System : SYSTEM =
begin
let high_pc = new_label () in
Debug.add_compilation_section_end ".text" high_pc;
+ Debug.compute_gnu_file_enum (fun f -> ignore (print_file oc f));
section oc Section_text;
fprintf oc "%a:\n" label high_pc
end
@@ -286,7 +287,7 @@ module Diab_System : SYSTEM =
fprintf oc ".L%d: .d2filenum \"%s\"\n" label f;
label
and end_line () = fprintf oc " .d2_line_end\n" in
- Debug.compute_file_enum end_label entry_label end_line
+ Debug.compute_diab_file_enum end_label entry_label end_line
end