From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9PpSB3sYRGg4WgQAWB0awg (envelope-from ) for ; Sat, 07 Jun 2025 06:46:19 -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=OS0xo7V1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 09E001E11C; Sat, 7 Jun 2025 06:46:19 -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 33C9C1E089 for ; Sat, 7 Jun 2025 06:46:18 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B10FF3858CDB for ; Sat, 7 Jun 2025 10:46:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B10FF3858CDB 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=OS0xo7V1 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 45B4F3858D26 for ; Sat, 7 Jun 2025 10:45:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45B4F3858D26 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 45B4F3858D26 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=1749293105; cv=none; b=U0OFtMolEM9pcixgscTqQkz4rxAURhds/+mKTjvm3BYTnCSMtBkJdLSMoTBJBwVfYjn3mByut5bx2jHsUVYEek63r2CFN71Or9/hYCspYCDlVn29/s0hgvqTc9l9GYYb2LnrWtZbM//S/ZPi2xZeeSdkaqC0mQXaFAIpYIBg7dA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749293105; c=relaxed/simple; bh=Ek7cuja23nxRqjsoZh8TSqhHOZW4jGm5pKTYayb/DGQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Wk790ZyBYuSjnUiVdQJoOFmwDYMWSt0FHUiXHsrDYuzViQDPp6VR5W5GEcnOWmbUC5RXgcXJzHhbfzM72qYClTSZohWIdsxGwMGTa6QRgwoTacWx/kxL1sz7kJbaWP8bfOq2boS7Vfua9B1wzXhEt2ZOFxMbJLvIl9QBXWE053A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45B4F3858D26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749293104; 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=laGvW7CCGf72eilTo73qK/lPb6ZleKe08PIOxHPQitQ=; b=OS0xo7V19aSYxu+q3IDpJTFiPK6Oxtdku9XgT2052th/M2UJC6k7bFWxWnDeZSiwFiYLm5 MNZ7R2AaHoPHc+SbTfwf1FMrNREy7WsqGNljYwxrp6lZ1hOIozy2Qzx2KTwQa1MZBsYqKt AqEY5FSse6lEFAj2ZrmrnV2E7WPx8vA= 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-659-2tJfyet2N2CVHI2O3j4zGQ-1; Sat, 07 Jun 2025 06:45:03 -0400 X-MC-Unique: 2tJfyet2N2CVHI2O3j4zGQ-1 X-Mimecast-MFC-AGG-ID: 2tJfyet2N2CVHI2O3j4zGQ_1749293102 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-442dc702850so18266515e9.1 for ; Sat, 07 Jun 2025 03:45:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749293102; x=1749897902; 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=laGvW7CCGf72eilTo73qK/lPb6ZleKe08PIOxHPQitQ=; b=U7ZrAxp8UTAMwjnrnk5HBRZGJ6gjLNDUyRhlrp5wVJ/WXlMPA/UvLHovisoKTPCD7I X/2BoHYiCja3/9iMCD+u5T5fZkdbRuNJEHc5A2r3O0xepC2UpELLpluWYq+3y7WIPKuR SY0wVjQwbbL0bWOKQ2HU9d/EqjGivqm1bGEiBCuFCKhlsTcdNGqhhKkFgkxTpKNWx7Rr I8KTWL1cFqT0sbZQtCP1A9aKwjukGmOhP+qrtip6w+K0+1Nl3mxbFA6MnljlR4ad/Cau X5aQrHFlDigb5iFVvLbwLlbtCQfyg/fx07f96azZJLtTyJmWZQs0QgyR4dv+1LHfXDjc bLdA== X-Gm-Message-State: AOJu0YxP7jakI69tXXAX/+8VSFnnlF4Yviw/3Catp86k+HXolbimybkd PSeK5WRKL1tu9rBWvrIa4JhfqiLa7U0SRCT/VcUIsL5QLrTQrHXqI361jXXmg5MwZ4wUi9kL883 y0m8Ijbkl/kCjckWHJzvLm1efGd9kr7OMQcsjPpz8B6uQu+dhKoINV6iZoIp12EwXTdUxQE9I6+ gj6+f25mh2vUgVgZ9Alu7BCXuOLVo//xd+DA0rVvHlS7IeaGw= X-Gm-Gg: ASbGncsSHBdfEvbB8Jd6LvsWxnVq4H3mlWjipYiop9Q2LuFiRnyYfTfN5Frmo2JZ5Gc eLZYA67VYlK031LCJono28Pi+3f9iwLXAmOdYQzKProTFz0kq/k3LrBt2p4AqmovDEayaM3JRBE syeDic2Mh8N4+i120n2NxeFhSM7P6WZQ18btNHB1YhvYSISiUYRDMBKHRiSjsQ+p27jsFzjF3L2 QwLmCuwTo2YKvxSvbq1KWWHH0RljLccWGnw1KmaD12Pyib0+rn+vuypl3Wnq4DKkitg03RoEKCC mtBTfwVNYCxwtu4zORE= X-Received: by 2002:a05:600c:c16d:b0:450:d611:eb95 with SMTP id 5b1f17b1804b1-4520137c97emr70566385e9.17.1749293101841; Sat, 07 Jun 2025 03:45:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUgcQr4bSRLsxo+IdhUKcBtt0LoFEsoK646Az4tDogolYn6SjECcPPEK9gjNyytz9MM6uDoQ== X-Received: by 2002:a05:600c:c16d:b0:450:d611:eb95 with SMTP id 5b1f17b1804b1-4520137c97emr70566235e9.17.1749293101342; Sat, 07 Jun 2025 03:45:01 -0700 (PDT) Received: from localhost ([109.144.219.96]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45213754973sm53141455e9.35.2025.06.07.03.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jun 2025 03:45:00 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 0/2] Python Style API Date: Sat, 7 Jun 2025 11:44:56 +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: foz302lyZT7sMPhPDow7IJIiIX-i2iHAjCsl-B-ZWyY_1749293102 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 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 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 | 342 ++++++++ gdb/ui-style.h | 6 + 8 files changed, 1985 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: 41cb00ce25900aadbf089f80bb2830494bf2a780 -- 2.47.1