From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kGSMAbzvQmi9QAMAWB0awg (envelope-from ) for ; Fri, 06 Jun 2025 09:40:12 -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=H320NKVZ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0213E1E11C; Fri, 6 Jun 2025 09:40:12 -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 6F3861E089 for ; Fri, 6 Jun 2025 09:40:11 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11A5A3857B98 for ; Fri, 6 Jun 2025 13:40:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11A5A3857B98 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=H320NKVZ Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id CA6263858CDA for ; Fri, 6 Jun 2025 13:38:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA6263858CDA 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 CA6263858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749217099; cv=none; b=M/n/GAFUVvPvLJJM0vfa+NKSAMn51w83+q5og5dTyTekqNrudiDtBn8oRn/QdJbqJ4xCou3JFpv01ym57HGcZc2u3LvuTWTH2Wo9zWuTyycDtM6L4MEPVxHoWwuBKfIpmrBIrgja93VieajKQALnzrN+JBMVeRxCS5KwIfJsyQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749217099; c=relaxed/simple; bh=FeFYuip3VuUPB+MdWoPcZmIC0HBRbpOlOzAQEFtCXC4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eg7768uhO4WiGNPT15fx/5dObatMZH7RVsvWh5nnUTyiwTIJ8Jc9dMjpOxE3Q80JDJHU+laauHc8cXNrchneGRJNjrzeFyuUxgCYd1YGLCPRPkBTbgArOeoS6MYrr3Sh04w5MZpaFBSjctZyjBpKEvKk1KjpamOqq/kTad7OVTY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA6263858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749217099; 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=5DfHwmjYi1jj0IDlZMIe/1CuXwsOb1IOSMKrpq9BPkY=; b=H320NKVZ4aJ0tT4SzgQSBpfWnG38eH0fzsAMtwnnsoQvBg7XA2Te4du2kCrLfuYd37p+NT DYZ0CTQgtlxWem1igySFaWZJYQE/asVl6aXUzc8Y0zVaU+A0bVCsI2LzCe+SMi6FrJUK0f Ofl0aKZgHOLGHkR8GRHnnUNofLzyllE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-SJWxyoVbMHKp6M2Brt1w5g-1; Fri, 06 Jun 2025 09:38:18 -0400 X-MC-Unique: SJWxyoVbMHKp6M2Brt1w5g-1 X-Mimecast-MFC-AGG-ID: SJWxyoVbMHKp6M2Brt1w5g_1749217097 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-450d50eacafso12289035e9.3 for ; Fri, 06 Jun 2025 06:38:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749217097; x=1749821897; 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=5DfHwmjYi1jj0IDlZMIe/1CuXwsOb1IOSMKrpq9BPkY=; b=LwNGDlyhfCIdAAmUtinbice7qL6SMlDm1S46x/SsNvSW9wIzGCzqNAYhssc5ZxN83j NEUYkZB2ZIKuKHZamUNv99WgLOfSdh1I5c7UDh8TedyJ9OzkDnwVSs56qWusa03URies NLSrrAxEGGZzhV0piSL1c5nbN4KaO83EsYwMdG/syQyeMq3R62dVe2QKlt3rFK0s4EUZ sDBAikf5M8q9w/QUzWJ2+OourE78u4N5h4WFgwCAHV4Mo8A8cn/nOVwLyZ3t7yWAodZ+ m/PEZO5nuN3NfCWbQk8Dxg5APEq2I/TFGOC8KZGCilzIskoQScMRFhlY5t47nhHvexiK 6/7Q== X-Gm-Message-State: AOJu0YwOg6nMRSR80b9Y1Q5pcVdr1QB+R/zd9qxMMMg83pLkb5BwGM2I wR/gNvRiljSFNGGwgLn8TVLkVFN0SQPGwB/FQWqukNl7Wo1rGsqheU9SRlPQgqJxhKZsQE3S2IC uHkaS7FkVJEoaHGrCxPP9DiyYQackmHsDrkBBVOm/uIpG/XSEtwsaZQ6LeVaqImWZhBfLu5iyiM oQA/M9KvTfv1we3V+HuNiSQJc9XqDcY7+4GoL7Ie680rwAQJA= X-Gm-Gg: ASbGncsvccm7NX8TQuDXFof76aZr8Mdnp7G0ONvapCVaXEleQ5IUm1fAXNl5eyiQH6N YcvEE2XJMi/8IA5IBEy9IKK3zcUTYe3YTHFjTX7vMMM074C/0wiCSwc3cUQtu+HCnYbrz2dAk+j V/bov0dasLdbyrBcTV8srFc8lLk0lmMnNt2QP2nNKUW9fPgbKdN76UEg1+XQrSymy1OgHxEohfC zT3GDY8nrZApwc5JFe0X81wKXh43bcF+EPHI76F1ir4lghjzAz8nXa//uRQTL7Vsc8wmLRzQf7U IcFV7KwTicbmQEzG5i8tcrJ98By0mVvd/38mfGnD/OJfp8Q= X-Received: by 2002:a05:600c:c166:b0:43c:ed61:2c26 with SMTP id 5b1f17b1804b1-452013ae65emr40936985e9.17.1749217096688; Fri, 06 Jun 2025 06:38:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfKcmDB31RtbNGWjqieA4Z/cXx4BjxKvjCDu8OZUkhAp3EuTxRXv0inVU7jRTriLNavu/aRw== X-Received: by 2002:a05:600c:c166:b0:43c:ed61:2c26 with SMTP id 5b1f17b1804b1-452013ae65emr40936775e9.17.1749217096258; Fri, 06 Jun 2025 06:38:16 -0700 (PDT) Received: from localhost (75.226.159.143.dyn.plus.net. [143.159.226.75]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-452730d15f4sm21984395e9.40.2025.06.06.06.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jun 2025 06:38:15 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 0/2] Python Style API Date: Fri, 6 Jun 2025 14:38:12 +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: s5KQQWqBMMhTd7Fwx6QKrsQVpgnrZ2NrtQ5dgrn-nwg_1749217097 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 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. --- 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 | 366 ++++++++ gdb/testsuite/gdb.python/py-style.exp | 339 ++++++++ gdb/ui-style.h | 6 + 8 files changed, 1982 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