/*
- cc -I. -DKERNEL_PRIVATE -O -o latency latency.c -lncurses
+ cc -I. -DPRIVATE -D__APPLE_PRIVATE -O -o latency latency.c -lncurses
*/
#include <mach/mach.h>
char name[32];
} codes_tab[MAX_ENTRIES];
-/* If NUMPARMS changes from the kernel, then PATHLENGTH will also reflect the change */
+
#define NUMPARMS 23
-#define PATHLENGTH (NUMPARMS*sizeof(long))
struct th_info {
int thread;
int arg1;
double stime;
long *pathptr;
- char pathname[PATHLENGTH + 1];
+ long pathname[NUMPARMS + 1];
};
#define MAX_THREADS 512
int loop_cnt, sample_sc_now;
int decrementer_usec = 0;
kern_return_t ret;
- int size;
+ unsigned int size;
host_name_port_t host;
void getdivisor();
void sample_sc();
for (i = 0; i < cur_max; i++) {
th_state[i].thread = 0;
th_state[i].type = -1;
- th_state[i].pathptr = (long *)0;
+ th_state[i].pathptr = (long *)NULL;
th_state[i].pathname[0] = 0;
}
cur_max = 0;
}
while ( (kd < end_of_sample) && ((kd->debugid & DBG_FUNC_MASK) == VFS_LOOKUP))
{
- if (!ti->pathptr) {
+ if (ti->pathptr == NULL) {
ti->arg1 = kd->arg1;
- memset(&ti->pathname[0], 0, (PATHLENGTH + 1));
- sargptr = (long *)&ti->pathname[0];
+ sargptr = ti->pathname;
*sargptr++ = kd->arg2;
*sargptr++ = kd->arg3;
*sargptr++ = kd->arg4;
+ /*
+ * NULL terminate the 'string'
+ */
+ *sargptr = 0;
ti->pathptr = sargptr;
} else {
handle.
*/
- if ((long *)sargptr >= (long *)&ti->pathname[PATHLENGTH])
+ if (sargptr >= &ti->pathname[NUMPARMS])
{
kd++;
continue;
if (kd->debugid & DBG_FUNC_START)
{
- (long *)ti->pathptr = (long *)&ti->pathname[PATHLENGTH];
+ ti->pathptr = &ti->pathname[NUMPARMS];
}
else
{
*sargptr++ = kd->arg2;
*sargptr++ = kd->arg3;
*sargptr++ = kd->arg4;
+ /*
+ * NULL terminate the 'string'
+ */
+ *sargptr = 0;
+
ti->pathptr = sargptr;
}
}
kd++;
}
+ p = (char *)ti->pathname;
kd--;
- /* print the tail end of the pathname */
- len = strlen(ti->pathname);
+ /* print the tail end of the pathname */
+ len = strlen(p);
if (len > 42)
len -= 42;
else
if (log_fp) {
fprintf(log_fp, "%9.1f %8.1f\t\t%-14.14s %-42s %-8x %-8x %d %s\n",
timestamp - start_bias, delta, "VFS_LOOKUP",
- &ti->pathname[len], ti->arg1, thread, cpunum, command);
+ &p[len], ti->arg1, thread, cpunum, command);
}
last_timestamp = timestamp;
else
ti->type = -1;
ti->stime = timestamp;
- ti->pathptr = (long *)0;
+ ti->pathptr = (long *)NULL;
#if 0
if (print_info && fp)
ti->thread = thread;
ti->child_thread = 0;
- ti->pathptr = (long *)0;
+ ti->pathptr = (long *)NULL;
}
}
ti->type = -1;
ti->thread = thread;
ti->type = -1;
- ti->pathptr = (long *)0;
+ ti->pathptr = (long *)NULL;
}
ti->child_thread = kd->arg1;
return (1);
ti->thread = thread;
ti->type = -1;
- ti->pathptr = (long *)0;
+ ti->pathptr = (long *)NULL;
ti->child_thread = 0;
}
while ( (kd <= kd_stop) && (kd->debugid & DBG_FUNC_MASK) == VFS_LOOKUP)
{
- if (!ti->pathptr) {
+ if (ti->pathptr == NULL) {
ti->arg1 = kd->arg1;
- memset(&ti->pathname[0], 0, (PATHLENGTH + 1));
- sargptr = (long *)&ti->pathname[0];
+ sargptr = ti->pathname;
*sargptr++ = kd->arg2;
*sargptr++ = kd->arg3;
*sargptr++ = kd->arg4;
+ /*
+ * NULL terminate the 'string'
+ */
+ *sargptr = 0;
+
ti->pathptr = sargptr;
} else {
handle.
*/
- if ((long *)sargptr >= (long *)&ti->pathname[PATHLENGTH])
+ if (sargptr >= &ti->pathname[NUMPARMS])
{
kd++;
continue;
if (kd->debugid & DBG_FUNC_START)
{
- (long *)ti->pathptr = (long *)&ti->pathname[PATHLENGTH];
+ ti->pathptr = &ti->pathname[NUMPARMS];
}
else
{
*sargptr++ = kd->arg2;
*sargptr++ = kd->arg3;
*sargptr++ = kd->arg4;
+ /*
+ * NULL terminate the 'string'
+ */
+ *sargptr = 0;
+
ti->pathptr = sargptr;
}
}
kd++;
}
+ p = (char *)ti->pathname;
kd--;
/* print the tail end of the pathname */
- len = strlen(ti->pathname);
+ len = strlen(p);
if (len > 42)
len -= 42;
else
fprintf(log_fp, "%9.1f %8.1f\t\t%-14.14s %-42s %-8x %-8x %d %s\n",
timestamp - start_bias, delta, "VFS_LOOKUP",
- &ti->pathname[len], ti->arg1, thread, cpunum, command);
+ &p[len], ti->arg1, thread, cpunum, command);
last_timestamp = timestamp;
break;