)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1001803,"name":"Samuel Obuch","email":"samuel.obuch@espressif.com","username":"sobuch"},"change_message_id":"a2760cf487a03af84c8abef256a394ff4de7c0f5","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"9924459c_6b1b7f4a","updated":"2026-07-01 09:58:43.000000000","message":"Hi Richard, I implemented this in our fork to get rid of the bucket overrun (keeping in mind that overlapping histograms must have the same addresses, as you suggested in [1]). Seems to work fine on our side, could you please check?\n\nAfter this improvement the only limiting factor for longer profiling is MAX_PROFILE_SAMPLE_NUM (so even 5-10seconds is now possible for esp32/s2/s3 depending on the setup).\n\n[1] - https://review.openocd.org/c/openocd/+/8739/comments/4d06ad21_5b9498d2","commit_id":"417d8051641b5baad070a880a2a8ba98ee1375fb"},{"author":{"_account_id":1002278,"name":"bryghtlabs-richard","display_name":"Richard Allen","username":"bryghtlabs-richard","status":"Firmware at BryghtLabs. Also rsaxvc at home."},"change_message_id":"6491f672236168d3251e48fd5546cb47fc49d099","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"d7acc79a_e92d2ca8","updated":"2026-07-02 15:36:50.000000000","message":"Looks good to me, and I like the approach you used.","commit_id":"417d8051641b5baad070a880a2a8ba98ee1375fb"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"8c737927793f9278779e8f93c32144d8747033d7","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":1,"id":"13da4744_bc88c06a","updated":"2026-07-04 22:35:12.000000000","message":"There is an error of overflow while you put more samples in a hist.\nI have put my comments below.\nBut reading further the code \u0027after\u0027 I have put the comments, I think you don\u0027t need to parse twice the array `samples[]`, once to get `counts[]` and another to check for overflow. The code would be simpler if you do everything at once.\nKeep `handle_profile_command` as it was before the patch and in `write_gmon()` in the single loop you compute `min`, `max` and `count` to call the simplified `write_gmon_hist()`.","commit_id":"417d8051641b5baad070a880a2a8ba98ee1375fb"}],"src/target/target.c":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"8c737927793f9278779e8f93c32144d8747033d7","unresolved":true,"context_lines":[{"line_number":4302,"context_line":"\t\t\twhile (this_pass \u003c sample_num \u0026\u0026 samples[this_pass] - max \u003c MAX_GAP \u0026\u0026 counts[this_pass] \u003c\u003d bucket_max)"},{"line_number":4303,"context_line":"\t\t\t\tmax \u003d samples[this_pass++];"},{"line_number":4304,"context_line":""},{"line_number":4305,"context_line":"\t\t\twrite_gmon_hist(f, samples, counts, this_pass, sample_rate, target);"},{"line_number":4306,"context_line":"\t\t}"},{"line_number":4307,"context_line":"\t\tsamples +\u003d this_pass;"},{"line_number":4308,"context_line":"\t\tcounts +\u003d this_pass;"}],"source_content_type":"text/x-csrc","patch_set":1,"id":"d4651d60_e2d55ac1","line":4305,"updated":"2026-07-04 22:35:12.000000000","message":"I think here there is an issue.\nThis call of `write_gmon_hist()` sends `this_pass` samples, each with its count. Then in `write_gmon_hist()` the counts get accumulated with\n`val +\u003d counts[i++];`\nbut few lines above you only check if\n`counts[this_pass] \u003c\u003d bucket_max`\nnot if the cumulative value exceeds `bucket_max \u003d UINT16_MAX`.\n\nFor me you should simplify `write_gmon_hist()` to only receive `f`, `min`, `max` and `count`, while keeping here the computation of the intervals.\nAnd only `min`  and `max` should be `uint32_t` as linked to PC values, while the rest should be `unsigned int`.","commit_id":"417d8051641b5baad070a880a2a8ba98ee1375fb"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"8c737927793f9278779e8f93c32144d8747033d7","unresolved":true,"context_lines":[{"line_number":4436,"context_line":"\t\treturn ERROR_FAIL;"},{"line_number":4437,"context_line":"\t}"},{"line_number":4438,"context_line":"\tcounts[0] \u003d 1;"},{"line_number":4439,"context_line":"\tuint32_t num_unique_samples \u003d 1;"},{"line_number":4440,"context_line":"\tfor (uint32_t in \u003d 1; in \u003c num_of_samples; ++in) {"},{"line_number":4441,"context_line":"\t\tuint32_t sample \u003d samples[in];"},{"line_number":4442,"context_line":"\t\tif (sample !\u003d samples[num_unique_samples - 1]) {"}],"source_content_type":"text/x-csrc","patch_set":1,"id":"929a530f_a62b9a0c","line":4439,"updated":"2026-07-04 22:35:12.000000000","message":"I find hard to read the code in this loop.\nPlus, use stdint type only when you have to match the data size on target. Here `in` and `num_unique_samples` are host counter variables; `unsigned int` is way better.\nProposal (not tested):\n```\nunsigned int num_of_samples;\n...\n// count repeated samples\nunsigned int out \u003d 0;\nuint32_t sample \u003d samples[0];\nunsigned int count \u003d 1;\nfor (unsigned int in \u003d 1; in \u003c num_of_samples; ++in) {\n\tif (samples[in] \u003d\u003d sample) {\n\t\t++count;\n\t\tcontinue;\n\t}\n\tcounts[out++] \u003d count;\n\tsample \u003d samples[in];\n\tcount \u003d 1;\n}\n// store last one\ncounts[out++] \u003d count;\n```","commit_id":"417d8051641b5baad070a880a2a8ba98ee1375fb"}]}
