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 9C9D4386F0CB for ; Fri, 24 Jun 2022 14:40:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C9D4386F0CB 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-0ZIAGGvUPGKA9pSKE37JFg-1; Fri, 24 Jun 2022 10:40:48 -0400 X-MC-Unique: 0ZIAGGvUPGKA9pSKE37JFg-1 Received: by mail-wm1-f69.google.com with SMTP id o3-20020a05600c510300b0039743540ac7so1112354wms.5 for ; Fri, 24 Jun 2022 07:40:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=ZQa8L/90yVgOV9YF9GrHXzSaVw5SBn8T8SVRuK3YNlY=; b=HMpPUqc6HxcXIXr43sRd7FJopbnnxNeRft5nUaN5ea84JAwSrLXIbFOgi4s7bomKpV 3u+iPSAM9fOhnuVaRZA6MdBm5p6lH0CVoTjgEBndVX+1v2+u7Y29s7GZiHBRRIPLvc13 NuTpsBDQPxXDcIaQEb1aw8AsGZAGNH379Dmmif8aEuj7va67zsm13+8pQLDdQtk1/Hum IZcfJvWOpE2Y5UoUC3FKqpH2xkb5jAmdPSX1rY45NnwnWtF07QN2DXPPmYql2vZyehnh mZFpurggA5UJix14bASvfrTJwe7Cju80RLw10F4e5g504G4MJE1sw9vpExAg9kLkSaoA UaHg== X-Gm-Message-State: AJIora8BJogi4yL8489MFAqRBxhKu+82M0koRlOOixQchPi5TrElPAmx DrBnG3/CBVS6i+OMfchWqVP+B53PoGa8yo1u4a9JzN42MKcDOb+q56rNi9OtBCC0+dl1ohjZZC9 Xde8RD1/CbdyGPUoLyX8yBg== X-Received: by 2002:a05:6000:1281:b0:21b:9c01:df79 with SMTP id f1-20020a056000128100b0021b9c01df79mr13328031wrx.563.1656081646710; Fri, 24 Jun 2022 07:40:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tdhy/yvxpF835hawoM/duMaOdT47zXNa3QYuKwdTT5mhBBmqBKM6ibSWgysutOhkHIr6oxrA== X-Received: by 2002:a05:6000:1281:b0:21b:9c01:df79 with SMTP id f1-20020a056000128100b0021b9c01df79mr13328010wrx.563.1656081646459; Fri, 24 Jun 2022 07:40:46 -0700 (PDT) Received: from localhost ([195.213.152.79]) by smtp.gmail.com with ESMTPSA id q26-20020a056000137a00b0021b8a3528bcsm2585701wrz.56.2022.06.24.07.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 07:40:46 -0700 (PDT) From: Andrew Burgess To: "Maciej W. Rozycki" , gdb-patches@sourceware.org Cc: Simon Sobisch , Tom Tromey Subject: Re: [PATCH v5 2/8] GDB/Python: Use None for `var_zuinteger_unlimited' value set to `unlimited' In-Reply-To: References: Date: Fri, 24 Jun 2022 15:40:45 +0100 Message-ID: <877d56azv6.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=-6.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2022 14:40:50 -0000 "Maciej W. Rozycki" writes: > Consistently with the `var_integer' and `var_uinteger' parameters return > the special value of None for a `var_zuinteger_unlimited' parameter set > to `unlimited' by using the Py_RETURN_NONE macro in this case, fixing > commit 0489430a0e1a ("Handle var_zuinteger and var_zuinteger_unlimited > from Python"); cf. PR python/20084. Adjust the testsuite > accordingly. Unfortunately, nice as it would be to make this change (for consistency), I think we're stuck with what we have. The -1 behaviour is documented for PARAM_ZUINTEGER_UNLIMITED in the manual so it is not unreasonable to assume that there could be code in the wild that relies on the existing behaviuor. Thanks, Andrew > --- > No change from v4. > > New change in v4. > --- > gdb/python/python.c | 10 +++++++++- > gdb/testsuite/gdb.python/py-parameter.exp | 4 ++-- > 2 files changed, 11 insertions(+), 3 deletions(-) > > gdb-python-var-zuinteger-unlimited-none.diff > Index: src/gdb/python/python.c > =================================================================== > --- src.orig/gdb/python/python.c > +++ src/gdb/python/python.c > @@ -507,9 +507,17 @@ gdbpy_parameter_value (const setting &va > Py_RETURN_NONE; > /* Fall through. */ > case var_zinteger: > - case var_zuinteger_unlimited: > return gdb_py_object_from_longest (var.get ()).release (); > > + case var_zuinteger_unlimited: > + { > + int val = var.get (); > + > + if (val == -1) > + Py_RETURN_NONE; > + return gdb_py_object_from_longest (val).release (); > + } > + > case var_uinteger: > { > unsigned int val = var.get (); > Index: src/gdb/testsuite/gdb.python/py-parameter.exp > =================================================================== > --- src.orig/gdb/testsuite/gdb.python/py-parameter.exp > +++ src/gdb/testsuite/gdb.python/py-parameter.exp > @@ -343,8 +343,8 @@ proc_with_prefix test_integer_parameter > } elseif {$kind == "PARAM_ZUINTEGER_UNLIMITED"} { > gdb_test_no_output "python test_param_$kind.value = -1" \ > "check that PARAM_ZUINTEGER value can be set to -1" > - gdb_test "python print(gdb.parameter('test-$kind'))" "-1" \ > - "check that PARAM_ZUINTEGER value is -1 after setting" > + gdb_test "python print(gdb.parameter('test-$kind'))" "None" \ > + "check that PARAM_ZUINTEGER value is None after setting" > } else { > error "invalid kind: $kind" > }