Skip to content

Commit

Permalink
More unique debug types.
Browse files Browse the repository at this point in the history
The typdef, enumerator and function_type types form the DebugTypes and
DwarfTypes shared a some fields. This commits renames them in order to
make them more unique and avoid potential name clashes.
  • Loading branch information
bschommer committed Jan 14, 2016
1 parent ca055fc commit 54effdc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
16 changes: 8 additions & 8 deletions debug/DebugInformation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ let insert_type (ty: typ) =
| TVoid _ -> None
| _ -> Some (attr_aux t)) in
let ftype = {
fun_return_type = ret;
fun_prototyped = prot;
fun_params = param;
fun_type_return_type = ret;
fun_type_prototyped = prot;
fun_type_params = param;
} in
FunctionType ftype
| TNamed (id,_) ->
Expand All @@ -128,8 +128,8 @@ let insert_type (ty: typ) =
Some (attr_aux t)
with Not_found -> None in
let t = {
typedef_file_loc = None;
typedef_name = id.name;
td_file_loc = None;
td_name = id.name;
typ = typ;
} in
Typedef t
Expand Down Expand Up @@ -406,14 +406,14 @@ let insert_global_declaration env dec =
| Gtypedef (id,t) ->
let id = insert_type (TNamed (id,[])) in
let tid = insert_type t in
replace_typedef id (fun typ -> {typ with typedef_file_loc = Some dec.gloc; typ = Some tid;});
replace_typedef id (fun typ -> {typ with td_file_loc = Some dec.gloc; typ = Some tid;});
| Genumdef (n,at,e) ->
ignore(insert_type (TEnum (n,at)));
let id = find_type (TEnum (n,[])) in
let enumerator = List.map (fun (i,c,_) ->
{
enumerator_name = i.name;
enumerator_const = c;
e_name = i.name;
e_const = c;
}) e in
replace_enum id (fun en ->
{en with enum_file_loc = Some dec.gloc; enum_enumerators = enumerator;})
Expand Down
16 changes: 8 additions & 8 deletions debug/DebugTypes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ type array_type = {
}

type typedef = {
typedef_file_loc: location option;
typedef_name: string;
typ: int option;
td_file_loc: location option;
td_name: string;
typ: int option;
}

type enumerator = {
enumerator_name: string;
enumerator_const: int64;
e_name: string;
e_const: int64;
}

type enum_type = {
Expand All @@ -85,9 +85,9 @@ type parameter_type = {
}

type function_type = {
fun_return_type: int option;
fun_prototyped: bool;
fun_params: parameter_type list;
fun_type_return_type: int option;
fun_type_prototyped: bool;
fun_type_params: parameter_type list;
}

type debug_types =
Expand Down
20 changes: 10 additions & 10 deletions debug/Dwarfgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ module Dwarfgenaux (Target: TARGET) =
let typedef_to_entry id t =
let i = get_opt_val t.typ in
let td = {
typedef_file_loc = file_loc_opt t.typedef_file_loc;
typedef_name = string_entry t.typedef_name;
typedef_file_loc = file_loc_opt t.td_file_loc;
typedef_name = string_entry t.td_name;
typedef_type = i;
} in
new_entry id (DW_TAG_typedef td)
Expand Down Expand Up @@ -170,8 +170,8 @@ module Dwarfgenaux (Target: TARGET) =
let enumerator_to_entry e =
let tag =
{
enumerator_value = Int64.to_int (e.enumerator_const);
enumerator_name = string_entry e.enumerator_name;
enumerator_value = Int64.to_int (e.e_const);
enumerator_name = string_entry e.e_name;
} in
new_entry (next_id ()) (DW_TAG_enumerator tag) in
let bs = sizeof_ikind enum_ikind in
Expand All @@ -186,7 +186,7 @@ module Dwarfgenaux (Target: TARGET) =
add_children enum children

let fun_type_to_entry id f =
let children = if not f.fun_prototyped then
let children = if not f.fun_type_prototyped then
let u = {
unspecified_parameter_artificial = None;
} in
Expand All @@ -200,11 +200,11 @@ module Dwarfgenaux (Target: TARGET) =
formal_parameter_variable_parameter = None;
formal_parameter_location = None;
} in
new_entry (next_id ()) (DW_TAG_formal_parameter fp)) f.fun_params;
new_entry (next_id ()) (DW_TAG_formal_parameter fp)) f.fun_type_params;
in
let s = {
subroutine_type = f.fun_return_type;
subroutine_prototyped = f.fun_prototyped
subroutine_type = f.fun_type_return_type;
subroutine_prototyped = f.fun_type_prototyped
} in
let s = new_entry id (DW_TAG_subroutine_type s) in
add_children s children
Expand Down Expand Up @@ -287,12 +287,12 @@ module Dwarfgenaux (Target: TARGET) =
| VolatileType v ->
add_type v.vol_type d
| FunctionType f ->
let d,c = match f.fun_return_type with
let d,c = match f.fun_type_return_type with
| Some t -> add_type t d
| None -> d,false in
List.fold_left (fun (d,c) p ->
let d,c' = add_type p.param_type d in
d,c||c') (d,c) f.fun_params
d,c||c') (d,c) f.fun_type_params
| CompositeType c ->
List.fold_left (fun (d,c) f ->
let d,c' = add_type f.cfd_typ d in
Expand Down

0 comments on commit 54effdc

Please sign in to comment.