aboutsummaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authorHsiangkai Wang <hsiangkai@gmail.com>2013-08-30 13:18:54 +0800
committerSpencer Oliver <spen@spen-soft.co.uk>2013-09-13 19:36:33 +0000
commita4bacdcb84f0d0cbd19a8db3833f65445c47904c (patch)
tree37895410745ec80f1ed8a5a36d635ce5101dbe62 /src/target
parentcd0ef0cd3f738a8e1b81cfc06b8ec46345f970f0 (diff)
downloadriscv-openocd-a4bacdcb84f0d0cbd19a8db3833f65445c47904c.zip
riscv-openocd-a4bacdcb84f0d0cbd19a8db3833f65445c47904c.tar.gz
riscv-openocd-a4bacdcb84f0d0cbd19a8db3833f65445c47904c.tar.bz2
target: Make profiling function more readable
Change variable name 'length' to 'numBuckets'. It is more readable. Change-Id: I913cba0746f887adf6da401a46cd5e9ea88d2c6d Signed-off-by: Hsiangkai Wang <hsiangkai@gmail.com> Reviewed-on: http://openocd.zylin.com/1606 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/target')
-rw-r--r--src/target/target.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/target/target.c b/src/target/target.c
index d34e144..11b12e5 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -3391,19 +3391,19 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
assert(addressSpace >= 2);
static const uint32_t maxBuckets = 16 * 1024; /* maximum buckets. */
- uint32_t length = addressSpace;
- if (length > maxBuckets)
- length = maxBuckets;
- int *buckets = malloc(sizeof(int)*length);
+ uint32_t numBuckets = addressSpace;
+ if (numBuckets > maxBuckets)
+ numBuckets = maxBuckets;
+ int *buckets = malloc(sizeof(int) * numBuckets);
if (buckets == NULL) {
fclose(f);
return;
}
- memset(buckets, 0, sizeof(int) * length);
+ memset(buckets, 0, sizeof(int) * numBuckets);
for (i = 0; i < sampleNum; i++) {
uint32_t address = samples[i];
long long a = address - min;
- long long b = length - 1;
+ long long b = numBuckets - 1;
long long c = addressSpace - 1;
int index_t = (a * b) / c; /* danger!!!! int32 overflows */
buckets[index_t]++;
@@ -3412,7 +3412,7 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
/* append binary memory gmon.out &profile_hist_hdr ((char*)&profile_hist_hdr + sizeof(struct gmon_hist_hdr)) */
writeLong(f, min); /* low_pc */
writeLong(f, max); /* high_pc */
- writeLong(f, length); /* # of samples */
+ writeLong(f, numBuckets); /* # of buckets */
writeLong(f, 100); /* KLUDGE! We lie, ca. 100Hz best case. */
writeString(f, "seconds");
for (i = 0; i < (15-strlen("seconds")); i++)
@@ -3421,9 +3421,9 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
/*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */
- char *data = malloc(2 * length);
+ char *data = malloc(2 * numBuckets);
if (data != NULL) {
- for (i = 0; i < length; i++) {
+ for (i = 0; i < numBuckets; i++) {
int val;
val = buckets[i];
if (val > 65535)
@@ -3432,7 +3432,7 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
data[i * 2 + 1] = (val >> 8) & 0xff;
}
free(buckets);
- writeData(f, data, length * 2);
+ writeData(f, data, numBuckets * 2);
free(data);
} else
free(buckets);