Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Catalin-Dan Udma <catalin-dan.udma@nxp.com>
To: Phil Muldoon <pmuldoon@redhat.com>,
	Catalin Udma	<catalin.udma@freescale.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Subject: RE: [PATCH] python: Use console format for output of gdb.execute command
Date: Thu, 03 Mar 2016 10:25:00 -0000	[thread overview]
Message-ID: <VI1PR0401MB177620A54CA0FB8AB317AE5EDABD0@VI1PR0401MB1776.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <56D76731.7060202@redhat.com>

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


  reply	other threads:[~2016-03-03 10:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 14:35 Catalin Udma
2016-03-02 22:20 ` Phil Muldoon
2016-03-03 10:25   ` Catalin-Dan Udma [this message]
2016-03-29 16:40 ` Pedro Alves
2016-03-31 10:43   ` Catalin-Dan Udma

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=VI1PR0401MB177620A54CA0FB8AB317AE5EDABD0@VI1PR0401MB1776.eurprd04.prod.outlook.com \
    --to=catalin-dan.udma@nxp.com \
    --cc=catalin.udma@freescale.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@redhat.com \
    /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