aboutsummaryrefslogtreecommitdiff
path: root/libraries/libprof/profil.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-05-10 00:00:04 -0400
committerPaul Selkirk <paul@psgd.org>2017-09-07 18:11:01 -0400
commit03d7fa26a89d44349df86e29ac782d075856c570 (patch)
treed2b70efd350b17e67896118e60aca392560fdec4 /libraries/libprof/profil.c
parentb2858c0eabeb2aba36ad7b5a964d52e51711c8df (diff)
Sigh, right offset for the wrong register. Get the PC (the address we
interrupted) rather than LR (the return address from the function we interrupted). Also, change u_short and u_int to unsigned short and unsigned int, since gcc recently decided that those aren't part of the C99 standard. Finally, add profilable versions of memcpy, memset, and friends, because they get called a lot in the course of unit testing, and it would be nice to know who's calling them.
Diffstat (limited to 'libraries/libprof/profil.c')
-rw-r--r--libraries/libprof/profil.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libraries/libprof/profil.c b/libraries/libprof/profil.c
index 004af77..0654879 100644
--- a/libraries/libprof/profil.c
+++ b/libraries/libprof/profil.c
@@ -17,7 +17,6 @@
#include <math.h>
#include "profil.h"
#include <string.h>
-#include <stdint.h>
#include "stm32f4xx_hal.h" /* __get_MSP */
@@ -30,7 +29,7 @@ extern void set_SysTick_hook(void (*hook)(void));
/* sample the current program counter */
static void SysTick_hook(void) {
- size_t pc = (size_t)((uint32_t *)__get_MSP())[7];
+ size_t pc = (size_t)((uint32_t *)__get_MSP())[8];
if (pc >= prof.lowpc && pc < prof.highpc) {
size_t idx = PROFIDX (pc, prof.lowpc, prof.scale);
prof.counter[idx]++;
@@ -55,7 +54,7 @@ static int profile_on (struct profinfo *p) {
* start or stop profiling
*
* profiling goes into the SAMPLES buffer of size SIZE (which is treated
- * as an array of u_shorts of size size/2)
+ * as an array of unsigned shorts of size size/2)
*
* each bin represents a range of pc addresses from OFFSET. The number
* of pc addresses in a bin depends on SCALE. (A scale of 65536 maps
@@ -63,7 +62,7 @@ static int profile_on (struct profinfo *p) {
* a scale of 1 maps each bin to 128k address). Scale may be 1 - 65536,
* or zero to turn off profiling
*/
-int profile_ctl (struct profinfo *p, char *samples, size_t size, size_t offset, u_int scale) {
+int profile_ctl (struct profinfo *p, char *samples, size_t size, size_t offset, unsigned int scale) {
size_t maxbin;
if (scale > 65536) {
@@ -75,7 +74,7 @@ int profile_ctl (struct profinfo *p, char *samples, size_t size, size_t offset,
memset(samples, 0, size);
memset(p, 0, sizeof *p);
maxbin = size >> 1;
- prof.counter = (u_short*)samples;
+ prof.counter = (unsigned short*)samples;
prof.lowpc = offset;
prof.highpc = PROFADDR(maxbin, offset, scale);
prof.scale = scale;
@@ -88,7 +87,7 @@ int profile_ctl (struct profinfo *p, char *samples, size_t size, size_t offset,
Every SLEEPTIME interval, the user's program counter (PC) is examined:
offset is subtracted and the result is multiplied by scale.
The word pointed to by this address is incremented. */
-int profil (char *samples, size_t size, size_t offset, u_int scale) {
+int profil (char *samples, size_t size, size_t offset, unsigned int scale) {
return profile_ctl (&prof, samples, size, offset, scale);
}