This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH] python: Use console format for output of gdb.execute command
- From: Catalin-Dan Udma <catalin-dan dot udma at nxp dot com>
- To: Phil Muldoon <pmuldoon at redhat dot com>, Catalin Udma <catalin dot udma at freescale dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Thu, 3 Mar 2016 10:25:31 +0000
- Subject: RE: [PATCH] python: Use console format for output of gdb.execute command
- Authentication-results: sourceware.org; auth=none
- Authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nxp.com;
- References: <1456756452-15880-1-git-send-email-catalin dot udma at freescale dot com> <56D76731 dot 7060202 at redhat dot com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
Thank you, Phil, for review. I added more info inline.
Regards,
Catalin
> -----Original Message-----
> From: Phil Muldoon [mailto:pmuldoon@redhat.com]
>
> While I have no problems with the patch, is the expectation that if
> the interpreter is in MI mode and a command has previously output that
> structured output, isn't the inverse the bug? Shouldn't gdb.execute
> honor the interpreter instead of forcing one?
[Catalin Udma]From GDB manual (7.11.50.20160229, chapter 23.2.2.1 Basic Python):
"gdb.execute (command [, from tty [, to string]]) [Function]
Evaluate command, a string, as a gdb CLI command"
Therefore a CLI command is expected and the output should be printed in CLI format
Only the MI commands should be printed on MI format.
Here some examples (gdb without this patch):
"info break" (CLI command) is always shown in CLI format, even interpreter is MI:
1.
info break
&"info break\n"
~"Num Type Disp Enb Address What\n"
~"1 breakpoint keep y 0x000000000000abcd \n"
2
python gdb.execute("info break")
&"python gdb.execute(\"info break\")\n"
~"Num Type Disp Enb Address What\n"
~"1 breakpoint keep y 0x000000000000abcd \n"
Based on the gdb manual definition, gdb.execute cannot directly execute a MI command, e.g:
python gdb.execute("-break-list")
&"python gdb.execute(\"-break-list\")\n"
&"Traceback (most recent call last):\n"
&" File \"<string>\", line 1, in <module>\n"
&"gdb.error: Undefined command: \"-break-list\". Try \"help\".\n"
&"Error while executing Python code.\n"
^error,msg="Error while executing Python code."
This can be done only using gdb.execute("interpreter-exec mi '-break-list'").
We can have a MI output for MI command, however this (e.g interpreter-exec) it is a CLI command.
This patch does not break the above command: using interpreter-exec + MI command, the
output is MI format.
>I'm not too sure on
> this, not being an MI expert, or whether some commands in GDB
> arbitrarily output one or the other. I'll dig around when I find some
> time and see if I can find anything definitive.
>
> The other thought of course is, if this is right, it arguably
> introduces an API regression. So we might have to work with some
> compatibility mode for existing scripts.
[Catalin Udma] I expect to have no regression with the existing scripts. But I'm happy to
take into consideration any use case I have missed and update the patch accordingly.
By the way, I ran the gdb dejagnu testsuite and found no regression with this patch.
>
> A tricky bug!
>
> Cheers
>
> Phil