Loading...
--- libmalloc/libmalloc-166.251.2/src/purgeable_malloc.c
+++ libmalloc/libmalloc-283.40.1/src/purgeable_malloc.c
@@ -215,7 +215,7 @@
kern_return_t err;
if (!reader) {
- reader = _szone_default_reader;
+ reader = _malloc_default_reader;
}
err = reader(task, zone_address, sizeof(szone_t), (void **)&szone);
@@ -223,8 +223,9 @@
return err;
}
- err = large_in_use_enumerator(
- task, context, type_mask, (vm_address_t)szone->large_entries, szone->num_large_entries, reader, recorder);
+ err = large_in_use_enumerator(task, context, type_mask,
+ (vm_address_t)szone->large_entries, szone->num_large_entries,
+ reader, recorder);
return err;
}
@@ -245,10 +246,31 @@
}
static void
-purgeable_print(szone_t *szone, boolean_t verbose)
-{
- malloc_report(MALLOC_REPORT_NOLOG | MALLOC_REPORT_NOPREFIX, "Scalable zone %p: inUse=%u(%y) flags=%d\n", szone,
- szone->num_large_objects_in_use, (int)szone->num_bytes_in_large_objects, szone->debug_flags);
+purgeable_print(task_t task, unsigned level MALLOC_UNUSED,
+ vm_address_t zone_address, memory_reader_t reader,
+ print_task_printer_t printer)
+{
+ szone_t *szone;
+ if (reader(task, zone_address, sizeof(szone_t), (void **)&szone)) {
+ printer("Purgeable zone %p: inUse=%u(%y) flags=%d\n", zone_address,
+ szone->num_large_objects_in_use,
+ (int)szone->num_bytes_in_large_objects,
+ szone->debug_flags);
+ }
+}
+
+static void
+purgeable_print_self(szone_t *szone, boolean_t verbose)
+{
+ purgeable_print(mach_task_self(), verbose ? MALLOC_VERBOSE_PRINT_LEVEL : 0,
+ (vm_address_t)szone, _malloc_default_reader, malloc_report_simple);
+}
+
+static void
+purgeable_print_task(task_t task, unsigned level, vm_address_t zone_address,
+ memory_reader_t reader, print_task_printer_t printer)
+{
+ purgeable_print(task, level, zone_address, reader, printer);
}
static void
@@ -304,10 +326,18 @@
}
static const struct malloc_introspection_t purgeable_introspect = {
- (void *)purgeable_ptr_in_use_enumerator, (void *)purgeable_good_size, (void *)purgeable_check, (void *)purgeable_print,
- purgeable_log, (void *)purgeable_force_lock, (void *)purgeable_force_unlock, (void *)purgeable_statistics,
- (void *)purgeable_locked, NULL, NULL, NULL, NULL, /* Zone enumeration version 7 and forward. */
- (void *)purgeable_reinit_lock, // reinit_lock version 9 and foward
+ (void *)purgeable_ptr_in_use_enumerator,
+ (void *)purgeable_good_size,
+ (void *)purgeable_check,
+ (void *)purgeable_print_self,
+ (void *)purgeable_log,
+ (void *)purgeable_force_lock,
+ (void *)purgeable_force_unlock,
+ (void *)purgeable_statistics,
+ (void *)purgeable_locked,
+ NULL, NULL, NULL, NULL, /* Zone enumeration version 7 and forward. */
+ (void *)purgeable_reinit_lock, // reinit_lock version 9 and forward
+ (void *)purgeable_print_task, // print_task version 11 and forward
}; // marked as const to spare the DATA section
@@ -359,7 +389,7 @@
}
#endif
- szone->basic_zone.version = 10;
+ szone->basic_zone.version = 11;
szone->basic_zone.size = (void *)purgeable_size;
szone->basic_zone.malloc = (void *)purgeable_malloc;
szone->basic_zone.calloc = (void *)purgeable_calloc;