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.129.124]) by sourceware.org (Postfix) with ESMTPS id E19DA3858CDB for ; Sat, 8 Oct 2022 16:00:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E19DA3858CDB Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-271-fhGsG8D7Mp2mHLY9cVnDGw-1; Sat, 08 Oct 2022 12:00:17 -0400 X-MC-Unique: fhGsG8D7Mp2mHLY9cVnDGw-1 Received: by mail-wm1-f72.google.com with SMTP id o18-20020a05600c339200b003bf24961658so4373194wmp.6 for ; Sat, 08 Oct 2022 09:00:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wjEO0lhmqataOjQZK2DSVRPnvvfIUDO9/Vc/kcqSpEI=; b=iKLioJUFKOpFYL3r6EbHhz/4rH6NrW13a6o01jo180kEjUHEE5lx/zFw/5Z11YlL4z 6xsvUVdQccgYCw0WG9iByXuoKZcZ7gjw88tvCt9UgxJkqccIjT0yZMszRJ9d1rX0corM KZSp4P2/Jjr/7K+vCoVok5+/ao8Fjjag1eQS+uVTrBoxF08wSbowPR9XdRJQv4g715Ru edcg3QzH5zVDnbjOYP3YagwEq3rfAMw59IlLzPrfHtQUQH38m62WI/zcUk7gKFF0EjCk nS/GEunHenQvWPcvEUlT495lkcIkvdd6cSt6ohHhTDophNcXivNTi1vE25RkkEORKZuJ eqXA== X-Gm-Message-State: ACrzQf0t3uhW7aAGfAlBBZycmleLKLyA2iqF4F1nS8OwfM1MFZqn7Kq2 YLFXAbORhomc/DiVe6dZJSJ+T3FpwPLqQa/Y7CHGS4VJ8KTVpe+d3BOGYazoaGL7XmXIc2fTnSl PhBWW/gnVZfrtUqmS8i/dXQ== X-Received: by 2002:a05:6000:4084:b0:22e:5b99:4c4a with SMTP id da4-20020a056000408400b0022e5b994c4amr6900247wrb.538.1665244815668; Sat, 08 Oct 2022 09:00:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40olZu3Oy3v0VMDeRhwL/zr4hdf9Wxz/d5qd8AR+VZoFA7KrEkFhRsA8dmV5S7HlMKeCRMZg== X-Received: by 2002:a05:6000:4084:b0:22e:5b99:4c4a with SMTP id da4-20020a056000408400b0022e5b994c4amr6900232wrb.538.1665244815344; Sat, 08 Oct 2022 09:00:15 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id v127-20020a1cac85000000b003b505d26776sm10671889wme.5.2022.10.08.09.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 09:00:14 -0700 (PDT) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH 2/3] gdb: improve disassembler styling when Pygments raises an exception In-Reply-To: <15cf0c9f-81ae-9bc8-79ba-e5b4eb1f0412@simark.ca> References: <15cf0c9f-81ae-9bc8-79ba-e5b4eb1f0412@simark.ca> Date: Sat, 08 Oct 2022 17:00:13 +0100 Message-ID: <87wn9ae25u.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP 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: Sat, 08 Oct 2022 16:00:21 -0000 Simon Marchi writes: >> +# Check that, if the user is using Python Pygments for disassembler >> +# styling, then the styling correctly switches off when an error is >> +# detected in the Python code. >> +proc test_disassembler_error_handling { } { >> + >> + # This test requires the Python Pygments module to be installed >> + # and used by GDB. >> + if { !$::python_disassembly_styling } { >> + return >> + } >> + >> + save_vars { env(TERM) } { >> + # We need an ANSI-capable terminal to get the output. >> + setenv TERM ansi >> + >> + # Restart GDB with the correct TERM variable setting, this >> + # means that GDB will enable styling. >> + clean_restart_and_disable "restart 4" $::binfile >> + >> + # Disable use of libopcodes for styling. As this function is >> + # only called when Python Pygments module is available, we >> + # should now be using that module to style the disassembler >> + # output. >> + gdb_test_no_output "maint set libopcodes-styling enabled off" >> + >> + # Disassemble a single instruction and ensure that the output >> + # has styling markers in it. >> + set insn_before [get_single_disassembled_insn] >> + gdb_assert { [regexp "\033" $insn_before] } \ >> + "have style markers when Pygments is working fine" >> + >> + # Now replace the standard function that colorizes the >> + # disassembler output, with a new function that always returns >> + # None, this should cause GDB to stop using the Pygments >> + # module for disassembler styling. >> + gdb_py_test_silent_cmd \ >> + [multi_line_input \ >> + "python" \ >> + "def replacement_colorize_disasm(content,gdbarch):" \ >> + " return None" \ >> + "gdb.styling.colorize_disasm = replacement_colorize_disasm" \ >> + "\004"] \ > > Any reason you are using \004 here, instead of end? I don't quite > understand why, but it seems to cause some random failures. Running the > test under `taskset -c 2` makes it fail most of the time. Running it > with check-read1 makes it fail consistently: > > FAIL: gdb.base/style.exp: capture_command_output for x/1i *main > > When changing \004 for end, it passes. I don't have an explanation why > though. It'll be a copy&paste. There's a couple of other places in the testsuite where this pattern is used. The patch below changes all three to use 'end'. How's this? Thanks, Andrew --- commit eccf885d59a785cc3d9a76bd75184a9b9420f6b9 Author: Andrew Burgess Date: Sat Oct 8 16:58:00 2022 +0100 gdb/testsuite: use 'end' and the end of python blocks Use the keyword 'end' to terminate blocks of Python code being sent to GDB, rather than sending \004. diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index c6ed996c280..146e2b6d757 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -444,7 +444,7 @@ proc test_disassembler_error_handling { } { "def replacement_colorize_disasm(content,gdbarch):" \ " return None" \ "gdb.styling.colorize_disasm = replacement_colorize_disasm" \ - "\004"] \ + "end"] \ "setup replacement colorize_disasm function" \ true diff --git a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp index 9503e6c10f5..f2cf8b0e6ec 100644 --- a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp +++ b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp @@ -102,5 +102,5 @@ gdb_py_test_silent_cmd \ " raise gdb.GdbError (\"miss-matched names\")" \ " if (r1 != r2):" \ " raise gdb.GdbError (\"miss-matched objects\")" \ - "\004" ] \ + "end" ] \ "check names and objects match" 1 diff --git a/gdb/testsuite/gdb.python/py-arch-reg-names.exp b/gdb/testsuite/gdb.python/py-arch-reg-names.exp index d3c600ffc0f..62c47e8200e 100644 --- a/gdb/testsuite/gdb.python/py-arch-reg-names.exp +++ b/gdb/testsuite/gdb.python/py-arch-reg-names.exp @@ -102,7 +102,7 @@ gdb_py_test_silent_cmd \ " raise gdb.GdbError (\"miss-matched names\")" \ " if (r1 != r2):" \ " raise gdb.GdbError (\"miss-matched objects\")" \ - "\004" ] \ + "end" ] \ "check names and objects match" 1 # Ensure that the '.find' method on the iterator returns the same