Re: GDB: Setting the prompt from python

Matt Rice via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CACTLOFrVPfSMXdn-v3ueUsP+LBLwDtH3=s2GZz7i3pyeadyQuw@mail.gmail.com>
On Sun, Oct 18, 2020 at 3:27 AM Paul Smith via Gdb <[email protected]> wrote:
>
> Is it possible to change the GDB prompt from within Python, such that
> the prompt contains a trailing space (like the default prompt)?
>
> I cannot figure it out.
>
> If I run set prompt from the normal command interpreter I can easily
> just put a space at the end and it works:
>
>   (gdb) set prompt XXX\n
>   XXXprint 1
>   1
>
>   (gdb) set prompt XXX \n
>   XXX print 1
>   1
>
> showing \n to indicate where I type ENTER
>
> Fine.  But this doesn't work from Python:
>
>   (gdb) python
>   > gdb.execute('set prompt XXX ', True)
>   > ^D
>   XXXprint 1
>   1
>
> It seems that no matter what I do, the trailing space is stripped off.
> Is there some other way to set the prompt from Python?

Weird, using the python prompt hook does work.

(gdb) python
>gdb.prompt_hook = lambda old_prompt: "XXX "
>end
XXX quit
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.