]> git.saurik.com Git - apple/hfs.git/blob - hfs-alloc-trace/hfs-alloc-trace.c
hfs-407.200.4.tar.gz
[apple/hfs.git] / hfs-alloc-trace / hfs-alloc-trace.c
1 //
2 // hfs-alloc-trace.c
3 // hfs-alloc-trace
4 //
5 // Created by Chris Suter on 8/19/15.
6 //
7 //
8
9 #include <sys/sysctl.h>
10 #include <stdlib.h>
11 #include <err.h>
12 #include <stdio.h>
13 #include <stdbool.h>
14
15 #include "../core/hfs_alloc_trace.h"
16
17 int main(void)
18 {
19 size_t sz = 128 * 1024;
20 struct hfs_alloc_trace_info *info = malloc(sz);
21
22 if (sysctlbyname("vfs.generic.hfs.alloc_trace_info", info, &sz,
23 NULL, 0)) {
24 err(1, "sysctlbyname failed");
25 }
26
27 for (int i = 0; i < info->entry_count; ++i) {
28 printf(" -- 0x%llx:%llu <%llu> --\n", info->entries[i].ptr,
29 info->entries[i].sequence, info->entries[i].size);
30 for (int j = 0; j < HFS_ALLOC_BACKTRACE_LEN; ++j)
31 printf("0x%llx\n", info->entries[i].backtrace[j]);
32 }
33
34 if (info->more)
35 printf("[skipped]\n");
36
37 return 0;
38 }