If LIBOBJC_DUMP_GC_STATUS_ON_SIGNAL is set, dump the GC state in response to kill -$(LIBOBJC_DUMP_GC_STATUS_ON_SIGNAL) {pid}.

main
theraven 15 years ago
parent cd9ac97fb8
commit 5b2c24bed3

@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include "gc_ops.h"
#define I_HIDE_POINTERS
#include <gc/gc.h>
@ -454,11 +455,17 @@ void* objc_gc_reallocate_collectable(void *ptr, size_t size, BOOL isScanned)
static void init(void)
{
GC_INIT();
char *sigNumber;
// Dump GC stats on exit - uncomment when debugging.
if (getenv("LIBOBJC_DUMP_GC_STATUS_ON_EXIT"))
{
atexit(GC_dump);
}
if ((sigNumber = getenv("LIBOBJC_DUMP_GC_STATUS_ON_SIGNAL")))
{
int s = sigNumber[0] ? (int)strtol(sigNumber, NULL, 10) : SIGUSR2;
signal(s, (void(*)(int))GC_dump);
}
refcounts = refcount_create(4096);
GC_clear_roots();
finalize = sel_registerName("finalize");

Loading…
Cancel
Save