From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14010 invoked by alias); 7 Jul 2010 06:01:18 -0000 Received: (qmail 13760 invoked by uid 22791); 7 Jul 2010 06:01:16 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Jul 2010 06:01:09 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id EF07C2BAC36; Wed, 7 Jul 2010 02:01:07 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KqAuFlByhpPu; Wed, 7 Jul 2010 02:01:07 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 9F1492BABFB; Wed, 7 Jul 2010 02:01:07 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id A18C3F5895; Tue, 6 Jul 2010 23:00:51 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [RFA/commit] breakpoint_re_set fails while connecting to gdbserver. Date: Wed, 07 Jul 2010 06:01:00 -0000 Message-Id: <1278482450-29659-1-git-send-email-brobecker@adacore.com> 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-07/txt/msg00107.txt.bz2 This is a problem that I noticed on GNU/Linux, when using both GDB and GDBserver to debug an Ada program. To reproduce, use any Ada program, built with debug info ("gnatmake -g ..."). Then start the program with gdbserver: % gdbserver :4444 simple_main And then insert a breakpoint using the name of an Ada function, followed by connecting to the target server: (gdb) b simple.test_simple Breakpoint 1 at 0x401f28: file simple.adb, line 16. (gdb) tar rem :4444 Remote debugging using :4444 Reading symbols from /lib64/ld-linux-x86-64.so.2... Reading symbols from /usr/lib/debug/lib/ld-2.11.1.so...done. done. Loaded symbols for /lib64/ld-linux-x86-64.so.2 !!! -> Error in re-setting breakpoint 1: Can't find member of namespace, class, !!! -> struct, or union named "simple.test_simple" !!! -> Hint: try 'simple.test_simple or 'simple.test_simple !!! -> (Note leading single quote.) 0x00007f4db3cf2af0 in _start () from /lib64/ld-linux-x86-64.so.2 Created trace state variable $trace_timestamp for target's variable 1. The problem is related to the fact that GDB found debug symbols for ld.so in /usr/lib/debug. For debugger configured with a prefix that is different from /usr, one way to force the problem to reproduce is to use: (gdb) set debug-file-directory /usr/lib/debug (assuming that debug info has been installed at that location). The problem is that the wrong language is used to parse the breakpoint location because it gets changed from under us as a side effect of some of the code that we use in prepration for re-parsing. In particular, breakpoint_re_set_one reads: set_language (b->language); input_radix = b->input_radix; s = b->addr_string; save_current_space_and_thread (); switch_to_program_space_and_thread (b->pspace); marker_spec = b->type == bp_static_tracepoint && is_marker_spec (s); [if (marker_spec) decode_tracepoint_spec (...) else decode_line_1] What happens in our case is that debugging information gets found for ld.so. As a result, the current_frame language is C whereas it would have been unknown if we did not have debugging info. And save_current_space_and_thread() implicitly causes the current frame to be selected, which changes the language automatically if the new language is not uknown and the the language mode is auto. The fix, until all parsing routines (including decode_line_1) get upgraded to take a language, is to select the breakpoint language as late as possible. In this case, we don't need to do that until we actually try to parse the breakpoint addr_string. It looks like it's not just the parse routines that need to be language- ified. We'll have to look at linespec as well. In the meantime, this should be good enough. gdb/ChangeLog: * breakpoint.c (breakpoint_re_set_one): Move call to set_language down, just before the block that parse the breakpoint addr_string. Tested on x86_64-linux, no regression. I will commit in a day or two (HEAD & branch) if there are no objection. --- gdb/breakpoint.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 4808298..f7660a9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -10068,7 +10068,6 @@ breakpoint_re_set_one (void *bint) return 0; } - set_language (b->language); input_radix = b->input_radix; s = b->addr_string; @@ -10077,6 +10076,7 @@ breakpoint_re_set_one (void *bint) marker_spec = b->type == bp_static_tracepoint && is_marker_spec (s); + set_language (b->language); TRY_CATCH (e, RETURN_MASK_ERROR) { if (marker_spec) -- 1.7.1