From ac48235ec7485f659162d6220c8b4c7731505423 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 11 Nov 2014 18:42:51 +0100 Subject: Added functions for printing of the abbreviations. --- debug/DwarfUtil.ml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'debug/DwarfUtil.ml') diff --git a/debug/DwarfUtil.ml b/debug/DwarfUtil.ml index 2123d1d7..4e29c0bf 100644 --- a/debug/DwarfUtil.ml +++ b/debug/DwarfUtil.ml @@ -77,6 +77,11 @@ module type ABBRV_DEFS = sig val string_of_byte: bool -> string val string_of_uleb: int -> string + val abbrv_section_start: out_channel -> unit + val abbrv_section_end: out_channel -> unit + val abbrv_prologue: out_channel -> int -> unit + val abbrv_epilogue: out_channel -> unit + val get_abbrv_start_addr: unit -> int val sibling_type_abbr: int val decl_file_type_abbr: int val decl_line_type_abbr: int @@ -115,7 +120,7 @@ module AbbrvPrinter(Defs:ABBRV_DEFS) = let abbrv = !curr_abbrv in incr curr_abbrv;abbrv - let abbrvs: string list ref = ref [] + let abbrvs: (string * int) list ref = ref [] let abbrv_mapping: (string,int) Hashtbl.t = Hashtbl.create 7 @@ -331,10 +336,19 @@ module AbbrvPrinter(Defs:ABBRV_DEFS) = (try Hashtbl.find abbrv_mapping abbrv_string with Not_found -> - abbrvs:=abbrv_string::!abbrvs; let id = next_abbrv in + abbrvs:=(abbrv_string,id)::!abbrvs; Hashtbl.add abbrv_mapping abbrv_string id; id) + let print_abbrv oc = + let abbrvs = List.sort (fun (_,a) (_,b) -> Pervasives.compare a b) !abbrvs in + Defs.abbrv_section_start oc; + List.iter (fun (s,id) -> + Defs.abbrv_prologue oc id; + output_string oc s; + Defs.abbrv_epilogue oc) abbrvs; + Defs.abbrv_section_end oc + end) -- cgit