From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 449343858023 for ; Sun, 27 Jun 2021 18:57:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 449343858023 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40652) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxZxq-0003DM-Jr for gdb@sourceware.org; Sun, 27 Jun 2021 14:57:06 -0400 Received: from ip5f5a8a3c.dynamic.kabel-deutschland.de ([95.90.138.60]:57281 helo=[192.168.111.41]) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lxZxq-00012s-AV for gdb@sourceware.org; Sun, 27 Jun 2021 14:57:06 -0400 From: Simon Sobisch To: gdb@sourceware.org Subject: subclass of gdb.Breakpoint - Is it possible to show an internal condition to the user? Message-ID: Date: Sun, 27 Jun 2021 20:57:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jun 2021 18:57:08 -0000 The GDB manual describes quite well how to subvlass gdb.Breakpoint and overwrite the stop method. This is very useful to implement conditions that need python code to execute, but it is something that is _additionally_ checked after the Breakpoint.condition was checked from GDB. Using "info breakpoints" the user sees this condition, but not the internal one. Comparision: (gdb) b 36 Breakpoint 2 at 0x5555555562c5: file TESTB.c, line 36. (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint keep y 0x00005555555562c5 in main at TESTB.c:36 (gdb) condition 2 argv=2 (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint keep y 0x00005555555562c5 in main at TESTB.c:36 stop only if argv=2 (gdb) py >class MyBreakpoint (gdb.Breakpoint): > def stop (self): > inf_val = gdb.parse_and_eval("argv") > if inf_val == 2: > return True > return False >end (gdb) py MyBreakpoint("36") Breakpoint 3 at 0x5555555562c5: file TESTB.c, line 36. (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint keep y 0x00005555555562c5 in main at TESTB.c:36 stop only if argv=2 3 breakpoint keep y 0x00005555555562c5 in main at TESTB.c:36 So with the subclass of gdb.Breakpoint: 1 the user possibly creates a condition that will never work (like ccondition 3 argv=3 - > if that is true then the stop method would be called and return false, so that it will never stop) 2 the user has no option to see which class of a breakpoint it is (could he, other than iterating over the breakpoints and check their class via python?) 3 the user cannot see what possibly complex condition (which is the reasonable use case to subclass and overwrite stop) is actually checke Question: Is it possible from the subclass to change the output of "info breakpoints" to show a note to the user, for example what complex condition is checked? If not: Can I suggest a new writable attribute "Breakpoint.note" that would be shown after "stop only if"? This way the subclass could present the user with something, for example ["stop only if easy-looking-condition"]. Thanks for thoughts and answers, Simon