From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6490 invoked by alias); 27 Apr 2010 10:54:02 -0000 Received: (qmail 6211 invoked by uid 22791); 27 Apr 2010 10:53:58 -0000 X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=BAYES_00,KAM_STOCKGEN,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cam-admin0.cambridge.arm.com (HELO cam-admin0.cambridge.arm.com) (217.140.96.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Apr 2010 10:53:52 +0000 Received: from cam-owa2.Emea.Arm.com (cam-owa2.emea.arm.com [10.1.105.18]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id o3RArZeI008098; Tue, 27 Apr 2010 11:53:35 +0100 (BST) Received: from [10.1.79.63] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 27 Apr 2010 11:53:34 +0100 Subject: Re: [PATCH] Gracefully handle not being able to access a DWARF register number From: Matthew Gretton-Dann To: tromey@redhat.com Cc: gdb-patches@sourceware.org, Richard Earnshaw In-Reply-To: References: <1272295674.16160.23.camel@e102111-lin.cambridge.arm.com> Content-Type: multipart/mixed; boundary="=-6x/ZgktZfa39CPPGlRCM" Date: Tue, 27 Apr 2010 10:54:00 -0000 Message-Id: <1272365614.19466.6.camel@e102111-lin.cambridge.arm.com> Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00905.txt.bz2 --=-6x/ZgktZfa39CPPGlRCM Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1378 On Mon, 2010-04-26 at 14:06 -0600, Tom Tromey wrote: > >>>>> "Matthew" == Matthew Gretton-Dann writes: > > Matthew> The attached patch changes these internal errors into warnings, and > Matthew> tries to return something sensible to the user. > > Why a warning and not an error? > > It seems to me that an error is preferable to returning incorrect > information. Agreed. > Matthew> Please could someone review and comment on the patch, and then if this > Matthew> is approved can they please commit it as I don't have commit rights. > > Do you have copyright assignment paperwork in place? Yes - through my employer (ARM). > Matthew> + warning (_("Unable to access DWARF register number %" BFD_VMA_FMT "d"), > Matthew> + p->v.expr.value); > > I think there is some other way to print a CORE_ADDR, but I forget what > it is. BFD_VMA_FMT seems suspect, just because it is not used anywhere > else in gdb. Okay. Please find attached an updated patch that addresses the above two issues. Proposed ChangeLog: 2010-04-27 Matthew Gretton-Dann * dwarf2loc.c (read_pieced_value, write_pieced_value, dwarf2_evaluate_loc_desc): Handle not being able to access DWARF registers gracefully. Thanks, Matt -- Matthew Gretton-Dann Principal Engineer - Tools, PD Software ARM Limited --=-6x/ZgktZfa39CPPGlRCM Content-Disposition: attachment; filename=1004-gdb-dwarf2loc.patch Content-Type: text/x-patch; name=1004-gdb-dwarf2loc.patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 2100 Index: gdb/dwarf2loc.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2loc.c,v retrieving revision 1.74 diff -u -p -u -p -r1.74 dwarf2loc.c --- gdb/dwarf2loc.c 17 Mar 2010 22:04:43 -0000 1.74 +++ gdb/dwarf2loc.c 27 Apr 2010 09:44:34 -0000 @@ -284,8 +284,16 @@ read_pieced_value (struct value *v) /* Big-endian, and we want less than full size. */ reg_offset = register_size (arch, gdb_regnum) - p->size; - get_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size, - contents + offset); + if (gdb_regnum != -1) + { + get_frame_register_bytes (frame, gdb_regnum, reg_offset, + p->size, contents + offset); + } + else + { + error (_("Unable to access DWARF register number %s"), + paddress (arch, p->v.expr.value)); + } } break; @@ -356,8 +364,16 @@ write_pieced_value (struct value *to, st /* Big-endian, and we want less than full size. */ reg_offset = register_size (arch, gdb_regnum) - p->size; - put_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size, - contents + offset); + if (gdb_regnum != -1) + { + put_frame_register_bytes (frame, gdb_regnum, reg_offset, + p->size, contents + offset); + } + else + { + error (_("Unable to write to DWARF register number %s"), + paddress (arch, p->v.expr.value)); + } } break; case DWARF_VALUE_MEMORY: @@ -454,7 +470,16 @@ dwarf2_evaluate_loc_desc (struct symbol struct gdbarch *arch = get_frame_arch (frame); CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0); int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, dwarf_regnum); - retval = value_from_register (SYMBOL_TYPE (var), gdb_regnum, frame); + if (gdb_regnum != -1) + { + retval = value_from_register (SYMBOL_TYPE (var), + gdb_regnum, frame); + } + else + { + error (_("Unable to access DWARF register number %s"), + paddress (arch, dwarf_regnum)); + } } break; --=-6x/ZgktZfa39CPPGlRCM--