)]}'
{"src/target/target.c":[{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"207a6a0513668e9e5e2cfbe8436b6f5b29e4bc5b","unresolved":false,"context_lines":[{"line_number":4993,"context_line":"\t\t\t\t\t *     You can specify %X and %Y in the event code."},{"line_number":4994,"context_line":"\t\t\t\t\t *     The idea is: %T - target name."},{"line_number":4995,"context_line":"\t\t\t\t\t *     The idea is: %N - target number"},{"line_number":4996,"context_line":"\t\t\t\t\t *     The idea is: %E - event name."},{"line_number":4997,"context_line":"\t\t\t\t\t */"},{"line_number":4998,"context_line":"\t\t\t\t\tJim_IncrRefCount(teap-\u003ebody);"},{"line_number":4999,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":1,"id":"5ef2cfe8_f3d174aa","side":"PARENT","line":4996,"updated":"2025-08-13 11:38:14.000000000","message":"Just to clarify:\n* target name can be obtained from `[target current]`.\n* target number similarly is `[lsearch [target names] [target current]]`.\n\nMaybe this should be specified in the documentation? E.g. adding something like: \"In the event body current target (see [15.2 Target State handling][2]) is changed to the one the event was triggered on.\" to [11.5 Target Events][1].\n\nShould there be a way to get current event? Seems a bit redundant since event body does not need to be a `proc`:\n```tcl\n$tgt configure -event $event_name \"common_handler $event_name\"\n```\n\nAlso, the list of events in the documentation is outdated, though it should be probably done in a different patch.\n\n1: https://openocd.org/doc-release/html/CPU-Configuration.html#Target-Events\n2: https://openocd.org/doc-release/html/General-Commands.html#Target-State-handling","commit_id":"3061149545b2be806b9a382995a33f5a60af9555"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"499d7b709b16a92936ce36839d58102e3f104271","unresolved":false,"context_lines":[{"line_number":4993,"context_line":"\t\t\t\t\t *     You can specify %X and %Y in the event code."},{"line_number":4994,"context_line":"\t\t\t\t\t *     The idea is: %T - target name."},{"line_number":4995,"context_line":"\t\t\t\t\t *     The idea is: %N - target number"},{"line_number":4996,"context_line":"\t\t\t\t\t *     The idea is: %E - event name."},{"line_number":4997,"context_line":"\t\t\t\t\t */"},{"line_number":4998,"context_line":"\t\t\t\t\tJim_IncrRefCount(teap-\u003ebody);"},{"line_number":4999,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":1,"id":"53e309d1_8b5782a0","side":"PARENT","line":4996,"in_reply_to":"56c01191_308e571f","updated":"2025-08-14 17:05:47.000000000","message":"After Paul comment on IRC, I\u0027m re-reading the comment addressed by this patch.\n\nWhile my interpretation is that it \"also\" suggests to use Tcl/Tk events for OpenOCD events, actually it only suggests to use special format strings (e.g. `%T`) to \"patch\" the event\u0027s code before executing it.\nSo at least the commit message is not appropriate.\n\nAs I wrote above, I plan to re-work the way the events are defined, by using namespaces. Here is a more complete proposal:\n```\nnamespace eval $_CHIPNAME.cpu {\n  namespace eval events {\n    proc halted {target} {\n      whatever\n    }\n    proc reset-deassert-pre {target halt} {\n      whatever\n    }\n  }\n}\n```\nHaving the possibility to pass directly variables to the procedures looks to me much clean than patching the code at runtime using format strings that has to be recovered from the documentation.\nActually `$target` is redundant, as it can be get with `[target current]` or through the namespace. And the name of the proc (that is also the name of the event) can be get with standard Tcl commands.\n\nBut I don\u0027t plan to complete the re-work above for v1.0.0 as it needs too many changes in code and existing scripts.\nSo, if you prefer, this patch can be frozen and re-examined after the re-work.","commit_id":"3061149545b2be806b9a382995a33f5a60af9555"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"bf3ff382d7dbb498d4f193ad32ca52e17f45cb58","unresolved":false,"context_lines":[{"line_number":4993,"context_line":"\t\t\t\t\t *     You can specify %X and %Y in the event code."},{"line_number":4994,"context_line":"\t\t\t\t\t *     The idea is: %T - target name."},{"line_number":4995,"context_line":"\t\t\t\t\t *     The idea is: %N - target number"},{"line_number":4996,"context_line":"\t\t\t\t\t *     The idea is: %E - event name."},{"line_number":4997,"context_line":"\t\t\t\t\t */"},{"line_number":4998,"context_line":"\t\t\t\t\tJim_IncrRefCount(teap-\u003ebody);"},{"line_number":4999,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":1,"id":"56c01191_308e571f","side":"PARENT","line":4996,"in_reply_to":"5ef2cfe8_f3d174aa","updated":"2025-08-13 13:50:27.000000000","message":"I ignored the proposals in the comment since the Tcl events are not suitable.\n\nAnyway, `target current` is already documented.\n\nThe target number is not really useful. It\u0027s helpful in telnet console when you want to change current target because you can just type the number, e.g. `targets 2`, instead of typing the whole target name, but it should not be used in a tcl script.\n\nRegarding the event name, I\u0027m re-working the way the events are defined.\nWhile I will keep for some time the backward compatibility, I plan to move them as `proc` with pre-defined name in a Tcl namespace named as the target.\n```\nnamespace eval $_CHIPNAME.cpu {\n\tproc event-halted {} {\n\t\twhatever\n\t}\n\tproc event-examine-end {} {\n\t\twhatever\n\t}\n}\n```\nIt will open the door to the possibility to cleanly pass arguments to the event handlers, which is something I already tried in a dirtier way in https://review.openocd.org/c/openocd/+/8815\nPlus, once the backward compatibility gets removed, this change will free some C code.\n\nAgree, the documentation is not completely aligned with the code.","commit_id":"3061149545b2be806b9a382995a33f5a60af9555"}]}
