Index: dwarf2out.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v retrieving revision 1.564 diff -u -p -r1.564 dwarf2out.c --- dwarf2out.c 24 Dec 2004 05:23:07 -0000 1.564 +++ dwarf2out.c 31 Dec 2004 20:05:35 -0000 @@ -9980,7 +9980,8 @@ add_location_or_const_value_attribute (d rtx rtl; dw_loc_descr_ref descr; var_loc_list *loc_list; - + bool can_use_fb = attr != DW_AT_frame_base && !DECL_EXTERNAL (decl); + struct var_loc_node *node; if (TREE_CODE (decl) == ERROR_MARK) return; @@ -9998,7 +9999,7 @@ add_location_or_const_value_attribute (d const char *endname; dw_loc_list_ref list; rtx varloc; - struct var_loc_node *node; + /* We need to figure out what section we should use as the base for the address ranges where a given location is valid. @@ -10037,7 +10038,7 @@ add_location_or_const_value_attribute (d node = loc_list->first; varloc = NOTE_VAR_LOCATION (node->var_loc_note); - list = new_loc_list (loc_descriptor (varloc, attr != DW_AT_frame_base), + list = new_loc_list (loc_descriptor (varloc, can_use_fb), node->label, node->next->label, secname, 1); node = node->next; @@ -10049,7 +10050,7 @@ add_location_or_const_value_attribute (d varloc = NOTE_VAR_LOCATION (node->var_loc_note); add_loc_descr_to_loc_list (&list, loc_descriptor (varloc, - attr != DW_AT_frame_base), + can_use_fb), node->label, node->next->label, secname); } @@ -10070,7 +10071,7 @@ add_location_or_const_value_attribute (d } add_loc_descr_to_loc_list (&list, loc_descriptor (varloc, - attr != DW_AT_frame_base), + can_use_fb), node->label, endname, secname); } @@ -10079,16 +10080,36 @@ add_location_or_const_value_attribute (d return; } + /* Try to get some constant RTL for this decl, and use that as the value of + the location. */ + rtl = rtl_for_decl_location (decl); if (rtl && (CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)) { add_const_value_attribute (die, rtl); return; } - + + /* We couldn't get any rtl, and we had no >1 element location list, so try + directly generating the location description from the tree. */ descr = loc_descriptor_from_tree (decl); if (descr) - add_AT_location_description (die, attr, descr); + { + add_AT_location_description (die, attr, descr); + return; + } + + /* Lastly, if we have tried to generate the location otherwise, and it + didn't work out (we wouldn't be here if we did), and we have a one entry + location list, try generating a location from that. */ + if (loc_list) + { + node = loc_list->first; + descr = loc_descriptor (NOTE_VAR_LOCATION (node->var_loc_note), + can_use_fb); + if (descr) + add_AT_location_description (die, attr, descr); + } } /* If we don't have a copy of this variable in memory for some reason (such