From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4693 invoked by alias); 20 May 2011 14:03:40 -0000 Received: (qmail 4679 invoked by uid 22791); 20 May 2011 14:03:39 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_EG,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; Fri, 20 May 2011 14:03:23 +0000 Received: (qmail 16222 invoked from network); 20 May 2011 14:03:23 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 May 2011 14:03:23 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: skip setting the svr4 shared library breakpoint if there's no execution (Re: Regression loading a tracefile in 7_3) Date: Fri, 20 May 2011 14:03:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.6.2; x86_64; ; ) Cc: Marc Khouzam References: <201105201257.53942.pedro@codesourcery.com> In-Reply-To: <201105201257.53942.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201105201503.21053.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-05/txt/msg00478.txt.bz2 Moving to gdb-patches, from On Friday 20 May 2011 12:57:53, Pedro Alves wrote: > On Friday 20 May 2011 03:03:20, Marc Khouzam wrote: > > Hi, > > > > I believe I'm seeing a regression loading a tracefile in GDB 7.3 > > I create a simple tracefile using GDB/gdbserver 7.3 but when I try to load > > that tracefile, I get an error about "PC register is not available", which > > causes my Eclipse session to abort. This is not happening in 7.2 or 7.2.1. > > > > > gdb.7.3 a.out > > GNU gdb (GDB) 7.2.90.20110519-cvs > > (gdb) interpreter-exec mi "-target-select tfile trace.7.3" > > ~"Created tracepoint 1 for target's tracepoint 1 at 0x804851f.\n" > > ^error,msg="PC register is not available" > > > > Hmm. > > #0 throw_error (error=NOT_AVAILABLE_ERROR, fmt=0x7f7908 "PC register is not available") at ../../src/gdb/exceptions.c:423 > #1 0x000000000053de3a in regcache_read_pc (regcache=0xd4b280) at ../../src/gdb/regcache.c:994 > #2 0x0000000000497053 in enable_break (info=0xd0df60, from_tty=1) at ../../src/gdb/solib-svr4.c:1536 > #3 0x00000000004980a8 in svr4_solib_create_inferior_hook (from_tty=1) at ../../src/gdb/solib-svr4.c:2194 > #4 0x000000000046faa7 in solib_create_inferior_hook (from_tty=1) at ../../src/gdb/solib.c:1240 > #5 0x0000000000586de2 in post_create_inferior (target=0xbc7120, from_tty=1) at ../../src/gdb/infcmd.c:427 > #6 0x00000000004d2ca8 in tfile_open (filename=0xd0d790 "/home/pedro/gdb/marck_tfile/build/gdb/./testsuite/basic.tf", from_tty=1) > at ../../src/gdb/tracepoint.c:3410 > > Here, in solib-svr4.c: > > /* Otherwise we find the dynamic linker's base address by examining > the current pc (which should point at the entry point for the > dynamic linker) and subtracting the offset of the entry point. > > This is more fragile than the previous approaches, but is a good > fallback method because it has actually been working well in > most cases. */ > if (!load_addr_found) > { > struct regcache *regcache > = get_thread_arch_regcache (inferior_ptid, target_gdbarch); > > load_addr = (regcache_read_pc (regcache) > - exec_entry_point (tmp_bfd, tmp_bfd_target)); > } > > We could skip this if the PC is not available, but: > > - why do we even try to set a shared library breakpoint > if the target has no execution (e.g., when debugging a core > file) in the first place? I'll try skipping enable_break in that > case and see if anything breaks. By inspection, it looks like > nothing will. svr4_in_dynsym_resolve_code will always > return false if we skip enable_break, but then again that function > is only used for run control. Nothing did break. Here's the patch. Anyone see a problem with this? I'd like to apply this to mainline and 7.3. -- Pedro Alves 2011-05-20 Pedro Alves gdb/ * solib-svr4.c (svr4_solib_create_inferior_hook): Skip setting shared library event breakpoint if there's no execution. gdb/testsuite/ * gdb.trace/tfile.exp: Add test that opening the basic.tf trace file doesn't error, using MI. --- gdb/solib-svr4.c | 5 +++++ gdb/testsuite/gdb.trace/tfile.exp | 5 +++++ 2 files changed, 10 insertions(+) Index: src/gdb/solib-svr4.c =================================================================== --- src.orig/gdb/solib-svr4.c 2011-05-20 14:36:49.428819003 +0100 +++ src/gdb/solib-svr4.c 2011-05-20 14:54:58.548819003 +0100 @@ -2188,6 +2188,11 @@ svr4_solib_create_inferior_hook (int fro /* Relocate the main executable if necessary. */ svr4_relocate_main_executable (); + /* No point setting a breakpoint in the dynamic linker if we can't + hit it (e.g., a core file, or a trace file). */ + if (!target_has_execution) + return; + if (!svr4_have_link_map_offsets ()) return; Index: src/gdb/testsuite/gdb.trace/tfile.exp =================================================================== --- src.orig/gdb/testsuite/gdb.trace/tfile.exp 2011-05-20 14:36:49.428819003 +0100 +++ src/gdb/testsuite/gdb.trace/tfile.exp 2011-05-20 14:54:58.548819003 +0100 @@ -116,3 +116,8 @@ Collected 0 trace frame.* Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).* Not looking at any trace frame.*" \ "tstatus on error trace file" + +# Make sure we can reopen without error. +gdb_test \ + "interpreter-exec mi \"-target-select tfile basic.tf\"" \ + "\\^connected.*"