From 06d846bd517cb0e47ab7b55cdbc912939524ca26 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 8 Apr 2019 17:23:31 +0200 Subject: 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 --- debug/DwarfPrinter.ml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'debug/DwarfPrinter.ml') 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 -- cgit From 65ac4adf1fb1c2642a8e69d098049dfa2ab90e92 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 9 Apr 2019 18:16:09 +0200 Subject: Simplified offset printing. Instead of printing an the start label and adding the offset by computing the difference of the range label and the start label use the range label directly. Bug 26234 --- debug/DwarfPrinter.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'debug/DwarfPrinter.ml') diff --git a/debug/DwarfPrinter.ml b/debug/DwarfPrinter.ml index 5634d58c..c5df5637 100644 --- a/debug/DwarfPrinter.ml +++ b/debug/DwarfPrinter.ml @@ -244,6 +244,7 @@ module DwarfPrinter(Target: DWARF_TARGET): (* Mapping from abbreviation string to abbreviaton id *) let abbrev_mapping: (string,int) Hashtbl.t = Hashtbl.create 7 + (* Mapping from abbreviation range id to label *) let range_labels : (int, int) Hashtbl.t = Hashtbl.create 7 (* Look up the id of the abbreviation and add it if it is missing *) @@ -444,8 +445,8 @@ module DwarfPrinter(Target: DWARF_TARGET): | 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" + fprintf oc " .4byte %a%a\n" + label lbl print_comment "DW_AT_ranges" | _ -> () let print_compilation_unit oc tag = -- cgit From 8b0724fdb1af4f89a603f7bde4b5b625c870e111 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Fri, 31 May 2019 11:55:57 +0200 Subject: Fix misspellings in messages, man pages, and comments This is a manual, partial merge of Github pull request #296 by @Fourchaux. flocq/, cparser/MenhirLib/ and parts of test/ have not been changed because these are local copies and the fixes should be performed upstream. --- debug/DwarfPrinter.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debug/DwarfPrinter.ml') diff --git a/debug/DwarfPrinter.ml b/debug/DwarfPrinter.ml index c5df5637..bbfcf311 100644 --- a/debug/DwarfPrinter.ml +++ b/debug/DwarfPrinter.ml @@ -241,7 +241,7 @@ module DwarfPrinter(Target: DWARF_TARGET): let abbrev = !curr_abbrev in incr curr_abbrev;abbrev - (* Mapping from abbreviation string to abbreviaton id *) + (* Mapping from abbreviation string to abbreviation id *) let abbrev_mapping: (string,int) Hashtbl.t = Hashtbl.create 7 (* Mapping from abbreviation range id to label *) -- cgit