From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 86370388700F for ; Wed, 22 Apr 2020 12:39:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 86370388700F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 10635AA7C for ; Wed, 22 Apr 2020 12:39:03 +0000 (UTC) Date: Wed, 22 Apr 2020 14:39:02 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb/testsuite] Fix .debug_ranges in gdb.mi/dw2-ref-missing-frame-func.c Message-ID: <20200422123900.GA20181@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-29.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2020 12:39:06 -0000 Hi, While investigating PR25862 (an assertion failure with target board cc-with-debug-names), I noticed that the .debug_aranges section in gdb.mi/dw2-ref-missing-frame-func.c contains a hardcoded 0: ... " .4byte 0 \n" // .Ldebug_info0 - Offset of Compilation Unit Info ... So when looking for an address in the range 0x4004a7-0x4004bf, we should find the CU at 0xc7: ... Compilation Unit @ offset 0xc7: Length: 0xba (32-bit) Version: 2 Abbrev Offset: 0x64 Pointer Size: 4 <0>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_high_pc : 0x4004bf DW_AT_low_pc : 0x4004a7 DW_AT_name : file1.txt DW_AT_producer : GNU C 3.3.3 DW_AT_language : 1 (ANSI C) ... but instead the .debug_aranges entry points us to the CU at 0x0: ... Length: 28 Version: 2 Offset into .debug_info: 0x0 Pointer Size: 4 Segment Size: 0 Address Length 004004a7 00000018 00000000 00000000 ... Fix this by using a label to refer to the start of the CU, similar to how that's done for gdb.dlang/watch-loc.c in the fix for PR24522: ... " .4byte .Lcu1_begin\n" // .Ldebug_info0 - Offset of Compilation Unit Info ... The label marks the start of the empty .debug_info section for dw2-ref-missing-frame-func.c, which is supposed to merge with the .debug_info section in dw2-ref-missing-frame.S, so in order for that to work, we need to make sure dw2-ref-missing-frame-func.o comes before dw2-ref-missing-frame.o in the link line. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/testsuite] Fix .debug_ranges in gdb.mi/dw2-ref-missing-frame-func.c gdb/testsuite/ChangeLog: 2020-04-22 Tom de Vries * gdb.mi/dw2-ref-missing-frame-func.c (.debug_aranges): Fix debug_info_offset. * gdb.mi/dw2-ref-missing-frame.exp: Make sure $objfuncfile comes before $objsfile in the line line. --- gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c | 5 ++++- gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c index e3aed56c920..6d68b5b99cf 100644 --- a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c +++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c @@ -57,11 +57,14 @@ asm ("cu_text_end:"); generated by GCC. (.gdb_index includes a gdb-generated map instead.) */ asm ( +" .pushsection .debug_info,\"\",%progbits \n" +".Lcu1_begin: \n" +" .popsection \n" " .pushsection .debug_aranges,\"\",%progbits \n" " .4byte .Laranges_end - .Laranges_start \n" // Length of Address Ranges Info ".Laranges_start: \n" " .2byte 0x2 \n" // DWARF Version -" .4byte 0 \n" // .Ldebug_info0 - Offset of Compilation Unit Info +" .4byte .Lcu1_begin\n" // .Ldebug_info0 - Offset of Compilation Unit Info " .byte 4 \n" // Size of Address " .byte 0 \n" // Size of Segment Descriptor " .2byte 0 \n" // Pad to 16 byte boundary diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp index f099054a2d2..01f1960230f 100644 --- a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp +++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp @@ -30,7 +30,7 @@ set objmainfile [standard_output_file ${testfile}-main.o] if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $objsfile object {}] != "" || [gdb_compile "${srcdir}/${subdir}/${srcfile2}" $objfuncfile object {}] != "" || [gdb_compile "${srcdir}/${subdir}/${srcfile3}" $objmainfile object {debug}] != "" - || [gdb_compile "$objsfile $objfuncfile $objmainfile" $binfile executable {}] != "" } { + || [gdb_compile "$objfuncfile $objsfile $objmainfile" $binfile executable {}] != "" } { return -1 }