)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1001369,"name":"Masayuki.Ishikawa@jp.sony.com","email":"Masayuki.Ishikawa@jp.sony.com","username":"masayuki_ishikawa_sony"},"change_message_id":"57f02c99e1a991e4312b797da8c0e92f3a84d7c9","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"6021c9aa_5e11d8a3","updated":"2024-03-22 06:38:02.000000000","message":"Carlos,\n\nI think we should use rtos_cortex_m_stack_align(). You can refer to ./src/rtos/rtos_riot_stackings.c and ./src/rtos/zephyr.c, which use the function.","commit_id":"9bb405c92c053348068cdaf7022ac53f4ca07666"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"864a66c0974c4b95913c21708c9cb98db33b95f4","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":3,"id":"b80a5d67_777a5a11","in_reply_to":"4ae734e3_0f1781b1","updated":"2024-03-25 14:08:51.000000000","message":"Actually I just realised that the changes I have made work for Nuttx 12.1.0 but in even newer versions of Nuttx they have changed the frame again to add the control register to the stack frame pushing all the offsets down making all of the offsets incorrect again. I\u0027m not sure how to handle this since it should obviously work with the latest Nuttx, but I also want it to work with the version I\u0027m currently using. Perhaps we can read the offsets from the symbols, or provide a mechanism to provide the offsets to openocd on init.\n\nhttps://github.com/apache/nuttx/commit/4370487fd689d4a3ddbeada9cbabc9cde287de4f","commit_id":"9bb405c92c053348068cdaf7022ac53f4ca07666"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"2968027d8ad4597f63b99f34efbc7c9d472d954d","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"7cc43c7c_11116067","in_reply_to":"6021c9aa_5e11d8a3","updated":"2024-03-22 18:17:03.000000000","message":"You are right. Originally I was having trouble getting it working using rtos_cortex_m_stack_align which calculates the SP based on the value just prior to the stack frame instead of the explicitly stored SP in the Nuttx frame. This was because in the FPU version, it wasn\u0027t reading the whole Nuttx frame, only enough to get the registers it needed so the calculation gave the wrong result \"new_stack_ptr \u003d stack_ptr - stacking-\u003estack_growth_direction * stacking-\u003estack_registers_size;\" But fixing the \"stack_registers_size\" to read the whole frame fixed the issue.\n\nI also discovered that the register offsets for the non-FPU version was also incorrect. It was using a 10 word software frame but Nuttx is using 11 words.\n\nI have tested both the FPU and non-FPU versions.","commit_id":"9bb405c92c053348068cdaf7022ac53f4ca07666"},{"author":{"_account_id":1001369,"name":"Masayuki.Ishikawa@jp.sony.com","email":"Masayuki.Ishikawa@jp.sony.com","username":"masayuki_ishikawa_sony"},"change_message_id":"e3bc09ee0b12d56a69ae5a3aa38626bd464334a3","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"7ffacc5a_b8388954","in_reply_to":"7cc43c7c_11116067","updated":"2024-03-25 00:04:31.000000000","message":"Thanks for the update.\nIt seems good.\n\nHowever, could you add the following information to the commit messages?\n- NuttX version you tested. (e.g. nuttx-12.4.0)\n- NuttX configuration you tested. (e.g. spresense:nsh)","commit_id":"9bb405c92c053348068cdaf7022ac53f4ca07666"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"20ab7a0c7953fd91995b0ee8791fda015674ef4b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"4ae734e3_0f1781b1","in_reply_to":"7ffacc5a_b8388954","updated":"2024-03-25 13:53:07.000000000","message":"I have updated the commit message to include what I used to test.","commit_id":"9bb405c92c053348068cdaf7022ac53f4ca07666"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"3b36c7777de80bb4b19201361ae481bfadba6e9b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"a63c9e58_71bf7b60","in_reply_to":"83d30e39_114d83b9","updated":"2024-08-23 17:44:58.000000000","message":"Done","commit_id":"9bb405c92c053348068cdaf7022ac53f4ca07666"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"68ebff0d6bc4a146458adefe5875df8458d6b94d","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":3,"id":"83d30e39_114d83b9","in_reply_to":"b80a5d67_777a5a11","updated":"2024-03-25 14:21:42.000000000","message":"Looks like I can read them from g_reg_offs.\nI will update this to read from g_reg_offs instead of using hardcoded offsets","commit_id":"9bb405c92c053348068cdaf7022ac53f4ca07666"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"2968027d8ad4597f63b99f34efbc7c9d472d954d","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"c3e9fae6_a9ce5e92","updated":"2024-03-22 18:17:03.000000000","message":"Updated to use rtos_cortex_m_stack_align and fixed incorrect register offsets","commit_id":"779056b5a22d77906a31595c3b59a30304427736"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"6b892d8cd3bba7898966d9c37939f58e114942e7","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":7,"id":"ecaffe06_d27d295f","updated":"2024-03-27 12:51:41.000000000","message":"Changed Nuttx rtos to read from g_reg_offs. I only changed it for cortex-m. Other architectures could also use the same nuttx_tcbinfo_stack_read, but I dont have any non-cortex-m devices to test with.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6d99d758ef275e5a24c074eb58483e1b8bb24f78","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":7,"id":"1658971d_c76181f4","updated":"2024-06-16 21:52:40.000000000","message":"The commit message does not fully describe the changes in this patch.\nE.g., why do you need to introduce ``rtos_register_stacking::stack_pointer_number``?\n\nI have to admit that I have never worked on these stack issues in rtos awareness code. Maybe I\u0027m missing something, but without a direction from the commit message I cannot just guess.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6eb694ba3f0b37b82d363c6a13f2e0a1ea8ba5d2","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"0acff08c_2192005f","updated":"2024-09-01 09:54:41.000000000","message":"Just some comment on the endianness handling, otherwise I\u0027m fine with this patch","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"3b36c7777de80bb4b19201361ae481bfadba6e9b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"60fcda15_38c4edbe","updated":"2024-08-23 17:44:58.000000000","message":"Thank you for reviewing my MR. Sorry I took so long to get back. I decided to remove much of what I added with stack_pointer_number. II think the generic code was trying to do too much and accommodate too many cases resulting in unreadable code. I have now put it back much closer to my original patch set where it is just done in the stack read function, which in my opinion is the correct place if a specific variant needs to modify values when reading the stack frame. please see the other comments for some more detail.","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"b7ba54897a961ae63cacd483b169748f741a1990","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":9,"id":"568281fb_ea07c314","updated":"2024-09-07 16:10:48.000000000","message":"Thanks for the rework.\nIt look ok for me; I just have a minor remark below.","commit_id":"e44a3ea733df1c1793e81b2a69b12a09dff75c03"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":9,"id":"9050fe6e_671eeeab","updated":"2024-09-03 14:41:55.000000000","message":"Updated to use existing endian handling functions.","commit_id":"e44a3ea733df1c1793e81b2a69b12a09dff75c03"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"a982fe6abe24c955db707d898698ce0f93be2d00","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":10,"id":"e7d43049_e17567a2","updated":"2024-09-11 13:08:47.000000000","message":"Thanks","commit_id":"77f47918e5cee2cabea9edbf264f06df9271e604"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"ae568a3ac869dfa331f0cb9683872e6d41c0b53a","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":10,"id":"cf04319b_cec6ecc8","updated":"2024-09-09 12:19:52.000000000","message":"Thanks. Updated as requested.","commit_id":"77f47918e5cee2cabea9edbf264f06df9271e604"}],"src/rtos/nuttx.c":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6d99d758ef275e5a24c074eb58483e1b8bb24f78","unresolved":true,"context_lines":[{"line_number":88,"context_line":"\t\"STOPPED\","},{"line_number":89,"context_line":"};"},{"line_number":90,"context_line":""},{"line_number":91,"context_line":"static target_addr_t target_buffer_get_addr(struct target *target, const uint8_t *buffer)"},{"line_number":92,"context_line":"{"},{"line_number":93,"context_line":"#if PTR_WIDTH \u003d\u003d 8"},{"line_number":94,"context_line":"\treturn target_buffer_get_u64(target, buffer);"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"e50315f5_e1bf489d","line":91,"updated":"2024-06-16 21:52:40.000000000","message":"I think you don\u0027t need to move this function.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":88,"context_line":"\t\"STOPPED\","},{"line_number":89,"context_line":"};"},{"line_number":90,"context_line":""},{"line_number":91,"context_line":"static target_addr_t target_buffer_get_addr(struct target *target, const uint8_t *buffer)"},{"line_number":92,"context_line":"{"},{"line_number":93,"context_line":"#if PTR_WIDTH \u003d\u003d 8"},{"line_number":94,"context_line":"\treturn target_buffer_get_u64(target, buffer);"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"5ff72cad_4919db41","line":91,"in_reply_to":"60125115_227dcf30","updated":"2024-09-03 14:41:55.000000000","message":"Done","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"3b36c7777de80bb4b19201361ae481bfadba6e9b","unresolved":true,"context_lines":[{"line_number":88,"context_line":"\t\"STOPPED\","},{"line_number":89,"context_line":"};"},{"line_number":90,"context_line":""},{"line_number":91,"context_line":"static target_addr_t target_buffer_get_addr(struct target *target, const uint8_t *buffer)"},{"line_number":92,"context_line":"{"},{"line_number":93,"context_line":"#if PTR_WIDTH \u003d\u003d 8"},{"line_number":94,"context_line":"\treturn target_buffer_get_u64(target, buffer);"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"60125115_227dcf30","line":91,"in_reply_to":"e50315f5_e1bf489d","updated":"2024-08-23 17:44:58.000000000","message":"You are right. I have put it back. I think it got moved when I needed it earlier at some point but that is no longer true.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6d99d758ef275e5a24c074eb58483e1b8bb24f78","unresolved":true,"context_lines":[{"line_number":110,"context_line":" * https://sourceware.org/gdb/current/onlinedocs/gdb/ARM-Features.html"},{"line_number":111,"context_line":" * https://sourceware.org/gdb/current/onlinedocs/gdb/RISC_002dV-Features.html"},{"line_number":112,"context_line":" */"},{"line_number":113,"context_line":"int nuttx_tcbinfo_stack_read(struct target *target,"},{"line_number":114,"context_line":"\tint64_t stack_ptr, const struct rtos_register_stacking *stacking,"},{"line_number":115,"context_line":"\tuint8_t *stack_data)"},{"line_number":116,"context_line":"{"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"313a58cd_cba1a488","line":113,"updated":"2024-06-16 21:52:40.000000000","message":"I don\u0027t see any dependency that requires this function to be in this file.\nIt should be moved in ``src/rtos/rtos_nuttx_stackings.c``\nas it\u0027s only used there, and should be declared as static.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"3b36c7777de80bb4b19201361ae481bfadba6e9b","unresolved":true,"context_lines":[{"line_number":110,"context_line":" * https://sourceware.org/gdb/current/onlinedocs/gdb/ARM-Features.html"},{"line_number":111,"context_line":" * https://sourceware.org/gdb/current/onlinedocs/gdb/RISC_002dV-Features.html"},{"line_number":112,"context_line":" */"},{"line_number":113,"context_line":"int nuttx_tcbinfo_stack_read(struct target *target,"},{"line_number":114,"context_line":"\tint64_t stack_ptr, const struct rtos_register_stacking *stacking,"},{"line_number":115,"context_line":"\tuint8_t *stack_data)"},{"line_number":116,"context_line":"{"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"d3db25aa_f4829764","line":113,"in_reply_to":"313a58cd_cba1a488","updated":"2024-08-23 17:44:58.000000000","message":"The dependency is reading the symbol NX_SYM_REG_OFFSETS which is an enum in nuttx.c.\n\nTo move this function into rtos_nuttx_stackings.c which I agree is a better place, I would need to put enum nuttx_symbol_vals somewhere both files can see which I also didnt really see a good place to move the enum. I have now moved the enum to src/rtos/rtos_nuttx_stackings.h\n\nLet me know if you have a better idea for resolving the dependency and/or best placement","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":110,"context_line":" * https://sourceware.org/gdb/current/onlinedocs/gdb/ARM-Features.html"},{"line_number":111,"context_line":" * https://sourceware.org/gdb/current/onlinedocs/gdb/RISC_002dV-Features.html"},{"line_number":112,"context_line":" */"},{"line_number":113,"context_line":"int nuttx_tcbinfo_stack_read(struct target *target,"},{"line_number":114,"context_line":"\tint64_t stack_ptr, const struct rtos_register_stacking *stacking,"},{"line_number":115,"context_line":"\tuint8_t *stack_data)"},{"line_number":116,"context_line":"{"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"a1b46854_bd7c9d42","line":113,"in_reply_to":"d3db25aa_f4829764","updated":"2024-09-03 14:41:55.000000000","message":"Done","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"}],"src/rtos/rtos.c":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6d99d758ef275e5a24c074eb58483e1b8bb24f78","unresolved":true,"context_lines":[{"line_number":657,"context_line":"\t\t\t} else {"},{"line_number":658,"context_line":"\t\t\t\tbuf_cpy(stack_data + offset, (*reg_list)[i].value, (*reg_list)[i].size);"},{"line_number":659,"context_line":"\t\t\t}"},{"line_number":660,"context_line":"\t\t}"},{"line_number":661,"context_line":"\t}"},{"line_number":662,"context_line":""},{"line_number":663,"context_line":"\tfree(stack_data);"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"4d7fde0a_507808c0","line":660,"updated":"2024-06-16 21:52:40.000000000","message":"I don\u0027t understand why this change and why do you need to introduce ``rtos_register_stacking::stack_pointer_number``!\n\nIn nuttx every ``stack_register_offset`` has SP with ``stack_register_offset::offset`` not equal -2. So the original code already uses the line\n``buf_cpy(stack_data + offset,  ...);``\nfor the SP, without any need for this unreadable change nor the introduction of ``rtos_register_stacking::stack_pointer_number``!","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":657,"context_line":"\t\t\t} else {"},{"line_number":658,"context_line":"\t\t\t\tbuf_cpy(stack_data + offset, (*reg_list)[i].value, (*reg_list)[i].size);"},{"line_number":659,"context_line":"\t\t\t}"},{"line_number":660,"context_line":"\t\t}"},{"line_number":661,"context_line":"\t}"},{"line_number":662,"context_line":""},{"line_number":663,"context_line":"\tfree(stack_data);"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"9db611de_4fe225d9","line":660,"in_reply_to":"09ad8113_cfd67c65","updated":"2024-09-03 14:41:55.000000000","message":"Done","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"3b36c7777de80bb4b19201361ae481bfadba6e9b","unresolved":true,"context_lines":[{"line_number":657,"context_line":"\t\t\t} else {"},{"line_number":658,"context_line":"\t\t\t\tbuf_cpy(stack_data + offset, (*reg_list)[i].value, (*reg_list)[i].size);"},{"line_number":659,"context_line":"\t\t\t}"},{"line_number":660,"context_line":"\t\t}"},{"line_number":661,"context_line":"\t}"},{"line_number":662,"context_line":""},{"line_number":663,"context_line":"\tfree(stack_data);"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"09ad8113_cfd67c65","line":660,"in_reply_to":"4d7fde0a_507808c0","updated":"2024-08-23 17:44:58.000000000","message":"I agree that this is complicated. It is trying to accommodate every case and has made this function complicated.\n\nPrevious to any of my changes there was the special case \"offset \u003d\u003d -2\" which said to replace the value of this register with the calculated SP (which may have been adjusted). It calculates using the stack frame location which works for some OS but not Nuttx. Nuttx needs to read a value from the stack frame (thus not -2) but also needs to be adjusted (in the current code only done on -2). So I introduced a new variable to tell which register to apply the stack correction to. But this has made everything more complicated. I have instead put hte code back much closer to what I had in patch set 1 where this adjustment is made when reading the stack so the values given to later functions are good values.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"}],"src/rtos/rtos_nuttx_stackings.c":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6eb694ba3f0b37b82d363c6a13f2e0a1ea8ba5d2","unresolved":true,"context_lines":[{"line_number":84,"context_line":"\t// hardware will add/remove automatically on both enter/exit."},{"line_number":85,"context_line":"\t// We need to adjust the SP to get the real SP of the stack."},{"line_number":86,"context_line":"\t// See Arm Reference manual \"Stack alignment on exception entry\""},{"line_number":87,"context_line":"\t// uint32_t xpsr \u003d le_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":88,"context_line":"\tuint32_t xpsr \u003d (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) ?"},{"line_number":89,"context_line":"\t\tle_to_h_u32(\u0026stack_data[XPSR_OFFSET]) :"},{"line_number":90,"context_line":"\t\tbe_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"89e29d7f_3474646b","line":87,"updated":"2024-09-01 09:54:41.000000000","message":"This line can be removed, as it is replaced by the endianness aware code below.\nCan you also convert the comment above to a multi-line comment within `/* */`?","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":84,"context_line":"\t// hardware will add/remove automatically on both enter/exit."},{"line_number":85,"context_line":"\t// We need to adjust the SP to get the real SP of the stack."},{"line_number":86,"context_line":"\t// See Arm Reference manual \"Stack alignment on exception entry\""},{"line_number":87,"context_line":"\t// uint32_t xpsr \u003d le_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":88,"context_line":"\tuint32_t xpsr \u003d (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) ?"},{"line_number":89,"context_line":"\t\tle_to_h_u32(\u0026stack_data[XPSR_OFFSET]) :"},{"line_number":90,"context_line":"\t\tbe_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"ba47db11_af53fa66","line":87,"in_reply_to":"89e29d7f_3474646b","updated":"2024-09-03 14:41:55.000000000","message":"Done","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6eb694ba3f0b37b82d363c6a13f2e0a1ea8ba5d2","unresolved":true,"context_lines":[{"line_number":85,"context_line":"\t// We need to adjust the SP to get the real SP of the stack."},{"line_number":86,"context_line":"\t// See Arm Reference manual \"Stack alignment on exception entry\""},{"line_number":87,"context_line":"\t// uint32_t xpsr \u003d le_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":88,"context_line":"\tuint32_t xpsr \u003d (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) ?"},{"line_number":89,"context_line":"\t\tle_to_h_u32(\u0026stack_data[XPSR_OFFSET]) :"},{"line_number":90,"context_line":"\t\tbe_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":91,"context_line":"\tif (xpsr \u0026 (1 \u003c\u003c 9)) {"},{"line_number":92,"context_line":"\t\tif (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) {"},{"line_number":93,"context_line":"\t\t\tuint32_t sp \u003d le_to_h_u32(\u0026stack_data[SP_OFFSET]);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"4e05f08c_17882441","line":90,"range":{"start_line":88,"start_character":1,"end_line":90,"end_character":40},"updated":"2024-09-01 09:54:41.000000000","message":"`uint32_t xpsr \u003d target_buffer_get_u32(target, \u0026stack_data[XPSR_OFFSET]);`","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":85,"context_line":"\t// We need to adjust the SP to get the real SP of the stack."},{"line_number":86,"context_line":"\t// See Arm Reference manual \"Stack alignment on exception entry\""},{"line_number":87,"context_line":"\t// uint32_t xpsr \u003d le_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":88,"context_line":"\tuint32_t xpsr \u003d (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) ?"},{"line_number":89,"context_line":"\t\tle_to_h_u32(\u0026stack_data[XPSR_OFFSET]) :"},{"line_number":90,"context_line":"\t\tbe_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":91,"context_line":"\tif (xpsr \u0026 (1 \u003c\u003c 9)) {"},{"line_number":92,"context_line":"\t\tif (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) {"},{"line_number":93,"context_line":"\t\t\tuint32_t sp \u003d le_to_h_u32(\u0026stack_data[SP_OFFSET]);"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"0b431f03_e793851a","line":90,"range":{"start_line":88,"start_character":1,"end_line":90,"end_character":40},"in_reply_to":"4e05f08c_17882441","updated":"2024-09-03 14:41:55.000000000","message":"thanks. I didn\u0027t see these functions. Much nicer to use these functions to handle endian","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6eb694ba3f0b37b82d363c6a13f2e0a1ea8ba5d2","unresolved":true,"context_lines":[{"line_number":89,"context_line":"\t\tle_to_h_u32(\u0026stack_data[XPSR_OFFSET]) :"},{"line_number":90,"context_line":"\t\tbe_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":91,"context_line":"\tif (xpsr \u0026 (1 \u003c\u003c 9)) {"},{"line_number":92,"context_line":"\t\tif (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) {"},{"line_number":93,"context_line":"\t\t\tuint32_t sp \u003d le_to_h_u32(\u0026stack_data[SP_OFFSET]);"},{"line_number":94,"context_line":"\t\t\th_u32_to_le(\u0026stack_data[SP_OFFSET], sp - 4 * stacking-\u003estack_growth_direction);"},{"line_number":95,"context_line":"\t\t} else {"},{"line_number":96,"context_line":"\t\t\tuint32_t sp \u003d be_to_h_u32(\u0026stack_data[SP_OFFSET]);"},{"line_number":97,"context_line":"\t\t\th_u32_to_be(\u0026stack_data[SP_OFFSET], sp - 4 * stacking-\u003estack_growth_direction);"},{"line_number":98,"context_line":"\t\t}"},{"line_number":99,"context_line":"\t}"},{"line_number":100,"context_line":""},{"line_number":101,"context_line":"\treturn ERROR_OK;"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"ac90bdb1_7fa37228","line":98,"range":{"start_line":92,"start_character":2,"end_line":98,"end_character":3},"updated":"2024-09-01 09:54:41.000000000","message":"```\nuint32_t sp \u003d target_buffer_get_u32(target, \u0026stack_data[SP_OFFSET]);\ntarget_buffer_set_u32(target, \u0026stack_data[SP_OFFSET],\n                      sp - 4 * stacking-\u003estack_growth_direction);\n```","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":89,"context_line":"\t\tle_to_h_u32(\u0026stack_data[XPSR_OFFSET]) :"},{"line_number":90,"context_line":"\t\tbe_to_h_u32(\u0026stack_data[XPSR_OFFSET]);"},{"line_number":91,"context_line":"\tif (xpsr \u0026 (1 \u003c\u003c 9)) {"},{"line_number":92,"context_line":"\t\tif (target-\u003eendianness \u003d\u003d TARGET_LITTLE_ENDIAN) {"},{"line_number":93,"context_line":"\t\t\tuint32_t sp \u003d le_to_h_u32(\u0026stack_data[SP_OFFSET]);"},{"line_number":94,"context_line":"\t\t\th_u32_to_le(\u0026stack_data[SP_OFFSET], sp - 4 * stacking-\u003estack_growth_direction);"},{"line_number":95,"context_line":"\t\t} else {"},{"line_number":96,"context_line":"\t\t\tuint32_t sp \u003d be_to_h_u32(\u0026stack_data[SP_OFFSET]);"},{"line_number":97,"context_line":"\t\t\th_u32_to_be(\u0026stack_data[SP_OFFSET], sp - 4 * stacking-\u003estack_growth_direction);"},{"line_number":98,"context_line":"\t\t}"},{"line_number":99,"context_line":"\t}"},{"line_number":100,"context_line":""},{"line_number":101,"context_line":"\treturn ERROR_OK;"}],"source_content_type":"text/x-csrc","patch_set":8,"id":"95ffb4cf_073242a1","line":98,"range":{"start_line":92,"start_character":2,"end_line":98,"end_character":3},"in_reply_to":"ac90bdb1_7fa37228","updated":"2024-09-03 14:41:55.000000000","message":"Done","commit_id":"a82d3790618c835e6944cdd0a7b990b756b46b3e"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"b7ba54897a961ae63cacd483b169748f741a1990","unresolved":true,"context_lines":[{"line_number":86,"context_line":"\t * See Arm Reference manual \"Stack alignment on exception entry\""},{"line_number":87,"context_line":"\t */"},{"line_number":88,"context_line":"\tuint32_t xpsr \u003d target_buffer_get_u32(target, \u0026stack_data[XPSR_OFFSET]);"},{"line_number":89,"context_line":"\tif (xpsr \u0026 (1 \u003c\u003c 9)) {"},{"line_number":90,"context_line":"\t\tuint32_t sp \u003d target_buffer_get_u32(target, \u0026stack_data[SP_OFFSET]);"},{"line_number":91,"context_line":"\t\ttarget_buffer_set_u32(target, \u0026stack_data[SP_OFFSET], sp - 4 * stacking-\u003estack_growth_direction);"},{"line_number":92,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":9,"id":"d1d73967_07e39fe3","line":89,"updated":"2024-09-07 16:10:48.000000000","message":"`if (xpsr \u0026 BIT(9)) {`","commit_id":"e44a3ea733df1c1793e81b2a69b12a09dff75c03"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"ae568a3ac869dfa331f0cb9683872e6d41c0b53a","unresolved":false,"context_lines":[{"line_number":86,"context_line":"\t * See Arm Reference manual \"Stack alignment on exception entry\""},{"line_number":87,"context_line":"\t */"},{"line_number":88,"context_line":"\tuint32_t xpsr \u003d target_buffer_get_u32(target, \u0026stack_data[XPSR_OFFSET]);"},{"line_number":89,"context_line":"\tif (xpsr \u0026 (1 \u003c\u003c 9)) {"},{"line_number":90,"context_line":"\t\tuint32_t sp \u003d target_buffer_get_u32(target, \u0026stack_data[SP_OFFSET]);"},{"line_number":91,"context_line":"\t\ttarget_buffer_set_u32(target, \u0026stack_data[SP_OFFSET], sp - 4 * stacking-\u003estack_growth_direction);"},{"line_number":92,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":9,"id":"2f218723_624f2bc7","line":89,"in_reply_to":"d1d73967_07e39fe3","updated":"2024-09-09 12:19:52.000000000","message":"changed to use BIT macro","commit_id":"e44a3ea733df1c1793e81b2a69b12a09dff75c03"}],"src/rtos/rtos_standard_stackings.c":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6d99d758ef275e5a24c074eb58483e1b8bb24f78","unresolved":true,"context_lines":[{"line_number":152,"context_line":" */"},{"line_number":153,"context_line":"target_addr_t rtos_cortex_m_stack_align(struct target *target,"},{"line_number":154,"context_line":"\tconst uint8_t *stack_data, const struct rtos_register_stacking *stacking,"},{"line_number":155,"context_line":"\ttarget_addr_t stack_ptr, size_t xpsr_offset, ssize_t sp_offset)"},{"line_number":156,"context_line":"{"},{"line_number":157,"context_line":"\tconst uint32_t ALIGN_NEEDED \u003d (1 \u003c\u003c 9);"},{"line_number":158,"context_line":"\tuint32_t xpsr;"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"f6a2a8c6_f8640b3d","line":155,"updated":"2024-06-16 21:52:40.000000000","message":"all RTOS pass ``sp_offset\u003d-2``, only exception is nuttx.\nI prefer you don\u0027t modify this function but you re-implement it inside ``nuttx_cortex_m_stack_align()`` by copying from here.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":152,"context_line":" */"},{"line_number":153,"context_line":"target_addr_t rtos_cortex_m_stack_align(struct target *target,"},{"line_number":154,"context_line":"\tconst uint8_t *stack_data, const struct rtos_register_stacking *stacking,"},{"line_number":155,"context_line":"\ttarget_addr_t stack_ptr, size_t xpsr_offset, ssize_t sp_offset)"},{"line_number":156,"context_line":"{"},{"line_number":157,"context_line":"\tconst uint32_t ALIGN_NEEDED \u003d (1 \u003c\u003c 9);"},{"line_number":158,"context_line":"\tuint32_t xpsr;"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"094f5609_6f14b358","line":155,"in_reply_to":"ee81e13c_323f0779","updated":"2024-09-03 14:41:55.000000000","message":"Done","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"3b36c7777de80bb4b19201361ae481bfadba6e9b","unresolved":true,"context_lines":[{"line_number":152,"context_line":" */"},{"line_number":153,"context_line":"target_addr_t rtos_cortex_m_stack_align(struct target *target,"},{"line_number":154,"context_line":"\tconst uint8_t *stack_data, const struct rtos_register_stacking *stacking,"},{"line_number":155,"context_line":"\ttarget_addr_t stack_ptr, size_t xpsr_offset, ssize_t sp_offset)"},{"line_number":156,"context_line":"{"},{"line_number":157,"context_line":"\tconst uint32_t ALIGN_NEEDED \u003d (1 \u003c\u003c 9);"},{"line_number":158,"context_line":"\tuint32_t xpsr;"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"ee81e13c_323f0779","line":155,"in_reply_to":"f6a2a8c6_f8640b3d","updated":"2024-08-23 17:44:58.000000000","message":"ok. I was going off a comment in the first patch set saying to use this function, but I can make it separate.","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"6d99d758ef275e5a24c074eb58483e1b8bb24f78","unresolved":true,"context_lines":[{"line_number":173,"context_line":"\tif ((xpsr \u0026 ALIGN_NEEDED) !\u003d 0) {"},{"line_number":174,"context_line":"\t\tLOG_DEBUG(\"XPSR(0x%08\" PRIx32 \") indicated stack alignment was necessary\\r\\n\","},{"line_number":175,"context_line":"\t\t\txpsr);"},{"line_number":176,"context_line":"\t\tnew_stack_ptr -\u003d (stacking-\u003estack_growth_direction * 4);"},{"line_number":177,"context_line":"\t}"},{"line_number":178,"context_line":"\treturn new_stack_ptr;"},{"line_number":179,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"0135750d_957b4a71","line":176,"updated":"2024-06-16 21:52:40.000000000","message":"I\u0027m not sure, but I\u0027m quite surprised!\nOn nuttx the ``new_stack_ptr`` is taken from ``stack_data[sp_offset]``.\nIf here we need to re-align it, it means the value in the stack was crap!\nOr in nuttx case is always ``(xpsr \u0026 ALIGN_NEEDED) \u003d\u003d 0`` ? In such case this part doesn\u0027t need to be copied in ``nuttx_cortex_m_stack_align()``!","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"3b36c7777de80bb4b19201361ae481bfadba6e9b","unresolved":true,"context_lines":[{"line_number":173,"context_line":"\tif ((xpsr \u0026 ALIGN_NEEDED) !\u003d 0) {"},{"line_number":174,"context_line":"\t\tLOG_DEBUG(\"XPSR(0x%08\" PRIx32 \") indicated stack alignment was necessary\\r\\n\","},{"line_number":175,"context_line":"\t\t\txpsr);"},{"line_number":176,"context_line":"\t\tnew_stack_ptr -\u003d (stacking-\u003estack_growth_direction * 4);"},{"line_number":177,"context_line":"\t}"},{"line_number":178,"context_line":"\treturn new_stack_ptr;"},{"line_number":179,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"9e57ccae_d3c506f5","line":176,"in_reply_to":"0135750d_957b4a71","updated":"2024-08-23 17:44:58.000000000","message":"Its not that the value on the stack was crap, but in cortex_m, this adjustment happen by hardware. Nuttx stores SP of the previous context from subtracting the size of a hardware placed frame from the current position during the ISR. This frame may/may not have been shifted (by hardware) depending on xPSR[9]. \n\nHere is a reference to ARM docs about this shift.\nhttps://developer.arm.com/documentation/ddi0403/d/System-Level-Architecture/System-Level-Programmers--Model/ARMv7-M-exception-model/Stack-alignment-on-exception-entry\n\n\nNuttx purposely ignores this and stores a potentially wrong SP (an SP that might be 4 bytes off), because the same hardware element that did the first shift on entry will do the reversal on exit. Nuttx chose to simplify its ISR by not ignoring it and letting the hardware do both operation. When reading the SP in openocd, it needs the correct SP, so it may/may not need to do an alignment.\n\nHere is a link to where nuttx ignores the xPRS[9] and stores SP.\nhttps://github.com/apache/nuttx/blob/master/arch/arm/src/armv7-m/arm_exception.S#L153","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"},{"author":{"_account_id":1002247,"name":"Daniel Lizewski","display_name":"Daniel Lizewski","email":"daniellizewski@geotab.com","username":"dlizewski"},"change_message_id":"1467bf2adaab1c558adab6dea2a3b7a27a6e4b7f","unresolved":false,"context_lines":[{"line_number":173,"context_line":"\tif ((xpsr \u0026 ALIGN_NEEDED) !\u003d 0) {"},{"line_number":174,"context_line":"\t\tLOG_DEBUG(\"XPSR(0x%08\" PRIx32 \") indicated stack alignment was necessary\\r\\n\","},{"line_number":175,"context_line":"\t\t\txpsr);"},{"line_number":176,"context_line":"\t\tnew_stack_ptr -\u003d (stacking-\u003estack_growth_direction * 4);"},{"line_number":177,"context_line":"\t}"},{"line_number":178,"context_line":"\treturn new_stack_ptr;"},{"line_number":179,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":7,"id":"b0de0b76_4965e976","line":176,"in_reply_to":"9e57ccae_d3c506f5","updated":"2024-09-03 14:41:55.000000000","message":"Done","commit_id":"b8e40c924bdf49e93500d927cc6bde687df52b52"}]}
