From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C0BAE3858D39 for ; Mon, 3 Apr 2023 10:02:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0BAE3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680516170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pBmeI3BeA5KAch9xjELdwW97b3VC3pDBamoIIpDWehM=; b=A4YhJnpGECVrKKKF96zNzHErR1BCz24rIGkjMc5npR0s0xiqTR4OQjqHEABaiZ2S/Ymbvx fRe4GR/UsWatlih2GoXO9LDsIcCy3+YBDDiYWxgDs43mrbBhs7Ab39iZg+WWgRtZyeJ2y4 Z2Mmj95iXhHFGpx1bPpDzHX5eWU7oO4= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-1GJ4CWVbNqekB8_CMB1PrA-1; Mon, 03 Apr 2023 06:02:49 -0400 X-MC-Unique: 1GJ4CWVbNqekB8_CMB1PrA-1 Received: by mail-qv1-f69.google.com with SMTP id g14-20020ad457ae000000b005aab630eb8eso12865844qvx.13 for ; Mon, 03 Apr 2023 03:02:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680516168; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pBmeI3BeA5KAch9xjELdwW97b3VC3pDBamoIIpDWehM=; b=4DoxKg/otE+WruvTsqtkQIAoS0Oi2y9DEznSVYSO7ApTklJ7tEz5cZffsiFrI39ntv W+yn/w1CaVSCWhn9oQkkRmVkiUPKfZIVi7t7xIgnJf/OGKD7FETfNAnJK9l7db5WGnCT aEM8WB57e7GbgmcVGtss54wFvODFkoys2inGZOjBLcokxnXZH5igqsAZqvtt1ovNW+Tb Ioo5PRqcqLnKoCLPZmzDTpaFy72XAoeKjBQv4L22WGWNBOZjVrvil+gc8Ea4x0GoD0JX Zi+Crsa8sp4ZrkSGFxjYAIXXVe7M0DeZIBdJ7odf8uE1C9g2J58sCIBGlyQCimcCovSj p7oA== X-Gm-Message-State: AAQBX9cFr+TP+0alRx6IXZO+vvOCyZ7dphrBFFhYjw1cLyaGfmXViqBc UY176ipHi+SNs8sGNpGeCrhLx39oIuQPprtTGc5YFD5TGN0P8YsA0aIFX19sHvqnOBrOtbuWy/o 8PgCMcrtfcjvCazoR+zfnKsTaygJLYw== X-Received: by 2002:a05:6214:d05:b0:5ca:6c32:f35 with SMTP id 5-20020a0562140d0500b005ca6c320f35mr54737437qvh.39.1680516168508; Mon, 03 Apr 2023 03:02:48 -0700 (PDT) X-Google-Smtp-Source: AKy350YTNr09TbpnEuYf8KCf0u7422dlLCbZPyewVSx2Im15ZuQJg2Viqm6GOh/sIp66p7zzcZ3PfA== X-Received: by 2002:a05:6214:d05:b0:5ca:6c32:f35 with SMTP id 5-20020a0562140d0500b005ca6c320f35mr54737390qvh.39.1680516167954; Mon, 03 Apr 2023 03:02:47 -0700 (PDT) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id b10-20020a0cbf4a000000b005dd8b9345d6sm2482246qvj.110.2023.04.03.03.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 03:02:47 -0700 (PDT) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH 02/10] gdb/python: make the gdb.unwinder.Unwinder class more robust In-Reply-To: References: Date: Mon, 03 Apr 2023 11:02:44 +0100 Message-ID: <875yade117.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Simon Marchi writes: > On 3/10/23 09:55, Andrew Burgess via Gdb-patches wrote: >> This commit makes a few related changes to the gdb.unwinder.Unwinder >> class attributes: >> >> 1. The 'name' attribute is now a read-only attribute. This prevents >> user code from changing the name after registering the unwinder. It >> seems very unlikely that any user is actually trying to do this in >> the wild, so I'm not very worried that this will upset anyone, >> >> 2. We now validate that the name is a string in the >> Unwinder.__init__ method, and throw an error if this is not the >> case. Hopefully nobody was doing this in the wild. This should >> make it easier to ensure the 'info unwinder' command shows sane >> output (how to display a non-string name for an unwinder?), >> >> 3. The 'enabled' attribute is now implemented with a getter and >> setter. In the setter we ensure that the new value is a boolean, >> but the real important change is that we call >> 'gdb.invalidate_cached_frames()'. This means that the backtrace >> will be updated if a user manually disables an unwinder (rather than >> calling the 'disable unwinder' command). It is not unreasonable to >> think that a user might register multiple unwinders (relating to >> some project) and have one command that disables/enables all the >> related unwinders. This command might operate by poking the enabled >> attribute of each unwinder object directly, after this commit, this >> would now work correctly. >> >> There's tests for all the changes, and lots of documentation updates >> that both cover the new changes, but also further improve (I think) >> the general documentation for GDB's Unwinder API. > > Hi Andrew, > > With this commit, I see: > > python global_test_unwinder.name = "foo"^M > Traceback (most recent call last):^M > File "", line 1, in ^M > AttributeError: can't set attribute 'name'^M > Error while executing Python code.^M > (gdb) FAIL: gdb.python/py-unwind.exp: python global_test_unwinder.name = "foo" Sorry about that. Turns out that older version of Python don't include the attribute name in the error message, I was seeing this: (gdb) python global_test_unwinder.name = "foo" Traceback (most recent call last): File "", line 1, in AttributeError: can't set attribute Error while executing Python code. (gdb) I've updated the test pattern so either is acceptable. I went ahead and pushed this fix. Thanks, Andrew --- commit 4c148f65fc148918d0be15607938770ad8c46e36 Author: Andrew Burgess Date: Mon Apr 3 10:56:10 2023 +0100 gdb/testsuite: fix failure in gdb.python/py-unwind.exp A potential test failure was introduced with commit: commit 6bf5f25bb150c0fbcb125e3ee466ba8f9680310b Date: Wed Mar 8 16:11:30 2023 +0000 gdb/python: make the gdb.unwinder.Unwinder class more robust In this commit a new test was added, however the expected output pattern varies depending on which Python version GDB is linked against. Older versions of Python result in output like this: (gdb) python global_test_unwinder.name = "foo" Traceback (most recent call last): File "", line 1, in AttributeError: can't set attribute Error while executing Python code. (gdb) While more recent versions of Python give a similar, but slightly more verbose error message, like this: (gdb) python global_test_unwinder.name = "foo" Traceback (most recent call last): File "", line 1, in AttributeError: can't set attribute 'name' Error while executing Python code. (gdb) The test was only accepting the first version of the output. This commit extends the test pattern so that either version will be accepted. diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp index fddf4f15393..d0a1960058b 100644 --- a/gdb/testsuite/gdb.python/py-unwind.exp +++ b/gdb/testsuite/gdb.python/py-unwind.exp @@ -107,7 +107,7 @@ check_info_unwinder "info unwinder after failed disable" on # 'register_unwinder'. gdb_test "python global_test_unwinder.name = \"foo\"" \ [multi_line \ - "AttributeError: can't set attribute" \ + "AttributeError: can't set attribute(?: 'name')?" \ "Error while executing Python code\\."] check_info_unwinder "info unwinder after failed name change" on