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.133.124]) by sourceware.org (Postfix) with ESMTPS id E46093858D35 for ; Wed, 22 Dec 2021 17:56:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E46093858D35 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-rf_VLL6eOKqTwikKvtNoTA-1; Wed, 22 Dec 2021 12:56:03 -0500 X-MC-Unique: rf_VLL6eOKqTwikKvtNoTA-1 Received: by mail-wr1-f72.google.com with SMTP id d6-20020adfa346000000b001a262748c6fso775224wrb.12 for ; Wed, 22 Dec 2021 09:56:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eE3rWUIQ9GC5+uRKM8ZD5SI6WiQk5pMN8Lyp2uJSKyo=; b=1xXAb3UhYX92BDVNI3ZUKPpRKCCJuc4bKkf5Zye4rH7bxhG2uzANAMeKlf6cyhrp17 rnfGzaVmrHXVaKmgqjkRlDn07XFhkl2sw3mTrHhnWtFu235fZIn+AhuZjhci3ype0uto 7nKuTLTP/Zs4zu8WdsZG36EJ7ga6c29ri4+e6lsF6ab+vghly4nrUXalsNPSLa+F2JkD 3Pz2E8ZI+rgQq8unymvTAPl2wp+Mhibq6EKFZDIQWyfZWG0mZnh/6mUZ6jgCT4pM76Dx FNY+CcVjlC28hEQ2aqG/xN6s5m9Y2w4O/zV6YA5McDfqjSTu1yusPwcMLGPh4X3azqKI GhyQ== X-Gm-Message-State: AOAM5327woqrxAf/oDICqbn+xOBgf9B0UXdSXueOaOWuyTf28eNPwvMo EFKllA3H9WQb+eXrd4OjFI6tfrxJoEw711Yq5wRZdSVQ6c7w+eXU9zQv4cZe/XRCDCgM4GjLP7d dxA9k97FzD1Y= X-Received: by 2002:a7b:cb51:: with SMTP id v17mr1657247wmj.185.1640195762137; Wed, 22 Dec 2021 09:56:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzE2BPXch1XRSrsu+Q9txe7rxpj5C7svswkcfATBwIm93o0B/WkzcIMSwzMC74UmIdd2SoYSw== X-Received: by 2002:a7b:cb51:: with SMTP id v17mr1657236wmj.185.1640195761959; Wed, 22 Dec 2021 09:56:01 -0800 (PST) Received: from localhost (host86-134-238-138.range86-134.btcentralplus.com. [86.134.238.138]) by smtp.gmail.com with ESMTPSA id j26sm4003408wms.46.2021.12.22.09.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 09:56:01 -0800 (PST) Date: Wed, 22 Dec 2021 17:56:00 +0000 From: Andrew Burgess To: Simon Sobisch Cc: gdb@sourceware.org Subject: Re: gdb.error: "define PI" is not a prefix command. Message-ID: <20211222175600.GA2308572@redhat.com> References: <0de334d3-d226-5d85-e517-946254380c7c@gnu.org> MIME-Version: 1.0 In-Reply-To: <0de334d3-d226-5d85-e517-946254380c7c@gnu.org> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 17:25:10 up 4 days, 7:13, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2021 17:56:08 -0000 * Simon Sobisch via Gdb [2021-12-22 16:12:11 +0100]: > The following shows the issue quite well: > > (gdb) macro define PI1 (3.1415926) > (gdb) print PI1 > $1 = 3.1415926000000001 > (gdb) py gdb.execute("print PI1", True, False) > $2 = 3.1415926000000001 > (gdb) py gdb.execute("macro define PI2 (3.1415926)", True, False) > Traceback (most recent call last): > File "", line 1, in > gdb.error: "define PI2" is not a prefix command. > Error while executing Python code. > (gdb) print PI2 > No symbol "PI2" in current context. > > This is happening with GDB 8.2, Python 3.6.8. > > It did work with GDB 7.6: > > (gdb) macro define PI1 (3.1415926) > (gdb) print PI1 > $1 = 3.1415925999999996 > (gdb) py gdb.execute("print PI1", True, False) > $2 = 3.1415925999999996 > (gdb) py gdb.execute("macro define PI2 (3.1415926)", True, False) > (gdb) print PI2 > $3 = 3.1415925999999996 > (gdb) py gdb.execute("print PI1", True, False) > $24 = 3.1415925999999996 > > I've thought that this was related to the different python version (2.7.5 on > GDB 7.6), but it isn't. After building GDB 11.1 on the test machine (same > Python, obviously) it also works there. > > > Question: > Is there any way to execute this command with Python in GDB 8.2 > (= without upgrading GDB)? I tried GDB 8.2.1, and the bug is fixed in this release, if a minor update is possible then this would be the easiest solution... Failing that I found that this works: (gdb) shell cat ~/tmp/file.gdb macro define PI2 (3.1415926) (gdb) py gdb.execute("source ~/tmp/file.gdb", True, False) (gdb) print PI2 $1 = 3.1415926000000001 Certainly not idea, but, if you really are stuck on 8.2 then you can write the problematic commands into a temporary file, and source that from Python code. There might be other hack folk come up with. Thanks, Andrew