tinyriscv-openocd/src
Antonio Borneo 1af83682e0 target: fix error on TCL command "return" in target event handler
The TCL command "return" always returns error code JIM_RETURN, to
indicate that the effective error code and message are elsewhere.

In the current implementation, the caller of target's event only
checks for return code JIM_OK and considers any other value,
including JIM_RETURN, as an error condition, thus dumping the
call-trace. The execution is not stopped because the error is not
further propagated, but the error message is annoying and
misleading.

It can be tested running
	openocd -f ./test.cfg
using the following script "test.cfg". You can replace the board
file in line 1, to use a board available in your lab:
  1	source [find board/st_nucleo_f4.cfg]
  2	[target current] configure -event reset-start {}
  3	[target current] configure -event reset-end {return}
  4	init
  5	proc a {} {[target current] invoke-event reset-start}
  6	proc b {} {[target current] invoke-event reset-end}
  7	proc c {} {a;b;echo "arrived at the end"}
  8	c
  9	shutdown
The execution produces:
	./test.cfg:7: Error:
	in procedure 'c' called at file "./test.cfg", line 8
	in procedure 'b' called at file "./test.cfg", line 7

	arrived at the end
that shows the call-trace but does not halt the execution.

The developer can avoid using the "return" command in the event
body by defining a TCL procedure that implements the handler and
that contains the "return" command, reducing the handler body to
a simple call to the procedure above. But this approach is either
not documented nor always intuitive while writing the handler,
causing waste of time to look for the false error.

Modify target_handle_event() to detect the specific return value
of the "return" command and to test the real error code that is,
eventually, specified to the TCL "return" command.

Change-Id: I2b860bab7233c6ed13ee4098e348d7533e1c4626
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4974
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-06-13 12:40:37 +01:00
..
flash flash/stm32h7x: fix register names to comply with RM0399 Rev2 and RM0433 Rev6 2019-06-13 12:40:16 +01:00
helper helper: add bitmap helper primitives 2019-06-06 16:32:57 +01:00
jtag jtag: drivers: buspirate: chunk SWD switch sequence transfer. 2019-06-13 12:39:38 +01:00
pld helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
rtos ARMv8: Update rtos_reg storage from 8 to 16 bytes 2019-06-12 15:15:15 +01:00
server gdb_server: remove call to jtag_execute_queue() 2019-06-06 16:33:41 +01:00
svf helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
target target: fix error on TCL command "return" in target event handler 2019-06-13 12:40:37 +01:00
transport helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
xsvf helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
Makefile.am Convert to non-recursive make 2016-12-08 16:23:10 +00:00
hello.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
hello.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
main.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
openocd.c armv8: valgrind memleak fixes 2018-04-10 09:13:02 +01:00
openocd.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00