From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 3B7D23858C27 for ; Thu, 10 Nov 2022 15:57:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3B7D23858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 8D22C10045121 for ; Thu, 10 Nov 2022 15:57:03 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id t9vLocJi9ovtqt9vLoLKPW; Thu, 10 Nov 2022 15:57:03 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=PshW0yA3 c=1 sm=1 tr=0 ts=636d1f4f a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=9xFQ1JgjjksA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=QHnqqIJDIHcbfczK23gA:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Giac3G0kzyGwp/D6ECksqiTXh0PZKmn0n44+lKiq8XE=; b=c/AUiBqTSP6uLY1xVKjhJtWDnQ 2uw2aasWkFLmfFf7Nv9f/KSOdIMwhUEzzb+LiUIICzV6iADKwNTou73kx1GRhJco1+d2ndmdFT4ha i3zvv9brm1yVYOvfLANbtb+Ba; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:56822 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ot9vL-000mLT-4E; Thu, 10 Nov 2022 08:57:03 -0700 From: Tom Tromey To: Philippe Waroquiers via Gdb-patches Cc: Philippe Waroquiers Subject: Re: [RFAv3] Show locno for 'multi location' breakpoint hit msg+conv var $bkptno $locno. References: <20220606094504.744323-1-philippe.waroquiers@skynet.be> X-Attribution: Tom Date: Thu, 10 Nov 2022 08:57:00 -0700 In-Reply-To: <20220606094504.744323-1-philippe.waroquiers@skynet.be> (Philippe Waroquiers via Gdb-patches's message of "Mon, 6 Jun 2022 11:45:04 +0200") Message-ID: <87a64yzttf.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.76.186 X-Source-L: No X-Exim-ID: 1ot9vL-000mLT-4E X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (murgatroyd) [97.122.76.186]:56822 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3022.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Philippe" == Philippe Waroquiers via Gdb-patches writes: Hi. Thanks for the patch. I'm sorry about the long delay on the review. I'm not really sure what to do about it but I think we need to make some change here, because too many patches are falling into this "10 pings" hole. Philippe> Before this patch, when a breakpoint that has multiple locations is reached, Philippe> GDB printed: Philippe> Thread 1 "zeoes" hit Breakpoint 1, some_func () at somefunc1.c:5 Philippe> This patch changes the message so that bkpt_print_id prints the precise Philippe> encountered breakpoint: Philippe> Thread 1 "zeoes" hit Breakpoint 1.2, some_func () at somefunc1.c:5 Philippe> In mi mode, bkpt_print_id also (optionally) prints a new table field "locno": Philippe> locno is printed when the breakpoint has more than one location. Philippe> Note that according to the GDB user manual node 'GDB/MI Development and Front Philippe> Ends', it is ok to add new fields without changing the MI version. I think the idea as a whole is sound, thank you for tackling this. Philippe> Also, when a breakpoint is reached, the convenience variables Philippe> $bkptno and $locno are set to the encountered breakpoint number Philippe> and location number. I believe we have a convention that new internally-created convenience variables will start with "_". I wondered a little whether we wanted to introduce $_bkptno or just repurpose the already-existing $bpnum, but I see we already do this kind of thing for tracepoints, and I suppose having different variables for different semantics is good... it's just a bit unfortunate that the names are similar. Note that the breakpoint number convenience variable is https://sourceware.org/bugzilla/show_bug.cgi?id=12464, so this should be in a Bug: trailer and also mentioned in the form "PR breakpoints/12464" somewhere in the commit message. Philippe> +Inside a command list, you can use the command Philippe> +@kbd{disable $bkptno} to disable the encountered breakpoint. Philippe> + Philippe> +If your breakpoint has several code locations, the command Philippe> +@kbd{disable $bkptno.$locno} will disable the specific breakpoint code Philippe> +location encountered. It may be worth mentioning that the $_bkptno.$_locno form will work even when your breakpoint only has a single location, and also the ".1" special case for single-location breakpoints. Philippe> @@ -8494,7 +8494,21 @@ print_stop_location (const target_waitstatus &ws) Philippe> LOCATION: Print only location Philippe> SRC_AND_LOC: Print location and source line. */ Philippe> if (do_frame_printing) Philippe> - print_stack_frame (get_selected_frame (NULL), 0, source_flag, 1); Philippe> + { Philippe> + if (tp->control.stop_bpstat != nullptr) Philippe> + { Philippe> + const struct breakpoint *b = tp->control.stop_bpstat->breakpoint_at; Philippe> + Philippe> + if (b != nullptr) Philippe> + { Philippe> + int locno = bpstat_locno (tp->control.stop_bpstat); Philippe> + set_internalvar_integer (lookup_internalvar ("bkptno"), b->number); Philippe> + set_internalvar_integer (lookup_internalvar ("locno"), Philippe> + (locno > 0 ? locno : 1)); This is in print_stop_location - but what if the location is not printed? I am curious if these variables can be, are intended to be, or should be usable from breakpoint conditions or silent 'commands'. I suspect maybe bpstat_do_actions_1 is a better spot for this, though I'm not really sure. Tom