From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29133 invoked by alias); 16 Sep 2010 22:23:42 -0000 Received: (qmail 29125 invoked by uid 22791); 16 Sep 2010 22:23:41 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Sep 2010 22:23:36 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8GMNZLN010370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 Sep 2010 18:23:35 -0400 Received: from mesquite.lan ([10.3.113.3]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8GMNYf3007460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 16 Sep 2010 18:23:34 -0400 Date: Fri, 17 Sep 2010 02:13:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [RFC] solib-svr4.c: Never attempt to place breakpoints on _start, __start, or main Message-ID: <20100916152334.7e4f1ee5@mesquite.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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-09/txt/msg00312.txt.bz2 I recently had a discussion with a colleague who, while debugging the linux kernel using GDB, noticed that GDB is writing a breakpoint to the _start address on every "step" and "continue". He had not placed a breakpoint at that address, nor did he want that address being written to in the event that the page containing that address had been recycled and was now being used for other purposes. I have found some cruft in solib-svr4.c which is responsible for this behavior -- well, I think it's cruft anyway. There's a bit of code at the end of enable_break() which, in desperation, attempts to place a breakpoint on one of _start, __start, or main, in that order only when all earlier attempts to place a shared library event breakpoint have failed. I have no doubt that there was probably some platform for which this once worked and was perhaps even needed, probably back in the days when GDB's SunOS and SVR4 shared library support was jumbled together in one file. I suspect that it may have been needed for SunOS support but was copied over to the SVR4 file in an abundance of caution. I doubt that there's any recent SVR4-like platform which requires this code. I've tested the patch below on Fedora 13 x86_64 (native) and do not see any regressions. Comments? (I.e. does anyone know of a platform or a situation where the code that I'm deleting is still needed?) * solib-svr4.c (bkpt_names): Delete. (enable_break): Don't attempt to break on the names formerly in bkpt_names: "_start", "__start", and "main". Index: solib-svr4.c =================================================================== RCS file: /cvs/src/src/gdb/solib-svr4.c,v retrieving revision 1.138 diff -u -p -r1.138 solib-svr4.c --- solib-svr4.c 3 Aug 2010 22:35:41 -0000 1.138 +++ solib-svr4.c 16 Sep 2010 22:15:30 -0000 @@ -74,11 +74,7 @@ struct lm_info /* On SVR4 systems, a list of symbols in the dynamic linker where GDB can try to place a breakpoint to monitor shared library - events. - - If none of these symbols are found, or other errors occur, then - SVR4 systems will fall back to using a symbol as the "startup - mapping complete" breakpoint address. */ + events. */ static const char * const solib_break_names[] = { @@ -92,14 +88,6 @@ static const char * const solib_break_na NULL }; -static const char * const bkpt_names[] = -{ - "_start", - "__start", - "main", - NULL -}; - static const char * const main_name_list[] = { "main_$main", @@ -1607,19 +1595,6 @@ enable_break (struct svr4_info *info, in } } - for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++) - { - msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile); - if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0)) - { - sym_addr = SYMBOL_VALUE_ADDRESS (msymbol); - sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch, - sym_addr, - ¤t_target); - create_solib_event_breakpoint (target_gdbarch, sym_addr); - return 1; - } - } return 0; }