aboutsummaryrefslogtreecommitdiffstats
path: root/debug/DwarfPrinter.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2019-04-08 17:23:31 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2019-04-16 18:33:34 +0200
commit06d846bd517cb0e47ab7b55cdbc912939524ca26 (patch)
tree3c6bd22e229b58d8a5ea2235837c9070e0f385a5 /debug/DwarfPrinter.ml
parent5cee733c33bd53c0f58e9896f238ab862e224e46 (diff)
downloadcompcert-kvx-06d846bd517cb0e47ab7b55cdbc912939524ca26.tar.gz
compcert-kvx-06d846bd517cb0e47ab7b55cdbc912939524ca26.zip
Reworked range entries.
The fist changes changes the offset for range entries to used labels instead of integer constants, leaving the computation to the assembler. The second part of the change the address changes the way ranges entries of scopes are printed. They need to be relative to the start address of the code in the section they are included. Bug 26234
Diffstat (limited to 'debug/DwarfPrinter.ml')
-rw-r--r--debug/DwarfPrinter.ml31
1 files changed, 23 insertions, 8 deletions
diff --git a/debug/DwarfPrinter.ml b/debug/DwarfPrinter.ml
index a45fff0c..5634d58c 100644
--- a/debug/DwarfPrinter.ml
+++ b/debug/DwarfPrinter.ml
@@ -244,6 +244,8 @@ module DwarfPrinter(Target: DWARF_TARGET):
(* Mapping from abbreviation string to abbreviaton id *)
let abbrev_mapping: (string,int) Hashtbl.t = Hashtbl.create 7
+ let range_labels : (int, int) Hashtbl.t = Hashtbl.create 7
+
(* Look up the id of the abbreviation and add it if it is missing *)
let get_abbrev entity has_sibling =
let abbrev_string = abbrev_string_of_entity entity has_sibling in
@@ -439,8 +441,11 @@ module DwarfPrinter(Target: DWARF_TARGET):
| Pc_pair (l,h) ->
print_addr oc "DW_AT_low_pc" l;
print_addr oc "DW_AT_high_pc" h
- | Offset i -> fprintf oc " .4byte %a+0x%d%a\n"
- label !debug_ranges_addr i print_comment "DW_AT_ranges"
+ | Offset i ->
+ let lbl = new_label () in
+ Hashtbl.add range_labels i lbl;
+ fprintf oc " .4byte %a+(%a-%a)%a\n"
+ label !debug_ranges_addr label lbl label !debug_ranges_addr print_comment "DW_AT_ranges"
| _ -> ()
let print_compilation_unit oc tag =
@@ -641,14 +646,23 @@ module DwarfPrinter(Target: DWARF_TARGET):
end
let print_ranges oc r =
+ let print_range_entry = function
+ | AddressRange l ->
+ List.iter (fun (b,e) ->
+ fprintf oc " %s %a\n" address label b;
+ fprintf oc " %s %a\n" address label e) l;
+ | OffsetRange (start, l) ->
+ List.iter (fun (b,e) ->
+ fprintf oc " %s %a-%a\n" address label b label start;
+ fprintf oc " %s %a-%a\n" address label e label start) l
+ in
section oc Section_debug_ranges;
print_label oc !debug_ranges_addr;
- List.iter (fun l ->
- List.iter (fun (b,e) ->
- fprintf oc " %s %a\n" address label b;
- fprintf oc " %s %a\n" address label e) l;
- fprintf oc " %s 0\n" address;
- fprintf oc " %s 0\n" address) r
+ List.iter (fun (lbl,l) ->
+ print_label oc (Hashtbl.find range_labels lbl);
+ print_range_entry l;
+ fprintf oc " %s 0\n" address;
+ fprintf oc " %s 0\n" address) r
let print_gnu_entries oc cp (lpc,loc) s r =
compute_abbrev cp;
@@ -679,6 +693,7 @@ module DwarfPrinter(Target: DWARF_TARGET):
(* Print the debug info and abbrev section *)
let print_debug oc debug =
Hashtbl.clear abbrev_mapping;
+ Hashtbl.clear range_labels;
Hashtbl.clear loc_labels;
match debug with
| Diab entries -> print_diab_entries oc entries