This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix behaviour of 'show' commands in hook functions in MI mode


On 12/18/2014 11:00 AM, Thomas Perry wrote:
> On 15/12/14 13:58, Pedro Alves wrote:
>> 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
> 
> Hi Pedro (and Joel),
> 
> Thanks very much for reviewing the patch.  I agree with you that there 
> are other aspects of the MI behaviour that don't seem to work as we 
> might expect.  

These aren't other aspects, but rather more manifestations of the
same issue.

> However, would the patch be acceptable on the grounds 
> that it improves the current behaviour (subject to passing tests), even 
> if its scope is limited to "show" commands?

I think the root cause should be identified instead.

> One alternative approach would be for GDB/MI to output a distinct 
> result-record for commands like "show" and "info threads" rather than 
> adding their output to records for other commands, but this will be a 
> more difficult (and risky) change.  What is your opinion on this?  Is 
> this likely to be an acceptable modification to the current behaviour?

No, not acceptable, sorry.  "info threads" is not special either.  It was
just an example.  The issue will manifest with any command that
uses ui_out for structured output.  Another example:

$ gdb -q -i=mi -ex "info break" /usr/bin/true
(gdb)
p 1
&"p 1\n"
~"$1 = 1"
~"\n"
^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)

I'd suspect that MI's cli uiout isn't being properly
wired up in these cases.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]