在debug芯片中后端flow script时,经常需要单行或分段复制到eda shell里看执行效果。如果能够在tcl script里设置断点,就能带来很大的便利。
经过请教和尝试,发现tcl的return
正是需要的功能。
据https://www.tcl-lang.org/man/tcl8.6/TclCmd/return.htm,return
的作用描述如下:
In its simplest usage, the return command is used without options in the body of a procedure to immediately return control to the caller of the procedure. If a result argument is provided, its value becomes the result of the procedure passed back to the caller. If result is not specified then an empty string will be returned to the caller as the result of the procedure.
The return command serves a similar function within script files that are evaluated by the source command. When source evaluates the contents of a file as a script, an invocation of the return command will cause script evaluation to immediately cease, and the value result (or an empty string) will be returned as the result of the source command.
简单来说return
有两个作用:
1、用在函数里,遇到return时,立即结束函数执行。
2、用在source的script里,遇到return时,立即结束script剩余代码的执行。