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 5E011385B804 for ; Mon, 31 Oct 2022 10:13:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5E011385B804 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=1667211181; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7pcJvO0QodnFNSPPBTYRU4/5tJQbYLVbaaU9cABuxmM=; b=LFQm+CCRkrv46Wz7O3M91zgH/jA624UgGaUUHvjEcNzX8F6Q5+yFCuIqtPL694TxdpXTdV vuNwN7O2evmCKYc5aC0NLIhNOaZHdNzU+XJHRX1+FAJLCOBMXxy5USu9I+nZMAXS/6UY8+ Fkh91gCZfC3dbDw8w9RXIi3YOtoQ9PU= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-639-gGokKAuSP26IE5XWR2Jfqg-1; Mon, 31 Oct 2022 06:12:59 -0400 X-MC-Unique: gGokKAuSP26IE5XWR2Jfqg-1 Received: by mail-qk1-f199.google.com with SMTP id bj1-20020a05620a190100b006fa12a05188so4857472qkb.4 for ; Mon, 31 Oct 2022 03:12:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=7pcJvO0QodnFNSPPBTYRU4/5tJQbYLVbaaU9cABuxmM=; b=Fg1oUdsZhYeNm+RUGiiaJ42sgwr8ICzqV3Wz7po5lm+fGaOfRbyZDJBU6cPRh3FhAu 3a0wNixWKzQEXINEozp1jWoUXNaU9VUAs6WECFA5DUQT2OjuvM4NQyZ7bS3T5oFjv19z +nCrMxYEmgUDtRGOC5o9QyH97qSSMO+XRCJwbwO844uL6HePFRBNVBdsfem5J9XskTBg Pq6cE0gMK5euaxRyWofnxc+5QOnMsyaBUPFd2ayg7eSSreJ4tGW4oAv/Erys/Qu4Rj11 kaHeKDwX2RYAiKp3378xKr6K0jtM1QwAT2pARi9aBlDAh6Q0Q/uZy1xe8ljQIPZ2/qY6 YSSg== X-Gm-Message-State: ACrzQf0faaSXlPTeXjUcW4mLSCSLLMQPFw4gECO4HGbxPHwoHjn5YyMZ Lm4wH81Nz0Fp8MenskucIXxISPnqSJ2e5Ja5DscOc+xaoZXz+8j+wMkRo8LCMcdV6RVL6fDOXqL H6GzLHTnXvkA= X-Received: by 2002:ad4:5eca:0:b0:4ba:535a:6d45 with SMTP id jm10-20020ad45eca000000b004ba535a6d45mr10018256qvb.56.1667211179330; Mon, 31 Oct 2022 03:12:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kAclo3XgPssr/9BofiujmEzrti2GCgmpP+mVegO0MDhUP/NfnZmQ6cuKOxkeFeRCuheuNOw== X-Received: by 2002:ad4:5eca:0:b0:4ba:535a:6d45 with SMTP id jm10-20020ad45eca000000b004ba535a6d45mr10018239qvb.56.1667211179044; Mon, 31 Oct 2022 03:12:59 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id s16-20020a05620a255000b006ee7923c187sm4463168qko.42.2022.10.31.03.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 03:12:58 -0700 (PDT) From: Andrew Burgess To: =?utf-8?B?5Yip5om/5piV?= , gdb@sourceware.org Subject: Re: Unexpected behavior of `gdb.PARAM_INTEGER` and `gdb.PARAM_UINTEGER` parameter In-Reply-To: References: Date: Mon, 31 Oct 2022 10:12:56 +0000 Message-ID: <87a65ccndj.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: =E5=88=A9=E6=89=BF=E6=98=95 via Gdb writes: > Hi, > > I've noticed that if we use Python API to create a `gdb.PARAM_INTEGER` or > `gdb.PARAM_UINTEGER` parameter this way: > > ``` > $ cat test.py > > import gdb > class ExampleParam(gdb.Parameter): > def __init__ (self, name): > super(ExampleParam, self).__init__ (name, gdb.COMMAND_DATA, > gdb.PARAM_INTEGER) > self.value =3D 0 > self.saved_value =3D True > > def get_set_string (self): > print(self.value) > return "Set to %r" % self.value > > ExampleParam("example=E2=80=9D) > ``` > > According to the docs here: > https://sourceware.org/gdb/onlinedocs/gdb/Parameters-In-Python.html, `0` > should be interpreted to mean "unlimited", so I expected that when a > `gdb.PARAM_INTEGER` or `gdb.PARAM_UINTEGER` parameter=E2=80=99s value is > "unlimited" in GDB, then the value in Python will be interpreted to 0. You are correct that this area is not well documented. These parameter types have always returned None for unlimited, so I don't think we'd want to consider changing the behaviour at this point. There is already a related patch on the mailing list that will improve the documentation of these parameter types: https://sourceware.org/pipermail/gdb-patches/2022-October/193253.html Thanks, Andrew > > But somehow, GDB interprets `None` to mean "unlimited" for that parameter > we created: > > ``` > $ gdb -q -nx -ex 'source test.py=E2=80=99 > (gdb) show example > The current value of 'example' is "unlimited=E2=80=9D. > (gdb) pi gdb.parameter("example") is None > True > (gdb) set example unlimited > None > Set to None > (gdb) pi gdb.parameter("example") is None > True > (gdb) show example > The current value of 'example' is "unlimited". > (gdb) set example 0 > None > Set to None > (gdb) pi gdb.parameter("example") is None > True > (gdb) show example > The current value of 'example' is "unlimited". > ``` > > You can notice that GDB set the value of the `example` to `None` instead = of > `0`. > > Is this the expected result? > > My GDB version is GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90, and I'm on > Ubuntu 22.04.1 LTS. > > Best Regards, > Alan Li