This is an automated email from Gerrit.

"Samuel Obuch <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9667

-- gerrit

commit 985b40a2d6a3b5d2e9f06ba5fac57967db26f4c8
Author: Samuel Obuch <[email protected]>
Date:   Wed May 20 03:04:33 2026 +0200

    target: fix off-by-one error in profiling bucket range
    
    Recent patch optimizing target profiling [1] seems to have introduced
    an issue with a mix of 2-byte and 3-byte instructions on xtensa targets.
    If a histogram range starts at an odd address, and last instruction
    has an even address (bucket_max - 1), samples at this instruction
    would not be counted.
    
    [1] - https://review.openocd.org/c/openocd/+/8739
    
    Change-Id: I08bbebdf8dcd1d9ae32ca719ea52e5022be0eb47
    Signed-off-by: Samuel Obuch <[email protected]>

diff --git a/src/target/target.c b/src/target/target.c
index 4d87412381..9c2849ed27 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4190,8 +4190,8 @@ static void write_gmon_hist(FILE *f, const uint32_t 
*samples, uint32_t sample_nu
        bool saturated_once = false;
        for (uint32_t i = 0, bidx = 0; bidx < address_space; bidx += 
sizeof(UNIT)) {
                uint32_t val = i;
-               uint32_t bmax = min + bidx;
-               while (i < sample_num && samples[i] <= bmax)
+               uint32_t bmax = min + bidx + sizeof(UNIT);
+               while (i < sample_num && samples[i] < bmax)
                        ++i;
                val = i - val;
 

-- 

Reply via email to