From 10d5ed08a324ffd10d4db8ec58bbf6e77253bc36 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Sun, 23 Aug 2015 20:11:18 +0200 Subject: Do not add subsize tag to array types without size such as flexible array members. --- debug/CtoDwarf.ml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'debug') diff --git a/debug/CtoDwarf.ml b/debug/CtoDwarf.ml index 99b77e6f..103849d0 100644 --- a/debug/CtoDwarf.ml +++ b/debug/CtoDwarf.ml @@ -188,29 +188,33 @@ and fun_to_dwarf_tag rt args = s.id,((s::others)@et) (* Generate a dwarf tag for the given array type *) -and array_to_dwarf_tag child size = +and array_to_dwarf_tag child size = + let append_opt a b = + match a with + | None -> b + | Some a -> a::b in let size_to_subrange s = - let b = (match s with + match s with | None -> None | Some i -> let i = Int64.to_int i in - Some (BoundConst i)) in - let s = { - subrange_type = None; - subrange_upper_bound = b; - } in - new_entry (DW_TAG_subrange_type s) in + let s = + { + subrange_type = None; + subrange_upper_bound = Some (BoundConst i); + } in + Some (new_entry (DW_TAG_subrange_type s)) in let rec aux t = (match t with | TArray (child,size,_) -> let sub = size_to_subrange size in let t,c,e = aux child in - t,sub::c,e + t,append_opt sub c,e | _ -> let t,e = type_to_dwarf t in t,[],e) in let t,children,e = aux child in let sub = size_to_subrange size in - let children = List.rev (sub::children) in + let children = List.rev (append_opt sub children) in let arr = { array_type_file_loc = None; array_type = t; -- cgit