From patchwork Mon Dec 20 11:18:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 76185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B9276B6F1E for ; Mon, 20 Dec 2010 22:19:33 +1100 (EST) Received: (qmail 9971 invoked by alias); 20 Dec 2010 11:19:32 -0000 Received: (qmail 9957 invoked by uid 22791); 20 Dec 2010 11:19:31 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from c2bthomr09.btconnect.com (HELO mail.btconnect.com) (213.123.20.127) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Dec 2010 11:19:26 +0000 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2bthomr09.btconnect.com with ESMTP id BDH70891; Mon, 20 Dec 2010 11:19:21 +0000 (GMT) Message-Id: <56186808-25DF-4EB9-AED6-3EDF309FEAA6@sandoe-acoustics.co.uk> From: IainS To: GCC Patches Mime-Version: 1.0 (Apple Message framework v936) Subject: [Patch Debug] Emit pubnames for reorder & partition case. Date: Mon, 20 Dec 2010 11:18:59 +0000 Cc: Mike Stump , Jakub Jelinek X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0301.4D0F3BA4.0041, actions=tag X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B020A.4D0F3BBB.013C, ss=1, fgs=0, ip=0.0.0.0, so=2010-07-22 22:03:31, dmn=2009-09-10 00:05:08, mode=single engine X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org At present, pubnames are not emitted when -freorder-blocks-and- partition is active. This causes debug linking to fail on Darwin. The following patch outputs code ranges for Dwarf >=3 and produces a work-around for Dwarf-2. With this patch [and the one in http://gcc.gnu.org/ml/gcc-patches/2010-12/msg01553.html ] we can re-enable -freorder-blocks-and-partition on Darwin and debug works (at least for the partition cases in the test-suite). OK for trunk? Iain gcc: * dwarf2out.c (gen_subprogram_die): Add pubnames with code ranges for DWARF >= 3. Add pubnames for the primary section and a reduced DIE for the secondary code fragment when outputting for DWARF == 2. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 168084) +++ gcc/dwarf2out.c (working copy) @@ -18897,7 +18897,6 @@ static void gen_subprogram_die (tree decl, dw_die_ref context_die) { - char label_id[MAX_ARTIFICIAL_LABEL_BYTES]; tree origin = decl_ultimate_origin (decl); dw_die_ref subr_die; tree fn_arg_types; @@ -19067,12 +19066,24 @@ if (!flag_reorder_blocks_and_partition) { - ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_BEGIN_LABEL, - current_function_funcdef_no); - add_AT_lbl_id (subr_die, DW_AT_low_pc, label_id); - ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL, - current_function_funcdef_no); - add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id); + dw_fde_ref fde = &fde_table[current_funcdef_fde]; + if (fde->dw_fde_begin) + { + /* We have already generated the labels. */ + add_AT_lbl_id (subr_die, DW_AT_low_pc, fde->dw_fde_begin); + add_AT_lbl_id (subr_die, DW_AT_high_pc, fde->dw_fde_end); + } + else + { + /* Create start/end labels and add the range. */ + char label_id[MAX_ARTIFICIAL_LABEL_BYTES]; + ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_BEGIN_LABEL, + current_function_funcdef_no); + add_AT_lbl_id (subr_die, DW_AT_low_pc, label_id); + ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL, + current_function_funcdef_no); + add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id); + } #if VMS_DEBUGGING_INFO /* HP OpenVMS Industry Standard 64: DWARF Extensions @@ -19088,8 +19099,6 @@ attributes allow a compiler to communicate the location(s) to use. */ { - dw_fde_ref fde = &fde_table[current_funcdef_fde]; - if (fde->dw_fde_vms_end_prologue) add_AT_vms_delta (subr_die, DW_AT_HP_prologue, fde->dw_fde_begin, fde->dw_fde_vms_end_prologue); @@ -19104,19 +19113,116 @@ add_arange (decl, subr_die); } else - { /* Do nothing for now; maybe need to duplicate die, one for - hot section and one for cold section, then use the hot/cold - section begin/end labels to generate the aranges... */ - /* - add_AT_lbl_id (subr_die, DW_AT_low_pc, hot_section_label); - add_AT_lbl_id (subr_die, DW_AT_high_pc, hot_section_end_label); - add_AT_lbl_id (subr_die, DW_AT_lo_user, unlikely_section_label); - add_AT_lbl_id (subr_die, DW_AT_hi_user, cold_section_end_label); + { /* Generate pubnames entries for the split function code + ranges. */ + dw_fde_ref fde = &fde_table[current_funcdef_fde]; - add_pubname (decl, subr_die); - add_arange (decl, subr_die); - add_arange (decl, subr_die); - */ + if (fde->dw_fde_switched_sections) + { + if (dwarf_version >= 3 || !dwarf_strict) + { + /* We should use ranges for non-contiguous code section + addresses. Use the actual code range for the initial + section, since the HOT/COLD labels might precede an + alignment offset. */ + bool range_list_added = false; + if (fde->in_std_section) + { + add_ranges_by_labels (subr_die, + fde->dw_fde_begin, + fde->dw_fde_end, + &range_list_added); + add_ranges_by_labels (subr_die, + fde->dw_fde_unlikely_section_label, + fde->dw_fde_unlikely_section_end_label, + &range_list_added); + } + else + { + add_ranges_by_labels (subr_die, + fde->dw_fde_begin, + fde->dw_fde_end, + &range_list_added); + add_ranges_by_labels (subr_die, + fde->dw_fde_hot_section_label, + fde->dw_fde_hot_section_end_label, + &range_list_added); + } + add_pubname (decl, subr_die); + if (range_list_added) + add_ranges (NULL); + } + else + { + /* There is no real support in DW2 for this .. so we make + a work-around. First, emit the pub name for the segment + containing the function label. Then make and emit a + simplified subprogram DIE for the second segment with the + name post-fixed with _$hot$ or _$cold$. We use the same + linkage name for the second die so that gdb will find both + sections when given "b foo". */ + const char *name = NULL; + tree decl_name = DECL_NAME (decl); + dw_die_ref seg_die; + + /* Do the 'primary' section. */ + add_AT_lbl_id (subr_die, DW_AT_low_pc, + fde->dw_fde_begin); + add_AT_lbl_id (subr_die, DW_AT_high_pc, + fde->dw_fde_end); + /* Add it. */ + add_pubname (decl, subr_die); + add_arange (decl, subr_die); + + /* Build a minimal DIE for the secondary section. */ + seg_die = new_die (DW_TAG_subprogram, + subr_die->die_parent, decl); + + if (TREE_PUBLIC (decl)) + add_AT_flag (seg_die, DW_AT_external, 1); + + if (decl_name != NULL + && IDENTIFIER_POINTER (decl_name) != NULL) + { + name = dwarf2_name (decl, 1); + if (! DECL_ARTIFICIAL (decl)) + add_src_coords_attributes (seg_die, decl); + + add_linkage_name (seg_die, decl); + } + gcc_assert (name!=NULL); + add_pure_or_virtual_attribute (seg_die, decl); + if (DECL_ARTIFICIAL (decl)) + add_AT_flag (seg_die, DW_AT_artificial, 1); + + if (fde->in_std_section) + { + name = concat (name, "_$cold$", NULL); + add_AT_lbl_id (seg_die, DW_AT_low_pc, + fde->dw_fde_unlikely_section_label); + add_AT_lbl_id (seg_die, DW_AT_high_pc, + fde->dw_fde_unlikely_section_end_label); + } + else + { + name = concat (name, "_$hot$", NULL); + add_AT_lbl_id (seg_die, DW_AT_low_pc, + fde->dw_fde_hot_section_label); + add_AT_lbl_id (seg_die, DW_AT_high_pc, + fde->dw_fde_hot_section_end_label); + } + add_name_attribute (seg_die, name); + add_pubname_string (name, seg_die); + add_arange (decl, seg_die); + } + } + else + { + add_AT_lbl_id (subr_die, DW_AT_low_pc, fde->dw_fde_begin); + add_AT_lbl_id (subr_die, DW_AT_high_pc, fde->dw_fde_end); + add_pubname (decl, subr_die); + add_arange (decl, subr_die); + } } #ifdef MIPS_DEBUGGING_INFO