From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id biuqFWUTwWnjejUAWB0awg (envelope-from ) for ; Mon, 23 Mar 2026 06:18:13 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HzATqj+A; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 48CF81E0BC; Mon, 23 Mar 2026 06:18:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8F95E1E04F for ; Mon, 23 Mar 2026 06:18:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 316644BAD17F for ; Mon, 23 Mar 2026 10:18:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 316644BAD17F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HzATqj+A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 538BE4B9DB71 for ; Mon, 23 Mar 2026 10:17:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 538BE4B9DB71 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 538BE4B9DB71 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774261065; cv=none; b=tuYPbgxtRi/meS1d7iEa2GoCbddSBsYDJvhIT3uLlQLE+O1rlaEie42qERtkQ/SZ3XBOdZpdkl5EZjg2RtXzC8MyvHG+31nufM/mlOk/J1ODhTFxl7mCGZO/TtqXTIMATLGO/GnWmMqdVCaLjl6A5OMgenfYc/IBM/F4a+DIUvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774261065; c=relaxed/simple; bh=gPbRQIOa+rum/NUaVSxWGBsh0hjGfZ+0A4TQHMBY5uw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ueKrMnRwTwmrAmyd4CCBLrE/zrjvZzVrpbC9Rpjs2TMViYHMbRg4cAMn+bKW7Vz0ZnmDO96eGfvvj40ha+J1zP9SLjGeiHLzCJxwZRwRh4oiymTkV7dW71iMlsy/jbkGD6+lftZRhjkePmli6QDAE0JYO3Q9xnahJYyx/BWn7js= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 538BE4B9DB71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774261065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9rYh6hCLyoAnwiZcY2RlnJJpJbQOf5RMnPEJjcd/zXU=; b=HzATqj+AZOJXbrQA2fnMGWaKsAB/5+QTdZp405ZqYKZvNHFnUR8tAcTIYR7QXTQcD8dWtS KbvMy+cakaIZ4cKMJ5P7maDeN3rJX6wfxUnGAIUvWzVRI1f6jFiJeuaUOTu1l4mYdNpXAz I3yIXNDNk9SeSDcEBQdS3/75I2AVsts= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-5w5NGrUIPviC7m_BCvq24w-1; Mon, 23 Mar 2026 06:17:43 -0400 X-MC-Unique: 5w5NGrUIPviC7m_BCvq24w-1 X-Mimecast-MFC-AGG-ID: 5w5NGrUIPviC7m_BCvq24w_1774261063 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-486fb142205so34423035e9.1 for ; Mon, 23 Mar 2026 03:17:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774261062; x=1774865862; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9rYh6hCLyoAnwiZcY2RlnJJpJbQOf5RMnPEJjcd/zXU=; b=WXaIwc2U2XW9DMS5SLk3Mj9/zrvI9DQfmx7ywKHv5zeCXhU1SZNcNMn8VnCvtnWA5d loaIAcIBsEXloR2ox5SI0rg4SWjybG2RpCjbe7hM0Bpnh0MWNSznc+paBjuMOzB18Xtn D7JFJMu8vpXgf43ztz/e1VzVUiSgCvcfYnz1RH1w8Dg8Uni5kVCRMKSQmpiW8+guCH2R t6B2Z2Uk29oWpvaoARXN4L85xQjOvhPGqTKYct8AkyKS3qKc6Ps9RSjp+3sO6E1Kto1G CPYJednkElvlIdRPaD+7UYCkP528JTeP+BuK2ndO8WCOw0ZA6jFFv59OAERfn2iuGvhx 0YMA== X-Gm-Message-State: AOJu0YzELp06TCLzBr2DFjnZ3t0pRky22PcxAAW/A6XFvfnedlITLD69 B3mhNI6uSVlieDlURbP/g2BpTx6TZtfUmcwg1a7D6lU8/pJcOVUjK9WI6/rG5HReRqyE4yxxGNY cVSxsPVuCZKDlblOdCFeK8cIEUsDKMcDcQe+41v1of+dklRYNtj+89eriSysIbsQ= X-Gm-Gg: ATEYQzwj/Z6XGpRwCAfRiK3vEUnJyHPse8mOtzLrjPXQDTrX45p0nCJmoFcoQb0hVRW tBhOrmZ/V5Pp5AOcFwbQyy8RA5YEooLK/42+BubfwB7T3qTVikbgmRgL2fta3tBBlzSdhVdh0/Y e558ywLPrb/N7syL2I8dmNhd8DrCIFzd8UpraVJT2fO4P5A4h88JOnKeq0wP5SrTMOJHIW1Wl0m /qx0E0usluGLRusUB51HqCNuruRbj7oJhnOsKFXq3s9//B3hIF4BgM+XXLnv/1iW2fr3rfW4UGB ecj8dPgP+Ix2HFg0T7jtZuK2rklNJAHVbEFja1VstrSHK7XUMc96cCXwTXU2uCCU9e3HWxORIDq 6JbTAf0qm3lL1GWIP X-Received: by 2002:a05:600c:1c0a:b0:485:40c6:f528 with SMTP id 5b1f17b1804b1-486fee2bb38mr175978135e9.30.1774261062498; Mon, 23 Mar 2026 03:17:42 -0700 (PDT) X-Received: by 2002:a05:600c:1c0a:b0:485:40c6:f528 with SMTP id 5b1f17b1804b1-486fee2bb38mr175977645e9.30.1774261062080; Mon, 23 Mar 2026 03:17:42 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-486ff19d3b7sm79113085e9.20.2026.03.23.03.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 03:17:41 -0700 (PDT) From: Andrew Burgess To: Eli Zaretskii Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/python: allow Architecture.disassemble to give styled output In-Reply-To: <86h5qacxif.fsf@gnu.org> References: <2412723aff2f39ed778743b957d2ab8da51335e1.1774020654.git.aburgess@redhat.com> <86h5qacxif.fsf@gnu.org> Date: Mon, 23 Mar 2026 10:17:40 +0000 Message-ID: <87se9q4zp7.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: D4Hgp2NRhEpjg_Eq2b-UhOCt5BtUcHMc0i4gre2gf6o_1774261063 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Eli Zaretskii writes: >> From: Andrew Burgess >> Cc: Andrew Burgess >> Date: Fri, 20 Mar 2026 15:31:11 +0000 >> >> Extend the Architecture.disassemble API to allow the user to request >> styled disassembler output via a new styling argument. A user can now >> write: >> >> insn = arch.disassemble(address, styling = True) >> >> The instruction strings returned within INSN will contain ANSI escape >> sequences so long as 'set style enabled on' is in effect. This means >> that the user's personal settings (disabling styling) will override a >> GDB extension that requests styled disassembler output. I think this >> makes sense. >> >> The default for the styling argument is False, this maintains the >> current unstyled output as default. >> --- >> gdb/NEWS | 5 + >> gdb/doc/python.texi | 7 +- >> gdb/python/py-arch.c | 11 +- >> .../gdb.python/py-arch-disasm-style.c | 52 ++++++++ >> .../gdb.python/py-arch-disasm-style.exp | 119 ++++++++++++++++++ >> 5 files changed, 189 insertions(+), 5 deletions(-) >> create mode 100644 gdb/testsuite/gdb.python/py-arch-disasm-style.c >> create mode 100644 gdb/testsuite/gdb.python/py-arch-disasm-style.exp >> >> diff --git a/gdb/NEWS b/gdb/NEWS >> index e46a5108272..da74c248c54 100644 >> --- a/gdb/NEWS >> +++ b/gdb/NEWS >> @@ -229,6 +229,11 @@ qExecAndArgs >> the appropriate user setting is enabled, and GDB knows how to >> style this source file. >> >> + ** The Architecture.disassemble method accepts a new 'styling' >> + argument, which defaults to False. When set to True the 'asm' >> + strings in the disassembler output can contain ANSI escape >> + sequences to indicate styling. >> + >> * Guile API > > This part is okay. > >> --- a/gdb/doc/python.texi >> +++ b/gdb/doc/python.texi >> @@ -7632,7 +7632,7 @@ Architectures In Python >> Return the name (string value) of the architecture. >> @end defun >> >> -@defun Architecture.disassemble (start_pc @r{[}, end_pc @r{[}, count@r{]]}) >> +@defun Architecture.disassemble (start_pc @r{[}, end_pc @r{[}, count@r{]]} @w{@r{[}, styling = @code{False}@r{]}}) >> Return a list of disassembled instructions starting from the memory >> address @var{start_pc}. The optional arguments @var{end_pc} and >> @var{count} determine the number of instructions in the returned list. >> @@ -7661,6 +7661,11 @@ Architectures In Python >> language flavor used is the same as that specified by the current CLI >> variable @code{disassembly-flavor}. @xref{Machine Code}. >> >> +When the optional argument @var{styling} is @code{True} the @var{asm} >> +string can contain ANSI terminal escape sequences if styling is >> +enabled (@pxref{Output Styling}). When @var{styling} is @code{False}, >> +which is the default, then no styling will be applied to @var{asm}. >> + > > This is also okay, but I don't think @var is correct for "asm", since > those are literal strings, not symbols that stand for something else. I changed to use @samp{...}, this seemed like the most appropriate option, and pushed this patch. Thanks, Andrew