From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 435103835431 for ; Fri, 17 Jun 2022 16:25:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 435103835431 Received: from ubuntu.lan (cust120-dsl54.idnet.net [212.69.54.120]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 2008486CF5; Fri, 17 Jun 2022 16:25:07 +0000 (UTC) Date: Fri, 17 Jun 2022 16:25:00 +0000 From: Lancelot SIX To: Simon Marchi Cc: gdb-patches@sourceware.org, Simon Marchi Subject: Re: [PATCH] gdb: reject inserting breakpoints between functions Message-ID: <20220617162125.pqcerpgquu5pruez@ubuntu.lan> References: <20220408200536.235329-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220408200536.235329-1-simon.marchi@efficios.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Fri, 17 Jun 2022 16:25:07 +0000 (UTC) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 16:25:09 -0000 Hi, I have just sent a patch[1] which sits on top of this one. I do not think there have been feedbacks on this yet, so I'd like to ping on this one on behalf on Simon. For what it is worth, I do agree with the change proposed changes as it is a pre-requisite for what I am proposing in [1]. Thanks, Lancelot. [1] https://sourceware.org/pipermail/gdb-patches/2022-June/190150.html > diff --git a/gdb/linespec.c b/gdb/linespec.c > index 9d4707cbb4e7..dd31cf2a9fc4 100644 > --- a/gdb/linespec.c > +++ b/gdb/linespec.c > @@ -2133,11 +2140,44 @@ create_sals_line_offset (struct linespec_state *self, > struct symbol *sym = (blocks[i] > ? block_containing_function (blocks[i]) > : NULL); > + symtab_and_line *sal = &intermediate_results[i]; > + > + /* Don't consider a match if: > + > + - the provided line did not give an exact match (so we started > + looking for lines below until we found one with code > + associated to it) > + - the found location is exactly the start of a function > + - the provided line is above the declaration line of the function > + > + Consider the following source: > + > + 10 } // end of a previous function > + 11 > + 12 int > + 13 main (void) > + 14 { > + 15 int i = 1; > + 16 > + 17 return 0; > + 18 } > + > + The intent of this heuristic is that a breakpoint requested on > + line 11 and 12 will not result on a breakpoint on main, but a > + breakpoint on line 13 will. A breakpoint requested on the empty > + line 16 will also result in a breakpoint in main, at line 17. */ > + if (!was_exact > + && sym != nullptr > + && sym->aclass () == LOC_BLOCK > + && sal->pc == BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) The BLOCK_ENTRY_PC and SYMBOL_BLOCK_VALUE macros have been removed. This should now be: + && sal->pc == sym->value_block ()->entry_pc () > + && val.line < sym->line ()) > + continue; > > if (self->funfirstline) > - skip_prologue_sal (&intermediate_results[i]); > - intermediate_results[i].symbol = sym; > - add_sal_to_sals (self, &values, &intermediate_results[i], > + skip_prologue_sal (sal); > + > + sal->symbol = sym; > + add_sal_to_sals (self, &values, sal, > sym ? sym->natural_name () : NULL, 0); > } > }