From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 4C1933954414 for ; Sat, 8 Oct 2022 02:25:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C1933954414 Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id ABD1D1E0D3; Fri, 7 Oct 2022 22:25:04 -0400 (EDT) Message-ID: <15cf0c9f-81ae-9bc8-79ba-e5b4eb1f0412@simark.ca> Date: Fri, 7 Oct 2022 22:25:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH 2/3] gdb: improve disassembler styling when Pygments raises an exception Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org References: From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, 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 02:25:07 -0000 > +# 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. Simon