From patchwork Wed Aug 12 21:33:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 8170 Received: (qmail 14507 invoked by alias); 12 Aug 2015 21:33:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14498 invoked by uid 89); 12 Aug 2015 21:33:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f201.google.com Received: from mail-pd0-f201.google.com (HELO mail-pd0-f201.google.com) (209.85.192.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 12 Aug 2015 21:33:10 +0000 Received: by pdbfa8 with SMTP id fa8so2522319pdb.1 for ; Wed, 12 Aug 2015 14:33:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:message-id:date:subject:from:to :content-type; bh=LtqnDg44kWgjzE2IVIJPZpGk/wQYShmgpZtug7WuuTQ=; b=M6bFo1OgO6avofj7C8ygm+51yMCgx00sHRtkHuG7/FdH8b+s2t8VHm1ABG2+RmgjV4 wX+k0NIKFIR6FqhNwcW7AR21bHIfTlImhalvhRCykAE53ykFwWqsFLyCYDe6404Dii8v /16r2wJ7emXqbE4nwnds6hvLuXa5VTPbr1PCI8mkyueO/ORyASq2W0lsUAZ2es2BzmN7 Ay43BfY+l9S1KKxhMJVDVOCJSBjQck0VR/Wktti1zPjrotoSLIT1PuVq7s9/yG9qzF0Q XjdeMWKXjViGlnOFUw2ZWpzOKK2QspMyB71W5cJTucfS3DxrG7xkYKKtPiT9bOEEe1pT BbVg== X-Gm-Message-State: ALoCoQmyR8ST1D4e0s3CiTj4HpJYy9blmob/A475YxYi8QXQpZegPtVFl33a0yzALt55zsViD60SsULmsW0xhW5p2SM6YwxOT+6c61ABAHSBWiL9Jm6YjH28xteqzpFQK8AhPeb1fX9/F1639MXfvqt4hWZ3VYCwwImvXLlfenJrG8QHndbickY= MIME-Version: 1.0 X-Received: by 10.68.102.99 with SMTP id fn3mr31835188pbb.2.1439415188796; Wed, 12 Aug 2015 14:33:08 -0700 (PDT) Message-ID: <047d7b675d880387a4051d23f744@google.com> Date: Wed, 12 Aug 2015 21:33:08 +0000 Subject: [PATCH] gdb.arch/amd64-entry-value-paramref.S: Fix DIE offsets From: Doug Evans To: gdb-patches@sourceware.org X-IsSubscribed: yes Hi. This patch has been failing for me (gdb internal error) for a very long time. I just never did anything about it because it wasn't important enough, but now's a good time to do a bit of test cleanup. The problem here is that DIE offsets are relative to the start of the CU, and if this test's .o is not the first .o linked then the current DIE offsets will be wrong. GDB will then crash on an internal error (*1) because it can't find a partial DIE at an expected offset. This patch restores a lot of the hardwired offsets, which the test tried to change because some DWARF was manually inserted into the generated output. And for those DIEs that need to change just adds "+2" to the designated offsets. This patch also restores some sibling attributes to further minimize differences from the generated output. [I know the original compiler emitted these sibling attributes because the original offsets (0x29, 0x39, etc.) aren't correct without them.] If you want to fix this by replacing all the label references with DIEfoo - .Ldebug_info0 go for it, but this patch differs from the generated file less. Until then, I plan to check this in. --- (*1): gdb obviously shouldn't internal-error on bad dwarf, but that's a separate bug. 2015-08-12 Doug Evans * gdb.arch/amd64-entry-value-paramref.S: Re-fixup DIE offsets, they're relative to the start of the CU. .section .debug_abbrev,"",@progbits @@ -255,6 +258,8 @@ DIEfe: .uleb128 0x10 # (DIE (0xfe) DW_TAG_pointer_type) .uleb128 0x13 # (DW_FORM_ref4) .uleb128 0x20 # (DW_AT_inline) .uleb128 0xb # (DW_FORM_data1) + .uleb128 0x1 # (DW_AT_sibling) + .uleb128 0x13 # (DW_FORM_ref4) .byte 0 .byte 0 .uleb128 0x3 # (abbrev code) @@ -310,6 +315,8 @@ DIEfe: .uleb128 0x10 # (DIE (0xfe) DW_TAG_pointer_type) .uleb128 0x18 # (DW_FORM_exprloc) .uleb128 0x2117 # (DW_AT_GNU_all_call_sites) .uleb128 0x19 # (DW_FORM_flag_present) + .uleb128 0x1 # (DW_AT_sibling) + .uleb128 0x13 # (DW_FORM_ref4) .byte 0 .byte 0 .uleb128 0x8 # (abbrev code) @@ -342,6 +349,8 @@ DIEfe: .uleb128 0x10 # (DIE (0xfe) DW_TAG_pointer_type) .uleb128 0x18 # (DW_FORM_exprloc) .uleb128 0x2117 # (DW_AT_GNU_all_call_sites) .uleb128 0x19 # (DW_FORM_flag_present) + .uleb128 0x1 # (DW_AT_sibling) + .uleb128 0x13 # (DW_FORM_ref4) .byte 0 .byte 0 .uleb128 0xa # (abbrev code) diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S index 7b1725d..bdf7ed1 100644 --- a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S +++ b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S @@ -117,65 +117,68 @@ vv: .long .Ldebug_ranges0+0 # DW_AT_ranges .quad 0 # DW_AT_low_pc .long .Ldebug_line0 # DW_AT_stmt_list -DIE29: .uleb128 0x2 # (DIE (0x29) DW_TAG_subprogram) + .uleb128 0x2 # (DIE (0x29) DW_TAG_subprogram) .ascii "bar\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc) .byte 0x15 # DW_AT_decl_line - .long DIE45 # DW_AT_type + .long 0x45 # DW_AT_type .byte 0x1 # DW_AT_inline -DIE39: .uleb128 0x3 # (DIE (0x39) DW_TAG_formal_parameter) + .long 0x45 # DW_AT_sibling + .uleb128 0x3 # (DIE (0x39) DW_TAG_formal_parameter) .ascii "ref\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc) .byte 0x15 # DW_AT_decl_line - .long DIE4c # DW_AT_type + .long 0x4c # DW_AT_type .byte 0 # end of children of DIE 0x29 -DIE45: .uleb128 0x4 # (DIE (0x45) DW_TAG_base_type) + .uleb128 0x4 # (DIE (0x45) DW_TAG_base_type) .byte 0x4 # DW_AT_byte_size .byte 0x5 # DW_AT_encoding .ascii "int\0" # DW_AT_name -DIE4c: .uleb128 0x5 # (DIE (0x4c) DW_TAG_const_type) - .long DIE51 # DW_AT_type -DIE51: .uleb128 0x6 # (DIE (0x51) DW_TAG_reference_type) + .uleb128 0x5 # (DIE (0x4c) DW_TAG_const_type) + .long 0x51 # DW_AT_type + .uleb128 0x6 # (DIE (0x51) DW_TAG_reference_type) .byte 0x8 # DW_AT_byte_size - .long DIE45 # DW_AT_type -DIE57: .uleb128 0x7 # (DIE (0x57) DW_TAG_subprogram) - .long DIE29 # DW_AT_abstract_origin + .long 0x45 # DW_AT_type + .uleb128 0x7 # (DIE (0x57) DW_TAG_subprogram) + .long 0x29 # DW_AT_abstract_origin .quad .LFB2 # DW_AT_low_pc .quad .LFE2-.LFB2 # DW_AT_high_pc .uleb128 0x1 # DW_AT_frame_base .byte 0x9c # DW_OP_call_frame_cfa # DW_AT_GNU_all_call_sites -DIE72: .uleb128 0x8 # (DIE (0x72) DW_TAG_formal_parameter) - .long DIE39 # DW_AT_abstract_origin + .long 0x7a # DW_AT_sibling + .uleb128 0x8 # (DIE (0x72) DW_TAG_formal_parameter) + .long 0x39 # DW_AT_abstract_origin .uleb128 0x1 # DW_AT_location .byte 0x55 # DW_OP_reg5 .byte 0 # end of children of DIE 0x57 -DIE7a: .uleb128 0x9 # (DIE (0x7a) DW_TAG_subprogram) + .uleb128 0x9 # (DIE (0x7a) DW_TAG_subprogram) # DW_AT_external .long .LASF3 # DW_AT_name: "main" .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc) .byte 0x1d # DW_AT_decl_line - .long DIE45 # DW_AT_type + .long 0x45 # DW_AT_type .quad .LFB1 # DW_AT_low_pc .quad .LFE1-.LFB1 # DW_AT_high_pc .uleb128 0x1 # DW_AT_frame_base .byte 0x9c # DW_OP_call_frame_cfa # DW_AT_GNU_all_call_sites -DIE9b: .uleb128 0xa # (DIE (0x9b) DW_TAG_lexical_block) + .long 0xd2 # DW_AT_sibling + .uleb128 0xa # (DIE (0x9b) DW_TAG_lexical_block) .quad .LBB2 # DW_AT_low_pc .quad .LBE2-.LBB2 # DW_AT_high_pc -DIEac: .uleb128 0xb # (DIE (0xac) DW_TAG_variable) + .uleb128 0xb # (DIE (0xac) DW_TAG_variable) .ascii "var\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc) .byte 0x1f # DW_AT_decl_line - .long DIE45 # DW_AT_type + .long 0x45 # DW_AT_type .uleb128 0x2 # DW_AT_location .byte 0x91 # DW_OP_fbreg .sleb128 -12 -DIEba: .uleb128 0xc # (DIE (0xba) DW_TAG_GNU_call_site) + .uleb128 0xc # (DIE (0xba) DW_TAG_GNU_call_site) .quad .LVL1 # DW_AT_low_pc - .long DIE57 # DW_AT_abstract_origin -DIEc7: .uleb128 0xd # (DIE (0xc7) DW_TAG_GNU_call_site_parameter) + .long 0x57 # DW_AT_abstract_origin + .uleb128 0xd # (DIE (0xc7) DW_TAG_GNU_call_site_parameter) .uleb128 0x1 # DW_AT_location .byte 0x55 # DW_OP_reg5 .uleb128 0x2 # DW_AT_GNU_call_site_value @@ -196,29 +199,29 @@ DIEc7: .uleb128 0xd # (DIE (0xc7) DW_TAG_GNU_call_site_parameter) .byte 0 # end of children of DIE 0xba .byte 0 # end of children of DIE 0x9b .byte 0 # end of children of DIE 0x7a -DIEd2: .uleb128 0xe # (DIE (0xd2) DW_TAG_variable) + .uleb128 0xe # (DIE (0xd2+2) DW_TAG_variable) .ascii "vv\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc) .byte 0x12 # DW_AT_decl_line - .long DIEe6 # DW_AT_type + .long 0xe6+2 # DW_AT_type # DW_AT_external .uleb128 0x9 # DW_AT_location .byte 0x3 # DW_OP_addr .quad vv -DIEe6: .uleb128 0xf # (DIE (0xe6) DW_TAG_volatile_type) - .long DIE45 # DW_AT_type -DIEeb: .uleb128 0xe # (DIE (0xeb) DW_TAG_variable) + .uleb128 0xf # (DIE (0xe6+2) DW_TAG_volatile_type) + .long 0x45 # DW_AT_type + .uleb128 0xe # (DIE (0xeb+2) DW_TAG_variable) .ascii "p\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc) .byte 0x12 # DW_AT_decl_line - .long DIEfe # DW_AT_type + .long 0xfe+2 # DW_AT_type # DW_AT_external .uleb128 0x9 # DW_AT_location .byte 0x3 # DW_OP_addr .quad p -DIEfe: .uleb128 0x10 # (DIE (0xfe) DW_TAG_pointer_type) + .uleb128 0x10 # (DIE (0xfe+2) DW_TAG_pointer_type) .byte 0x8 # DW_AT_byte_size - .long DIEe6 # DW_AT_type + .long 0xe6+2 # DW_AT_type .byte 0 # end of children of DIE 0xb .Linfo_end: