This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix behaviour of 'show' commands in hook functions in MI mode
- From: Pedro Alves <palves at redhat dot com>
- To: Thomas Perry <tperry981 at gmail dot com>, gdb-patches at sourceware dot org
- Date: Mon, 15 Dec 2014 13:58:27 +0000
- Subject: Re: [PATCH] Fix behaviour of 'show' commands in hook functions in MI mode
- Authentication-results: sourceware.org; auth=none
- References: <5465DC37 dot 5040808 at gmail dot com>
On 11/14/2014 10:40 AM, Thomas Perry wrote:
> The following patch modifies the behaviour of a 'show' command executed
> in a hook function in MI mode, so that it will print the result using
> the console-mode behaviour, wrapped up as an MI console-stream-output
> record.
>
> I hope this is reasonable -- please get in touch if it warrants discussion.
Sorry, I don't think special-casing "show" is the right solution.
See e.g.:
$ echo -e "define hook-run\ninfo threads\nend\nrun\nquit" > x
$ ./gdb -i=mi -x x /usr/bin/true
...
*stopped,threads=[],reason="exited-normally"
^^^^^^^^^^
vs:
$ echo -e "define hook-run\nend\nrun\nquit" > x
*stopped,reason="exited-normally"
But simpler, even without a hook:
$ echo -e "info threads" > x
$ gdb -q -i=mi -x x /usr/bin/true
...
(gdb)
p 1
&"p 1\n"
~"$1 = 1"
~"\n"
^done,threads=[]
^^^^^^^^^^^
(gdb)
p 1
&"p 1\n"
~"$2 = 1"
~"\n"
^done // correct now
(gdb)
Or even without a command file:
$ gdb -q -i=mi -ex "set inferior-tty /dev/null" -ex "show inferior-tty" /usr/bin/true
=thread-group-added,id="i1"
...
=cmd-param-changed,param="inferior-tty",value="/dev/null"
(gdb)
p 1
&"p 1\n"
~"$1 = 1"
~"\n"
^done,value="/dev/null"
^^^^^^^^^^^^^^^^^
(gdb)
Thanks,
Pedro Alves