Hi, Some time ago Jan Lübbe (shoragan) asked an interesting question on IRC: why the hell some Tcl functions do not return anything at all when he's calling them via the RPC interface?
After quite some digging through the code I finally understood that: 1. OpenOCD has a smart cool trick to make API easier to use: when some function outputs anything via the normal logging mechanism and doesn't explicitly set return value and doesn't throw an exception, the return value is automatically set to what it logged. Seems to be rather useful. 2. Some OpenOCD commands work exactly that way, e.g. "flash list". 3. Some (e.g. "flash bank") do not because they are routed through "ocd_bouncer" that strips the result if the command doesn't return an error. Among these commands there're very useful memory reading routines. My current theory is that ocd_bouncer was introduced to avoid duplication of the output on openocd console as it also automatically prints a return value of any command. I think that's an unnecessary complication, an unexpected undocumented hurdle to anyone who wants to use Tcl API (either interactively via telnet or via the RPC interface). Known (but undocumented) workarounds are: "capture" command (undocumented) or using "ocd_" prefix for some (but not all) calls (clumsy, undocumented). As I think the 1. trick is a good one (and ocd_bouncer is a bad one), I'm proposing to: 1. Eliminate ocd_bouncer altogether; 2. Disable auto-printing return values to the openocd console; 3. Add back whatever important output missing after 2. as logging. What do you folks think? -- Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software! mailto:[email protected] ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
