From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +OrCBLL0Q2P1/AgAWB0awg (envelope-from ) for ; Mon, 10 Oct 2022 06:32:18 -0400 Received: by simark.ca (Postfix, from userid 112) id 111531E112; Mon, 10 Oct 2022 06:32:18 -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=TTog3h2G; 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=unavailable 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 B6DB11E0D3 for ; Mon, 10 Oct 2022 06:32:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11D863858425 for ; Mon, 10 Oct 2022 10:32:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11D863858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665397937; bh=XTomJsn6tHJ6sV5edbL55gPFfFwxZpNWbDtk98EGNl4=; 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=TTog3h2GBheWAQ/mU+dJDThwYtr+WI/9KvKQb6zaGVN0DS2DaKW6f8hMjq3skWVWt UzCuppm1l0bGlYghSKVBi+8+hDVDPOQkS1LCp4jxJ1wsR32EoIDv3ta6WJrUJ+gl5i /mcFXrHPelm51ugOSf8yy8UAP5FPKCaTDGN81/yE= Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 8C131385840A for ; Mon, 10 Oct 2022 10:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C131385840A Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AC9D11F8AC; Mon, 10 Oct 2022 10:31:54 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 73F0913ACA; Mon, 10 Oct 2022 10:31:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id N1cVGpr0Q2NZLAAAMHmgww (envelope-from ); Mon, 10 Oct 2022 10:31:54 +0000 Message-ID: <32ac73a1-c0b8-75cf-72d3-bd11471d0fe6@suse.de> Date: Mon, 10 Oct 2022 12:31:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 2/3] gdb: improve disassembler styling when Pygments raises an exception Content-Language: en-US To: Andrew Burgess , Simon Marchi , gdb-patches@sourceware.org References: <15cf0c9f-81ae-9bc8-79ba-e5b4eb1f0412@simark.ca> <87wn9ae25u.fsf@redhat.com> <9ea099ee-e984-63ad-0400-dd9a6f9fa6ef@simark.ca> <87tu4cdnws.fsf@redhat.com> In-Reply-To: <87tu4cdnws.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed 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: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 10/10/22 11:32, Andrew Burgess via Gdb-patches wrote: > Simon Marchi writes: > >> On 2022-10-08 12:00, Andrew Burgess wrote: >>> 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 >> >> This is fine with me, but again, I didn't dig into it so I don't really >> know what sending a \004 was causing, > > Hi, > > Given you were seeing problems with the use of \004, and the tests > definitely were not about whether \004 could be used or not, I've pushed > the patch I proposed (exact version is below). > I found this independently and filed a PR ( https://sourceware.org/bugzilla/show_bug.cgi?id=29664 ) and wrote the same fix (in the same three test-cases), and was about to commit ... The FAIL is caused by using gdb_py_test_silent_cmd, which adds a "\n" at the end of the command in combination with "\004", causing a stray "\n" that generates an extra prompt, which makes the prompt matching unpredictable. Thanks, - Tom