From: Andrew Burgess <aburgess@redhat.com>
To: Simon Sobisch <simonsobisch@gnu.org>
Cc: gdb@sourceware.org
Subject: Re: gdb.error: "define PI" is not a prefix command.
Date: Wed, 22 Dec 2021 17:56:00 +0000 [thread overview]
Message-ID: <20211222175600.GA2308572@redhat.com> (raw)
In-Reply-To: <0de334d3-d226-5d85-e517-946254380c7c@gnu.org>
* Simon Sobisch via Gdb <gdb@sourceware.org> [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 "<string>", line 1, in <module>
> 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
prev parent reply other threads:[~2021-12-22 17:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 15:12 Simon Sobisch
2021-12-22 17:56 ` Andrew Burgess [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211222175600.GA2308572@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb@sourceware.org \
--cc=simonsobisch@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).