From c3579778940839b9d4753ec47169ceadda55c083 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 24 Aug 2015 17:21:01 +0200 Subject: Fixed error in handling of anonymous struct/union/enum types. Composite types should be always handled by the composite_type_info table and not by the normal type table. --- debug/CtoDwarf.ml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'debug') diff --git a/debug/CtoDwarf.ml b/debug/CtoDwarf.ml index 753f4cdd..c5f1142c 100644 --- a/debug/CtoDwarf.ml +++ b/debug/CtoDwarf.ml @@ -197,7 +197,7 @@ and array_to_dwarf_tag child size = match s with | None -> None | Some i -> - let i = Int64.to_int i in + let i = Int64.to_int (Int64.sub i Int64.one) in let s = { subrange_type = None; @@ -276,23 +276,30 @@ and attr_type_to_dwarf typ typ_string = (* Translate a given type to its dwarf representation *) and type_to_dwarf (typ: typ): int * dw_entry list = - let typ = strip_attributes typ in - let typ_string = typ_to_string typ in - try - Hashtbl.find type_table typ_string,[] - with Not_found -> - attr_type_to_dwarf typ typ_string + match typ with + | TStruct (i,_) + | TUnion (i,_) + | TEnum (i,_) -> + let t = get_composite_type i.stamp in + t,[] + | _ -> + let typ = strip_attributes typ in + let typ_string = typ_to_string typ in + try + Hashtbl.find type_table typ_string,[] + with Not_found -> + attr_type_to_dwarf typ typ_string (* Translate a typedef to its corresponding dwarf representation *) let typedef_to_dwarf gloc (name,t) = let i,t = type_to_dwarf t in - Hashtbl.add typedef_table name i; let td = { typedef_file_loc = gloc; typedef_name = name; typedef_type = i; } in let td = new_entry (DW_TAG_typedef td) in + Hashtbl.add typedef_table name td.id; td::t (* Translate a global var to its corresponding dwarf representation *) -- cgit