From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /PCDOo0UQGgajQAAWB0awg (envelope-from ) for ; Wed, 04 Jun 2025 05:40:29 -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=FEd0FfpK; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DDDFA1E102; Wed, 4 Jun 2025 05:40:29 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 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, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE 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 B342E1E089 for ; Wed, 4 Jun 2025 05:40:28 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D06803858408 for ; Wed, 4 Jun 2025 09:40:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D06803858408 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=FEd0FfpK 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 086C63858D32 for ; Wed, 4 Jun 2025 09:39:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 086C63858D32 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 086C63858D32 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=1749029977; cv=none; b=j6q1yzZ4a2A4zvUjh4hi1qHb2QjKcfUzxW3/4qfxAsrrhxNwfrZmDs5ZIfa0bPwxnT9xoW6ZrtsERndxqTvlRGHnXYekMvSXxW61+eHYib555FuwgHcynrZJlkye0PHot9XHpKcIXgQQ/NyE3U+ImzEW0ESUtS8RY3ajZFYc04A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749029977; c=relaxed/simple; bh=/BBvnowKp3FZzBPvpTa6Gdvb1H5JEJZv/g28uiij+U0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JHDn8rtG+S+u+D3MU/QFjr9X/txDOR2InMU8Hkrm6iUJ5HBvpKDkdIH8XJ6vXMT5I7U9GxdtMG30xqZWifBeU7rzf+J7k1xuW7e3lXQi2eTlE7MhOvPkiwlUlG6kyrBGIxhT/DXWDBxx4YnzTbdnoCYrysZP8L+ALRrLSeFSwtQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 086C63858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749029976; 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; bh=VqCct0mSV1GRloGZJnO1GHHRmM7NV4rnFYBdTWdGDlY=; b=FEd0FfpK8OYnnzIgtb7RFKvE+aCGc5coTUkcZBpWI2qwWAjsN2wmmEU4DIObwEbuI/PMec 8Z3E/fQKFKnRL1nhqnMygRKOZce1ViJ8d+3k7vsUYManZXtiqSZcLiBQMKMSRBwmKB/Udg Lv76MyRMsHyOfSTi1F8mfd+7jrENoi0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-ksEl-5bsOcm5utL1h9NUSA-1; Wed, 04 Jun 2025 05:39:35 -0400 X-MC-Unique: ksEl-5bsOcm5utL1h9NUSA-1 X-Mimecast-MFC-AGG-ID: ksEl-5bsOcm5utL1h9NUSA_1749029974 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-450787c8626so38453455e9.1 for ; Wed, 04 Jun 2025 02:39:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749029974; x=1749634774; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VqCct0mSV1GRloGZJnO1GHHRmM7NV4rnFYBdTWdGDlY=; b=OnlWlZrEjyPj/+YNORPxs2nxEyXiTCrYIntoJ95/2kpmqpOAW1VNuMoSy4WGuakU8G PZTXQ+EAZXgwa0o/8ugRK98N4i5wnwFbvp6HPPH5rYkkctsN+Rs9x9tOwFQbk4ZPS2C9 8hCdzitxfTa/zFfk2aHurq7cXn9L/3ZGGPT06alMu1IoSnlmFIOMeyWqV/RX0rkO0XOt eGGLGe0V7Ow/Gv4in+0gfaNiiXitGaqrGK9V64VLz/rCJcADmvL/cAR0h/lqUvOJ9THM K2fe5MXaTD4jv/4++f1pLXKCFY2gQQD02WfnR/fVRnDdNFdNPc4SSFaUPuBfHurnaTjS FAlg== X-Gm-Message-State: AOJu0YyMzwDj/rrAPD7nTxwuOVY/U7nY8HAgmR6lFKHbmpRbDBxNEHNu oU//uPMXW4MOc1BAOWOKI4D+6q5dpbKxNeCl5YfdxBXwK/+Fx3KrkAYm+kDmhAksGR21qJCe5m3 ECUF4o3QAc1l5Tk5GprRKwiBpVO4OnJK4dZ1B+RKDb5XIdu2GYQiVxPT1MuRjDKNs2goxDsYzD7 gyb8ruQ38uOSbDKe1xgDypMdIKwQHo+vT4Xc50ivEkGzzSXbw= X-Gm-Gg: ASbGnctJuut5lcnnOSYy+mOtEzPfqGNqKN7M+ShUPn4zu/Ce4h5R6JDh+Xf5LtKkLLZ NUhpjfVdkyca5m4HIlbcSzgmWEWtc38ij2wX4ufT5splUQOuxGfSSQZXZYqYUCMjj3dt1sB87jJ ntGNgeraH/nlWlDO/zL/cwPZoVQIVYVeAcaMxDqSoV4gbapIN5NI20GMMtAzJVnVmBMynT8RIst r36KceVroHTueUIErip1T1wNkYZvgsqzeIwlxne4lEz2/ppgtZWzYrjiRGTRCv5HRqDdPxhTT09 RtqstcdshHcijg9vXJymsCKDUEUQTdBwx7t4 X-Received: by 2002:a05:600c:a49:b0:442:f482:c429 with SMTP id 5b1f17b1804b1-451f0a72994mr16252935e9.8.1749029974100; Wed, 04 Jun 2025 02:39:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHd7r5rXEOJD0yKS2JVQ4xJlIYd+Edk2hnt992s5jyWBRWo6cDMHjHMKcBfPGySxkduhiKYTg== X-Received: by 2002:a05:600c:a49:b0:442:f482:c429 with SMTP id 5b1f17b1804b1-451f0a72994mr16252665e9.8.1749029973670; Wed, 04 Jun 2025 02:39:33 -0700 (PDT) Received: from localhost (75.226.159.143.dyn.plus.net. [143.159.226.75]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-450d7facf9dsm187579835e9.17.2025.06.04.02.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jun 2025 02:39:33 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 0/2] Python Style API Date: Wed, 4 Jun 2025 10:39:27 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kRISbeQPi37TuGYSUWIO-W3w41Nwb2TuX-0EJIKzfSs_1749029974 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 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. Thanks, Andrew --- Andrew Burgess (2): gdb/python: add gdb.Style class gdb/python: new class gdb.StyleParameterSet gdb/Makefile.in | 1 + gdb/NEWS | 11 + gdb/doc/python.texi | 253 ++++++ gdb/python/lib/gdb/__init__.py | 209 +++++ gdb/python/py-style.c | 797 ++++++++++++++++++ .../gdb.python/py-style-parameter-set.exp | 361 ++++++++ gdb/testsuite/gdb.python/py-style.exp | 339 ++++++++ gdb/ui-style.h | 6 + 8 files changed, 1977 insertions(+) create mode 100644 gdb/python/py-style.c create mode 100644 gdb/testsuite/gdb.python/py-style-parameter-set.exp create mode 100644 gdb/testsuite/gdb.python/py-style.exp base-commit: f84a4db958af0ee1521acdf69eb2be38ea2e66a3 -- 2.47.1