From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9A905386EC38 for ; Fri, 24 Jun 2022 12:01:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A905386EC38 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-oQ83nZ2yPVq0z_S8FngNcA-1; Fri, 24 Jun 2022 08:01:29 -0400 X-MC-Unique: oQ83nZ2yPVq0z_S8FngNcA-1 Received: by mail-wr1-f72.google.com with SMTP id i16-20020adfa510000000b0021b8e9f7666so285502wrb.19 for ; Fri, 24 Jun 2022 05:01:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=wH3W38gKToDwblnRgN3vV/w69ndk7p4eiqhVaPm68bk=; b=yA0IqiG/4/P9nR7LMF9ExKYUDWukB/LdqyaTdF/O99qL5/vpYn2IVyAU33ouO43VrG hm3tmmwHcsASJ6gTi9gDP76Krk8Upv61B0vlu3IMzRoExjIvzflBLJ7S7YdbKPEI23iP ldNDhxzCWA1JcjA1gY4TiHh+wjmKf70gO2JIb7vc8a9mm5HogqPOBQQZZorZ9+ful8Lg T833Zq/ROwfitX0DnauBecod+C1cgKL73bvBphotmPcaxMhE7U7tboXKzeYvf62W6z/l 6FUDaqEHfmGf8PVDTC7B+Z0lgw0DKPfPWtp25YzXmc2B6XstrEMc8AXAA3WNLSDwK9n0 ZRJw== X-Gm-Message-State: AJIora8HvQtBViyNZMgxRqfk65IKBi3nFtRMUpoIV+kP36IxCCfxJAUH skgmmJTU5y5SM2xU7sFyPhKAv0IL/8bvlHn1lHkAxsBlZVErsWUlge3U6M9JiIxodLJneB9MK0t zWHe5Vzkc4rz4oAjfZDQzSg== X-Received: by 2002:a05:600c:3d0f:b0:3a0:374b:dc74 with SMTP id bh15-20020a05600c3d0f00b003a0374bdc74mr3516741wmb.8.1656072088013; Fri, 24 Jun 2022 05:01:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uV4csml/+xX/4wWtxz3seEBL6uoczK4WmqvzRbQqI2oau/W/SFNnE+fz3FedynQOa6W2WVFQ== X-Received: by 2002:a05:600c:3d0f:b0:3a0:374b:dc74 with SMTP id bh15-20020a05600c3d0f00b003a0374bdc74mr3516719wmb.8.1656072087808; Fri, 24 Jun 2022 05:01:27 -0700 (PDT) Received: from localhost ([195.213.152.79]) by smtp.gmail.com with ESMTPSA id 10-20020a05600c26ca00b003973b9d0447sm7519272wmv.36.2022.06.24.05.01.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 05:01:13 -0700 (PDT) From: Andrew Burgess To: Enze Li , gdb-patches@sourceware.org Cc: pedro@palves.net, enze.li@gmx.com Subject: Re: [PATCH 2/2] gdb/testsuite: add a clear test to py-breakpoint.exp In-Reply-To: References: <877d5ac7i9.fsf@redhat.com> Date: Fri, 24 Jun 2022 13:00:54 +0100 Message-ID: <87mte2b79l.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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, 24 Jun 2022 12:01:32 -0000 Enze Li via Gdb-patches writes: > Hi Andrew, > > Thanks for your review. Please see below. > > On Tue, 2022-06-21 at 17:21 +0100, Andrew Burgess wrote: >> Enze Li via Gdb-patches writes: >>=20 >> > This patch adds a test case to try to clear an internal python >> > breakpoint using the clear command. >> >=20 >> > This was suggested by Pedro during a code review of the following >> > commit. >> >=20 >> > =C2=A0 commit a5c69b1e49bae4d0dcb20f324cebb310c63495c6 >> > =C2=A0 Date:=C2=A0=C2=A0 Sun Apr 17 15:09:46 2022 +0800 >> >=20 >> > =C2=A0=C2=A0=C2=A0 gdb: fix using clear command to delete non-user bre= akpoints(PR >> > cli/7161) >> >=20 >> > Tested on x86_64 openSUSE Tumbleweed. >> > --- >> > =C2=A0gdb/testsuite/gdb.python/py-breakpoint.exp | 41 >> > ++++++++++++++++++++++ >> > =C2=A01 file changed, 41 insertions(+) >> >=20 >> > diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp >> > b/gdb/testsuite/gdb.python/py-breakpoint.exp >> > index 58b1af3a0da..984c20f9dc2 100644 >> > --- a/gdb/testsuite/gdb.python/py-breakpoint.exp >> > +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp >> > @@ -296,6 +296,27 @@ proc_with_prefix test_watchpoints { } { >> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"Test watchpoint write= " >> > =C2=A0} >> > =C2=A0 >> > +# get_maint_bp_num bp_name >> > +# >> > +# Purpose: >> > +#=C2=A0=C2=A0=C2=A0 Get the number of a specified internal breakpoint= . >> > +# >> > +# Parameter: >> > +#=C2=A0=C2=A0=C2=A0 The parameter "bp_name" indicates the name of the= internal >> > breakpoint >> > +#=C2=A0=C2=A0=C2=A0 to get. >> > +# >> > +# Return: >> > +#=C2=A0=C2=A0=C2=A0 Internal breakpoint number.=C2=A0 Empty string if= fails. >> > +# >> > +proc get_maint_bp_num { bp_name } { >> > +=C2=A0=C2=A0=C2=A0 gdb_test_multiple "maint info break" "find $bp_nam= e internal >> > bp num" { >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-re -wrap "0x.*(-\[0-9\]).*= $bp_name.*" { >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return $= expect_out(1,string) >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} >> > +=C2=A0=C2=A0=C2=A0 } >> > +=C2=A0=C2=A0=C2=A0 return "" >> > +} >> > + >> > =C2=A0proc_with_prefix test_bkpt_internal { } { >> > =C2=A0=C2=A0=C2=A0=C2=A0 global srcfile testfile hex decimal >> > =C2=A0 >> > @@ -309,6 +330,26 @@ proc_with_prefix test_bkpt_internal { } { >> > =C2=A0=C2=A0=C2=A0=C2=A0 if ![runto_main] then { >> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return 0 >> > =C2=A0=C2=A0=C2=A0=C2=A0 } >> > +=C2=A0=C2=A0=C2=A0 delete_breakpoints >> > +=C2=A0=C2=A0=C2=A0 gdb_py_test_silent_cmd=C2=A0 "python bp1 =3D gdb.B= reakpoint >> > (\"main\", type=3Dgdb.BP_BREAKPOINT, wp_class=3Dgdb.WP_WRITE, >> > internal=3DTrue )" \ >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"Set internal breakpoint" 0 >> > + >> > +=C2=A0=C2=A0=C2=A0 set bp_num [get_maint_bp_num "main"] >>=20 >> Instead of adding get_maint_bp_num, would this work? >>=20 >> =C2=A0 set bp_num [get_python_valueof bp1.number "*DEFAULT*"] > > It works! There's no need to add a new procedure, and I'll drop it. Excellent! > >>=20 >> > +=C2=A0=C2=A0=C2=A0 set bp_addr [get_maint_bp_addr $bp_num] >> > + >> > +=C2=A0=C2=A0=C2=A0 gdb_test "maint info break $bp_num" \ >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"$bp_num.*$bp_addr.*" \ >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"maint info breakpoint \$bp= _num" >> > + >> > +=C2=A0=C2=A0=C2=A0 gdb_test "python gdb.execute(\'clear *$bp_addr\')"= \ >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0".*No breakpoint at \\*$bp_= addr.*" \ >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"clear internal breakpoint" >>=20 >> You might also want to try calling clear without the gdb.execute, >> just >> in case the Python layer makes a difference. >>=20 >> Thanks, >> Andrew > > In fact, there already exists a test case in the trunk which calling > clear command without python extention. (See clear_non_user_bp.exp, > line 86). However, if it is still needed here, pls let me know. I'll leave it up to you then. I think if you did add it, the test would be slightly different than anything else. But probably not in any significant way, so I don't really mind. Thanks, Andrew > > Best Regards, > Enze > >>=20 >> > + >> > +=C2=A0=C2=A0=C2=A0 # Check again, make sure that GDB really didn't de= lete the >> > internal breakpoint. >> > +=C2=A0=C2=A0=C2=A0 gdb_test "maint info break $bp_num" \ >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"$bp_num.*$bp_addr.*" \ >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"maint info breakpoint \$bp= _num after clear" >> > + >> > =C2=A0=C2=A0=C2=A0=C2=A0 delete_breakpoints >> > =C2=A0=C2=A0=C2=A0=C2=A0 gdb_py_test_silent_cmd=C2=A0 "python wp1 =3D = gdb.Breakpoint >> > (\"result\", type=3Dgdb.BP_WATCHPOINT, wp_class=3Dgdb.WP_WRITE, >> > internal=3DTrue )" \ >> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"Set watchpoint" 0 >> > --=20 >> > 2.36.1 >>=20