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 096C53858CDB for ; Sat, 8 Oct 2022 16:01:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 096C53858CDB 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 55B7A1E0CB; Sat, 8 Oct 2022 12:01:17 -0400 (EDT) Message-ID: <9ea099ee-e984-63ad-0400-dd9a6f9fa6ef@simark.ca> Date: Sat, 8 Oct 2022 12:01:16 -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: <15cf0c9f-81ae-9bc8-79ba-e5b4eb1f0412@simark.ca> <87wn9ae25u.fsf@redhat.com> From: Simon Marchi In-Reply-To: <87wn9ae25u.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 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 16:01:20 -0000 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, Thanks! Simon