)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"552049ca582adaa27484c5107baafc4c1f1ea8b8","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":11,"id":"e224d064_10ead956","updated":"2021-09-22 09:41:20.000000000","message":"Are there any objections to merging?","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"328d799e11161eb603a8fe3370b6ae3577d46f61","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":11,"id":"58287790_6cfaa2ba","updated":"2022-02-15 22:49:24.000000000","message":"I\u0027m sorry for forgetting completely this series. Too many patches.\nI have few comments below, nothing disruptive.","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"39ab74c1b7240b0335bbbc820150f33a14cc6230","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":12,"id":"8ffabed4_81922b12","updated":"2022-02-19 20:40:39.000000000","message":"minor issue with documentation. Code is OK, thanks","commit_id":"e4c6321ae4a8d325cb2cf90009a4e4505eb28082"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"fc3e2269c1e7db816dd17aea24de2b44ec312083","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":13,"id":"b0306146_7f27aabd","updated":"2022-02-20 14:21:00.000000000","message":"Thanks","commit_id":"aab6c2a0237487167b615fdfd66c6bb90e1bf33f"}],"doc/openocd.texi":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"328d799e11161eb603a8fe3370b6ae3577d46f61","unresolved":true,"context_lines":[{"line_number":11209,"context_line":""},{"line_number":11210,"context_line":"@item @b{set_reg} \u003c@var{dict}\u003e"},{"line_number":11211,"context_line":""},{"line_number":11212,"context_line":"Set target register values from a Tcl dictionary"},{"line_number":11213,"context_line":"@item @b{flash banks} \u003c@var{driver}\u003e \u003c@var{base}\u003e \u003c@var{size}\u003e \u003c@var{chip_width}\u003e \u003c@var{bus_width}\u003e \u003c@var{target}\u003e [@option{driver options} ...]"},{"line_number":11214,"context_line":""},{"line_number":11215,"context_line":"Return information about the flash banks"}],"source_content_type":"text/x-texinfo","patch_set":11,"id":"be887213_21e412a6","line":11212,"updated":"2022-02-15 22:49:24.000000000","message":"Not sure this is the right place in the documentation for this command.\nThis is the section \"Internal low-level Commands\"\nMaybe better in section Target State handling together with {reg}","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"39ab74c1b7240b0335bbbc820150f33a14cc6230","unresolved":false,"context_lines":[{"line_number":11209,"context_line":""},{"line_number":11210,"context_line":"@item @b{set_reg} \u003c@var{dict}\u003e"},{"line_number":11211,"context_line":""},{"line_number":11212,"context_line":"Set target register values from a Tcl dictionary"},{"line_number":11213,"context_line":"@item @b{flash banks} \u003c@var{driver}\u003e \u003c@var{base}\u003e \u003c@var{size}\u003e \u003c@var{chip_width}\u003e \u003c@var{bus_width}\u003e \u003c@var{target}\u003e [@option{driver options} ...]"},{"line_number":11214,"context_line":""},{"line_number":11215,"context_line":"Return information about the flash banks"}],"source_content_type":"text/x-texinfo","patch_set":11,"id":"72fef2b4_ef9e047a","line":11212,"in_reply_to":"440af3aa_2dbff261","updated":"2022-02-19 20:40:39.000000000","message":"This disappeared in patchset 12. Instead should be moved in section \"Target State handling\"","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"613df1992dfdb4db112aea69bd8d770cfa31820d","unresolved":false,"context_lines":[{"line_number":11209,"context_line":""},{"line_number":11210,"context_line":"@item @b{set_reg} \u003c@var{dict}\u003e"},{"line_number":11211,"context_line":""},{"line_number":11212,"context_line":"Set target register values from a Tcl dictionary"},{"line_number":11213,"context_line":"@item @b{flash banks} \u003c@var{driver}\u003e \u003c@var{base}\u003e \u003c@var{size}\u003e \u003c@var{chip_width}\u003e \u003c@var{bus_width}\u003e \u003c@var{target}\u003e [@option{driver options} ...]"},{"line_number":11214,"context_line":""},{"line_number":11215,"context_line":"Return information about the flash banks"}],"source_content_type":"text/x-texinfo","patch_set":11,"id":"5857acdc_ea329371","line":11212,"in_reply_to":"72fef2b4_ef9e047a","updated":"2022-02-20 12:19:50.000000000","message":"Oups, it\u0027s there now.","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"d4a09fbd5e3bb4860268bd35d759acbf4dce87cc","unresolved":false,"context_lines":[{"line_number":11209,"context_line":""},{"line_number":11210,"context_line":"@item @b{set_reg} \u003c@var{dict}\u003e"},{"line_number":11211,"context_line":""},{"line_number":11212,"context_line":"Set target register values from a Tcl dictionary"},{"line_number":11213,"context_line":"@item @b{flash banks} \u003c@var{driver}\u003e \u003c@var{base}\u003e \u003c@var{size}\u003e \u003c@var{chip_width}\u003e \u003c@var{bus_width}\u003e \u003c@var{target}\u003e [@option{driver options} ...]"},{"line_number":11214,"context_line":""},{"line_number":11215,"context_line":"Return information about the flash banks"}],"source_content_type":"text/x-texinfo","patch_set":11,"id":"440af3aa_2dbff261","line":11212,"in_reply_to":"be887213_21e412a6","updated":"2022-02-19 17:45:03.000000000","message":"Done","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"39ab74c1b7240b0335bbbc820150f33a14cc6230","unresolved":true,"context_lines":[{"line_number":11559,"context_line":"@item @b{array2mem} \u003c@var{varname}\u003e \u003c@var{width}\u003e \u003c@var{addr}\u003e \u003c@var{nelems}\u003e"},{"line_number":11560,"context_line":""},{"line_number":11561,"context_line":"Convert a Tcl array to memory locations and write the values"},{"line_number":11562,"context_line":""},{"line_number":11563,"context_line":"@item @b{flash banks} \u003c@var{driver}\u003e \u003c@var{base}\u003e \u003c@var{size}\u003e \u003c@var{chip_width}\u003e \u003c@var{bus_width}\u003e \u003c@var{target}\u003e [@option{driver options} ...]"},{"line_number":11564,"context_line":""},{"line_number":11565,"context_line":"Return information about the flash banks"}],"source_content_type":"text/x-texinfo","patch_set":12,"id":"fa59a78a_9ca53e00","line":11562,"updated":"2022-02-19 20:40:39.000000000","message":"plus this added empty line has no reason to be here. It\u0027s a remaining of moving the documentation","commit_id":"e4c6321ae4a8d325cb2cf90009a4e4505eb28082"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"613df1992dfdb4db112aea69bd8d770cfa31820d","unresolved":false,"context_lines":[{"line_number":11559,"context_line":"@item @b{array2mem} \u003c@var{varname}\u003e \u003c@var{width}\u003e \u003c@var{addr}\u003e \u003c@var{nelems}\u003e"},{"line_number":11560,"context_line":""},{"line_number":11561,"context_line":"Convert a Tcl array to memory locations and write the values"},{"line_number":11562,"context_line":""},{"line_number":11563,"context_line":"@item @b{flash banks} \u003c@var{driver}\u003e \u003c@var{base}\u003e \u003c@var{size}\u003e \u003c@var{chip_width}\u003e \u003c@var{bus_width}\u003e \u003c@var{target}\u003e [@option{driver options} ...]"},{"line_number":11564,"context_line":""},{"line_number":11565,"context_line":"Return information about the flash banks"}],"source_content_type":"text/x-texinfo","patch_set":12,"id":"77f3202a_caac49d9","line":11562,"in_reply_to":"fa59a78a_9ca53e00","updated":"2022-02-20 12:19:50.000000000","message":"Correct","commit_id":"e4c6321ae4a8d325cb2cf90009a4e4505eb28082"}],"src/target/target.c":[{"author":{"_account_id":1001667,"name":"Jan Matyas","email":"jan.matyas@codasip.com","username":"JanMatCodasip"},"change_message_id":"055c77b7c48cc25ed0219d208c0dfe4354ac8b6f","unresolved":false,"context_lines":[{"line_number":4892,"context_line":""},{"line_number":4893,"context_line":"\t\tif (reg) {"},{"line_number":4894,"context_line":"\t\t\tbuf_set_u32(reg-\u003evalue, 0, 32, value);"},{"line_number":4895,"context_line":"\t\t\treg-\u003edirty \u003d true;"},{"line_number":4896,"context_line":"\t\t}"},{"line_number":4897,"context_line":"\t}"},{"line_number":4898,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":5,"id":"aedf27f1_bb79522c","line":4895,"updated":"2021-06-03 11:22:53.000000000","message":"What is exactly the meaning of \"reg-\u003edirty\"? Are the targets required to write the new values to the registers when marked as \"dirty\"?\n\nI believe that\u0027s not the case. Looking at the code of the targets, many of them simply do not check (or otherwise use) the \"dirty\" flag.\n\nSo it seems to me that setting dirty\u003dtrue is not enough to make the target update the register. Is that correct understanding?\n\nI think the \"set\" callback from struct reg_arch_type should be used here to make sure the register update really happens, same as in handle_reg_command(). The target can of course use the \"dirty\" flag and postpone the register access to a later time, but that is an implementation detail.","commit_id":"fe6e60b9a4a4c3426464df29b3246652eea69441"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"60e523adc031a7e069cfe5fe3f5690e0a11459ac","unresolved":false,"context_lines":[{"line_number":4892,"context_line":""},{"line_number":4893,"context_line":"\t\tif (reg) {"},{"line_number":4894,"context_line":"\t\t\tbuf_set_u32(reg-\u003evalue, 0, 32, value);"},{"line_number":4895,"context_line":"\t\t\treg-\u003edirty \u003d true;"},{"line_number":4896,"context_line":"\t\t}"},{"line_number":4897,"context_line":"\t}"},{"line_number":4898,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":5,"id":"aedf27f1_dbd3f603","line":4895,"in_reply_to":"aedf27f1_bb79522c","updated":"2021-06-03 17:08:42.000000000","message":"The dirty flag is used to report that this register has been modified by OpenOCD.\nOpenOCD loads the registers from the target immediately after \"halt\" and puts back only the \"dirty\" registers before \"resume\".\nSo this part looks correct.","commit_id":"fe6e60b9a4a4c3426464df29b3246652eea69441"},{"author":{"_account_id":1001667,"name":"Jan Matyas","email":"jan.matyas@codasip.com","username":"JanMatCodasip"},"change_message_id":"da9b6f6e5376a3b5e30c2fbb8cad1de1e5364a2a","unresolved":false,"context_lines":[{"line_number":4892,"context_line":""},{"line_number":4893,"context_line":"\t\tif (reg) {"},{"line_number":4894,"context_line":"\t\t\tbuf_set_u32(reg-\u003evalue, 0, 32, value);"},{"line_number":4895,"context_line":"\t\t\treg-\u003edirty \u003d true;"},{"line_number":4896,"context_line":"\t\t}"},{"line_number":4897,"context_line":"\t}"},{"line_number":4898,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":5,"id":"aedf27f1_7bc3ea0a","line":4895,"in_reply_to":"aedf27f1_dbd3f603","updated":"2021-06-04 05:55:46.000000000","message":"I am sorry, we appear to have different opinions here.\n\nI still believe setting of reg-\u003edirty\u003dtrue is insufficient to change the register value. I have the following arguments to support that claim:\n\n1) Please search for uses of \"struct reg.dirty\" within src/target. It is apparent that many targets simply do not check reg-\u003edirty anyhow. The \"riscv\" target is just one example out of many.\n\nThat means for this change won\u0027t work correctly with just reg-\u003edirty\u003dtrue, unless we rework multiple targets first!\n\n2) Register writes can have side effects, and the user may wish to write the register immediately. As an example, take the \"tselect\" CSR in RISC-V, whose value immediately affects values or \"tdata1\", \"tdata2\" and other registers. So the decision whether the register write should happen immediately or can be cached for a later time should be left  at the discretion of the target itself.\n\n3) Look at handle_reg_command(). Reg-\u003edirty\u003dtrue is not used there either. Instead \"struct reg_arch_type.set\" is utilized. That appears to be the proper API for register write, it is in line with 2), and it works on all targets.\n\n4) The same is true for gdb_set_registers_packet().\n\nIn other words, IMO the reg-\u003edirty flag should be left for internal use of targets that wish (and are abůe) to use it, but OpenOCD should not be setting that flag from target-independent code.","commit_id":"fe6e60b9a4a4c3426464df29b3246652eea69441"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"1ee20df86aa94eb858c9829faa2b4d3fdcbacf6b","unresolved":false,"context_lines":[{"line_number":4825,"context_line":"static int target_set_reg(Jim_Interp *interp, struct target *target,"},{"line_number":4826,"context_line":"\t\tint argc, Jim_Obj * const *argv)"},{"line_number":4827,"context_line":"{"},{"line_number":4828,"context_line":"\tif (argc !\u003d 1) {"},{"line_number":4829,"context_line":"\t\tJim_WrongNumArgs(interp, 0, argv, \"\u003cdict\u003e\");"},{"line_number":4830,"context_line":"\t\treturn JIM_ERR;"},{"line_number":4831,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_0ee85edc","line":4828,"updated":"2021-06-07 09:30:06.000000000","message":"I don\u0027t know if could be useful or user friendly extending this to argc as even number, so\nset_reg reg0 val0\nset_reg reg0 val0 reg1 val1\ncan be accepted. Mainly the first example looks interesting.\nBelow some further hint.","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"4749bc2a42a1822b24d75111a2a8c10f4c4844bc","unresolved":false,"context_lines":[{"line_number":4825,"context_line":"static int target_set_reg(Jim_Interp *interp, struct target *target,"},{"line_number":4826,"context_line":"\t\tint argc, Jim_Obj * const *argv)"},{"line_number":4827,"context_line":"{"},{"line_number":4828,"context_line":"\tif (argc !\u003d 1) {"},{"line_number":4829,"context_line":"\t\tJim_WrongNumArgs(interp, 0, argv, \"\u003cdict\u003e\");"},{"line_number":4830,"context_line":"\t\treturn JIM_ERR;"},{"line_number":4831,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_6e8b2a1c","line":4828,"in_reply_to":"aedf27f1_0ee85edc","updated":"2021-06-07 22:08:19.000000000","message":"I\u0027m not a fan of this actually. The current approach allows us to add some optional parameters later without breaking the API.","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"d9b74fd4b238157163ee762033de74e3ae895679","unresolved":false,"context_lines":[{"line_number":4826,"context_line":"\t\tint argc, Jim_Obj * const *argv)"},{"line_number":4827,"context_line":"{"},{"line_number":4828,"context_line":"\tif (argc !\u003d 1) {"},{"line_number":4829,"context_line":"\t\tJim_WrongNumArgs(interp, 0, argv, \"\u003cdict\u003e\");"},{"line_number":4830,"context_line":"\t\treturn JIM_ERR;"},{"line_number":4831,"context_line":"\t}"},{"line_number":4832,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_ce125601","line":4829,"updated":"2021-06-07 08:21:18.000000000","message":"CRAP!!! Jimtcl has changed API with commit cc6d59e7bb61 (\"zlib: Fix arg error checking\")\nhttps://github.com/msteveb/jimtcl/commit/cc6d59e7bb61#diff-aeb280132ac849d311b230a992fef849e850020b4f4705e728192690954b9fdc\nThat was already in jimtcl 0.77!\n\nOpenOCD crash with command\nset_reg r0 1 r1 0\ninstead of returning syntax error.\n\nThere are other 4 calls to Jim_WrongNumArgs(.., 0, ...) plus 32 calls that pass a variable (not sure if it can be zero).\nPlease check at least this patch and 5312. For the rest it will take some time to check and fix!","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"4749bc2a42a1822b24d75111a2a8c10f4c4844bc","unresolved":false,"context_lines":[{"line_number":4826,"context_line":"\t\tint argc, Jim_Obj * const *argv)"},{"line_number":4827,"context_line":"{"},{"line_number":4828,"context_line":"\tif (argc !\u003d 1) {"},{"line_number":4829,"context_line":"\t\tJim_WrongNumArgs(interp, 0, argv, \"\u003cdict\u003e\");"},{"line_number":4830,"context_line":"\t\treturn JIM_ERR;"},{"line_number":4831,"context_line":"\t}"},{"line_number":4832,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_ce76d639","line":4829,"in_reply_to":"aedf27f1_8edc4e4d","updated":"2021-06-07 22:08:19.000000000","message":"Hm strange, actually I tested this. Will check again...","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"cd8981ffb1f535de8fb243b99dc1e876967ebd0d","unresolved":false,"context_lines":[{"line_number":4826,"context_line":"\t\tint argc, Jim_Obj * const *argv)"},{"line_number":4827,"context_line":"{"},{"line_number":4828,"context_line":"\tif (argc !\u003d 1) {"},{"line_number":4829,"context_line":"\t\tJim_WrongNumArgs(interp, 0, argv, \"\u003cdict\u003e\");"},{"line_number":4830,"context_line":"\t\treturn JIM_ERR;"},{"line_number":4831,"context_line":"\t}"},{"line_number":4832,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_8edc4e4d","line":4829,"in_reply_to":"aedf27f1_ce125601","updated":"2021-06-07 08:31:37.000000000","message":"It should become\nJim_WrongNumArgs(interp, 1, argv - 1, \"\u003cdict\u003e\");","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"1ee20df86aa94eb858c9829faa2b4d3fdcbacf6b","unresolved":false,"context_lines":[{"line_number":4831,"context_line":"\t}"},{"line_number":4832,"context_line":""},{"line_number":4833,"context_line":"\tint tmp;"},{"line_number":4834,"context_line":"\tJim_Obj **dict \u003d Jim_DictPairs(interp, argv[0], \u0026tmp);"},{"line_number":4835,"context_line":""},{"line_number":4836,"context_line":"\tif (!dict)"},{"line_number":4837,"context_line":"\t\treturn JIM_ERR;"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_aef4b2ba","line":4834,"range":{"start_line":4834,"start_character":18,"end_line":4834,"end_character":31},"updated":"2021-06-07 09:30:06.000000000","message":"if (argc \u003e 1 \u0026\u0026 (argc % 2) \u003d\u003d 0) {\n   dict \u003d argv;\n   tmp \u003d argc;\n}\nand you can simply reuse the rest of the code to handle\nset_reg reg0 val0 reg1 val1 ...","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"1ee20df86aa94eb858c9829faa2b4d3fdcbacf6b","unresolved":false,"context_lines":[{"line_number":4842,"context_line":"\t\tconst char *reg_name \u003d dict[i]-\u003ebytes;"},{"line_number":4843,"context_line":"\t\tconst char *reg_value \u003d dict[i + 1]-\u003ebytes;"},{"line_number":4844,"context_line":"\t\tstruct reg *reg \u003d register_get_by_name(target-\u003ereg_cache, reg_name,"},{"line_number":4845,"context_line":"\t\t\tfalse);"},{"line_number":4846,"context_line":""},{"line_number":4847,"context_line":"\t\tif (!reg || !reg-\u003eexist) {"},{"line_number":4848,"context_line":"\t\t\tJim_SetResultFormatted(interp, \"Unknown register \u0027%s\u0027\", reg_name);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_4ee66615","line":4845,"range":{"start_line":4845,"start_character":3,"end_line":4845,"end_character":8},"updated":"2021-06-07 09:30:06.000000000","message":"This should be true, as it\u0027s done in \"reg\" command, otherwise you cannot change a register that is in the \"next\" continuation of register list.","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"4749bc2a42a1822b24d75111a2a8c10f4c4844bc","unresolved":false,"context_lines":[{"line_number":4842,"context_line":"\t\tconst char *reg_name \u003d dict[i]-\u003ebytes;"},{"line_number":4843,"context_line":"\t\tconst char *reg_value \u003d dict[i + 1]-\u003ebytes;"},{"line_number":4844,"context_line":"\t\tstruct reg *reg \u003d register_get_by_name(target-\u003ereg_cache, reg_name,"},{"line_number":4845,"context_line":"\t\t\tfalse);"},{"line_number":4846,"context_line":""},{"line_number":4847,"context_line":"\t\tif (!reg || !reg-\u003eexist) {"},{"line_number":4848,"context_line":"\t\t\tJim_SetResultFormatted(interp, \"Unknown register \u0027%s\u0027\", reg_name);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_8e90ce47","line":4845,"range":{"start_line":4845,"start_character":3,"end_line":4845,"end_character":8},"in_reply_to":"aedf27f1_4ee66615","updated":"2021-06-07 22:08:19.000000000","message":"Check","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"1ee20df86aa94eb858c9829faa2b4d3fdcbacf6b","unresolved":false,"context_lines":[{"line_number":4844,"context_line":"\t\tstruct reg *reg \u003d register_get_by_name(target-\u003ereg_cache, reg_name,"},{"line_number":4845,"context_line":"\t\t\tfalse);"},{"line_number":4846,"context_line":""},{"line_number":4847,"context_line":"\t\tif (!reg || !reg-\u003eexist) {"},{"line_number":4848,"context_line":"\t\t\tJim_SetResultFormatted(interp, \"Unknown register \u0027%s\u0027\", reg_name);"},{"line_number":4849,"context_line":"\t\t\treturn JIM_ERR;"},{"line_number":4850,"context_line":"\t\t}"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_cef1f6c9","line":4847,"updated":"2021-06-07 09:30:06.000000000","message":"maybe it\u0027s better to control the arguments of the command before executing anything. I mean, first a loop on all the arguments to check if all the register names are valid, then a second loop to update them.","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"4749bc2a42a1822b24d75111a2a8c10f4c4844bc","unresolved":false,"context_lines":[{"line_number":4844,"context_line":"\t\tstruct reg *reg \u003d register_get_by_name(target-\u003ereg_cache, reg_name,"},{"line_number":4845,"context_line":"\t\t\tfalse);"},{"line_number":4846,"context_line":""},{"line_number":4847,"context_line":"\t\tif (!reg || !reg-\u003eexist) {"},{"line_number":4848,"context_line":"\t\t\tJim_SetResultFormatted(interp, \"Unknown register \u0027%s\u0027\", reg_name);"},{"line_number":4849,"context_line":"\t\t\treturn JIM_ERR;"},{"line_number":4850,"context_line":"\t\t}"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_ee9e3a59","line":4847,"in_reply_to":"aedf27f1_cef1f6c9","updated":"2021-06-07 22:08:19.000000000","message":"Actually I had the same idea but then I noticed that set_reg()  can still easily fail. For example, when you write an unaligned PC value to RISC-V targets. Hence, I\u0027m not sure if it\u0027s worth the extra loop. What do you think?","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"1ee20df86aa94eb858c9829faa2b4d3fdcbacf6b","unresolved":false,"context_lines":[{"line_number":4849,"context_line":"\t\t\treturn JIM_ERR;"},{"line_number":4850,"context_line":"\t\t}"},{"line_number":4851,"context_line":""},{"line_number":4852,"context_line":"\t\tuint8_t *buf \u003d malloc(DIV_ROUND_UP(reg-\u003esize, 8));"},{"line_number":4853,"context_line":""},{"line_number":4854,"context_line":"\t\tif (!buf)"},{"line_number":4855,"context_line":"\t\t\treturn ERROR_FAIL;"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_6ebecad3","line":4852,"updated":"2021-06-07 09:30:06.000000000","message":"with a first loop to check the reg names, you can detect the max reg-\u003esize and alloc/free only once outside the second loop","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"1ee20df86aa94eb858c9829faa2b4d3fdcbacf6b","unresolved":false,"context_lines":[{"line_number":4852,"context_line":"\t\tuint8_t *buf \u003d malloc(DIV_ROUND_UP(reg-\u003esize, 8));"},{"line_number":4853,"context_line":""},{"line_number":4854,"context_line":"\t\tif (!buf)"},{"line_number":4855,"context_line":"\t\t\treturn ERROR_FAIL;"},{"line_number":4856,"context_line":""},{"line_number":4857,"context_line":"\t\tstr_to_buf(reg_value, strlen(reg_value), buf, reg-\u003esize, 0);"},{"line_number":4858,"context_line":"\t\tint retval \u003d reg-\u003etype-\u003eset(reg, buf);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_8ec3ee60","line":4855,"updated":"2021-06-07 09:30:06.000000000","message":"NO! this is a jim command, you can only return JIM_OK or JIM_ERR.\nPlease also add\nLOG_ERROR(\"Out of memory\");","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"4749bc2a42a1822b24d75111a2a8c10f4c4844bc","unresolved":false,"context_lines":[{"line_number":4852,"context_line":"\t\tuint8_t *buf \u003d malloc(DIV_ROUND_UP(reg-\u003esize, 8));"},{"line_number":4853,"context_line":""},{"line_number":4854,"context_line":"\t\tif (!buf)"},{"line_number":4855,"context_line":"\t\t\treturn ERROR_FAIL;"},{"line_number":4856,"context_line":""},{"line_number":4857,"context_line":"\t\tstr_to_buf(reg_value, strlen(reg_value), buf, reg-\u003esize, 0);"},{"line_number":4858,"context_line":"\t\tint retval \u003d reg-\u003etype-\u003eset(reg, buf);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_2e952236","line":4855,"in_reply_to":"aedf27f1_8ec3ee60","updated":"2021-06-07 22:08:19.000000000","message":"Absolutely correct, silly me","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"1ee20df86aa94eb858c9829faa2b4d3fdcbacf6b","unresolved":false,"context_lines":[{"line_number":4858,"context_line":"\t\tint retval \u003d reg-\u003etype-\u003eset(reg, buf);"},{"line_number":4859,"context_line":"\t\tfree(buf);"},{"line_number":4860,"context_line":""},{"line_number":4861,"context_line":"\t\tif (retval !\u003d ERROR_OK)"},{"line_number":4862,"context_line":"\t\t\treturn retval;"},{"line_number":4863,"context_line":"\t}"},{"line_number":4864,"context_line":""},{"line_number":4865,"context_line":"\treturn JIM_OK;"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_2eb8c2e1","line":4862,"range":{"start_line":4861,"start_character":0,"end_line":4862,"end_character":17},"updated":"2021-06-07 09:30:06.000000000","message":"The check is correct, because -\u003eset() returns openocd errors, but the returned error value has to be JIM_ERR.\nCould be good to rename this function jim_something to remember it returns a JIM_XXX","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"4749bc2a42a1822b24d75111a2a8c10f4c4844bc","unresolved":false,"context_lines":[{"line_number":4858,"context_line":"\t\tint retval \u003d reg-\u003etype-\u003eset(reg, buf);"},{"line_number":4859,"context_line":"\t\tfree(buf);"},{"line_number":4860,"context_line":""},{"line_number":4861,"context_line":"\t\tif (retval !\u003d ERROR_OK)"},{"line_number":4862,"context_line":"\t\t\treturn retval;"},{"line_number":4863,"context_line":"\t}"},{"line_number":4864,"context_line":""},{"line_number":4865,"context_line":"\treturn JIM_OK;"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"aedf27f1_4e9ae667","line":4862,"range":{"start_line":4861,"start_character":0,"end_line":4862,"end_character":17},"in_reply_to":"aedf27f1_2eb8c2e1","updated":"2021-06-07 22:08:19.000000000","message":"Same","commit_id":"099d6a5d60de084ca2729739622bfbf1bb617ca3"},{"author":{"_account_id":1001667,"name":"Jan Matyas","email":"jan.matyas@codasip.com","username":"JanMatCodasip"},"change_message_id":"f52040cd11f055171c8ec989e45bc4b42e009098","unresolved":false,"context_lines":[{"line_number":5667,"context_line":"\t\t.usage \u003d \"arrayname bitwidth address count\","},{"line_number":5668,"context_line":"\t},"},{"line_number":5669,"context_line":"\t{"},{"line_number":5670,"context_line":"\t\t.name \u003d \"set_reg\","},{"line_number":5671,"context_line":"\t\t.mode \u003d COMMAND_EXEC,"},{"line_number":5672,"context_line":"\t\t.jim_handler \u003d jim_target_set_reg,"},{"line_number":5673,"context_line":"\t\t.help \u003d \"Set target register values\","}],"source_content_type":"text/x-csrc","patch_set":10,"id":"aedf27f1_11cf1f84","line":5670,"updated":"2021-06-18 05:56:18.000000000","message":"Just an idea - would you like to call this \"set_regs\" (plural) to differentiate it from the existing \"reg\" command and make it apparent that it is able to set more registers?","commit_id":"bc89ab7074e5085d69a5decb6b17ac1a665714c2"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"328d799e11161eb603a8fe3370b6ae3577d46f61","unresolved":true,"context_lines":[{"line_number":4849,"context_line":"\tconst unsigned int length \u003d tmp;"},{"line_number":4850,"context_line":""},{"line_number":4851,"context_line":"\tfor (unsigned int i \u003d 0; i \u003c length; i +\u003d 2) {"},{"line_number":4852,"context_line":"\t\tconst char *reg_name \u003d dict[i]-\u003ebytes;"},{"line_number":4853,"context_line":"\t\tconst char *reg_value \u003d dict[i + 1]-\u003ebytes;"},{"line_number":4854,"context_line":"\t\tstruct reg *reg \u003d register_get_by_name(target-\u003ereg_cache, reg_name,"},{"line_number":4855,"context_line":"\t\t\tfalse);"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"057c082a_d87ff5bd","line":4852,"updated":"2022-02-15 22:49:24.000000000","message":"Don\u0027t use internals of jimtcl; they could change anytime. Use the API, instead:\nconst char *reg_name \u003d Jim_String(dict[i]);\nconst char *reg_value \u003d Jim_String(dict[i + 1]);","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"d4a09fbd5e3bb4860268bd35d759acbf4dce87cc","unresolved":false,"context_lines":[{"line_number":4849,"context_line":"\tconst unsigned int length \u003d tmp;"},{"line_number":4850,"context_line":""},{"line_number":4851,"context_line":"\tfor (unsigned int i \u003d 0; i \u003c length; i +\u003d 2) {"},{"line_number":4852,"context_line":"\t\tconst char *reg_name \u003d dict[i]-\u003ebytes;"},{"line_number":4853,"context_line":"\t\tconst char *reg_value \u003d dict[i + 1]-\u003ebytes;"},{"line_number":4854,"context_line":"\t\tstruct reg *reg \u003d register_get_by_name(target-\u003ereg_cache, reg_name,"},{"line_number":4855,"context_line":"\t\t\tfalse);"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"0ffa2b42_31a981e7","line":4852,"in_reply_to":"057c082a_d87ff5bd","updated":"2022-02-19 17:45:03.000000000","message":"Done","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"328d799e11161eb603a8fe3370b6ae3577d46f61","unresolved":true,"context_lines":[{"line_number":5329,"context_line":"\tstruct target *target \u003d get_current_target(cmd_ctx);"},{"line_number":5330,"context_line":"\treturn target_jim_set_reg(interp, target, argc, argv);"},{"line_number":5331,"context_line":"}"},{"line_number":5332,"context_line":""},{"line_number":5333,"context_line":"static int jim_target_tap_disabled(Jim_Interp *interp)"},{"line_number":5334,"context_line":"{"},{"line_number":5335,"context_line":"\tJim_SetResultFormatted(interp, \"[TAP is disabled]\");"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"9ec99fe7_e61863d9","line":5332,"updated":"2022-02-15 22:49:24.000000000","message":"I don\u0027t see any difference between this function and jim_set_reg() above, apart from name of variables.\nI\u0027ve never realized that after my big reworking of these functions, now there is no more difference between the implementation of \"$target_name command\" and \"command\"!\nNot only jim_target_command() and jim_command() are now the same (so one can be dropped), but there is also no reason to have a common target_jim_command() called by the two. The whole can be written as a single function.\nDo you agree?\n\nActually I have already addressed this for handle_md_command()/handle_mw_command().\nThe other commands can be simplified in further patches.","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"2a0ec910733d039e6146d9b48fda94863133ccd8","unresolved":true,"context_lines":[{"line_number":5329,"context_line":"\tstruct target *target \u003d get_current_target(cmd_ctx);"},{"line_number":5330,"context_line":"\treturn target_jim_set_reg(interp, target, argc, argv);"},{"line_number":5331,"context_line":"}"},{"line_number":5332,"context_line":""},{"line_number":5333,"context_line":"static int jim_target_tap_disabled(Jim_Interp *interp)"},{"line_number":5334,"context_line":"{"},{"line_number":5335,"context_line":"\tJim_SetResultFormatted(interp, \"[TAP is disabled]\");"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"4cb7b04b_a7c72d1b","line":5332,"in_reply_to":"40834f98_86301d3b","updated":"2022-02-18 16:05:40.000000000","message":"No, no need to switch to COMMAND_HANDLER().\nThis patch adds two commands \"set_reg\": one standalone and another prefixed by \"$target_name\".\nThe jim_handler of these two commands are two separate functions, jim_set_reg() and jim_target_set_reg(), that implement the exact same code.\nMy suggestion is to drop one of the two functions and use the same jim_handler for both cases.\nThen, further simplification, the new common handler becomes the only caller of static target_jim_set_reg(), that can be merged with the common handler.\n\nSo, this patch will only add one function that will be used as handler by two new commands.","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"d4a09fbd5e3bb4860268bd35d759acbf4dce87cc","unresolved":false,"context_lines":[{"line_number":5329,"context_line":"\tstruct target *target \u003d get_current_target(cmd_ctx);"},{"line_number":5330,"context_line":"\treturn target_jim_set_reg(interp, target, argc, argv);"},{"line_number":5331,"context_line":"}"},{"line_number":5332,"context_line":""},{"line_number":5333,"context_line":"static int jim_target_tap_disabled(Jim_Interp *interp)"},{"line_number":5334,"context_line":"{"},{"line_number":5335,"context_line":"\tJim_SetResultFormatted(interp, \"[TAP is disabled]\");"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"af815d11_8da2121b","line":5332,"in_reply_to":"4cb7b04b_a7c72d1b","updated":"2022-02-19 17:45:03.000000000","message":"Yes, makes totally sense.","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"},{"author":{"_account_id":1000853,"name":"zapb","display_name":"Marc Schink","email":"dev@zapb.de","username":"zapb"},"change_message_id":"2c5927b254a54532b37180257506ccdcc1cc8b78","unresolved":true,"context_lines":[{"line_number":5329,"context_line":"\tstruct target *target \u003d get_current_target(cmd_ctx);"},{"line_number":5330,"context_line":"\treturn target_jim_set_reg(interp, target, argc, argv);"},{"line_number":5331,"context_line":"}"},{"line_number":5332,"context_line":""},{"line_number":5333,"context_line":"static int jim_target_tap_disabled(Jim_Interp *interp)"},{"line_number":5334,"context_line":"{"},{"line_number":5335,"context_line":"\tJim_SetResultFormatted(interp, \"[TAP is disabled]\");"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"40834f98_86301d3b","line":5332,"in_reply_to":"9ec99fe7_e61863d9","updated":"2022-02-18 14:45:47.000000000","message":"Not sure if I get you correctly. Do you suggest to change everything to a single COMMAND_HANDLER() function?","commit_id":"60152e037c64ddfac8a1b784f911b792fc50f08d"}]}
