)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"d50deff9d07f5f9bec087d6cf1e64f4ee808e7f4","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"d6dcc538_131969cc","updated":"2025-08-25 12:56:15.000000000","message":"Antonio, I\u0027m really sorry I was unable to review this patch in time.","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"d1ad133aedde6b7e8a7735c4f458f61a0e506b26","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"54bd402f_220861d2","updated":"2025-09-28 13:35:03.000000000","message":"I somehow missed the impact of this change. Just noticed it because some tests in my testbench fail. Does this mean we cannot return OpenOCD-specific errors in the future? Because this drastically changes the Tcl RPC interface.","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"eb594226f19bb26395c2f60e663f438dadbc0262","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"1fd65a55_5beca398","updated":"2025-08-25 13:45:33.000000000","message":"I\u0027ve filed an issue in JimTcl[1]. Please, take a look.\nhttps://github.com/msteveb/jimtcl/issues/356","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"c524d176b76c9170d27cd71eaf467a7d40049108","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":3,"id":"862be3bf_c3b01a6a","in_reply_to":"0d266660_d18f3c6c","updated":"2025-10-22 12:22:46.000000000","message":"Antonio, Marc,\n\nPerhaps we can revert this change?\n\nThe issue with JimTCL 0.84 is resolved [1], only the `JIM_USAGE` (-1) will change the behavior and it\u0027s not used in OpenOCD.\n\nMaybe we can discuss and come up with a better solution? IMHO there still should be a way to distinguish the error kind (e.g. invalid argument vs communication failure) and relying on error messages to do so does not seem feasible to me.\n\n1: https://github.com/msteveb/jimtcl/issues/356","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"65513fa9e3239fe68caab7ec17ea2d9c63bcef8b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"12381fb9_1114f520","in_reply_to":"1fd65a55_5beca398","updated":"2025-08-27 16:21:13.000000000","message":"The way Tcl handles an error is by returning value JIM_ERROR (or TCL_ERROR in https://github.com/tcltk/tcl/blob/main/generic/tcl.h#L478 ) and setting a result string with the relevant explanation.\nReturning values other than JIM_ERROR or TCL_ERROR, for me it\u0027s not the right way to go because we diverge from standard Tcl. We are decoupling OpenOCD build from Jim Tcl library; we cannot rely on undocumented behavior of the libraries.\nThe link above also points to:\n```\n * Integer return codes in the range TCL_CODE_USER_MIN to TCL_CODE_USER_MAX are\n * reserved for the use of packages.\n```\nNot clear to me if we can use them. But there is no equivalent in Jim Tcl. See also https://core.tcl-lang.org/tips/doc/trunk/tip/696.md","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"b9b1f7e276fef768b2221512fd5a2f500ffb2a24","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"0d266660_d18f3c6c","in_reply_to":"54bd402f_220861d2","updated":"2025-10-19 14:34:03.000000000","message":"I did not expected that the testbenches would use such error codes.\nMy first version of this patch also missed it in the test utils.tcl\n\nBut as I wrote in the commit message, we were exploiting a corner case of JimTcl.\nWe cannot rely on it and we cannot anticipate future changes that can impact such error handling.\n\nIn Tcl interpreter https://github.com/tcltk/tcl/blob/main/generic/tcl.h#L496\nthere is an explicit range for error codes \"reserved for the use of packages\". Is it something we can use? Or we could still clash with some \"package\"?\nBut these are missing in JimTcl https://github.com/msteveb/jimtcl/blob/master/jim.h#L130\n\nI personally prefer to keep the Tcl way:\n- command returns a code OK or ERROR;\n- command returns a string that is either the command output or the error string.","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"025a23f1658b4ab246228e918b876c87867d3d3e","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":3,"id":"63bcc467_d68e4fdd","in_reply_to":"862be3bf_c3b01a6a","updated":"2025-10-24 13:36:21.000000000","message":"Please notice that it\u0027s only by chance that the error code (-1) is not used anymore by OpenOCD.\nSee `src/helper/log.h` in git commits\n74eb754abcb49bd8a61b42398ba80d1a895a4604\n4668bd264cfe64c3e3ddd0f75cb5bf2e5e85f717\nError (-1) used to exist, then it was replaced by another and the old code was never reused.\n\nI\u0027m still convinced that, independently by the changes in JimTcl, we should follow the Tcl error convention, like reported in:\nhttps://www.tcl-lang.org/man/tcl8.4/TclCmd/catch.htm\n\nAnyway, I understand your need to check more in details the OpenOCD commands.\nI think I have found a \"reasonably standard\" way to propagate the error code.\nPlease check https://review.openocd.org/c/openocd/+/9186","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"}],"src/helper/command.c":[{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"d50deff9d07f5f9bec087d6cf1e64f4ee808e7f4","unresolved":true,"context_lines":[{"line_number":500,"context_line":"\tretcode \u003d Jim_SetAssocData(interp, \"context\", NULL, context);"},{"line_number":501,"context_line":"\tif (retcode \u003d\u003d JIM_OK) {"},{"line_number":502,"context_line":"\t\t/* associated the return value */"},{"line_number":503,"context_line":"\t\tJim_DeleteAssocData(interp, \"retval\");"},{"line_number":504,"context_line":"\t\tretcode \u003d Jim_SetAssocData(interp, \"retval\", NULL, \u0026retval);"},{"line_number":505,"context_line":"\t\tif (retcode \u003d\u003d JIM_OK) {"},{"line_number":506,"context_line":"\t\t\tretcode \u003d Jim_Eval_Named(interp, line, NULL, 0);"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"c261911d_374abce4","side":"PARENT","line":503,"updated":"2025-08-25 12:56:15.000000000","message":"This is a great simplification!\nI was under the impression the whole associated \"retval\" deal was redundant, but I was to afraid of what may come if I was to remove it)","commit_id":"ba982b801aac7f883343040b5f008573d3d9d3a8"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"65513fa9e3239fe68caab7ec17ea2d9c63bcef8b","unresolved":false,"context_lines":[{"line_number":500,"context_line":"\tretcode \u003d Jim_SetAssocData(interp, \"context\", NULL, context);"},{"line_number":501,"context_line":"\tif (retcode \u003d\u003d JIM_OK) {"},{"line_number":502,"context_line":"\t\t/* associated the return value */"},{"line_number":503,"context_line":"\t\tJim_DeleteAssocData(interp, \"retval\");"},{"line_number":504,"context_line":"\t\tretcode \u003d Jim_SetAssocData(interp, \"retval\", NULL, \u0026retval);"},{"line_number":505,"context_line":"\t\tif (retcode \u003d\u003d JIM_OK) {"},{"line_number":506,"context_line":"\t\t\tretcode \u003d Jim_Eval_Named(interp, line, NULL, 0);"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"71cbb64e_045f8b39","side":"PARENT","line":503,"in_reply_to":"c261911d_374abce4","updated":"2025-08-27 16:21:13.000000000","message":"In the past OpenOCD registered Jim native commands and OpenOCD handler commands.\nThis \"retval\" was an hack to pass in Jim an OpenOCD error code and recover it here.\nBut it was not properly documented and over time it got probably not properly used.\nNow all OpenOCD commands are managed through the same handler type. We do not need such hack anymore as every OpenOCD command passes through `jim_exec_command()` and the returned value is there.\nWe could take back this mechanism, if we need it again.","commit_id":"ba982b801aac7f883343040b5f008573d3d9d3a8"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"d50deff9d07f5f9bec087d6cf1e64f4ee808e7f4","unresolved":true,"context_lines":[{"line_number":471,"context_line":"\t\treturn JIM_OK;"},{"line_number":472,"context_line":""},{"line_number":473,"context_line":"\t// used by telnet server to close one connection"},{"line_number":474,"context_line":"\tif (retval \u003d\u003d ERROR_COMMAND_CLOSE_CONNECTION)"},{"line_number":475,"context_line":"\t\treturn JIM_EXIT;"},{"line_number":476,"context_line":""},{"line_number":477,"context_line":"\treturn JIM_ERR;"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"25d11c92_223566e2","line":474,"updated":"2025-08-25 12:56:15.000000000","message":"[nitpick] IMHO, a `switch (retval)` would more concise and a bit clearer.","commit_id":"33c1a1c0e545c2cd5bb6c56972d0593955f5f070"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"d50deff9d07f5f9bec087d6cf1e64f4ee808e7f4","unresolved":true,"context_lines":[{"line_number":474,"context_line":"\tif (retval \u003d\u003d ERROR_COMMAND_CLOSE_CONNECTION)"},{"line_number":475,"context_line":"\t\treturn JIM_EXIT;"},{"line_number":476,"context_line":""},{"line_number":477,"context_line":"\treturn JIM_ERR;"},{"line_number":478,"context_line":"}"},{"line_number":479,"context_line":""},{"line_number":480,"context_line":"int command_run_line(struct command_context *context, char *line)"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"009a71cd_de50d7cb","line":477,"updated":"2025-08-25 12:56:15.000000000","message":"Shouldn\u0027t all `ERROR_COMMAND_*` be handled specially? Otherwise it seems like they are redundant. E.g. returning `ERROR_COMMAND_ARGUMENT_INVALID` from a handler is exactly the same as `ERROR_FAIL`.","commit_id":"33c1a1c0e545c2cd5bb6c56972d0593955f5f070"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"65513fa9e3239fe68caab7ec17ea2d9c63bcef8b","unresolved":true,"context_lines":[{"line_number":474,"context_line":"\tif (retval \u003d\u003d ERROR_COMMAND_CLOSE_CONNECTION)"},{"line_number":475,"context_line":"\t\treturn JIM_EXIT;"},{"line_number":476,"context_line":""},{"line_number":477,"context_line":"\treturn JIM_ERR;"},{"line_number":478,"context_line":"}"},{"line_number":479,"context_line":""},{"line_number":480,"context_line":"int command_run_line(struct command_context *context, char *line)"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"6414610b_a2950c2f","line":477,"in_reply_to":"009a71cd_de50d7cb","updated":"2025-08-27 16:21:13.000000000","message":"Today only `ERROR_COMMAND_SYNTAX_ERROR` triggers a common message string.\nFor the other `ERROR_COMMAND_*` each command prepares the message through `command_print()`.\nI\u0027m open to accept changes to the current behavior.","commit_id":"33c1a1c0e545c2cd5bb6c56972d0593955f5f070"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"d50deff9d07f5f9bec087d6cf1e64f4ee808e7f4","unresolved":true,"context_lines":[{"line_number":522,"context_line":"\t}"},{"line_number":523,"context_line":""},{"line_number":524,"context_line":"\tif (retcode \u003d\u003d JIM_EXIT) {"},{"line_number":525,"context_line":"\t\t// used by telnet server to close one connection"},{"line_number":526,"context_line":"\t\treturn ERROR_COMMAND_CLOSE_CONNECTION;"},{"line_number":527,"context_line":"\t}"},{"line_number":528,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":2,"id":"35f3d797_3a14ef8e","line":525,"updated":"2025-08-25 12:56:15.000000000","message":"I\u0027d suggest dropping the mention of telnet.","commit_id":"33c1a1c0e545c2cd5bb6c56972d0593955f5f070"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"65513fa9e3239fe68caab7ec17ea2d9c63bcef8b","unresolved":true,"context_lines":[{"line_number":522,"context_line":"\t}"},{"line_number":523,"context_line":""},{"line_number":524,"context_line":"\tif (retcode \u003d\u003d JIM_EXIT) {"},{"line_number":525,"context_line":"\t\t// used by telnet server to close one connection"},{"line_number":526,"context_line":"\t\treturn ERROR_COMMAND_CLOSE_CONNECTION;"},{"line_number":527,"context_line":"\t}"},{"line_number":528,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":2,"id":"cd2121f1_05aae719","line":525,"in_reply_to":"35f3d797_3a14ef8e","updated":"2025-08-27 16:21:13.000000000","message":"Today the telnet session is closed by the Tcl command `exit` that in Jim library returns this special `JIM_EXIT`.\nIf one day we switch to another Tcl library, this `JIM_EXIT` could be not present anymore. See https://github.com/tcltk/tcl/blob/main/generic/tcl.h#L478\nThe command `exit` in the Tcl/Tk project above calls libc `exit()` that does not return.\nI let the decision on how to handle this to who will ever try to use another Tcl library.\nIn mean time, I prefer keeping this comment as a guide for such future development.","commit_id":"33c1a1c0e545c2cd5bb6c56972d0593955f5f070"}],"testing/tcl_commands/utils.tcl":[{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"d50deff9d07f5f9bec087d6cf1e64f4ee808e7f4","unresolved":true,"context_lines":[{"line_number":32,"context_line":"\t}"},{"line_number":33,"context_line":""},{"line_number":34,"context_line":"\tproc check_syntax_err script {"},{"line_number":35,"context_line":"\t\ttailcall check_for_error 1 {} $script"},{"line_number":36,"context_line":"\t}"},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"\tproc check_matches {pattern script} {"}],"source_content_type":"text/x-tcl","patch_set":3,"id":"aeb5b46c_abb183f5","line":35,"updated":"2025-08-25 12:56:15.000000000","message":"AFAIU, the fact that there is only one error code from now on will make it a lot harder to create scripts that should meaningfully handle errors, distinguishing different error types.","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"65513fa9e3239fe68caab7ec17ea2d9c63bcef8b","unresolved":true,"context_lines":[{"line_number":32,"context_line":"\t}"},{"line_number":33,"context_line":""},{"line_number":34,"context_line":"\tproc check_syntax_err script {"},{"line_number":35,"context_line":"\t\ttailcall check_for_error 1 {} $script"},{"line_number":36,"context_line":"\t}"},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"\tproc check_matches {pattern script} {"}],"source_content_type":"text/x-tcl","patch_set":3,"id":"bd964089_3affa476","line":35,"in_reply_to":"aeb5b46c_abb183f5","updated":"2025-08-27 16:21:13.000000000","message":"It should be handled through the returned message string, like for every other Tcl command.","commit_id":"93f16eed4d4db379671293277e9b6e7d5aba6c9b"}]}
