From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22011 invoked by alias); 28 Jun 2018 17:32:59 -0000 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 Received: (qmail 21995 invoked by uid 89); 28 Jun 2018 17:32:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:1943 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Jun 2018 17:32:57 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6E71A56145; Thu, 28 Jun 2018 13:32:56 -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 vXtQYOU71yEg; Thu, 28 Jun 2018 13:32:56 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 3C27456144; Thu, 28 Jun 2018 13:32:56 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 7D2B88793F; Thu, 28 Jun 2018 10:32:54 -0700 (PDT) Date: Thu, 28 Jun 2018 17:32:00 -0000 From: Joel Brobecker To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] Fix running to breakpoint set in inline function by lineno/address Message-ID: <20180628173254.GB2511@adacore.com> References: <77528608-be2c-5a21-e250-36e7d56ba950@redhat.com> <20180628145035.24713-1-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180628145035.24713-1-palves@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-SW-Source: 2018-06/txt/msg00695.txt.bz2 > Commit 61b04dd04ac2 ("Change inline frame breakpoint skipping logic > (fix gdb.gdb/selftest.exp)") caused a GDB crash when you set a > breakpoint by line number in an inline function, and then run to the > breakpoint: > > $ gdb -q test Reading symbols from test...done. > (gdb) b inline-break.c:32 > Breakpoint 1 at 0x40062f: file inline-break.c, line 32. > (gdb) run > Starting program: /[...]/test > [1] 75618 segmentation fault /[...]/gdb -q test > > The problem occurs because we assume that a bp_location's symbol is > not NULL, which is not true when we set the breakpoint with a linespec > location: > > Program received signal SIGSEGV, Segmentation fault. > 0x00000000006f42bb in stopped_by_user_bp_inline_frame ( > stop_chain=, frame_block=) > at gdb/inline-frame.c:305 > 305 && frame_block == SYMBOL_BLOCK_VALUE (loc->symbol)) > (gdb) p loc->symbol > $1 = (const symbol *) 0x0 > > The same thing happens if you run to a breakpoint set in an inline > function by address: > > (gdb) b *0x40062f > Breakpoint 3 at 0x40062f: file inline-break.c, line 32. > > To fix this, add a null pointer check, to avoid the crash, and make it > so that if there's not symbol for the location, then we present the > stop at the inline function. This preserves the previous behavior > when e.g., setting a breakpoint by address, with "b *ADDRESS". > > gdb/ChangeLog: > yyyy-mm-dd Pedro Alves > > * inline-frame.c (stopped_by_user_bp_inline_frame): Return > true if the the location has no symbol. > > gdb/testsuite/ChangeLog: > yyyy-mm-dd Pedro Alves > > * gdb.opt/inline-break.c (func1): Add "break here" marker. > * gdb.opt/inline-break.exp: Test setting breakpoints by line > number and address and running to them. Thanks, Pedro. I had a look, and FWIW, the patch looks good to me. -- Joel