From b4846ffadfa3fbb73ffa7d9c43e5218adeece8da Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 18 Aug 2015 12:50:19 +0200 Subject: Added support for the location of non static global variables. --- debug/CtoDwarf.ml | 2 +- debug/DwarfPrinter.ml | 8 +++++++- debug/DwarfTypes.mli | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'debug') diff --git a/debug/CtoDwarf.ml b/debug/CtoDwarf.ml index cead6099..99b77e6f 100644 --- a/debug/CtoDwarf.ml +++ b/debug/CtoDwarf.ml @@ -304,7 +304,7 @@ let glob_var_to_dwarf (s,n,t,_) gloc = variable_file_loc = (Some gloc); variable_declaration = Some at_decl; variable_external = Some ext; - variable_location = None; + variable_location = if ext then Some (LocSymbol n.name) else None; variable_name = n.name; variable_segment = None; variable_type = i; diff --git a/debug/DwarfPrinter.ml b/debug/DwarfPrinter.ml index 67245ca8..70b68634 100644 --- a/debug/DwarfPrinter.ml +++ b/debug/DwarfPrinter.ml @@ -74,6 +74,7 @@ module DwarfPrinter(Target: DWARF_TARGET)(DwarfAbbrevs:DWARF_ABBREVS): | None -> () | Some (LocConst _) -> add_abbr_entry (0x2,location_const_type_abbr) buf | Some (LocBlock _) -> add_abbr_entry (0x2,location_block_type_abbr) buf + | Some (LocSymbol _) -> add_abbr_entry (0x2,location_block_type_abbr) buf (* Dwarf entity to string function *) let abbrev_string_of_entity entity has_sibling = @@ -294,7 +295,12 @@ module DwarfPrinter(Target: DWARF_TARGET)(DwarfAbbrevs:DWARF_ABBREVS): fprintf oc " .byte 0x%X\n" b let print_loc oc loc = - () + match loc with + | LocSymbol s -> + fprintf oc " .sleb128 5\n"; + fprintf oc " .byte 3\n"; + fprintf oc " .4byte %s\n" s + | _ -> () let print_data_location oc dl = () diff --git a/debug/DwarfTypes.mli b/debug/DwarfTypes.mli index d6592bd9..4852e550 100644 --- a/debug/DwarfTypes.mli +++ b/debug/DwarfTypes.mli @@ -37,6 +37,7 @@ type address = int type block = string type location_value = + | LocSymbol of string | LocConst of constant | LocBlock of block -- cgit