On Mon, Jun 17, 2019 at 2:47 PM Leonard Crestez <[email protected]> wrote:
>
> Hello,
>
> This is a continuation of my questions on irc. There were some recent

Out-of-topic:
Would be nice to get access to the old IRC discussions, but I cannot
find such history for OpenOCD.
Someone has ever recorded them and made accessible?

> 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.
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. In particular it breaks a bunch of scripts I have
> which look like this:
>
> proc dump_myip {base} {
>      echo "MYIP_REG1:"
>      mdw [expr $base + 0x000]
>      echo "MYIP_REG1:"
>      mdw [expr $base + 0x012]
>      echo "MYIP_REG1:"
>      mdw [expr $base + 0x032]
> }
>
> It's not terribly difficult to replace all "mdw *" with "echo [mdw *]"
> but it seems strange. The "mdw" command stands for "Memory Display Word"
> so my expectation is that it would "display" and other commands (like
> mem2array) should be used to fetch memory values for manipulation inside
> TCL. The output of "mdw" looks like "0x30360800: 00824110" so a regexp
> would be required to strip the header and prepend 0x to the actual value.

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).
Critical error messages should go through LOG_ERROR to inform everyone.
Two weaknesses of current command_output_text():
- if the terminal has not set the output_handler, the print is lost.
We need to improve it and LOG_USER() the message in that case.
- It's missing a printf() style wrapper! It would make the switch much easier.

> Doesn't it make more sense for most commands to "display" instead?

Not for "most" but only for the commands that are supposed to "display"

Antonio


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

Reply via email to