From patchwork Sat Jun 23 00:15:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27996 Received: (qmail 73105 invoked by alias); 23 Jun 2018 00:15:48 -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 72872 invoked by uid 89); 23 Jun 2018 00:15:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:catch_c, DIEs X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.65.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Jun 2018 00:15:11 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 191C0400CC24C for ; Fri, 22 Jun 2018 19:15:10 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id WWCrfdH9zkBj6WWCrf3oLA; Fri, 22 Jun 2018 19:15:10 -0500 X-Authority-Reason: nr=8 Received: from 75-166-79-120.hlrn.qwest.net ([75.166.79.120]:50824 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fWWCr-0027KK-ML; Fri, 22 Jun 2018 19:15:09 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Handle DW_AT_ranges in partial_die_info::read Date: Fri, 22 Jun 2018 18:15:06 -0600 Message-Id: <20180623001506.19362-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fWWCr-0027KK-ML X-Source-Sender: 75-166-79-120.hlrn.qwest.net (pokyo.Home) [75.166.79.120]:50824 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes On x86-64 Fedora 28, with the system gcc (8.1.1), I got this failure when running the gdb.gdb tests: (gdb) call catch_command_errors(execute_command, "python print(5)", 0) Cannot resolve function catch_command_errors to any overloaded instance Debugging interactively showed that gdb was not finding debug info for execute_command: (top-gdb) print execute_command $2 = {} 0x7ecec0 However, the DWARF was definitely there: [4d5a860] subprogram external true name "execute_command" decl_file "../../binutils-gdb/gdb/top.c" decl_line 540 decl_column 1 linkage_name "_Z15execute_commandPKci" ranges 0x429cfc..0x429d32, 0x7ecec0..0x7ed3d3 frame_base 0..0xffffffffffffffff:0 call_frame_cfa GNU_all_call_sites true sibling [4d5b890] structure_type Debugging further showed that the DIE was being rejected by load_partial_dies, because the partial DIE's "has_pc_info" flag was not set. This patch fixes the problem by changing partial_die_info::read to recognize DW_AT_ranges. I had filed this as PR symtab/23331. Someday it would be good to unify the partial symtab and full symtab DWARF readers. That would make this sort of bug much less likely. I am not completely sure this patch is correct. Perhaps it's necessary to arrange to pass the partial symtab into dwarf2_ranges_read. Also, I did not know how to write a standalone test case for this. It does fix a regression locally, though. Tested by the buildbot. gdb/ChangeLog 2018-06-22 Tom Tromey PR symtab/23331: * dwarf2read.c (partial_die_info::read): Handle DW_AT_ranges. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2read.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9539c87ca18..5cc427bd49b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-06-22 Tom Tromey + + PR symtab/23331: + * dwarf2read.c (partial_die_info::read): Handle DW_AT_ranges. + 2018-06-22 Alan Hayward * regcache.c (readable_regcache::read_part): Fix asserts. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 4ad05274064..8e5389c55b6 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -18424,6 +18424,25 @@ partial_die_info::read (const struct die_reader_specs *reader, if (cu->header.version >= 4 && attr_form_is_constant (&attr)) high_pc_relative = 1; break; + case DW_AT_ranges: + { + bool need_ranges_base = tag != DW_TAG_compile_unit; + unsigned int ranges_offset = (DW_UNSND (&attr) + + (need_ranges_base + ? cu->ranges_base + : 0)); + + /* Value of the DW_AT_ranges attribute is the offset in + the .debug_ranges section. */ + if (dwarf2_ranges_read (ranges_offset, &lowpc, &highpc, cu, + nullptr)) + { + has_low_pc_attr = 1; + has_high_pc_attr = 1; + high_pc_relative = 0; + } + } + break; case DW_AT_location: /* Support the .debug_loc offsets. */ if (attr_form_is_block (&attr))