From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21164 invoked by alias); 22 Mar 2011 11:13:29 -0000 Received: (qmail 21113 invoked by uid 22791); 22 Mar 2011 11:13:27 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Mar 2011 11:13:21 +0000 Received: (qmail 3031 invoked from network); 22 Mar 2011 11:13:19 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Mar 2011 11:13:19 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: Regression: graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further Date: Tue, 22 Mar 2011 14:40:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.6.1; x86_64; ; ) Cc: Jan Kratochvil References: <201102221834.42413.pedro@codesourcery.com> <20110320184845.GA30084@host1.jankratochvil.net> In-Reply-To: <20110320184845.GA30084@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103221113.17253.pedro@codesourcery.com> 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: 2011-03/txt/msg00992.txt.bz2 On Sunday 20 March 2011 18:48:45, Jan Kratochvil wrote: > Hi Pedro, > > on a testfile from the Fedora patchset there is a regression, IMO a valid one: Agreed. > http://pkgs.fedoraproject.org/gitweb/?p=gdb.git;a=blob_plain;f=gdb-6.8-bz457187-largefile-test.patch;hb=f15/master > = This file is included in this mail. Thanks! > The core file does not have accessible registers. It was not a goal of the > testcase, it tests something else. But it has found this unrelated > regression. Yeah, nice test. > (gdb) x/i 0x400078 > 0x400078: hlt > PASS: gdb.arch/i386-biarch-core.exp: .text is readable > -> > (gdb) x/i 0x400078 > PC not available > FAIL: gdb.arch/i386-biarch-core.exp: .text is readable > I believe one should be able to evaluate PC-indepenent > expressions even if PC is not available. Yep, and you can. The quirk is x/i / disassemble specific. The error is thrown while trying to decide whether to print the "==>" that indicates the current PC. > Even the first part is regressing (although it stays PASS->PASS): > (gdb) core-file gdb.arch/i386-biarch-core.core > [New LWP 6901] > warning: Couldn't recognize general-purpose registers in core file. > Core was generated by `./bad'. > Program terminated with signal 11, Segmentation fault. > warning: Couldn't recognize general-purpose registers in core file. > #0 0x00000000 in ?? () > -> > (gdb) core-file gdb.arch/i386-biarch-core.core > [New LWP 6901] > warning: Couldn't recognize general-purpose registers in core file. > PC register is not available Fixed as well. After the patch: (...) warning: Couldn't recognize general-purpose registers in core file. Core was generated by `./bad'. Program terminated with signal 11, Segmentation fault. warning: Couldn't recognize general-purpose registers in core file. #0 in ?? () (gdb) and: (gdb) x/i 0x400078 0x400078: hlt Below's the patch. Doesn't cause regressions for me. Did you see any other regression? Thanks, Pedro Alves 2011-03-27 Pedro Alves * infcmd.c (post_create_inferior): Ignore NOT_AVAILABLE_ERROR errors when reading the `stop_pc'. * printcmd.c (pc_prefix): Use get_frame_pc_if_available instead of get_frame_pc. --- gdb/infcmd.c | 14 ++++++++++++-- gdb/printcmd.c | 4 +--- 2 files changed, 13 insertions(+), 5 deletions(-) Index: src/gdb/infcmd.c =================================================================== --- src.orig/gdb/infcmd.c 2011-03-15 20:15:05.000000000 +0000 +++ src/gdb/infcmd.c 2011-03-22 10:22:17.729088002 +0000 @@ -395,6 +395,8 @@ strip_bg_char (char **args) void post_create_inferior (struct target_ops *target, int from_tty) { + volatile struct gdb_exception ex; + /* Be sure we own the terminal in case write operations are performed. */ target_terminal_ours (); @@ -404,8 +406,16 @@ post_create_inferior (struct target_ops don't need to. */ target_find_description (); - /* Now that we know the register layout, retrieve current PC. */ - stop_pc = regcache_read_pc (get_current_regcache ()); + /* Now that we know the register layout, retrieve current PC. But + if the PC is unavailable (e.g., we're opening a core file with + missing registers info), ignore it. */ + stop_pc = 0; + TRY_CATCH (ex, RETURN_MASK_ERROR) + { + stop_pc = regcache_read_pc (get_current_regcache ()); + } + if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + throw_exception (ex); if (exec_bfd) { Index: src/gdb/printcmd.c =================================================================== --- src.orig/gdb/printcmd.c 2011-03-15 20:15:34.000000000 +0000 +++ src/gdb/printcmd.c 2011-03-22 10:21:41.829088002 +0000 @@ -759,9 +759,7 @@ pc_prefix (CORE_ADDR addr) CORE_ADDR pc; frame = get_selected_frame (NULL); - pc = get_frame_pc (frame); - - if (pc == addr) + if (get_frame_pc_if_available (frame, &pc) && pc == addr) return "=> "; } return " ";