From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id vqu5D5bfQGPZqAcAWB0awg (envelope-from ) for ; Fri, 07 Oct 2022 22:25:26 -0400 Received: by simark.ca (Postfix, from userid 112) id 333601E112; Fri, 7 Oct 2022 22:25:26 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=o3CuJxCz; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AA11C1E0D3 for ; Fri, 7 Oct 2022 22:25:25 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5E22395447E for ; Sat, 8 Oct 2022 02:25:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5E22395447E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665195924; bh=3ykTGONM99CQ0NoaEEjcNurjeMgol2AzYbanO4gF2/w=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=o3CuJxCzcP3Dxk0JE6oG0Fe9ng1nqR3vyAuzsYJVpR6gGE4+zjm1gtsz4A1kC+7x5 OmXvEPs+lX8MzQwj4/bPidqKdr4ad/MzCODK7NE903fgZmMISfM5qJmpS48eWU/70G kwqkibohEqELTWP3P9TmxONEF8dXu1sYn0hJam68= 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: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" > +# 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