aboutsummaryrefslogtreecommitdiffstats
path: root/debug/DwarfUtil.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2014-11-11 18:42:51 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2014-11-11 18:42:51 +0100
commitac48235ec7485f659162d6220c8b4c7731505423 (patch)
tree59a828e7e21daa7682871b14173b8a177e92cab7 /debug/DwarfUtil.ml
parent977f81ff4962750f14970b8a32e30d90407572fe (diff)
downloadcompcert-kvx-ac48235ec7485f659162d6220c8b4c7731505423.tar.gz
compcert-kvx-ac48235ec7485f659162d6220c8b4c7731505423.zip
Added functions for printing of the abbreviations.
Diffstat (limited to 'debug/DwarfUtil.ml')
-rw-r--r--debug/DwarfUtil.ml18
1 files changed, 16 insertions, 2 deletions
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)