#include <mach/mach.h>
#include <stdlib.h>
#include <stdio.h>
+#include <unistd.h>
#include <signal.h>
#include <strings.h>
#include <nlist.h>
int total_threads = 0;
kd_threadmap *mapptr = 0;
-#define MAX_ENTRIES 1024
+#define MAX_ENTRIES 4096
struct ct {
int type;
char name[32];
#define INTERRUPT 0x01050000
#define DECR_TRAP 0x01090000
#define DECR_SET 0x01090004
-#define MACH_vmfault 0x01300000
+#define MACH_vmfault 0x01300008
#define MACH_sched 0x01400000
#define MACH_stkhandoff 0x01400008
#define VFS_LOOKUP 0x03010090
struct th_info *ti;
int cpunum;
char *p;
+ uint64_t user_addr;
cpunum = CPU_NUMBER(kd->timestamp);
if ((p = find_code(type))) {
if (type == INTERRUPT) {
fprintf(fp, "INTERRUPT %-8x %d %s\n", thread, cpunum, command);
- } else if (type == MACH_vmfault && kd->arg2 <= DBG_CACHE_HIT_FAULT) {
- fprintf(fp, "%-28.28s %-8.8s %-8x %-8x %d %s\n",
- p, fault_name[kd->arg2], kd->arg1,
+ } else if (type == MACH_vmfault && kd->arg4 <= DBG_CACHE_HIT_FAULT) {
+ user_addr = ((uint64_t)kd->arg1 << 32) | (uint32_t)kd->arg2;
+
+ fprintf(fp, "%-28.28s %-8.8s %-16qx %-8x %d %s\n",
+ p, fault_name[kd->arg4], user_addr,
thread, cpunum, command);
} else {
fprintf(fp, "%-28.28s %-8x %-8x %-8x %d %s\n",
return;
}
for (i = 0; i < MAX_ENTRIES; i++) {
- n = fscanf(fp, "%x%s\n", &code, name);
+ n = fscanf(fp, "%x%127s\n", &code, name);
if (n != 2)
break;
bzero(tmpstr, 1024);
/* Build the temporary nm file path */
- sprintf(tmp_nm_file, "/tmp/knm.out.%d", getpid());
+ strcpy(tmp_nm_file,"/tmp/knm.out.XXXXXX");
+ if (!mktemp(tmp_nm_file)) {
+ fprintf(stderr, "Error in mktemp call\n");
+ return;
+ }
/* Build the nm command and create a tmp file with the output*/
sprintf (tmpstr, "/usr/bin/nm -f -n -s __TEXT __text %s > %s",