From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id dEuVJ4honGgKUwIAWB0awg (envelope-from ) for ; Wed, 13 Aug 2025 06:27:20 -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=DLuSmvtQ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 86D021E04C; Wed, 13 Aug 2025 06:27:20 -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 server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 7CFD91E04C for ; Wed, 13 Aug 2025 06:27:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D1A03858D37 for ; Wed, 13 Aug 2025 10:27:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D1A03858D37 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=DLuSmvtQ 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 69F3F3858407 for ; Wed, 13 Aug 2025 10:26:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69F3F3858407 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 69F3F3858407 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=1755080760; cv=none; b=n7/LAFnHTW+UcftvayoMav8krdkKY31BfKEexfqCloAeBH0/9I2n0n5wihZq4RHfhPDnhAf3k2ZCvCcnPpfipgWXR/GZpScJA3d/zH+4szwTd0Kl9NaqF6ww4XxWhzVEHkJk9CHP4eP4VJ8290FxwabH10evyInG5yQ1jzVRLYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755080760; c=relaxed/simple; bh=65xYz+7hYkuAdWouCRK6eV232zEFjJ9AI6skN+mgimk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mN0bjp7kzGmmFK/l5STHtzsWtLjxot9zV86nZoNgOZVoDMqs7JQXu4KJwk/5yEmI/2XeBAH2ph82PJCQU7KHsLOZVx/K1jDoEN9/PN0tjQpsG+VhkQqLquun00rZgKkbOhWXF35Ot1HvESamxFGZBjBiWy+oIeQisgs0iLyy/D0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69F3F3858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755080760; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=09xKwGzrKTwx73uByV6OhLAOXURUYFlcVfsQpWywc6U=; b=DLuSmvtQHz3kP6SDtYrdGlW1HnBGSe7KnNJvyVbgZmufyJjaEvthwA8BUO4j3wPMvxuqPx XCQTu7YWDNKhMwmRH5xTw/uF4QuUDeWle89y6mshFUfRVaUSbczsMPNSnNq+q469mjGSaS 5vskf4KvZhoz6JD1NFT9XFFnAqkHjoY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-218-wxxC6DXzNO2CLVhKykIEeA-1; Wed, 13 Aug 2025 06:25:59 -0400 X-MC-Unique: wxxC6DXzNO2CLVhKykIEeA-1 X-Mimecast-MFC-AGG-ID: wxxC6DXzNO2CLVhKykIEeA_1755080758 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3b91b45dc0cso143025f8f.1 for ; Wed, 13 Aug 2025 03:25:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755080757; x=1755685557; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=09xKwGzrKTwx73uByV6OhLAOXURUYFlcVfsQpWywc6U=; b=CNsnb4kDuQo0kbOUV3ge22ZnzCj/wkxcL+YDtRXmPNV3Z1LOIJ/6++zOQZPbs0FIkn sZ56oy5bSeOdCruBbNKSWas6/GNvsZA+cH35oZ2KHiYwxMOTm5VbaZCy1PY2RmzKeHXE pmrJ+LLz4RoZgWTUHIIV/oV7clWjjHTO8hfK1pEou4wu1IS+IBsNf4eaggB71XyvW5ag XtK6j7/mXb9H7ib1jh7fY2FfYmdRe+JT9qliRqP3eTD/7bfjwqC7tL/680yvU2ajFfcs ATvLdlRoEH/kcHel1DES0/QW5tTdWbewMbp1i6uZ6RgjiIPpNEUEycXSbs5ypqwL6q59 I1mQ== X-Gm-Message-State: AOJu0Yz8HQPeJflM6zx8zodqTNX9LIRqU/XHvrgLVutN3lwvBnZ/v9je 5F0bCdWuTphrcJ+NcLr8psqPfV2mOph6RmVCrFDYmHsG8sEmpJFiP6CubTxv1Okjw/qY49ljgiQ 9Hj7GCs/MRLNVCOyq+BNG3Pb3rQYyJlKkz+FMHHUsOEHIiBFmQbFLEz6bv6271KuwtS5o9qCTTp YUBaZ4lDofakWzZNN26wLFn2hdY3ipDN5+zgIBtK2Xm6b+Kn0= X-Gm-Gg: ASbGnctyxrjeikM3erIpTT8Dl6tW0WZHYYbsUyqTma+WL0Ao2HZwGh/9Usltd6Ey4LM jIDLe1nS8hmdLtBPeCCR/BiTcw3ejl+IQeRA0XYjJVXJMoOxUHhuInOomUirmjIap22RyZ8L9PM l5sG/52K1N1EWJJrWSpLviyrpN9dXTyh9nrwQGgvuutsm8ZtWPGAQB6nC8fy3dYwx0Kexj2jTvq z8yAwC9KxJ1NUc3OLknSdGFjfQckVgybitPlp4lG0zgzi2SE1HP8L/VMYDrMilzfqCx/GcU7umI RwM072iqWYRAfnaYyEL/qF54Ln1bJtETFZ4NtfvOiOoocoNkDGyuuiVEcKc= X-Received: by 2002:a05:6000:2503:b0:3b8:eb9f:e65 with SMTP id ffacd0b85a97d-3b917d2aa8emr1794365f8f.5.1755080757271; Wed, 13 Aug 2025 03:25:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwuF3W1GagYWavz0ek5gTj9UIWwAYCuGE7uYW0bMwIXAba7ScLtN3QCa5vyBGVexNuuhrr3w== X-Received: by 2002:a05:6000:2503:b0:3b8:eb9f:e65 with SMTP id ffacd0b85a97d-3b917d2aa8emr1794347f8f.5.1755080756787; Wed, 13 Aug 2025 03:25:56 -0700 (PDT) Received: from localhost (13.81.93.209.dyn.plus.net. [209.93.81.13]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b79c3c51e2sm45894476f8f.32.2025.08.13.03.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 03:25:56 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv7 0/4] Fix for gdb.Color + pagination AND new gdb.Style API Date: Wed, 13 Aug 2025 11:25:48 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: U_UHCdaCJ7fMmNOw792yvZDbVapB4nlMKjNI3Os7Nls_1755080758 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 Patch #1 in this series can be reviewed and approved separately from the other 3 patches if needed. It contains a fix for using the gdb.Color API within custom GDB commands where pagination might be triggered. This fix is needed by the later 3 patches though, which is why they are all bundled together. The following text really describes the motivation for the last 3 patches in this series: After the gdb.Color support was added to the Python API I wondered if this would be enough to easily add styling to custom Python commands. But I don't think it is, there's still lots that would need to be handled in user code, for example, the intensity setting. And having styles that track named styles (e.g. if I want to apply the 'filename' style to some text from Python). So this series builds on top of the gdb.Color API to provide a new gdb.Style API which, I hope, makes it easy to start writing Python commands that can use GDB's styles. Here's an example of a simple custome command that uses styles: import os class user_home_cmd(gdb.Command): def __init__(self): super().__init__("user-home", gdb.COMMAND_USER) self._style = gdb.Style('filename') def invoke(self, args, from_tty): print("The filename is %s." % (self._style.apply(os.environ['HOME']))) user_home_cmd() The new 'user-home' command prints the current users home directory using 'filename' style. Changing the 'filename' style and re-running the command will track the style changes. In v2: - Fixed an issue with the py-style-parameter-set.exp test; GDB was not started in a terminal with styling support in one case, so tests would fail depending on how the testsuite was being run. In v3: - Another test issue. This time, the error message given when parsing an argument of the wrong type changes with Python version. Relax the regexp to accept any 'TypeError' message. In v4: - Two new patches. First patch extends pager_file so that gdb.Color, and gdb.Style when it's added can work well with GDB's pager. Last patch extends the gdb.write() Python function to also support styling. - I've renamed some of the classes in python/py-style.c, nothing major, I replaced 'stylepy' with 'style' in some names. I think the new names are clearer, and better match the rest of GDB's Python API code. - Unfortunately, the new pager_file changes mean that this patch series now depends on this other patch: https://inbox.sourceware.org/gdb-patches/444008aeae2bb3c68cf868fa317374b3d7973860.1750197766.git.aburgess@redhat.com Without that patch there will be some failures in gdb.python/py-color-pagination.exp. I'm not proposing to merge this until that other patch, or something like it, is merged. But this series could be reviewed independently. In v5: - The pager_file styling fixes mentioned for v4 have now been merged to master. I've rebased this series on top of them, and all the tests are now passing. - I've tweaked the wording for a couple of the commit messages just to make things clearer. - No real code changes. In v6: - Rebased as there were some style related changes merged to master recently. No conflicts, and everything still works fine, so there are no real changes here. In v7: - Rebased as there were more style related changes to master which caused some merged conflicts, and test failures. Both turned out to be trivial to fix. Thanks, Andrew --- Andrew Burgess (4): gdb: allow gdb.Color to work correctly with pagination gdb/python: add gdb.Style class gdb/python: new class gdb.StyleParameterSet gdb/python: extend gdb.write to support styled output gdb/Makefile.in | 1 + gdb/NEWS | 14 + gdb/doc/python.texi | 262 +++++- gdb/python/lib/gdb/__init__.py | 209 +++++ gdb/python/py-style.c | 824 ++++++++++++++++++ gdb/python/python-internal.h | 15 + gdb/python/python.c | 46 +- .../gdb.python/py-color-pagination.exp | 172 ++++ .../gdb.python/py-color-pagination.py | 82 ++ .../gdb.python/py-style-parameter-set.exp | 366 ++++++++ gdb/testsuite/gdb.python/py-style.exp | 371 ++++++++ gdb/ui-style.h | 6 + gdb/utils.c | 21 +- 13 files changed, 2372 insertions(+), 17 deletions(-) create mode 100644 gdb/python/py-style.c create mode 100644 gdb/testsuite/gdb.python/py-color-pagination.exp create mode 100644 gdb/testsuite/gdb.python/py-color-pagination.py create mode 100644 gdb/testsuite/gdb.python/py-style-parameter-set.exp create mode 100644 gdb/testsuite/gdb.python/py-style.exp base-commit: 97b6ffe44b98479f991ab38b4c59f4fd0f30198e -- 2.47.1