On 6/25/2019 7:11 PM, Antonio Borneo wrote:
> On Thu, Jun 20, 2019 at 12:52 PM Leonard Crestez
> <[email protected]> wrote:
>>
>> On 19.06.2019 11:23, Antonio Borneo wrote:
>>> On Mon, Jun 17, 2019 at 2:47 PM Leonard Crestez <[email protected]> 
>>> wrote:
>>
>>>> This is a continuation of my questions on irc. There were some recent
>>>> changes regarding how OpenOCD handles command output and as far as I can
>>>> tell the default was switched so that all commands will "return" instead
>>>> of "display" by default.
>>>
>>> Yes, I participated at this change.
>>> For me the change was necessarily to remove the old crust of printing
>>> everything and returning nothing, with the "ocd_" prefix to "try" to
>>> get a return value.
>>
>> I tried playing with ocd_ prefix in older releases but all I remember is
>> confusion.
>>
>> The right solution for grabbing the output of a command is the `capture`
>> function, correct?
> 
> Oops, apologise. Completely lost this message.
> 
> The fact that ocd_ prefix was not working properly is part of the
> problem that the implementation of the commands is not always correct.
> "capture" should be the right command to do that, but we still miss a
> full audit of all the existing commands, so it's still possible it
> doesn't work as expected.

That ocd_ prefix was definitely odd and I don't know what you mean by 
"not working properly".

Making "capture" just work in all cases instead of ocd_ would make sense 
but it seems the solution was to just push a bunch of printed display 
info into a "result" instead.

>>> But the job is not terminated, as you mention for the commands mdX
>>>
>>>> This doesn't make much sense to me because most commands have
>>>> human-readable output which is not intended for machine consumption. For
>>>> example "mdw" does pretty alignments, "targets" shows a table and "reg"
>>>> shows register names.
>>> Yes, the commands mdX should printout the value with all the nice and
>>> funny format, and only return the eventual error value.
>>> For reading a value from memory we already have mem2array and the
>>> wrappers mrX, so no need to use mdX.
>>
>>> I think the proper function for printing in mdX (and in most other
>>> places) should be command_output_text(). This prints only to the
>>> terminal that issued the command without polluting the other terminals
>>> (in case you have several telnet and gdb connections to a single
>>> openocd).
>>
>> So you're saying that patches switching mdX back to "display" would be
>> welcome, correct?
> 
> Definitively yes!

>  From my last post in this thread I have spent some time reviewing the
> different LOG_xxx(), command_output_text() and command_print(), the
> impact on changing current code, and I have changed my mind.
> At least for the mdX functions, the fix should simply require to
> change command_print() to LOG_USER() in target_handle_md_output(). Do
> not use command_output_text() as I wrote above.

As far as I can tell the current output methods are:
  * command_print: append to TCL result
  * command_output_text: output to a single client with a 
special-purpose non capturable channel?
  * LOG_xxx: broadcast to everybody

It would make sense to switch mdX to LOG_ but it would also make sense 
to me to switch all of "targets". However I saw patches which converted 
the other way: from LOG_xxx to command_print:

     http://openocd.zylin.com/#/c/5092/

Doesn't it make more sense for error to be printed to the log instead of 
returned as a string result?

Both the interfaces and their usage in code is confusing.

--
Regards,
Leonard


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to