aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-10-12 14:33:15 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-10-12 17:18:07 +0200
commit012827a7cba40f434b9fc6ce1b46dc725473eae7 (patch)
tree35a1742582fafc3c83f581311453e9bf9211a8b1 /debug
parentd4c9a7c5b47670bad12d54a3fd4de0ad4eceb1ee (diff)
downloadcompcert-kvx-012827a7cba40f434b9fc6ce1b46dc725473eae7.tar.gz
compcert-kvx-012827a7cba40f434b9fc6ce1b46dc725473eae7.zip
Unified function for adding the atom identifier.
Instead of defining two functions for adding the mapping from atom to debug id we use one function which then sets the corresponding values. Bug 17392.
Diffstat (limited to 'debug')
-rw-r--r--debug/Debug.ml9
-rw-r--r--debug/Debug.mli6
-rw-r--r--debug/DebugInformation.ml28
-rw-r--r--debug/DebugInit.ml8
4 files changed, 24 insertions, 27 deletions
diff --git a/debug/Debug.ml b/debug/Debug.ml
index 161ee3ed..22f913c5 100644
--- a/debug/Debug.ml
+++ b/debug/Debug.ml
@@ -23,8 +23,7 @@ open DwarfTypes
type implem =
{
mutable init: string -> unit;
- mutable atom_function: ident -> atom -> unit;
- mutable atom_global_variable: ident -> atom -> unit;
+ mutable atom_global: ident -> atom -> unit;
mutable set_composite_size: ident -> struct_or_union -> int option -> unit;
mutable set_member_offset: ident -> string -> int -> unit;
mutable set_bitfield_offset: ident -> string -> int -> string -> int -> unit;
@@ -58,8 +57,7 @@ type implem =
let implem =
{
init = (fun _ -> ());
- atom_function = (fun _ _ -> ());
- atom_global_variable = (fun _ _ -> ());
+ atom_global = (fun _ _ -> ());
set_composite_size = (fun _ _ _ -> ());
set_member_offset = (fun _ _ _ -> ());
set_bitfield_offset = (fun _ _ _ _ _ -> ());
@@ -91,8 +89,7 @@ let implem =
}
let init_compile_unit name = implem.init name
-let atom_function id atom = implem.atom_function id atom
-let atom_global_variable id atom = implem.atom_global_variable id atom
+let atom_global id atom = implem.atom_global id atom
let set_composite_size id sou size = implem.set_composite_size id sou size
let set_member_offset id field off = implem.set_member_offset id field off
let set_bitfield_offset id field off underlying size = implem.set_bitfield_offset id field off underlying size
diff --git a/debug/Debug.mli b/debug/Debug.mli
index 577b0ef8..94862844 100644
--- a/debug/Debug.mli
+++ b/debug/Debug.mli
@@ -21,8 +21,7 @@ open BinNums
type implem =
{
mutable init: string -> unit;
- mutable atom_function: ident -> atom -> unit;
- mutable atom_global_variable: ident -> atom -> unit;
+ mutable atom_global: ident -> atom -> unit;
mutable set_composite_size: ident -> struct_or_union -> int option -> unit;
mutable set_member_offset: ident -> string -> int -> unit;
mutable set_bitfield_offset: ident -> string -> int -> string -> int -> unit;
@@ -56,8 +55,7 @@ type implem =
val implem: implem
val init_compile_unit: string -> unit
-val atom_function: ident -> atom -> unit
-val atom_global_variable: ident -> atom -> unit
+val atom_global: ident -> atom -> unit
val set_composite_size: ident -> struct_or_union -> int option -> unit
val set_member_offset: ident -> string -> int -> unit
val set_bitfield_offset: ident -> string -> int -> string -> int -> unit
diff --git a/debug/DebugInformation.ml b/debug/DebugInformation.ml
index d1747f8e..4c566744 100644
--- a/debug/DebugInformation.ml
+++ b/debug/DebugInformation.ml
@@ -302,9 +302,6 @@ let local_variables: (int, local_information) Hashtbl.t = Hashtbl.create 7
(* Mapping from stampt to the debug id of the local variable *)
let stamp_to_local: (int,int) Hashtbl.t = Hashtbl.create 7
-(* Mapping form atom to the debug id of the local variable *)
-let atom_to_local: (atom, int) Hashtbl.t = Hashtbl.create 7
-
(* Map from scope id + function id to debug id *)
let scope_to_local: (int * int,int) Hashtbl.t = Hashtbl.create 7
@@ -492,6 +489,21 @@ let atom_function id atom =
Hashtbl.add atom_to_scope (atom,sid) tid) scope_to_local
with Not_found -> ()
+let atom_global id atom =
+ try
+ let id' = (Hashtbl.find stamp_to_definition id.stamp) in
+ let g = Hashtbl.find definitions id' in
+ match g with
+ | Function f ->
+ replace_fun id' ({f with fun_atom = Some atom;});
+ Hashtbl.add atom_to_definition atom id';
+ Hashtbl.iter (fun (fid,sid) tid -> if fid = id.stamp then
+ Hashtbl.add atom_to_scope (atom,sid) tid) scope_to_local
+ | GlobalVariable var ->
+ replace_var id' ({var with gvar_atom = Some atom;});
+ Hashtbl.add atom_to_definition atom id'
+ with Not_found -> ()
+
let atom_parameter fid id atom =
try
let fid',f = find_fun_stamp fid.stamp in
@@ -509,8 +521,7 @@ let add_fun_addr atom (high,low) =
let atom_local_variable id atom =
try
let id,var = find_lvar_stamp id.stamp in
- replace_lvar id ({var with lvar_atom = Some atom;});
- Hashtbl.add atom_to_local atom id
+ replace_lvar id ({var with lvar_atom = Some atom;})
with Not_found -> ()
let add_lvar_scope f_id var_id s_id =
@@ -589,7 +600,6 @@ module IntSet = Set.Make(struct
end)
let open_scopes: IntSet.t ref = ref IntSet.empty
-let open_vars: atom list ref = ref []
let open_scope atom s_id lbl =
try
@@ -620,7 +630,6 @@ let start_live_range (f,v) lbl loc =
match old_r with
| RangeLoc old_r ->
let n_r = { range_start = Some lbl; range_end = None; var_loc = loc } in
- open_vars := v::!open_vars;
Hashtbl.replace var_locations (f,v) (RangeLoc (n_r::old_r))
| _ -> () (* Parameter that is passed as variable *)
@@ -640,9 +649,7 @@ let stack_variable (f,v) (sp,loc) =
let function_end atom loc =
IntSet.iter (fun id -> close_scope atom id loc) !open_scopes;
- open_scopes := IntSet.empty;
- List.iter (fun id-> end_live_range (atom,id) loc) !open_vars;
- open_vars:= []
+ open_scopes := IntSet.empty
let compilation_section_start: (string,int) Hashtbl.t = Hashtbl.create 7
let compilation_section_end: (string,int) Hashtbl.t = Hashtbl.create 7
@@ -690,7 +697,6 @@ let init name =
Hashtbl.reset atom_to_definition;
Hashtbl.reset local_variables;
Hashtbl.reset stamp_to_local;
- Hashtbl.reset atom_to_local;
Hashtbl.reset scope_to_local;
Hashtbl.reset atom_to_scope;
Hashtbl.reset compilation_section_start;
diff --git a/debug/DebugInit.ml b/debug/DebugInit.ml
index 7ee56ff1..09714628 100644
--- a/debug/DebugInit.ml
+++ b/debug/DebugInit.ml
@@ -20,8 +20,7 @@ open Debug
let init_debug () =
implem.init <- DebugInformation.init;
- implem.atom_function <- DebugInformation.atom_function;
- implem.atom_global_variable <- DebugInformation.atom_global_variable;
+ implem.atom_global <- DebugInformation.atom_global;
implem.set_composite_size <- DebugInformation.set_composite_size;
implem.set_member_offset <- DebugInformation.set_member_offset;
implem.set_bitfield_offset <- DebugInformation.set_bitfield_offset;
@@ -43,7 +42,6 @@ let init_debug () =
implem.start_live_range <- DebugInformation.start_live_range;
implem.end_live_range <- DebugInformation.end_live_range;
implem.stack_variable <- DebugInformation.stack_variable;
- implem.function_end <- DebugInformation.function_end;
implem.add_label <- DebugInformation.add_label;
implem.atom_parameter <- DebugInformation.atom_parameter;
implem.add_compilation_section_start <- DebugInformation.add_compilation_section_start;
@@ -57,8 +55,7 @@ let init_debug () =
let init_none () =
implem.init <- (fun _ -> ());
- implem.atom_function <- (fun _ _ -> ());
- implem.atom_global_variable <- (fun _ _ -> ());
+ implem.atom_global <- (fun _ _ -> ());
implem.set_composite_size <- (fun _ _ _ -> ());
implem.set_member_offset <- (fun _ _ _ -> ());
implem.set_bitfield_offset <- (fun _ _ _ _ _ -> ());
@@ -76,7 +73,6 @@ let init_none () =
implem.start_live_range <- (fun _ _ _ -> ());
implem.end_live_range <- (fun _ _ -> ());
implem.stack_variable <- (fun _ _ -> ());
- implem.function_end <- (fun _ _ -> ());
implem.add_label <- (fun _ _ _ -> ());
implem.atom_parameter <- (fun _ _ _ -> ());
implem.add_compilation_section_start <- (fun _ _ -> ());