aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2014-10-27 18:35:34 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2014-10-27 18:35:34 +0100
commitcb19f7307cfe0beb4ae16c53005c6d0df8162f4a (patch)
tree8ac47da93df3089e39891edc91fbeff40b9837da
parent5fc20400421e12c91ec5f47fde1b3ea25d1da30e (diff)
downloadcompcert-kvx-cb19f7307cfe0beb4ae16c53005c6d0df8162f4a.tar.gz
compcert-kvx-cb19f7307cfe0beb4ae16c53005c6d0df8162f4a.zip
Added the type information to the global information stored for each atom.
-rw-r--r--cfrontend/C2C.ml20
-rw-r--r--debug/DwarfUtil.ml5
2 files changed, 20 insertions, 5 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml
index 73d9edbd..9b3d2d32 100644
--- a/cfrontend/C2C.ml
+++ b/cfrontend/C2C.ml
@@ -38,7 +38,8 @@ type atom_info =
(* 1 section for data, 3 sections (code/lit/jumptbl) for functions *)
a_access: Sections.access_mode; (* access mode, e.g. small data area *)
a_inline: bool; (* function declared inline? *)
- a_loc: location (* source location *)
+ a_loc: location; (* source location *)
+ a_typ: C.typ; (* type of the atom *)
}
let decl_atom : (AST.ident, atom_info) Hashtbl.t = Hashtbl.create 103
@@ -159,7 +160,9 @@ let name_for_string_literal env s =
a_sections = [Sections.for_stringlit()];
a_access = Sections.Access_default;
a_inline = false;
- a_loc = Cutil.no_loc };
+ a_loc = Cutil.no_loc;
+ a_typ= TArray (TInt (IUChar,[]),Some (Int64.of_int (String.length s +1)),[]);
+ };
Hashtbl.add stringTable s id;
id
@@ -848,7 +851,9 @@ let convertFundef loc env fd =
a_sections = Sections.for_function env id' fd.fd_ret;
a_access = Sections.Access_default;
a_inline = fd.fd_inline;
- a_loc = loc };
+ a_loc = loc;
+ a_typ = TFun (fd.fd_ret,Some fd.fd_params,fd.fd_vararg,fd.fd_attrib);
+ };
(id', Gfun(Internal {fn_return = ret;
fn_callconv = convertCallconv fd.fd_vararg fd.fd_attrib;
fn_params = params;
@@ -935,7 +940,9 @@ let convertGlobvar loc env (sto, id, ty, optinit) =
a_sections = [section];
a_access = access;
a_inline = false;
- a_loc = loc };
+ a_loc = loc ;
+ a_typ = ty;
+ };
let volatile = List.mem C.AVolatile attr in
let readonly = List.mem C.AConst attr && not volatile in
(id', Gvar {gvar_info = ty'; gvar_init = init';
@@ -1135,3 +1142,8 @@ let atom_location a =
(Hashtbl.find decl_atom a).a_loc
with Not_found ->
Cutil.no_loc
+
+let atom_typ a =
+ try
+ Some (Hashtbl.find decl_atom a).a_typ
+ with Not_found -> None
diff --git a/debug/DwarfUtil.ml b/debug/DwarfUtil.ml
index ec5495c1..100e35bf 100644
--- a/debug/DwarfUtil.ml
+++ b/debug/DwarfUtil.ml
@@ -26,6 +26,10 @@ let reset_id () =
(* Hashtable to from type name to entry id *)
let type_table: (string, int) Hashtbl.t = Hashtbl.create 7
+(* Clear the type map *)
+let reset_type_table () =
+ Hashtbl.clear type_table
+
(* Generate a new entry from a given tag *)
let new_entry tag =
let id = next_id () in
@@ -35,7 +39,6 @@ let new_entry tag =
id = id;
}
-
(* Add an entry as child to another entry *)
let add_children entry child =
{entry with children = child::entry.children;}